4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungbae Shin <seungbae.shin@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #include "include/mm_sound_plugin_run.h"
25 #include "include/mm_sound_mgr_run.h"
26 #include "include/mm_sound_thread_pool.h"
31 static void _MMsoundMgrRunRunInternal(void *param);
33 static MMSoundPluginType *g_run_plugins = NULL;
35 int MMSoundMgrRunInit(const char *targetdir)
40 debug_error("Please Check Init twice\n");
41 return MM_ERROR_SOUND_INTERNAL;
43 MMSoundPluginScan(targetdir, MM_SOUND_PLUGIN_TYPE_RUN, &g_run_plugins);
49 int MMSoundMgrRunFini(void)
53 MMSoundPluginRelease(g_run_plugins);
60 int MMSoundMgrRunRunAll(void)
66 while (g_run_plugins[loop].type != MM_SOUND_PLUGIN_TYPE_NONE) {
67 MMSoundThreadPoolRun((void*)loop, _MMsoundMgrRunRunInternal);
75 int MMSoundMgrRunStopAll(void)
77 mmsound_run_interface_t intface;
83 while (g_run_plugins && g_run_plugins[loop].type != MM_SOUND_PLUGIN_TYPE_NONE) {
84 debug_msg("loop : %d\n", loop);
85 MMSoundPluginGetSymbol(&g_run_plugins[loop], RUN_GET_INTERFACE_FUNC_NAME, &func);
86 MMSoundPlugRunCastGetInterface(func)(&intface);
95 static void _MMsoundMgrRunRunInternal(void *param)
97 int err = MM_ERROR_NONE;
98 mmsound_run_interface_t intface;
101 debug_enter("plugin number %d\n", (int)param);
103 err = MMSoundPluginGetSymbol(&g_run_plugins[(int)param], RUN_GET_INTERFACE_FUNC_NAME, &func);
104 if (err != MM_ERROR_NONE) {
105 debug_error("Get Symbol RUN_GET_INTERFACE_FUNC_NAME is fail : %x\n", err);
107 err = MMSoundPlugRunCastGetInterface(func)(&intface);
108 if (err != MM_ERROR_NONE) {
109 debug_error("Get interface fail : %x\n", err);
110 /* If error occur, clean interface */
111 //memset(&g_run_plugins[(int)param], 0, sizeof(mmsound_run_interface_t));
113 if(intface.SetThreadPool)
114 intface.SetThreadPool(MMSoundThreadPoolRun);
116 debug_msg("Trace\n");
117 debug_msg("Trace\n");