tone-player and wav-player in sound-server were moved to pulseaudio.
sound_server is not necessary to play sound/tone. Tizen_HW_Touch.ogg is
moved to pulseaudio-modules-tizen package.
[Version] 0.13.0
[Issue Type] Improvement
Change-Id: I06f5088db6381d5ca79d73d45bcfa143bc4a3923
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
SUBDIRS = common \
pkgconfig \
. \
- server \
testsuite
SUBDIRS += focus_server
libmmfbootsound_la_LIBADD = $(MMCOMMON_LIBS) $(VCONF_LIBS)
libmmfbootsound_la_CFLAGS += $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x020 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\"
libmmfbootsound_la_LIBADD += $(MMLOGSVR_LIBS)
+
.object = "/org/tizen/AudioClient1",
.interface = "org.tizen.AudioClient1"
},
- [AUDIO_PROVIDER_SOUND_PLAYER] = {
- .bus_name = "org.pulseaudio.Server",
- .object = "/org/pulseaudio/SoundPlayer",
- .interface = "org.pulseaudio.SoundPlayer"
- }
};
static const mm_sound_dbus_method_info_t g_methods[AUDIO_METHOD_MAX] = {
[AUDIO_METHOD_TEST] = {
.name = "MethodTest1",
},
- [AUDIO_METHOD_SOUND_PLAY] = {
- .name = "SoundPlay",
- },
- [AUDIO_METHOD_SOUND_STOP] = {
- .name = "SoundStop",
- },
- [AUDIO_METHOD_STOP_TONE] = {
- .name = "StopTone",
- },
- [AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO] = {
- .name = "PlayDTMFWithStreamInfo",
- },
[AUDIO_METHOD_SET_VOLUME_LEVEL] = {
.name = "SetVolumeLevel",
},
[AUDIO_EVENT_TEST] = {
.name = "SignalTest1",
},
- [AUDIO_EVENT_SOUND_PLAY_EOS] = {
- .name = "EOS",
- },
[AUDIO_EVENT_VOLUME_CHANGED] = {
.name = "VolumeChanged",
},
(cb_data->user_cb)(AUDIO_EVENT_FOCUS_CHANGED, params, cb_data->user_data);
else if (!strcmp(signal_name, g_events[AUDIO_EVENT_FOCUS_WATCH].name))
(cb_data->user_cb)(AUDIO_EVENT_FOCUS_WATCH, params, cb_data->user_data);
- else if (!strcmp(signal_name, g_events[AUDIO_EVENT_SOUND_PLAY_EOS].name))
- (cb_data->user_cb)(AUDIO_EVENT_SOUND_PLAY_EOS, params, cb_data->user_data);
else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DEVICE_RUNNING_CHANGED].name))
(cb_data->user_cb)(AUDIO_EVENT_DEVICE_RUNNING_CHANGED, params, cb_data->user_data);
else if (!strcmp(signal_name, g_events[AUDIO_EVENT_DUCKING_STATE_CHANGED].name))
AC_SUBST(VCONF_CFLAGS)
AC_SUBST(VCONF_LIBS)
-PKG_CHECK_MODULES(VCONF, sndfile)
-AC_SUBST(SNDFILE_CFLAGS)
-AC_SUBST(SNDFILE_LIBS)
-
AC_ARG_ENABLE(pulse, AC_HELP_STRING([--enable-pulse], [enable pulseaudio client]),
[
case "${enableval}" in
],[USE_PRELINK=no])
AM_CONDITIONAL([USE_PRELINK], [test "x$USE_PRELINK" = "xyes"])
-AC_ARG_WITH(plugindir, AS_HELP_STRING([--with-plugindir=<path>],[sound-server plugin dir]))
-if test -z "$with_plugindir" ; then
-PLUGIN_DIR=/usr/lib/soundplugins/
-else
-PLUGIN_DIR=$with_plugindir
-fi
-AC_SUBST(PLUGIN_DIR)
-AC_DEFINE_UNQUOTED(PLUGIN_DIR,"$PLUGIN_DIR", [sound-server plugin dir])
-
AC_ARG_ENABLE(unittests, AC_HELP_STRING([--enable-unittests], [unittest build]),
[
case "${enableval}" in
AC_CONFIG_FILES([
common/Makefile
Makefile
-server/Makefile
-server/plugin/Makefile
-server/plugin/wav/Makefile
-server/plugin/tone/Makefile
focus_server/Makefile
pkgconfig/Makefile
pkgconfig/mm-sound.pc
typedef void (*mm_sound_stop_callback_func) (void *data, int id);
/*
- * MMSound Play APIs
- */
-
-int mm_sound_play_sound_with_stream_info(const char *filename, char *stream_type, int stream_id, unsigned int loop, mm_sound_stop_callback_func _completed_cb, void *data, int *handle);
-
-/**
- * This function is to stop playing system sound.
- *
- * @param handle [in] Handle of mm_sound_play_sound
- *
- * @return This function returns MM_ERROR_NONE on success, or negative value
- * with error code.
- *
- * @remark When system sound is terminated with this function call, it does not
- * call stop callback which was set when start playing system sound.
- * @see mm_sound_play_sound
- * @pre An sound play handle should be valid.
- * @post Playing sound file will be stopped.
- * @par Example
- * @code
-int g_stop=0;
-void _stop_callback(void* data)
-{
- printf("Stop callback\n");
- g_stop = 1;
-}
-
-int play_file_one_second()
-{
- char filename[] ="testfile.wav";
- volume_type_t volume = VOLUME_TYPE_SYSTEM;
- int ret = 0;
- int handle = -1;
-
- ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
- if(ret < 0)
- {
- printf("play file failed\n");
- }
- else
- {
- printf("play file success\n");
- }
-
- sleep(1); //wait 1 second
-
- ret = mm_sound_stop_sound(handle);
- if(ret < 0)
- {
- printf("stop failed\n");
- }
- else
- {
- printf("play stopped\n");
- }
- return 0;
-}
- * @endcode
- */
-int mm_sound_stop_sound(int handle);
-
-
-/**
- * Enumerations for TONE
- */
-
-typedef enum {
- MM_SOUND_TONE_DTMF_0 = 0, /**< Predefined DTMF 0 */
- MM_SOUND_TONE_DTMF_1, /**< Predefined DTMF 1 */
- MM_SOUND_TONE_DTMF_2, /**< Predefined DTMF 2 */
- MM_SOUND_TONE_DTMF_3, /**< Predefined DTMF 3 */
- MM_SOUND_TONE_DTMF_4, /**< Predefined DTMF 4 */
- MM_SOUND_TONE_DTMF_5, /**< Predefined DTMF 5 */
- MM_SOUND_TONE_DTMF_6, /**< Predefined DTMF 6 */
- MM_SOUND_TONE_DTMF_7, /**< Predefined DTMF 7 */
- MM_SOUND_TONE_DTMF_8, /**< Predefined DTMF 8 */
- MM_SOUND_TONE_DTMF_9, /**< Predefined DTMF 9 */
- MM_SOUND_TONE_DTMF_S, /**< Predefined DTMF Star - Asterisk (*) */
- MM_SOUND_TONE_DTMF_P, /**< Predefined DTMF sharP (#) */
- MM_SOUND_TONE_DTMF_A, /**< Predefined DTMF A (A) */
- MM_SOUND_TONE_DTMF_B, /**< Predefined DTMF B (B) */
- MM_SOUND_TONE_DTMF_C, /**< Predefined DTMF C (C) */
- MM_SOUND_TONE_DTMF_D, /**< Predefined DTMF D (D) */
-
- /**< Pre-defined TONE */
- MM_SOUND_TONE_SUP_DIAL, /**Call supervisory tone, Dial tone: CEPT: 425Hz, continuous */
- MM_SOUND_TONE_ANSI_DIAL, /**Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous */
- MM_SOUND_TONE_JAPAN_DIAL, /**Call supervisory tone, Dial tone: JAPAN: 400Hz, continuous*/
- MM_SOUND_TONE_SUP_BUSY, /**Call supervisory tone, Busy: CEPT: 425Hz, 500ms ON, 500ms OFF... */
- MM_SOUND_TONE_ANSI_BUSY, /**Call supervisory tone, Busy: ANSI (IS-95): 480Hz+620Hz, 500ms ON, 500ms OFF... */
- MM_SOUND_TONE_JAPAN_BUSY, /**Call supervisory tone, Busy: JAPAN: 400Hz, 500ms ON, 500ms OFF...*/
- MM_SOUND_TONE_SUP_CONGESTION, /**Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF */
- MM_SOUND_TONE_ANSI_CONGESTION, /**Call supervisory tone, Congestion: ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF... */
- MM_SOUND_TONE_SUP_RADIO_ACK, /**Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON */
- MM_SOUND_TONE_JAPAN_RADIO_ACK, /**Call supervisory tone, Radio path acknowlegment : JAPAN: 400Hz, 1s ON, 2s OFF...*/
- MM_SOUND_TONE_SUP_RADIO_NOTAVAIL, /**Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts */
- MM_SOUND_TONE_SUP_ERROR, /**Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF... */
- MM_SOUND_TONE_SUP_CALL_WAITING, /**Call supervisory tone, Call Waiting: CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF... */
- MM_SOUND_TONE_ANSI_CALL_WAITING, /**Call supervisory tone, Call Waiting: ANSI (IS-95): 440 Hz, 300 ms ON, 9.7 s OFF, (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...) */
- MM_SOUND_TONE_SUP_RINGTONE, /**Call supervisory tone, Ring Tone: CEPT, JAPAN: 425Hz, 1s ON, 4s OFF... */
- MM_SOUND_TONE_ANSI_RINGTONE, /**Call supervisory tone, Ring Tone: ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF... */
- MM_SOUND_TONE_PROP_BEEP, /**General beep: 400Hz+1200Hz, 35ms ON */
- MM_SOUND_TONE_PROP_ACK, /**Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts */
- MM_SOUND_TONE_PROP_NACK, /**Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON */
- MM_SOUND_TONE_PROP_PROMPT, /**Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON */
- MM_SOUND_TONE_PROP_BEEP2, /**Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON */
- MM_SOUND_TONE_SUP_INTERCEPT, /**Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms */
- MM_SOUND_TONE_SUP_INTERCEPT_ABBREV, /**Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds */
- MM_SOUND_TONE_SUP_CONGESTION_ABBREV, /**Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds */
- MM_SOUND_TONE_SUP_CONFIRM, /**Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone repeated 3 times in a 100 ms on, 100 ms off cycle */
- MM_SOUND_TONE_SUP_PIP, /**Call supervisory tone (IS-95), pip tone: four bursts of 480 Hz tone (0.1 s on, 0.1 s off). */
- MM_SOUND_TONE_CDMA_DIAL_TONE_LITE, /**425Hz continuous */
- MM_SOUND_TONE_CDMA_NETWORK_USA_RINGBACK, /**CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...*/
- MM_SOUND_TONE_CDMA_INTERCEPT, /**CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...*/
- MM_SOUND_TONE_CDMA_ABBR_INTERCEPT, /**CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON */
- MM_SOUND_TONE_CDMA_REORDER, /**CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF... */
- MM_SOUND_TONE_CDMA_ABBR_REORDER, /**CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times */
- MM_SOUND_TONE_CDMA_NETWORK_BUSY, /**CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous */
- MM_SOUND_TONE_CDMA_CONFIRM, /**CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times */
- MM_SOUND_TONE_CDMA_ANSWER, /**CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF */
- MM_SOUND_TONE_CDMA_NETWORK_CALLWAITING, /**CDMA Network Callwaiting tone: 440Hz 300ms ON */
- MM_SOUND_TONE_CDMA_PIP, /**CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times */
- MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL, /**ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times, 2091 32ms ON, 2556 48ms ON, 4s OFF */
- MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP, /**ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times, 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 8times, 2091Hz 32ms ON, 4s OFF.*/
- MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI, /**ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times, 2091Hz 16ms ON, 200ms OFF */
- MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT3, /**SDN Call sign PAT3 tone: silent tone */
- MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING, /**ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON */
- MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT5, /**ISDN Pat5 tone: silent tone */
- MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT6, /**ISDN Pat6 tone: silent tone */
- MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT7, /**ISDN Pat7 tone: silent tone */
- MM_SOUND_TONE_CDMA_HIGH_L, /**TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times 4000ms OFF, Repeat .... */
- MM_SOUND_TONE_CDMA_MED_L, /**TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times 4000ms OFF, Repeat .... */
- MM_SOUND_TONE_CDMA_LOW_L, /**TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, 4000ms OFF, Repeat .... */
- MM_SOUND_TONE_CDMA_HIGH_SS, /**CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
- MM_SOUND_TONE_CDMA_MED_SS, /**CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
- MM_SOUND_TONE_CDMA_LOW_SS, /**CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
- MM_SOUND_TONE_CDMA_HIGH_SSL, /**CDMA HIGH SSL tone: {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
- MM_SOUND_TONE_CDMA_MED_SSL, /**CDMA MED SSL tone: {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
- MM_SOUND_TONE_CDMA_LOW_SSL, /**CDMA LOW SSL tone: {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
- MM_SOUND_TONE_CDMA_HIGH_SS_2, /**CDMA HIGH SS2 tone: {3700Hz 25ms, 4000Hz 25ms} 20 times, 1000ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 3000ms OFF, repeat .... */
- MM_SOUND_TONE_CDMA_MED_SS_2, /**CDMA MED SS2 tone: {2600Hz 25ms, 2900Hz 25ms} 20 times, 1000ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 3000ms OFF, repeat .... */
- MM_SOUND_TONE_CDMA_LOW_SS_2, /**CDMA LOW SS2 tone: {1300Hz 25ms, 1450Hz 25ms} 20 times, 1000ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 3000ms OFF, repeat .... */
- MM_SOUND_TONE_CDMA_HIGH_SLS, /**CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT */
- MM_SOUND_TONE_CDMA_MED_SLS, /**CDMA MED SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT */
- MM_SOUND_TONE_CDMA_LOW_SLS, /**CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT */
- MM_SOUND_TONE_CDMA_HIGH_S_X4, /**CDMA HIGH S X4 tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 2500ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_MED_S_X4, /**CDMA MED S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_LOW_S_X4, /**CDMA LOW S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT....*/
- MM_SOUND_TONE_CDMA_HIGH_PBX_L, /**CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_MED_PBX_L, /**CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_LOW_PBX_L, /**CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_HIGH_PBX_SS, /**CDMA HIGH PBX SS tone: {3700Hz 25ms, 4000Hz 25ms} 8 times 200 ms OFF, {3700Hz 25ms 4000Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_MED_PBX_SS, /**CDMA MED PBX SS tone: {2600Hz 25ms, 2900Hz 25ms} 8 times 200 ms OFF, {2600Hz 25ms 2900Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_LOW_PBX_SS, /**CDMA LOW PBX SS tone: {1300Hz 25ms, 1450Hz 25ms} 8 times 200 ms OFF, {1300Hz 25ms 1450Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_HIGH_PBX_SSL, /**CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_MED_PBX_SSL, /**CDMA MED PBX SSL tone:{2600Hz 25ms, 2900Hz 25ms} 8 times 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_LOW_PBX_SSL, /**CDMA LOW PBX SSL tone:{1300Hz 25ms, 1450Hz 25ms} 8 times 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_HIGH_PBX_SLS, /**CDMA HIGH PBX SLS tone:{3700Hz 25ms, 4000Hz 25ms} 8 times 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 1000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_MED_PBX_SLS, /**CDMA MED PBX SLS tone:{2600Hz 25ms, 2900Hz 25ms} 8 times 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 1000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_LOW_PBX_SLS, /**CDMA LOW PBX SLS tone:{1300Hz 25ms, 1450Hz 25ms} 8 times 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 1000ms OFF, REPEAT.... */
- MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4, /**CDMA HIGH PBX X S4 tone: {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 800ms OFF, REPEAT... */
- MM_SOUND_TONE_CDMA_MED_PBX_S_X4, /**CDMA MED PBX X S4 tone: {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 800ms OFF, REPEAT... */
- MM_SOUND_TONE_CDMA_LOW_PBX_S_X4, /**CDMA LOW PBX X S4 tone: {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 800ms OFF, REPEAT... */
- MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE, /**CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON 622Hz 62ms ON, 1109Hz 62ms ON */
- MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE, /**CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON */
- MM_SOUND_TONE_CDMA_ONE_MIN_BEEP, /**CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON */
- MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE, /**CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON */
- MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE, /**CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON */
- MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE, /**CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms, 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms*/
- MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK, /**CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times 4990ms OFF, REPEAT... */
- MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD, /**CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times */
- MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE, /**CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms */
- MM_SOUND_TONE_CDMA_CALLDROP_LITE, /**CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms */
- MM_SOUND_TONE_CDMA_NETWORK_BUSY_ONE_SHOT, /**CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. */
- MM_SOUND_TONE_CDMA_ABBR_ALERT, /**CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON */
- MM_SOUND_TONE_CDMA_SIGNAL_OFF, /**CDMA_SIGNAL_OFF - silent tone */
- MM_SOUND_TONE_LOW_FRE, /**100Hz continuous */
- MM_SOUND_TONE_MED_FRE, /**200Hz continuous */
- MM_SOUND_TONE_HIGH_FRE, /**300Hz continuous */
- MM_SOUND_TONE_NUM,
-} MMSoundTone_t;
-
-typedef unsigned long sound_time_msec_t; /**< millisecond unit */
-
-int mm_sound_play_tone_with_stream_info(MMSoundTone_t tone, char *stream_type, int stream_id, const double volume, const int duration, int *handle);
-
-/*
* Enumerations of device & route
*/
int mm_sound_client_initialize(void);
int mm_sound_client_finalize(void);
-int mm_sound_client_play_tone_with_stream_info(int tone, char *stream_type, int stream_id, double volume, int duration, int *handle);
-int mm_sound_client_play_sound_with_stream_info(MMSoundPlayParam *param, int *handle, char* stream_type, int stream_id);
-int mm_sound_client_stop_sound(int handle);
-int mm_sound_client_stop_tone(int handle);
int mm_sound_client_set_volume_by_type(volume_type_t type, const unsigned int level);
int mm_sound_client_get_volume_by_type(volume_type_t type, unsigned int *level);
int mm_sound_client_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data, unsigned int *subs_id);
AUDIO_PROVIDER_STREAM_MANAGER,
AUDIO_PROVIDER_FOCUS_SERVER,
AUDIO_PROVIDER_AUDIO_CLIENT,
- AUDIO_PROVIDER_SOUND_PLAYER,
AUDIO_PROVIDER_MAX
} audio_provider_t;
typedef enum audio_method {
AUDIO_METHOD_TEST,
- AUDIO_METHOD_SOUND_PLAY,
- AUDIO_METHOD_SOUND_STOP,
- AUDIO_METHOD_STOP_TONE,
- AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO,
AUDIO_METHOD_GET_BT_A2DP_STATUS,
AUDIO_METHOD_SET_PATH_FOR_ACTIVE_DEVICE,
AUDIO_METHOD_GET_CONNECTED_DEVICE_LIST,
typedef enum audio_event {
AUDIO_EVENT_TEST,
- AUDIO_EVENT_SOUND_PLAY_EOS,
AUDIO_EVENT_VOLUME_CHANGED,
AUDIO_EVENT_DEVICE_CONNECTED,
AUDIO_EVENT_DEVICE_INFO_CHANGED,
typedef void (*mm_sound_proxy_userdata_free) (void *data);
-int mm_sound_proxy_play_tone_with_stream_info(int client_pid, int tone, char *stream_type, int stream_id, int volume, int repeat, int *codechandle);
-int mm_sound_proxy_play_sound_with_stream_info(const char* filename, int repeat,
- int client_pid, int *codechandle, char *stream_type, int stream_index);
-int mm_sound_proxy_stop_sound(int handle);
-int mm_sound_proxy_stop_tone(int handle);
-int mm_sound_proxy_add_play_sound_end_callback(mm_sound_stop_callback_wrapper_func func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id);
-int mm_sound_proxy_remove_play_sound_end_callback(unsigned subs_id);
int mm_sound_proxy_get_current_connected_device_list(int device_flags, GList** device_list);
int mm_sound_proxy_get_device_by_id(int device_id, mm_sound_device_t **device);
int mm_sound_proxy_add_device_connected_callback(mm_sound_device_connected_wrapper_cb func, void *userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id);
}
///////////////////////////////////
-//// MMSOUND PLAY APIs
-///////////////////////////////////
-EXPORT_API
-int mm_sound_play_sound_with_stream_info(const char *filename, char *stream_type, int stream_id, unsigned int loop, mm_sound_stop_callback_func callback, void *data, int *handle)
-{
- MMSoundPlayParam param = { 0, };
- int err;
-
- param.filename = filename;
- param.volume = 0; //volume value dose not effect anymore
- param.callback = callback;
- param.data = data;
-
- if (loop == 0)
- param.loop = -1;
- else
- param.loop = loop;
-
- err = mm_sound_client_play_sound_with_stream_info(¶m, handle, stream_type, stream_id);
- if (err < 0) {
- debug_error("Failed to play sound");
- return err;
- }
-
- debug_warning("success : handle=[%p]", handle);
-
- return MM_ERROR_NONE;
-
-}
-
-
-EXPORT_API
-int mm_sound_stop_sound(int handle)
-{
- int err;
-
- debug_warning("enter : handle=[%d]", handle);
- /* Stop sound */
- err = mm_sound_client_stop_sound(handle);
- if (err < 0) {
- debug_error("Fail to stop sound");
- return err;
- }
- debug_warning("success : handle=[%d]", handle);
-
- return MM_ERROR_NONE;
-}
-
-EXPORT_API
-int mm_sound_stop_tone(int handle)
-{
- int err;
-
- debug_warning("enter : handle=[%d]", handle);
-
- err = mm_sound_client_stop_tone(handle);
- if (err < 0) {
- debug_error("Fail to stop tone. err=0x%x", err);
- return err;
- }
- debug_msg("success : handle=[%d]", handle);
-
- return MM_ERROR_NONE;
-}
-
-///////////////////////////////////
-//// MMSOUND TONE APIs
-///////////////////////////////////
-EXPORT_API
-int mm_sound_play_tone_with_stream_info(MMSoundTone_t tone, char *stream_type, int stream_id, const double volume, const int duration, int *handle)
-{
-
- int err = MM_ERROR_NONE;
-
- err = mm_sound_client_play_tone_with_stream_info(tone, stream_type, stream_id, volume, duration, handle);
- if (err < 0) {
- debug_error("Failed to play sound");
- return err;
- }
-
- return err;
-
-}
-
-///////////////////////////////////
//// MMSOUND ROUTING APIs
///////////////////////////////////
/*****************************************************************************************
DBUS SUPPORTED FUNCTIONS
******************************************************************************************/
-int mm_sound_client_play_tone_with_stream_info(int tone, char *stream_type, int stream_id,
- double volume, int duration, int *handle)
-{
- int ret = MM_ERROR_NONE;
-
- debug_fenter();
-
- ret = mm_sound_proxy_play_tone_with_stream_info(getpid(), tone, stream_type, stream_id, volume, duration, handle);
-
- debug_fleave();
- return ret;
-}
-
-static void _mm_sound_stop_callback_wrapper_func(int ended_handle, void *userdata)
-{
- struct callback_data *cb_data = (struct callback_data*) userdata;
- play_sound_end_callback_data_t *end_cb_data;
-
- debug_log("ended_handle : %d", ended_handle);
-
- if (cb_data == NULL) {
- debug_warning("stop callback data null");
- return;
- }
-
- end_cb_data = (play_sound_end_callback_data_t*) cb_data->extra_data;
-
- if (ended_handle == end_cb_data->watching_handle) {
- debug_log("Interested playing handle end : %d", ended_handle);
- ((mm_sound_stop_callback_func)(cb_data->user_cb))(cb_data->user_data, ended_handle);
- if (mm_sound_proxy_remove_play_sound_end_callback(end_cb_data->subs_id) != MM_ERROR_NONE)
- debug_error("mm_sound_client_dbus_remove_play_file_end_callback failed");
- } else {
- debug_log("Not interested playing handle : %d", ended_handle);
- }
-}
-
-static void play_end_callback_data_free_func(void *data)
-{
- struct callback_data *cb_data = (struct callback_data*) data;
-
- if (cb_data) {
- g_free(cb_data->extra_data);
- g_free(cb_data);
- }
-}
-
-int mm_sound_client_play_sound_with_stream_info(MMSoundPlayParam *param, int *handle, char* stream_type, int stream_id)
-{
- int ret = MM_ERROR_NONE;
- struct callback_data *cb_data = NULL;
- play_sound_end_callback_data_t *end_cb_data;
-
- ret = mm_sound_proxy_play_sound_with_stream_info(param->filename, param->loop,
- getpid(), handle, stream_type, stream_id);
- if (ret != MM_ERROR_NONE) {
- debug_error("Play Sound Failed");
- return ret;
- }
- if (param->callback) {
- end_cb_data = (play_sound_end_callback_data_t *) g_try_malloc0(sizeof(play_sound_end_callback_data_t));
- if (!end_cb_data) {
- debug_error("Failed to alloc end_cb_data");
- return MM_ERROR_OUT_OF_MEMORY;
- }
- end_cb_data->watching_handle = *handle;
- GET_CB_DATA(cb_data, param->callback, param->data, end_cb_data);
-
- ret = mm_sound_proxy_add_play_sound_end_callback(_mm_sound_stop_callback_wrapper_func, cb_data,
- play_end_callback_data_free_func, &end_cb_data->subs_id);
- if (ret != MM_ERROR_NONE)
- debug_error("Add callback for play sound(%d) Failed", *handle);
- }
-
- debug_fleave();
- return ret;
-
-}
-
-int mm_sound_client_stop_sound(int handle)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- if (handle < 0) {
- ret = MM_ERROR_INVALID_ARGUMENT;
- return ret;
- }
-
- ret = mm_sound_proxy_stop_sound(handle);
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_client_stop_tone(int handle)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- if (handle < 0 || handle > CLIENT_HANDLE_MAX)
- return MM_ERROR_INVALID_ARGUMENT;
-
- ret = mm_sound_proxy_stop_tone(handle);
-
- debug_fleave();
- return ret;
-}
-
static int _mm_sound_client_device_list_dump(GList *device_list)
{
int ret = MM_ERROR_NONE;
int test_var = 0;
g_variant_get(params, "(i)", &test_var);
((mm_sound_test_cb)(cb_data->user_cb))(test_var, cb_data->user_data);
- } else if (event == AUDIO_EVENT_SOUND_PLAY_EOS) {
- int ended_handle = 0;
- g_variant_get(params, "(i)", &ended_handle);
- ((mm_sound_stop_callback_wrapper_func)(cb_data->user_cb))(ended_handle, cb_data->user_data);
} else if (event == AUDIO_EVENT_DUCKING_STATE_CHANGED) {
int idx = 0;
int is_ducked = 0;
return ret;
}
-int mm_sound_proxy_play_tone_with_stream_info(int client_pid, int tone, char *stream_type, int stream_index, int volume, int repeat, int *codechandle)
-{
- int ret = MM_ERROR_NONE;
- int handle = 0;
- GVariant *params = NULL, *result = NULL;
-
- debug_fenter();
-
- if (!codechandle) {
- debug_error("Param for play is null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- if ((params = g_variant_new("(iiiisi)", tone, repeat, volume, client_pid, stream_type, stream_index)) == NULL) {
- debug_error("Construct Param for method call failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus play tone failed");
- g_variant_unref(result);
- return ret;
- }
-
- if (result) {
- g_variant_get(result, "(i)", &handle);
- debug_log("handle : %d", handle);
- *codechandle = handle;
- g_variant_unref(result);
- } else {
- debug_error("reply null");
- ret = MM_ERROR_SOUND_INTERNAL;
- }
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_proxy_play_sound_with_stream_info(const char* filename, int repeat,
- int client_pid, int *codechandle, char *stream_type, int stream_id)
-{
- int ret = MM_ERROR_NONE;
- int handle = 0;
- GVariant *params = NULL, *result = NULL;
-
- if (!filename || !codechandle) {
- debug_error("Param for play is null");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- if (access(filename, F_OK) != 0) {
- char str_error[256];
- strerror_r(errno, str_error, sizeof(str_error));
- debug_error("file [%s] doesn't exists : [%s][%d]", filename, str_error, errno);
- return MM_ERROR_SOUND_FILE_NOT_FOUND;
- }
-
- debug_fenter();
-
- if ((params = g_variant_new("(siisi)", filename, repeat, client_pid, stream_type, stream_id)) == NULL) {
- debug_error("Construct Param for method call failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_PLAYER, AUDIO_METHOD_SOUND_PLAY, params, &result)) != MM_ERROR_NONE) {
- debug_error("dbus play file failed");
- return ret;
- }
-
- if (result) {
- g_variant_get(result, "(i)", &handle);
- if (handle < 0) {
- debug_log("handle is invalid : %d", handle);
- ret = MM_ERROR_SOUND_INTERNAL;
- } else {
- *codechandle = handle;
- }
- g_variant_unref(result);
- } else {
- debug_error("reply null");
- ret = MM_ERROR_SOUND_INTERNAL;
- }
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_proxy_stop_sound(int handle)
-{
- int ret = MM_ERROR_NONE;
- GVariant *result = NULL;
-
- debug_fenter();
-
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_PLAYER, AUDIO_METHOD_SOUND_STOP, g_variant_new("(i)", handle), &result)) != MM_ERROR_NONE)
- debug_error("dbus stop file playing failed");
-
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_proxy_stop_tone(int handle)
-{
- int ret = MM_ERROR_NONE;
- GVariant *result = NULL;
-
- debug_fenter();
-
- if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_SOUND_SERVER, AUDIO_METHOD_STOP_TONE, g_variant_new("(i)", handle), &result)) != MM_ERROR_NONE)
- debug_error("dbus stop file playing failed");
-
- if (result)
- g_variant_unref(result);
-
- debug_fleave();
- return ret;
-}
-
-int mm_sound_proxy_add_play_sound_end_callback(mm_sound_stop_callback_wrapper_func func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id)
-{
- int ret = MM_ERROR_NONE;
- struct callback_data *cb_data;
-
- debug_fenter();
-
- CB_DATA_NEW(cb_data, func, userdata, freefunc);
-
- if ((ret = mm_sound_dbus_signal_subscribe_to(AUDIO_PROVIDER_SOUND_PLAYER, AUDIO_EVENT_SOUND_PLAY_EOS, dbus_callback, cb_data, simple_callback_data_free_func, &cb_data->subs_id)) != MM_ERROR_NONE)
- debug_error("add play sound end callback failed");
- else
- *subs_id = cb_data->subs_id;
-
- debug_fleave();
-
- return ret;
-}
-
-int mm_sound_proxy_remove_play_sound_end_callback(unsigned subs_id)
-{
- int ret = MM_ERROR_NONE;
- debug_fenter();
-
- if ((ret = mm_sound_dbus_signal_unsubscribe(subs_id)) != MM_ERROR_NONE)
- debug_error("Remove Play File End callback failed");
-
- debug_fleave();
- return ret;
-}
-
int mm_sound_proxy_register_focus(int index, const char *stream_type, int *id)
{
int ret = MM_ERROR_NONE;
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
-Version: 0.12.73
+Version: 0.13.0
Release: 0
Group: System/Libraries
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
-Source2: sound-server.service
-Source3: sound-server.conf
Source4: focus-server.service
Source5: focus-server.path
Source6: focus-server.conf
Source7: libmm-sound.notstrip
Source8: focus-server-tv.service
%endif
-Source9: org.tizen.SoundServer.service
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(mm-common)
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(libpulse)
-BuildRequires: pkgconfig(sndfile)
%if "%{tizen_profile_name}" == "tv"
BuildRequires: pkgconfig(lwipc)
%endif
%endif
%description
-MMSound Package contains client lib and sound_server binary for sound system
-
+MMSound package contains focus-server and client interfaces connected to audio system
%package devel
Summary: MMSound development package
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/etc/dbus-1/system.d/
-cp %{SOURCE3} %{buildroot}/etc/dbus-1/system.d/sound-server.conf
cp %{SOURCE6} %{buildroot}/etc/dbus-1/system.d/focus-server.conf
%if "%{tizen_profile_name}" == "tv"
cp %{SOURCE8} %{SOURCE4}
%endif
mkdir -p %{buildroot}/usr/share/dbus-1/system-services/
-cp %{SOURCE9} %{buildroot}/usr/share/dbus-1/system-services/org.tizen.SoundServer.service
%make_install
%if "%{tizen_profile_name}" == "tv"
install -m0644 %{SOURCE7} %{buildroot}%{_sysconfdir}/notstrip/libmm-sound.notstrip
%endif
install -d %{buildroot}%{_unitdir}/paths.target.wants
-install -m0644 %{SOURCE2} %{buildroot}%{_unitdir}/
install -m0644 %{SOURCE4} %{buildroot}%{_unitdir}/
install -m0644 %{SOURCE5} %{buildroot}%{_unitdir}/
ln -sf ../focus-server.path %{buildroot}%{_unitdir}/paths.target.wants/focus-server.path
%manifest libmm-sound.manifest
%defattr(-,root,root,-)
%{_bindir}/focus_server
-%{_bindir}/sound_server
%{_libdir}/libmmfsound.so.*
%{_libdir}/libmmfsoundcommon.so.*
%{_libdir}/libmmfkeysound.so.*
%{_libdir}/libmmfbootsound.so.*
-%{_libdir}/soundplugins/libsoundplugintone.so
-%{_libdir}/soundplugins/libsoundpluginwave.so
-%if 0%{?tizen_audio_feature_ogg_enable}
-%{_libdir}/soundplugins/libsoundplugintremoloogg.so
-%endif
%if "%{tizen_profile_name}" == "tv"
%{_sysconfdir}/notstrip/libmm-sound.notstrip
%endif
%{_unitdir}/paths.target.wants/focus-server.path
%{_unitdir}/focus-server.service
%{_unitdir}/focus-server.path
-/usr/share/sounds/sound-server/*
%license LICENSE.APLv2
-/etc/dbus-1/system.d/sound-server.conf
/etc/dbus-1/system.d/focus-server.conf
-%{_datadir}/dbus-1/system-services/org.tizen.SoundServer.service
-%{_unitdir}/sound-server.service
%if 0%{?gtests:1}
%{_bindir}/gtest-libmm-sound
%endif
+++ /dev/null
-[D-BUS Service]
-Name=org.tizen.SoundServer
-Exec=/bin/false
-SystemdService=sound-server.service
+++ /dev/null
-<?xml version="1.0"?><!--*-nxml-*-->
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
- <policy user="multimedia_fw">
- <allow own="org.tizen.SoundServer"/>
- <allow send_destination="org.tizen.SoundServer"/>
- </policy>
- <policy user="root">
- <allow own="org.tizen.SoundServer"/>
- <allow send_destination="org.tizen.SoundServer"/>
- </policy>
- <policy context="default">
- <deny own="org.tizen.SoundServer"/>
- <deny send_destination="org.tizen.SoundServer"/>
- <allow send_destination="org.tizen.SoundServer" send_interface="org.tizen.SoundServer1"/>
- </policy>
-</busconfig>
-
+++ /dev/null
-[Unit]
-Description=Start the sound-server
-
-[Service]
-ExecStart=/usr/bin/sound_server -S
-Restart=no
-RestartSec=0
-MemoryLimit=50M
-User=multimedia_fw
-Group=multimedia_fw
-SmackProcessLabel=System
-SecureBits=keep-caps
-Capabilities=cap_lease=i
-
+++ /dev/null
-SUBDIRS = plugin
-
-bin_PROGRAMS = sound_server
-sound_server_SOURCES = mm_sound_mgr_codec.c \
- mm_sound_mgr_ipc.c \
- mm_sound_mgr_ipc_dbus.c \
- mm_sound_plugin.c \
- mm_sound_server.c \
- mm_sound_thread_pool.c
-
-sound_server_CFLAGS = -I$(srcdir)/../include \
- -I$(srcdir)/include \
- $(MMCOMMON_CFLAGS) \
- $(MMLOGSVR_CFLAGS) \
- -DMMF_LOG_OWNER=0x002 \
- -DMMF_DEBUG_PREFIX=\"MMF-SOUND\" \
- -D__DEBUG_MODE__ -D__USE_LOGMANAGER__ \
- $(MMSESSION_CFLAGS) \
- $(GLIB2_CFLAGS) \
- $(GIO_CFLAGS)
-
-sound_server_LDADD = $(MMLOGSVR_LIBS) \
- -ldl -lrt \
- $(MMCOMMON_LIBS) \
- $(MMSESSION_LIBS) \
- $(GLIB2_LIBS) \
- $(GIO_LIBS) \
- $(srcdir)/../libmmfsound.la \
- $(srcdir)/../common/libmmfsoundcommon.la
-
-if USE_PULSE
-sound_server_CFLAGS += -DPULSE_CLIENT $(PA_CFLAGS) $(PASIMPLE_CFLAGS)
-sound_server_LDADD += $(PA_LIBS) $(PASIMPLE_CFLAGS)
-endif
-
-sound_server_DEPENDENCIES = $(srcdir)/../common/libmmfsoundcommon.la
-if !USE_PRELINK
-sound_server_CFLAGS += -fPIC -pie
-endif
-installsounddir = $(prefix)/share/sounds/sound-server
-installsound_DATA = sounds/Tizen_HW_Touch.ogg
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-#ifndef __MM_SOUND_MGR_CODEC_H__
-#define __MM_SOUND_MGR_CODEC_H__
-
-#include <stdbool.h>
-
-#include <mm_sound_stream.h>
-
-typedef struct {
- int tone;
- int repeat_count;
- double volume;
- void *stopcb;
- int (*callback)(int, void *, void *, int);
- void *msgcallback; /* Client callback function */
- void *msgdata; /* Client callback data */
- void *param;
- char *pfilename;
- int samplerate;
- int channels;
- int volume_config;
- char stream_type[MAX_STREAM_TYPE_LEN];
- int stream_index;
-} mmsound_mgr_codec_param_t;
-
-int MMSoundMgrCodecInit(const char *targetdir, GSourceFunc _shutdown_cb);
-int MMSoundMgrCodecFini(void);
-
-int MMSoundMgrCodecPlayWithStreamInfo(int *slotid, const mmsound_mgr_codec_param_t *param);
-int MMSoundMgrCodecStop(const int slotid);
-int MMSoundMgrCodecPlayDtmfWithStreamInfo(int *slotid, const mmsound_mgr_codec_param_t *param);
-
-
-#endif /* __MM_SOUND_MGR_CODEC_H__ */
-
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_MGR_IPC_H__
-#define __MM_SOUND_MGR_IPC_H__
-
-#include <glib.h>
-
-/* Msg processing */
-int _MMSoundMgrIpcPlayFileWithStreamInfo(char* filename, int repeat, int volume,
- int client_pid, int *codechandle, char *stream_type, int stream_index);
-int _MMSoundMgrIpcStop(int handle);
-int _MMSoundMgrIpcPlayDTMFWithStreamInfo(int tone, int repeat, int volume, int client_pid, int *codechandle,
- char *stream_type, int stream_index);
-
-int __mm_sound_mgr_ipc_notify_play_file_end(int handle);
-
-#endif /* __MM_SOUND_MGR_H__ */
+++ /dev/null
-#ifndef __MM_SOUND_MGR_IPC_DBUS_H__
-#define __MM_SOUND_MGR_IPC_DBUS_H__
-
-#include <gio/gio.h>
-
-int __mm_sound_mgr_ipc_dbus_notify_play_file_end(int handle);
-
-int MMSoundMgrDbusInit(void);
-void MMSoundMgrDbusFini(void);
-
-
-#endif /* __MM_SOUND_MGR_DBUS_H__ */
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-#ifndef __MM_SOUND_PLUGIN_H__
-#define __MM_SOUND_PLUGIN_H__
-
-enum {
- MM_SOUND_PLUGIN_TYPE_NONE = 0,
- MM_SOUND_PLUGIN_TYPE_CODEC,
- MM_SOUND_PLUGIN_TYPE_RUN,
- MM_SOUND_PLUGIN_TYPE_LAST,
-};
-
-typedef struct {
- int type;
- void *module;
-} MMSoundPluginType;
-
-/* Plugin Interface */
-int MMSoundGetPluginType(void);
-
-/* Utility Interfaces */
-int MMSoundPluginScan(const char *plugindir, const int type, MMSoundPluginType **pluginlist);
-int MMSoundPluginRelease(MMSoundPluginType *pluginlist);
-
-int MMSoundPluginOpen(char *file, MMSoundPluginType *plugin);
-int MMSoundPluginClose(MMSoundPluginType *plugin);
-int MMSoundPluginGetSymbol(MMSoundPluginType *plugin, const char *symbol, void **func);
-
-#endif /* __MM_SOUND_PLUGIN_H__ */
-
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_PLUGIN_CODEC_H__
-#define __MM_SOUND_PLUGIN_CODEC_H__
-
-#include "mm_sound_plugin.h"
-#include <mm_types.h>
-
-#define MAX_STREAM_TYPE_LEN 64
-#define MM_SOUND_MAX_FILENAME 256
-
-enum MMSoundSupportedCodec {
- MM_SOUND_SUPPORTED_CODEC_INVALID = -1, /**< Invalid codec type */
- MM_SOUND_SUPPORTED_CODEC_WAVE, /**< WAVE codec */
- MM_SOUND_SUPPORTED_CODEC_DTMF, /**< DTMF codec */
- MM_SOUND_SUPPORTED_CODEC_NUM, /**< Number of audio codec type */
-};
-
-typedef struct {
- int codec;
- int channels;
- int samplerate;
- int format;
- int doffset;
- int size;
- int duration; /**the wav file play duration, Unit: ms*/
-} mmsound_codec_info_t;
-
-typedef struct {
- int (*stop_cb)(int, bool);
- int pid;
- int param;
- int tone;
- int repeat_count;
- double volume;
- int volume_config;
- int keytone;
- char *pfilename;
- char stream_type[MAX_STREAM_TYPE_LEN];
- int stream_index;
- pthread_mutex_t *codec_wave_mutex;
-} mmsound_codec_param_t;
-
-typedef struct {
- int* (*GetSupportTypes)(void);
- int (*SetThreadPool) (int (*)(void*, void (*)(void*)));
- int (*Parse)(const char*, mmsound_codec_info_t*);
- int (*Create)(mmsound_codec_param_t*, mmsound_codec_info_t*, MMHandleType*);
- int (*Play)(MMHandleType);
- int (*Stop)(MMHandleType);
- int (*Destroy)(MMHandleType);
-} mmsound_codec_interface_t;
-
-/* Utility Functions */
-#define CODEC_GET_INTERFACE_FUNC_NAME "MMSoundPlugCodecGetInterface"
-#define MMSoundPlugCodecCastGetInterface(func) ((int (*)(mmsound_codec_interface_t*))(func))
-
-int MMSoundPlugCodecGetInterface(mmsound_codec_interface_t *intf);
-
-#endif /* __MM_SOUND_PLUGIN_CODEC_H__ */
-
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __MM_SOUND_THREAD_POOL_H__
-#define __MM_SOUND_THREAD_POOL_H__
-
-#include <glib.h>
-
-int MMSoundThreadPoolDump(int fulldump);
-int MMSoundThreadPoolInit(void);
-int MMSoundThreadPoolRun(void *param, void (*func)(void*));
-int MMSoundThreadPoolFini(void);
-
-#endif /* __MM_SOUND_THREAD_POOL_H__ */
+++ /dev/null
-
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <pthread.h>
-#include <unistd.h>
-
-#include <mm_error.h>
-#include <mm_types.h>
-#include <mm_debug.h>
-
-#include <glib.h>
-
-#include "include/mm_sound_mgr_codec.h"
-#include "include/mm_sound_mgr_ipc.h"
-#include "include/mm_sound_plugin_codec.h"
-#include "include/mm_sound_thread_pool.h"
-
-#include "../include/mm_sound_common.h"
-#include "../include/mm_sound.h"
-
-#define SHUTDOWN_TIMEOUT_SEC 60
-#define STATUS_IDLE 0
-#define STATUS_SOUND 3
-#define SOUND_SLOT_START 0
-#define MANAGER_HANDLE_MAX 256
-
-typedef struct {
- int (*callback)(int, void *, void *, int); /* msg_type(pid) client callback & client data info */
- void *param;
- int pid;
- void *msgcallback;
- void *msgdata;
- MMHandleType plughandle;
-
- int pluginid;
- int status;
-} __mmsound_mgr_codec_handle_t;
-
-static MMSoundPluginType *g_codec_plugins = NULL;
-static __mmsound_mgr_codec_handle_t g_slots[MANAGER_HANDLE_MAX];
-static mmsound_codec_interface_t g_plugins[MM_SOUND_SUPPORTED_CODEC_NUM];
-static pthread_mutex_t g_slot_mutex;
-static GSourceFunc g_shutdown_cb;
-static guint g_timer_id = 0;
-
-#ifdef DEBUG_DETAIL
-#define SLOT_LOCK() do { \
- debug_msg("Before Slot_mutex LOCK"); \
- pthread_mutex_lock(&g_slot_mutex); \
- debug_msg("After Slot_mutex LOCK"); \
-} while (0)
-#define SLOT_UNLOCK() do { \
- debug_msg("Before Slot_mutex UNLOCK"); \
- pthread_mutex_unlock(&g_slot_mutex); \
- debug_msg("After Slot_mutex UNLOCK"); \
-} while (0)
-#else
-#define SLOT_LOCK() do { pthread_mutex_lock(&g_slot_mutex); } while (0)
-#define SLOT_UNLOCK() do { pthread_mutex_unlock(&g_slot_mutex); } while (0)
-#endif
-
-static int _MMSoundMgrCodecRegisterInterface(MMSoundPluginType *plugin);
-static int _MMSoundMgrCodecStopCallback(int slotid, bool stop_by_user);
-static gboolean _mm_sound_mgr_codec_slot_is_empty();
-
-static gboolean _idle_cb(gpointer user_data)
-{
- if (_mm_sound_mgr_codec_slot_is_empty()) {
- debug_msg("slot is empty, ready to shutdown! %p", g_shutdown_cb);
- if (g_shutdown_cb)
- g_shutdown_cb(NULL);
- } else {
- debug_warning("slot is not empty!!! no shutdown...");
- }
-
- return FALSE;
-}
-
-static gboolean _timeout_cb(gpointer user_data)
-{
- debug_warning("TIMEOUT : add idle callback now...");
-
- g_idle_add(_idle_cb, NULL);
- g_timer_id = 0;
-
- return FALSE;
-}
-
-
-/* FIXME : critical section for g_timer_id? */
-static void _mm_sound_mgr_codec_shutdown_timer_start()
-{
- if (g_timer_id > 0) {
- debug_error("Already active timer [%d] exists", g_timer_id);
- return;
- }
- if (g_shutdown_cb) {
- g_timer_id = g_timeout_add_seconds(SHUTDOWN_TIMEOUT_SEC, _timeout_cb, NULL);
- debug_warning("TIMER : new timer [%d]", g_timer_id);
- } else {
- debug_warning("No Timer started due to invalid shutdown callback");
- }
-}
-
-static void _mm_sound_mgr_codec_shutdown_timer_stop()
-{
- if (g_timer_id > 0) {
- debug_warning("TIMER : remove timer id [%d]", g_timer_id);
- g_source_remove(g_timer_id);
- g_timer_id = 0;
- } else {
- debug_log("No Timer to stop...");
- }
-}
-
-static int _mm_sound_mgr_codec_slot_get_empty(int *slot)
-{
- int slotid = 0;
- int err = MM_ERROR_NONE;
-
- SLOT_LOCK();
-
- while (1) {
- for (slotid = SOUND_SLOT_START; slotid < MANAGER_HANDLE_MAX ; slotid++) {
- if (g_slots[slotid].status == STATUS_IDLE) {
- g_slots[slotid].status = STATUS_SOUND;
- break;
- }
- }
-
- if (slotid < MANAGER_HANDLE_MAX) {
- debug_msg("New handle allocated (codec slot ID : [%d])", slotid);
- *slot = slotid;
- break;
- }
-
- /* FIXME: avoiding infinite wait is required */
- debug_warning("Handle is full..wait for a while and will retry...");
- sleep(1);
- }
-
- _mm_sound_mgr_codec_shutdown_timer_stop();
-
- SLOT_UNLOCK();
-
- return err;
-}
-
-static gboolean _mm_sound_mgr_codec_slot_is_empty()
-{
- int slotid = 0;
-
- for (slotid = SOUND_SLOT_START; slotid < MANAGER_HANDLE_MAX ; slotid++) {
- if (g_slots[slotid].status == STATUS_SOUND)
- break;
- }
-
- return (slotid == MANAGER_HANDLE_MAX) ? TRUE : FALSE;
-}
-
-static void _mm_sound_mgr_codec_slot_clear(int slotid, bool dump)
-{
- memset(&g_slots[slotid], 0, sizeof(__mmsound_mgr_codec_handle_t));
- g_slots[slotid].status = STATUS_IDLE;
-
- if (dump)
- debug_warning("SlotID [%d] cleared", slotid);
-}
-
-int MMSoundMgrCodecInit(const char *targetdir, GSourceFunc _shutdown_cb)
-{
- int loop = 0;
- int slotid = 0;
-
- debug_enter();
-
- memset(g_slots, 0, sizeof(g_slots));
-
- if (pthread_mutex_init(&g_slot_mutex, NULL)) {
- debug_error("pthread_mutex_init failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- for (slotid = 0; slotid < MANAGER_HANDLE_MAX; slotid++)
- _mm_sound_mgr_codec_slot_clear(slotid, false);
-
- if (g_codec_plugins) {
- debug_warning("Please Check Init twice");
- MMSoundPluginRelease(g_codec_plugins);
- }
-
- MMSoundPluginScan(targetdir, MM_SOUND_PLUGIN_TYPE_CODEC, &g_codec_plugins);
- if (g_codec_plugins) {
- while (g_codec_plugins[loop].type != MM_SOUND_PLUGIN_TYPE_NONE)
- _MMSoundMgrCodecRegisterInterface(&g_codec_plugins[loop++]);
- }
-
- if (_shutdown_cb)
- g_shutdown_cb = _shutdown_cb;
- else
- debug_warning("shutdown callback is NULL");
-
- debug_leave();
- return MM_ERROR_NONE;
-}
-
-int MMSoundMgrCodecFini(void)
-{
- debug_enter();
-
- memset(g_plugins, 0, sizeof(mmsound_codec_interface_t) * MM_SOUND_SUPPORTED_CODEC_NUM);
- MMSoundPluginRelease(g_codec_plugins);
- g_codec_plugins = NULL;
- pthread_mutex_destroy(&g_slot_mutex);
-
- debug_leave();
- return MM_ERROR_NONE;
-}
-
-static int _MMSoundMgrCodecFindCodecPluginID(enum MMSoundSupportedCodec codec_to_find)
-{
- int plugin_id = 0;
- int *codec_type;
-
- for (plugin_id = 0; plugin_id < MM_SOUND_SUPPORTED_CODEC_NUM; plugin_id++) {
- if (g_plugins[plugin_id].GetSupportTypes) {
- codec_type = g_plugins[plugin_id].GetSupportTypes();
- if (codec_type[0] == codec_to_find)
- return plugin_id;
- }
- }
-
- return -1;
-}
-
-int MMSoundMgrCodecPlayWithStreamInfo(int *slotid, const mmsound_mgr_codec_param_t *param)
-{
- int plugin_id = 0;
- mmsound_codec_info_t info;
- mmsound_codec_param_t codec_param;
- int err = MM_ERROR_NONE;
-
-#ifdef DEBUG_DETAIL
- debug_enter();
-#endif
- plugin_id = _MMSoundMgrCodecFindCodecPluginID(MM_SOUND_SUPPORTED_CODEC_WAVE);
- if (plugin_id == -1) {
- debug_error("Could not find proper codec plugin!!!");
- err = MM_ERROR_SOUND_INTERNAL;
- goto cleanup;
- }
-
- err = g_plugins[plugin_id].Parse(param->pfilename, &info);
- if (err != MM_ERROR_NONE) {
- debug_error("Could not parse file [%s] by plugin[%d]", param->pfilename, plugin_id);
- goto cleanup;
- }
-
- err = _mm_sound_mgr_codec_slot_get_empty(slotid);
- if (err != MM_ERROR_NONE || *slotid < 0) {
- debug_error("Empty g_slot is not found");
- goto cleanup;
- }
-
- codec_param.volume_config = -1; //setting volume config to -1 since using stream info instead of volume type
- codec_param.repeat_count = param->repeat_count;
- codec_param.volume = param->volume;
- codec_param.pfilename = param->pfilename;
- codec_param.stop_cb = _MMSoundMgrCodecStopCallback;
- codec_param.param = *slotid;
- codec_param.pid = (int)param->param;
- codec_param.stream_index = param->stream_index;
- MMSOUND_STRNCPY(codec_param.stream_type, param->stream_type, MAX_STREAM_TYPE_LEN);
- SLOT_LOCK();
-
- /* Codec id WAV or MP3 */
- g_slots[*slotid].pluginid = plugin_id;
- g_slots[*slotid].param = param->param; /* This arg is used callback data */
-
- debug_msg("Using Slotid : [%d] Slot Status : [%d]", *slotid, g_slots[*slotid].status);
-
- err = g_plugins[g_slots[*slotid].pluginid].Create(&codec_param, &info, &(g_slots[*slotid].plughandle));
- debug_msg("Created audio handle : [%p]", g_slots[*slotid].plughandle);
- if (err != MM_ERROR_NONE) {
- debug_error("Plugin create fail : 0x%08X", err);
- g_slots[*slotid].status = STATUS_IDLE;
- SLOT_UNLOCK();
- goto cleanup;
- }
-
- err = g_plugins[g_slots[*slotid].pluginid].Play(g_slots[*slotid].plughandle);
- if (err != MM_ERROR_NONE) {
- debug_error("Fail to play : 0x%08X", err);
- g_plugins[g_slots[*slotid].pluginid].Destroy(g_slots[*slotid].plughandle);
- }
-
- SLOT_UNLOCK();
-
-cleanup:
- if (_mm_sound_mgr_codec_slot_is_empty())
- _mm_sound_mgr_codec_shutdown_timer_start();
-
-#ifdef DEBUG_DETAIL
- debug_leave();
-#endif
-
- return err;
-
-}
-
-int MMSoundMgrCodecPlayDtmfWithStreamInfo(int *slotid, const mmsound_mgr_codec_param_t *param)
-{
- int plugin_id = 0;
- mmsound_codec_info_t info;
- mmsound_codec_param_t codec_param;
- int err = MM_ERROR_NONE;
-
-#ifdef DEBUG_DETAIL
- debug_enter();
-#endif
- plugin_id = _MMSoundMgrCodecFindCodecPluginID(MM_SOUND_SUPPORTED_CODEC_DTMF);
- if (plugin_id == -1) {
- debug_error("Could not find proper codec plugin!!!");
- err = MM_ERROR_SOUND_INTERNAL;
- goto cleanup;
- }
-
- /*The count num means codec type DTMF */
- debug_msg("DTMF[%d] Repeat[%d] Volume[%f] plugin_codec[%d]", param->tone, param->repeat_count, param->volume, plugin_id);
-
- if (g_plugins[plugin_id].GetSupportTypes == NULL) { /* Codec not found */
- debug_error("unsupported file type %d", plugin_id);
- printf("unsupported file type %d", plugin_id);
- err = MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE;
- goto cleanup;
- }
-
-#ifdef DEBUG_DETAIL
- debug_msg("Get New handle");
-#endif
-
- err = _mm_sound_mgr_codec_slot_get_empty(slotid);
- if (err != MM_ERROR_NONE || *slotid < 0) {
- debug_error("Empty g_slot is not found");
- goto cleanup;
- }
-
- codec_param.tone = param->tone;
- codec_param.repeat_count = param->repeat_count;
- codec_param.volume = param->volume;
- codec_param.stop_cb = _MMSoundMgrCodecStopCallback;
- codec_param.param = *slotid;
- codec_param.pid = (int)param->param;
- codec_param.volume_config = -1; //setting volume config to -1 since using stream info instead of volume type
- codec_param.stream_index = param->stream_index;
- MMSOUND_STRNCPY(codec_param.stream_type, param->stream_type, MAX_STREAM_TYPE_LEN);
- SLOT_LOCK();
-
- g_slots[*slotid].pluginid = plugin_id;
- g_slots[*slotid].param = param->param; /* This arg is used callback data */
-
-#ifdef DEBUG_DETAIL
- debug_msg("Using Slotid : [%d] Slot Status : [%d]", *slotid, g_slots[*slotid].status);
-#endif
-
- err = g_plugins[g_slots[*slotid].pluginid].Create(&codec_param, &info, &(g_slots[*slotid].plughandle));
- debug_msg("Created audio handle : [%p]", g_slots[*slotid].plughandle);
- if (err != MM_ERROR_NONE) {
- debug_error("Plugin create fail : 0x%08X", err);
- g_slots[*slotid].status = STATUS_IDLE;
- SLOT_UNLOCK();
- goto cleanup;
- }
-
- err = g_plugins[g_slots[*slotid].pluginid].Play(g_slots[*slotid].plughandle);
- if (err != MM_ERROR_NONE) {
- debug_error("Fail to play : 0x%08X", err);
- g_plugins[g_slots[*slotid].pluginid].Destroy(g_slots[*slotid].plughandle);
- }
-
- SLOT_UNLOCK();
- debug_msg("Using Slotid : [%d] Slot Status : [%d]", *slotid, g_slots[*slotid].status);
-
-cleanup:
-#ifdef DEBUG_DETAIL
- debug_leave();
-#endif
-
- return err;
-
-}
-
-int MMSoundMgrCodecStop(const int slotid)
-{
- int err = MM_ERROR_NONE;
-
- debug_enter("(Slotid : [%d])", slotid);
-
- if (slotid < 0 || MANAGER_HANDLE_MAX <= slotid)
- return MM_ERROR_INVALID_ARGUMENT;
-
- SLOT_LOCK();
- if (g_slots[slotid].status == STATUS_IDLE) {
- err = MM_ERROR_SOUND_INVALID_STATE;
- debug_warning("The playing slots is not found, Slot ID : [%d]", slotid);
- goto cleanup;
- }
-#ifdef DEBUG_DETAIL
- debug_msg("Found slot, Slotid [%d] State [%d]", slotid, g_slots[slotid].status);
-#endif
-
- err = g_plugins[g_slots[slotid].pluginid].Stop(g_slots[slotid].plughandle);
- if (err != MM_ERROR_NONE)
- debug_error("Fail to STOP Code : 0x%08X", err);
-
-cleanup:
- SLOT_UNLOCK();
- debug_leave("(err : 0x%08X)", err);
-
- return err;
-}
-
-static int _MMSoundMgrCodecStopCallback(int slotid, bool stop_by_user)
-{
- int err = MM_ERROR_NONE;
-
- if (slotid < 0 || slotid >= MANAGER_HANDLE_MAX) {
- debug_error("Slot(%d) is invalid", slotid);
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- debug_enter("Slot(%d) : stop-by-user(%d)", slotid, stop_by_user);
-
- if (!stop_by_user) {
- /* NOTE : slot is already locked by MMSoundMgrCodecStop() in user stop case */
- SLOT_LOCK();
-
- if (g_slots[slotid].pluginid == MM_SOUND_SUPPORTED_CODEC_WAVE)
- __mm_sound_mgr_ipc_notify_play_file_end(slotid);
-
- debug_msg("Client callback msg_type (instance) : [%d]", (int)g_slots[slotid].param);
- }
-
- debug_msg("Handle allocated handle : [%p]", g_slots[slotid].plughandle);
- err = g_plugins[g_slots[slotid].pluginid].Destroy(g_slots[slotid].plughandle);
- if (err < 0)
- debug_critical("Slot(%d) : Fail to destroy slot, err [0x%x]", slotid, err);
-
- _mm_sound_mgr_codec_slot_clear(slotid, true);
- if (_mm_sound_mgr_codec_slot_is_empty())
- _mm_sound_mgr_codec_shutdown_timer_start();
-
- if (!stop_by_user)
- SLOT_UNLOCK();
-
- debug_fleave();
-
- return err;
-}
-
-
-
-static int _MMSoundMgrCodecRegisterInterface(MMSoundPluginType *plugin)
-{
- int err = MM_ERROR_NONE;
- int plugin_id = 0;
- void *getinterface = NULL;
-
-#ifdef DEBUG_DETAIL
- debug_enter();
-#endif
-
- /* find emptry slot */
- for (plugin_id = 0; plugin_id < MM_SOUND_SUPPORTED_CODEC_NUM; plugin_id++) {
- if (g_plugins[plugin_id].GetSupportTypes == NULL)
- break;
- }
-
- if (plugin_id == MM_SOUND_SUPPORTED_CODEC_NUM) {
- debug_critical("The plugin support type is not valid");
- return MM_ERROR_COMMON_OUT_OF_RANGE;
- }
-
- err = MMSoundPluginGetSymbol(plugin, CODEC_GET_INTERFACE_FUNC_NAME, &getinterface);
- if (err != MM_ERROR_NONE) {
- debug_error("Get Symbol CODEC_GET_INTERFACE_FUNC_NAME is fail : %x", err);
- goto cleanup;
- }
- debug_msg("interface[%p] empty_slot[%d]", getinterface, plugin_id);
-
- err = MMSoundPlugCodecCastGetInterface(getinterface)(&g_plugins[plugin_id]);
- if (err != MM_ERROR_NONE) {
- debug_error("Get interface fail : %x", err);
-
-cleanup:
- /* If error occur, clean interface */
- memset(&g_plugins[plugin_id], 0, sizeof(mmsound_codec_interface_t));
- } else {
- if (g_plugins[plugin_id].SetThreadPool)
- g_plugins[plugin_id].SetThreadPool(MMSoundThreadPoolRun);
- }
-
-#ifdef DEBUG_DETAIL
- debug_leave();
-#endif
-
- return err;
-}
-
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "include/mm_sound_mgr_ipc.h"
-#include "include/mm_sound_mgr_ipc_dbus.h"
-
-#include "../include/mm_sound_common.h"
-#include "include/mm_sound_mgr_codec.h"
-#include <mm_debug.h>
-#include <mm_error.h>
-
-/******************************************************************************************
- Functions For handling request from client
-******************************************************************************************/
-// except msgid
-int _MMSoundMgrIpcStop(int handle)
-{
- int ret = MM_ERROR_NONE;
-
- ret = MMSoundMgrCodecStop(handle);
-
- if (ret != MM_ERROR_NONE) {
- debug_error("Fail to stop sound");
- return ret;
- }
-
- return MM_ERROR_NONE;
-}
-
-int _MMSoundMgrIpcPlayFileWithStreamInfo(char *filename, int repeat, int volume,
- int client_pid, int *codechandle, char *stream_type, int stream_index)
-{
- mmsound_mgr_codec_param_t param = { 0, };
- int ret = MM_ERROR_NONE;
-
- /* Set sound player parameter */
- param.repeat_count = repeat;
- param.volume = volume;
- param.param = (void*)client_pid;
- param.pfilename = filename;
- param.stream_index = stream_index;
- MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
-
- ret = MMSoundMgrCodecPlayWithStreamInfo(codechandle, ¶m);
- if (ret != MM_ERROR_NONE) {
- debug_error("Will be closed a sources, codechandle : 0x%08X", *codechandle);
- return ret;
- }
-
- return MM_ERROR_NONE;
-
-}
-
-int _MMSoundMgrIpcPlayDTMFWithStreamInfo(int tone, int repeat, int volume, int client_pid, int *codechandle,
- char *stream_type, int stream_index)
-{
- mmsound_mgr_codec_param_t param = { 0, };
- int ret = MM_ERROR_NONE;
-
- /* Set sound player parameter */
- param.tone = tone;
- param.repeat_count = repeat;
- param.volume = volume;
- param.param = (void*)client_pid;
- param.stream_index = stream_index;
- MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
-
- debug_msg("DTMF %d", param.tone);
- debug_msg("Loop %d", param.repeat_count);
- debug_msg("Volume %f", param.volume);
- debug_msg("stream type %s", param.stream_type);
- debug_msg("stream index %d", param.stream_index);
-
-
- ret = MMSoundMgrCodecPlayDtmfWithStreamInfo(codechandle, ¶m);
- if (ret != MM_ERROR_NONE) {
- debug_error("Will be closed a sources, codec handle : [0x%d]", *codechandle);
- return ret;
- }
-
- return ret;
-}
-
-/******************************************************************************************
- Functions For Server-Side to notify Clients
-******************************************************************************************/
-
-int __mm_sound_mgr_ipc_notify_play_file_end(int handle)
-{
- return __mm_sound_mgr_ipc_dbus_notify_play_file_end(handle);
-}
-
+++ /dev/null
-
-#include <string.h>
-
-#include <mm_error.h>
-#include <mm_debug.h>
-
-#include <gio/gio.h>
-
-#include "include/mm_sound_mgr_ipc_dbus.h"
-#include "include/mm_sound_mgr_ipc.h"
-#include "../include/mm_sound_dbus.h"
-
-
-#define BUS_NAME_SOUND_SERVER "org.tizen.SoundServer"
-#define OBJECT_SOUND_SERVER "/org/tizen/SoundServer1"
-#define INTERFACE_SOUND_SERVER "org.tizen.SoundServer1"
-
-/* workaround for AF volume gain tuning */
-#define PROC_DBUS_OBJECT "/Org/Tizen/ResourceD/Process"
-#define PROC_DBUS_INTERFACE "org.tizen.resourced.process"
-#define PROC_DBUS_METHOD "ProcExclude"
-
-/* Introspection data for the service we are exporting */
-static const gchar introspection_xml[] =
- "<node>"
- " <interface name='org.tizen.SoundServer1'>"
- " <method name='MethodTest1'>"
- " <arg type='i' name='num1' direction='in'/>"
- " <arg type='i' name='num2' direction='in'/>"
- " <arg type='i' name='multiple' direction='out'/>"
- " </method>"
- " <method name='GetBTA2DPStatus'>"
- " <arg type='b' name='is_bt_on' direction='out'/>"
- " <arg type='s' name='bt_name' direction='out'/>"
- " </method>"
- " <method name='PlayFileStartWithStreamInfo'>"
- " <arg type='s' name='filename' direction='in'/>"
- " <arg type='i' name='repeat' direction='in'/>"
- " <arg type='i' name='volume' direction='in'/>"
- " <arg type='i' name='client_pid' direction='in'/>"
- " <arg type='s' name='stream_type' direction='in'/>"
- " <arg type='i' name='stream_index' direction='in'/>"
- " <arg type='i' name='handle' direction='out'/>"
- " </method>"
- " <method name='StopTone'>"
- " <arg type='i' name='handle' direction='in'/>"
- " </method>"
- " <method name='PlayDTMFWithStreamInfo'>"
- " <arg type='i' name='tone' direction='in'/>"
- " <arg type='i' name='repeat' direction='in'/>"
- " <arg type='i' name='volume' direction='in'/>"
- " <arg type='i' name='client_pid' direction='in'/>"
- " <arg type='s' name='stream_type' direction='in'/>"
- " <arg type='i' name='stream_index' direction='in'/>"
- " <arg type='i' name='handle' direction='out'/>"
- " </method>"
- " <method name='GetConnectedDeviceList'>"
- " <arg type='i' name='device_mask' direction='in'/>"
- " <arg type='a(iiiis)' name='device_list' direction='out'/>"
- " </method>"
- " </interface>"
- "</node>";
-static GDBusConnection* conn_g;
-
-static void handle_method_play_file_start_with_stream_info(GDBusMethodInvocation* invocation);
-static void handle_method_play_file_stop(GDBusMethodInvocation* invocation);
-static void handle_method_play_dtmf_with_stream_info(GDBusMethodInvocation* invocation);
-static void handle_method_test(GDBusMethodInvocation* invocation);
-
-/* Currently , Just using method's name and handler */
-/* TODO : generate introspection xml automatically, with these value include argument and reply */
-/* TODO : argument check with these information */
-/* TODO : divide object and interface with features (ex. play, path, device) */
-static mm_sound_dbus_method_intf_t methods[AUDIO_METHOD_MAX] = {
- [AUDIO_METHOD_TEST] = {
- .info = {
- .name = "MethodTest1",
- },
- .handler = handle_method_test
- },
- [AUDIO_METHOD_STOP_TONE] = {
- .info = {
- .name = "StopTone",
- },
- .handler = handle_method_play_file_stop
- },
- [AUDIO_METHOD_PLAY_DTMF_WITH_STREAM_INFO] = {
- .info = {
- .name = "PlayDTMFWithStreamInfo",
- },
- .handler = handle_method_play_dtmf_with_stream_info
- },
-};
-
-static GDBusNodeInfo *introspection_data = NULL;
-static guint sound_server_owner_id ;
-
-/*
- For pass error code with 'g_dbus_method_invocation_return_error'
- We have to use some glib features like GError, GQuark
-*/
-/* Only For error types which is currently being used in server-side */
-static const GDBusErrorEntry mm_sound_error_entries[] = {
- {MM_ERROR_OUT_OF_MEMORY, "org.tizen.multimedia.OutOfMemory"},
- {MM_ERROR_OUT_OF_STORAGE, "org.tizen.multimedia.OutOfStorage"},
- {MM_ERROR_INVALID_ARGUMENT, "org.tizen.multimedia.InvalidArgument"},
- {MM_ERROR_POLICY_INTERNAL, "org.tizen.multimedia.PolicyInternal"},
- {MM_ERROR_NOT_SUPPORT_API, "org.tizen.multimedia.NotSupportAPI"},
- {MM_ERROR_POLICY_BLOCKED, "org.tizen.multimedia.PolicyBlocked"},
- {MM_ERROR_END_OF_FILE, "org.tizen.multimedia.EndOfFile"},
- {MM_ERROR_COMMON_OUT_OF_RANGE, "org.tizen.multimedia.common.OutOfRange"},
- {MM_ERROR_COMMON_UNKNOWN, "org.tizen.multimedia.common.Unknown"},
- {MM_ERROR_COMMON_NO_FREE_SPACE, "org.tizen.multimedia.common.NoFreeSpace"},
- {MM_ERROR_SOUND_INTERNAL, "org.tizen.multimedia.audio.Internal"},
- {MM_ERROR_SOUND_INVALID_STATE, "org.tizen.multimedia.audio.InvalidState"},
- {MM_ERROR_SOUND_NO_FREE_SPACE, "org.tizen.multimedia.audio.NoFreeSpace"},
- {MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE, "org.tizen.multimedia.audio.UnsupportedMediaType"},
- {MM_ERROR_SOUND_INVALID_POINTER, "org.tizen.multimedia.audio.InvalidPointer"},
- {MM_ERROR_SOUND_INVALID_FILE, "org.tizen.multimedia.audio.InvalidFile"},
- {MM_ERROR_SOUND_FILE_NOT_FOUND, "org.tizen.multimedia.audio.FileNotFound"},
- {MM_ERROR_SOUND_NO_DATA, "org.tizen.multimedia.audio.NoData"},
- {MM_ERROR_SOUND_INVALID_PATH, "org.tizen.multimedia.audio.InvalidPath"},
-};
-
-static const char* _convert_error_code(int err_code)
-{
- int i = 0;
-
- for (i = 0; i < G_N_ELEMENTS(mm_sound_error_entries); i++) {
- if (err_code == mm_sound_error_entries[i].error_code)
- return mm_sound_error_entries[i].dbus_error_name;
- }
-
- return "org.tizen.multimedia.common.Unknown";
-}
-
-static int mm_sound_mgr_ipc_dbus_send_signal(audio_event_t event, GVariant *parameter)
-{
- if (mm_sound_dbus_emit_signal(AUDIO_PROVIDER_SOUND_SERVER, event, parameter) != MM_ERROR_NONE) {
- debug_error("Sound Server Emit signal failed");
- return MM_ERROR_SOUND_INTERNAL;
- }
- return MM_ERROR_NONE;
-}
-
-static int _get_sender_pid(GDBusMethodInvocation* invocation)
-{
- GVariant* value;
- guint pid = 0;
- const gchar* sender;
- GDBusConnection * connection = NULL;
- GError* err = NULL;
-
- connection = g_dbus_method_invocation_get_connection(invocation);
- sender = g_dbus_method_invocation_get_sender(invocation);
-
- debug_log("connection = %p, sender = %s", connection, sender);
-
- value = g_dbus_connection_call_sync(connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",
- "org.freedesktop.DBus", "GetConnectionUnixProcessID",
- g_variant_new("(s)", sender, NULL), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
- if (value) {
- g_variant_get(value, "(u)", &pid);
- debug_log("Sender PID = [%d]", pid);
- g_variant_unref(value);
- } else {
- debug_error("err code = %d, err msg = %s", err->code, err->message);
- }
- return pid;
-}
-
-static void _method_call_return_value(GDBusMethodInvocation *invocation, GVariant *params)
-{
- const char *method_name;
- method_name = g_dbus_method_invocation_get_method_name(invocation);
- debug_msg("Method Call '%s' success", method_name);
- g_dbus_method_invocation_return_value(invocation, params);
-}
-static void _method_call_return_error(GDBusMethodInvocation *invocation, int ret)
-{
- const char *err_name, *method_name;
- err_name = _convert_error_code(ret);
- method_name = g_dbus_method_invocation_get_method_name(invocation);
- debug_error("Method Call '%s' failed, err '%s(%X)'", method_name, err_name, ret);
- g_dbus_method_invocation_return_dbus_error(invocation, err_name, "failed");
-}
-
-static void handle_method_test(GDBusMethodInvocation* invocation)
-{
- int ret = MM_ERROR_NONE;
- int val = 0, val2 = 0;
- GVariant *params = NULL;
-
- debug_fenter();
-
- if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
- debug_error("Parameter for Method is NULL");
- ret = MM_ERROR_SOUND_INTERNAL;
- goto send_reply;
- }
-
- g_variant_get(params, "(ii)", &val, &val2);
- debug_log("Got value : %d , %d", val, val2);
-
- if ((ret = mm_sound_mgr_ipc_dbus_send_signal(AUDIO_EVENT_TEST, g_variant_new("(i)", val+val2))) != MM_ERROR_NONE)
- debug_error("signal send error : %X", ret);
- else
- debug_error("signal send success");
-
-send_reply:
- if (ret == MM_ERROR_NONE) {
- _method_call_return_value(invocation, g_variant_new("(i)", val * val2));
- } else {
- ret = MM_ERROR_INVALID_ARGUMENT;
- _method_call_return_error(invocation, ret);
- }
-
- debug_fleave();
-}
-
-static void handle_method_play_file_start_with_stream_info(GDBusMethodInvocation* invocation)
-{
- gchar* filename = NULL;
- gchar *stream_type = NULL;
- gint32 ret = MM_ERROR_NONE, slotid = 0;
- gint32 repeat = 0, volume = 0, pid = 0, stream_index = 0;
- GVariant *params = NULL;
-
- debug_fenter();
-
- if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
- debug_error("Parameter for Method is NULL");
- ret = MM_ERROR_SOUND_INTERNAL;
- goto send_reply;
- }
-
- g_variant_get(params, "(siiisi)", &filename, &repeat, &volume, &pid, &stream_type, &stream_index);
- if (!filename) {
- debug_error("filename null");
- ret = MM_ERROR_SOUND_INTERNAL;
- goto send_reply;
- }
- ret = _MMSoundMgrIpcPlayFileWithStreamInfo(filename, repeat, volume, _get_sender_pid(invocation),
- &slotid, stream_type, stream_index);
-
-send_reply:
- if (ret == MM_ERROR_NONE)
- _method_call_return_value(invocation, g_variant_new("(i)", slotid));
- else
- _method_call_return_error(invocation, ret);
-
- g_free(filename);
- g_free(stream_type);
-
- debug_fleave();
-}
-
-static void handle_method_play_dtmf_with_stream_info(GDBusMethodInvocation* invocation)
-{
- int ret = MM_ERROR_NONE, slotid = 0;
- int tone = 0, repeat = 0, volume = 0, pid = 0, stream_index = 0;
- char* stream_type = NULL;
- GVariant *params = NULL;
-
- debug_fenter();
-
- if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
- debug_error("Parameter for Method is NULL");
- ret = MM_ERROR_SOUND_INTERNAL;
- goto send_reply;
- }
-
- g_variant_get(params, "(iiiisi)", &tone, &repeat, &volume, &pid, &stream_type, &stream_index);
- ret = _MMSoundMgrIpcPlayDTMFWithStreamInfo(tone, repeat, volume, _get_sender_pid(invocation), &slotid, stream_type, stream_index);
-
-send_reply:
- if (ret == MM_ERROR_NONE)
- _method_call_return_value(invocation, g_variant_new("(i)", slotid));
- else
- _method_call_return_error(invocation, ret);
-
- debug_fleave();
-}
-
-static void handle_method_play_file_stop(GDBusMethodInvocation* invocation)
-{
- int ret = MM_ERROR_NONE;
- int handle = 0;
- GVariant *params = NULL;
-
- debug_fenter();
-
- if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
- debug_error("Parameter for Method is NULL");
- ret = MM_ERROR_SOUND_INTERNAL;
- goto send_reply;
- }
-
- g_variant_get(params, "(i)", &handle);
- ret = _MMSoundMgrIpcStop(handle);
-
-send_reply:
- if (ret == MM_ERROR_NONE)
- _method_call_return_value(invocation, g_variant_new("()"));
- else
- _method_call_return_error(invocation, ret);
-
- debug_fleave();
-}
-
-static void handle_method_call(GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer userdata)
-{
- int method_idx = 0;
-
- if (!parameters) {
- debug_error("Parameter Null");
- return;
- }
- debug_log("Method Call, obj : %s, intf : %s, method : %s", object_path, interface_name, method_name);
-
- for (method_idx = 0; method_idx < AUDIO_METHOD_MAX; method_idx++) {
- if (!g_strcmp0(method_name, methods[method_idx].info.name))
- methods[method_idx].handler(invocation);
- }
-}
-
-
-static GVariant* handle_get_property(GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *property_name,
- GError **error,
- gpointer userdata)
-{
- debug_log("Get Property, obj : %s, intf : %s, prop : %s", object_path, interface_name, property_name);
- return NULL;
-}
-
-static gboolean handle_set_property(GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *property_name,
- GVariant *value,
- GError **error,
- gpointer userdata)
-{
- debug_log("Set Property, obj : %s, intf : %s, prop : %s", object_path, interface_name, property_name);
- return TRUE;
-}
-
-static const GDBusInterfaceVTable interface_vtable = {
- handle_method_call,
- handle_get_property,
- handle_set_property
-};
-
-static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
-{
- guint reg_id;
- debug_log("Bus Acquired (%s)", name);
-
- conn_g = connection;
- reg_id = g_dbus_connection_register_object(connection,
- OBJECT_SOUND_SERVER,
- introspection_data->interfaces[0],
- &interface_vtable,
- NULL,
- NULL,
- NULL);
- if (!reg_id) {
- debug_error("Register object(%s) failed", OBJECT_SOUND_SERVER);
- return ;
- }
-
-}
-
-static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
-{
- debug_log("Name Acquired (%s)", name);
-}
-
-static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
-{
- debug_log("Name Lost (%s)", name);
-}
-
-static int _mm_sound_mgr_dbus_own_name(GBusType bus_type, const char* wellknown_name, guint* owner_id)
-{
- guint oid;
-
- debug_log("Own name (%s) for sound-server", wellknown_name);
-
- oid = g_bus_own_name(bus_type, wellknown_name, G_BUS_NAME_OWNER_FLAGS_NONE,
- on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
- if (oid <= 0) {
- debug_error("Dbus own name failed");
- return MM_ERROR_SOUND_INTERNAL;
- } else {
- *owner_id = oid;
- }
-
- debug_log("OwnerID (%d) for sound-server", *owner_id);
-
- return MM_ERROR_NONE;
-}
-
-static void _mm_sound_mgr_dbus_unown_name(guint oid)
-{
- debug_log("Unown name for Sound-Server [%d]", oid);
- if (oid > 0)
- g_bus_unown_name(oid);
-}
-
-int __mm_sound_mgr_ipc_dbus_notify_play_file_end(int handle)
-{
- int ret = MM_ERROR_NONE;
- GVariant* param = NULL;
-
- debug_log("Send play file ended signal");
-
- param = g_variant_new("(i)", handle);
- if (param) {
- if ((ret = mm_sound_mgr_ipc_dbus_send_signal(AUDIO_EVENT_SOUND_PLAY_EOS, param)) != MM_ERROR_NONE)
- debug_error("Send play file end for '%d' failed", handle);
- } else {
- debug_error("Build variant for dbus param failed");
- }
-
- return ret;
-}
-
-int MMSoundMgrDbusInit(void)
-{
- debug_enter();
-
- introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
- if (!introspection_data) {
- debug_error("g_dbus_node_info_new_for_xml() failed...");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if (_mm_sound_mgr_dbus_own_name(G_BUS_TYPE_SYSTEM, BUS_NAME_SOUND_SERVER, &sound_server_owner_id) != MM_ERROR_NONE) {
- debug_error("dbus own name for sound-server error");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- debug_leave();
-
- return MM_ERROR_NONE;
-}
-
-void MMSoundMgrDbusFini(void)
-{
- debug_enter();
-
- _mm_sound_mgr_dbus_unown_name(sound_server_owner_id);
- g_dbus_node_info_unref(introspection_data);
-
- debug_leave();
-}
-
-
-
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <dlfcn.h>
-
-#include "include/mm_sound_plugin.h"
-#include <mm_error.h>
-#include <mm_debug.h>
-
-static char* __strcatdup(const char *str1, const char *str2, const char *str3);
-static int _MMSoundPluginGetList(const char *plugdir, char ***list);
-static int _MMSoundPluginDestroyList(char **list);
-
-int MMSoundPluginScan(const char *plugindir, const int type, MMSoundPluginType **pluginlist)
-{
- char **list = NULL;
- int err = MM_ERROR_NONE;
- char *item = NULL;
- int index = 0;
- MMSoundPluginType plugin[100];
- int plugin_index = 0;
-
- debug_fenter();
-
- debug_msg(" Plugin dir :: %s ", plugindir);
- err = _MMSoundPluginGetList(plugindir, &list);
- if (err != MM_ERROR_NONE)
- return err;
-
- while ((item = list[index++]) != NULL) {
- if (MMSoundPluginOpen(item, &plugin[plugin_index]) != MM_ERROR_NONE) {
- debug_warning("%s is not sound plugin", item);
- continue;
- }
- if (plugin[plugin_index].type != type)
- MMSoundPluginClose(&plugin[plugin_index]);
- else
- plugin_index++;
- }
-
- _MMSoundPluginDestroyList(list);
-
- *pluginlist = (MMSoundPluginType*) malloc(sizeof(MMSoundPluginType) * (plugin_index+1));
- if ((*pluginlist) == NULL) {
- debug_critical("Memory allocation fail");
- /* Occur segmentation fault */
- *pluginlist = (void*)1;
- }
-
- memcpy(*pluginlist, plugin, sizeof(MMSoundPluginType) * (plugin_index+1));
- /* Marking end of array */
- (*pluginlist)[plugin_index].type = MM_SOUND_PLUGIN_TYPE_NONE;
- (*pluginlist)[plugin_index].module = NULL;
-
- debug_fleave();
-
- return MM_ERROR_NONE;
-}
-
-int MMSoundPluginRelease(MMSoundPluginType *pluginlist)
-{
- int loop = 0;
-
- debug_fenter();
-
- if (!pluginlist)
- return MM_ERROR_NONE;
-
- while (pluginlist[loop].type != MM_SOUND_PLUGIN_TYPE_NONE)
- MMSoundPluginClose(&pluginlist[loop++]);
-
- free(pluginlist);
-
- debug_fleave();
-
- return MM_ERROR_NONE;
-}
-
-int MMSoundPluginOpen(char *file, MMSoundPluginType *plugin)
-{
- void *pdll = NULL;
- int (*func)(void) = NULL;
- int t = -1;
-
- debug_fenter();
-
- pdll = dlopen(file, RTLD_NOW | RTLD_GLOBAL);
-
- if (pdll == NULL) {
- debug_error("%s", dlerror());
- return MM_ERROR_SOUND_INVALID_FILE;
- }
-
- func = (int (*)(void))dlsym(pdll, "MMSoundGetPluginType");
- if (func == NULL) {
- dlclose(pdll);
- debug_error("Cannot find symbol : MMSoundGetPluginType");
- return MM_ERROR_SOUND_INVALID_FILE;
- }
- t = func();
-
- debug_msg("%s is %s", file,
- t == MM_SOUND_PLUGIN_TYPE_CODEC ? "CODEC" :
- t == MM_SOUND_PLUGIN_TYPE_RUN ? "RUN" : "Unknown");
- switch (t) {
- case MM_SOUND_PLUGIN_TYPE_CODEC:
- case MM_SOUND_PLUGIN_TYPE_RUN:
- plugin->type = t;
- plugin->module = pdll;
- break;
- default:
- debug_error("Type is %d", t);
- dlclose(pdll);
- return MM_ERROR_SOUND_INVALID_FILE;
- }
-
- debug_fleave();
-
- return MM_ERROR_NONE;
-}
-
-int MMSoundPluginClose(MMSoundPluginType *plugin)
-{
- debug_fenter();
-
- if (plugin->module)
- dlclose(plugin->module);
- plugin->type = MM_SOUND_PLUGIN_TYPE_NONE;
- plugin->module = NULL;
-
- debug_fleave();
- return MM_ERROR_NONE;
-}
-
-int MMSoundPluginGetSymbol(MMSoundPluginType *plugin, const char *symbol, void **func)
-{
- void *fn = NULL;
-
- debug_fenter();
-
- if (plugin->module == NULL)
- return MM_ERROR_SOUND_INVALID_FILE;
- fn = dlsym(plugin->module, symbol);
- if (fn == NULL)
- return MM_ERROR_SOUND_INVALID_FILE;
- *func = fn;
-
- debug_fleave();
- return MM_ERROR_NONE;
-}
-#define MAX_PATH_SIZE 256
-static int _MMSoundPluginGetList(const char *plugdir, char ***list)
-{
- struct dirent **entry = NULL;
- int items;
- struct stat finfo;
- char **temp;
- int tn = 0;
- static char curdir[MAX_PATH_SIZE];
- int item_idx;
- int ret = MM_ERROR_NONE;
-
- items = scandir(plugdir, &entry, NULL, alphasort);
- debug_msg("Items %d", items);
-
- if (items == -1)
- return MM_ERROR_INVALID_ARGUMENT;
-
- temp = (char **)malloc(sizeof(char *) * (items + 1));
- if (!temp) {
- ret = MM_ERROR_OUT_OF_MEMORY;
- goto free_entry;
- }
- memset(temp, 0, sizeof(char*) * (items + 1));
- memset(curdir, '\0', sizeof(curdir));
- if (NULL == getcwd(curdir, sizeof(curdir)-1)) {
- if (temp) {
- free(temp);
- temp = NULL;
- }
- ret = MM_ERROR_OUT_OF_STORAGE;
- goto free_entry;
- }
- /* FIXME : need to handle error case */
- if (chdir(plugdir) != 0) {
- debug_error("chdir error");
- if (temp) {
- free(temp);
- temp = NULL;
- }
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto free_entry;
- }
-
- for (item_idx = items; item_idx--; ) {
- if (stat(entry[item_idx]->d_name, &finfo) < 0) {
- debug_error("Stat error");
- if (temp) {
- free(temp);
- temp = NULL;
- }
- ret = MM_ERROR_INVALID_ARGUMENT;
- goto free_entry;
- }
-
- debug_log("item %d is %s", item_idx, entry[item_idx]->d_name);
-
- if (S_ISREG(finfo.st_mode))
- temp[tn++] = __strcatdup(plugdir, "/", entry[item_idx]->d_name);
- }
- *list = temp;
-free_entry:
- for (item_idx = 0; item_idx < items; item_idx++)
- free(entry[item_idx]);
- free(entry);
- return ret;
-}
-
-static int _MMSoundPluginDestroyList(char **list)
-{
- int tn = 0;
- while (list[tn])
- free(list[tn++]);
- free(list);
- return MM_ERROR_NONE;
-}
-
-static char* __strcatdup(const char *str1, const char *str2, const char *str3)
-{
- char *dest = NULL;
- int len = 0;
- len = strlen(str1) + strlen(str2) + strlen(str3) + 1;
- dest = (char*) malloc(len*sizeof(char));
- if (!dest)
- return NULL;
- strncpy(dest, str1, len-1);
- strncat(dest, str2, len-strlen(dest)-1);
- strncat(dest, str3, len-strlen(dest)-1);
- return dest;
-}
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <getopt.h>
-
-#include <mm_error.h>
-#include <mm_debug.h>
-
-#include <glib.h>
-
-#include "../include/mm_sound_common.h"
-#include "../include/mm_sound_utils.h"
-#include "include/mm_sound_thread_pool.h"
-#include "include/mm_sound_mgr_codec.h"
-#include "include/mm_sound_mgr_ipc_dbus.h"
-
-#include "../config.h" /* for PLUGIN_DIR */
-
-#define PLUGIN_ENV "MM_SOUND_PLUGIN_PATH"
-#define PLUGIN_MAX 30
-#define MAX_PLUGIN_DIR_PATH_LEN 256
-
-#define USE_SYSTEM_SERVER_PROCESS_MONITORING
-
-typedef struct {
- char plugdir[MAX_PLUGIN_DIR_PATH_LEN];
- int startserver;
- int printlist;
- int testmode;
-} server_arg;
-
-static int _get_option(int argc, char **argv, server_arg *arg);
-static int _usage(int argc, char **argv);
-
-static struct sigaction sigint_action; /* Backup pointer of SIGINT handler */
-static struct sigaction sigabrt_action; /* Backup pointer of SIGABRT signal handler */
-static struct sigaction sigsegv_action; /* Backup pointer of SIGSEGV fault signal handler */
-static struct sigaction sigterm_action; /* Backup pointer of SIGTERM signal handler */
-static struct sigaction sigsys_action; /* Backup pointer of SIGSYS signal handler */
-static void _exit_handler(int sig);
-
-static GMainLoop *g_mainloop;
-
-static gboolean _shutdown_cb(gpointer user_data)
-{
- debug_warning("TIMER : quit mainloop now!");
- g_main_loop_quit(g_mainloop);
-
- return FALSE;
-}
-
-static void _mainloop_run()
-{
- g_mainloop = g_main_loop_new(NULL, TRUE);
- if (g_mainloop == NULL) {
- debug_error("g_main_loop_new() failed");
- return;
- }
-
- g_main_loop_run(g_mainloop);
-}
-
-static int _get_option(int argc, char **argv, server_arg *arg)
-{
- int c;
- static struct option long_options[] = {
- {"start", 0, 0, 'S'},
- {"list", 0, 0, 'L'},
- {"help", 0, 0, 'H'},
- {"plugdir", 1, 0, 'P'},
- {"testmode", 0, 0, 'T'},
- {0, 0, 0, 0}
- };
- memset(arg, 0, sizeof(server_arg));
-
- MMSOUND_STRNCPY(arg->plugdir, PLUGIN_DIR, MAX_PLUGIN_DIR_PATH_LEN);
-
- arg->testmode = 0;
-
- while (1) {
- int opt_idx = 0;
-
- c = getopt_long(argc, argv, "SFLHRUP:Tiurd", long_options, &opt_idx);
- if (c == -1)
- break;
- switch (c) {
- case 'S': /* Start daemon */
- arg->startserver = 1;
- break;
- case 'L': /* list of plugins */
- arg->printlist = 1;
- break;
- case 'P': /* Custom plugindir */
- MMSOUND_STRNCPY(arg->plugdir, optarg, MAX_PLUGIN_DIR_PATH_LEN);
- break;
- case 'T': /* Test mode */
- arg->testmode = 1;
- break;
- case 'H': /* help msg */
- default:
- return _usage(argc, argv);
- }
- }
- if (argc == 1)
- return _usage(argc, argv);
- return 0;
-}
-
-//__attribute__ ((destructor))
-static void _exit_handler(int sig)
-{
-#ifdef USE_GCOV
- mm_sound_gcov_flush();
-#endif
-
- switch (sig) {
- case SIGINT:
- sigaction(SIGINT, &sigint_action, NULL);
- debug_error("signal(SIGINT) error");
- break;
- case SIGABRT:
- sigaction(SIGABRT, &sigabrt_action, NULL);
- debug_error("signal(SIGABRT) error");
- break;
- case SIGSEGV:
- sigaction(SIGSEGV, &sigsegv_action, NULL);
- debug_error("signal(SIGSEGV) error");
- break;
- case SIGTERM:
- sigaction(SIGTERM, &sigterm_action, NULL);
- debug_error("signal(SIGTERM) error");
- break;
- case SIGSYS:
- sigaction(SIGSYS, &sigsys_action, NULL);
- debug_error("signal(SIGSYS) error");
- break;
- default:
- break;
- }
- raise(sig);
-}
-
-static int _usage(int argc, char **argv)
-{
- fprintf(stderr, "Usage: %s [Options]\n", argv[0]);
- fprintf(stderr, "\t%-20s: start sound server.\n", "--start,-S");
- fprintf(stderr, "\t%-20s: help message.\n", "--help,-H");
-
- return 1;
-}
-
-int main(int argc, char **argv)
-{
- server_arg serveropt;
- struct sigaction action;
-#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
- int pid;
-#endif
-
- action.sa_handler = _exit_handler;
- action.sa_flags = 0;
- sigemptyset(&action.sa_mask);
-
- if (_get_option(argc, argv, &serveropt))
- return 1;
-
- debug_warning("sound_server [%d] init ", getpid());
-
- /* Daemon process create */
- if (!serveropt.testmode && serveropt.startserver) {
-#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
- daemon(0, 0); //chdir to ("/"), and close stdio
-#endif
- }
-
- /* Sound Server Starts!!!*/
- debug_warning("sound_server [%d] start ", getpid());
-
- signal(SIGPIPE, SIG_IGN); //ignore SIGPIPE
-
-#if !defined(USE_SYSTEM_SERVER_PROCESS_MONITORING)
- while (1) {
- if ((pid = fork()) < 0) {
- fprintf(stderr, "Sub Fork Error\n");
- return 2;
- } else if (pid == 0) {
- break;
- } else if (pid > 0) {
- wait(&ret);
- fprintf(stderr, "Killed by signal [%05X]\n", ret);
- fprintf(stderr, "Daemon is run againg\n");
- }
- }
-#endif
- sigaction(SIGABRT, &action, &sigabrt_action);
- sigaction(SIGSEGV, &action, &sigsegv_action);
- sigaction(SIGTERM, &action, &sigterm_action);
- sigaction(SIGSYS, &action, &sigsys_action);
-
-#ifdef USE_GCOV
- mm_sound_gcov_set_prefix();
-#endif
-
- if (serveropt.startserver || serveropt.printlist) {
- MMSoundMgrDbusInit();
- if (MMSoundThreadPoolInit()) {
- debug_error("failed to MMSoundThreadPoolInit()");
- goto exit;
- }
- MMSoundMgrCodecInit(serveropt.plugdir, _shutdown_cb);
- }
-
- debug_warning("sound_server [%d] initialization complete...now, start running!!", getpid());
-
- if (serveropt.startserver) {
- /* Start MainLoop */
- _mainloop_run();
- }
-
-exit:
- debug_warning("sound_server [%d] terminating ", getpid());
-
- if (serveropt.startserver || serveropt.printlist) {
- MMSoundMgrCodecFini();
- MMSoundThreadPoolFini();
- MMSoundMgrDbusFini();
- }
-
- debug_warning("sound_server [%d] exit ----------------- END ", getpid());
-
- return 0;
-}
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <mm_error.h>
-#include <mm_debug.h>
-#include <mm_sound_thread_pool.h>
-
-#include <glib.h>
-
-static GThreadPool *g_pool;
-
-#define MAX_UNUSED_THREADS_IN_THREADPOOL 10
-
-typedef struct __THREAD_INFO {
- void (*func)(gpointer data);
- void *param;
-} THREAD_INFO;
-
-static void __DummyWork(void *param)
-{
- debug_msg("thread index = %d", (int)param);
- sleep(1);
-}
-
-static void __ThreadWork(gpointer data, gpointer user_data)
-{
- THREAD_INFO *info = (THREAD_INFO *)data;
- if (info) {
- if (info->func) {
- debug_log("Calling [%p] with param [%p]", info->func, info->param);
- info->func(info->param);
- } else {
- debug_warning("No func to call....");
- }
-
- /* Info was allocated by MMSoundThreadPoolRun().
- The actual content of info should be freed whether inside func or outside (if handle) */
- debug_log("free [%p]", info);
- free(info);
- info = NULL;
- } else {
- debug_warning("No valid thread info...Nothing to do...");
- }
-}
-
-int MMSoundThreadPoolDump(int fulldump)
-{
- if (g_pool == NULL) {
- debug_error("No thread pool initialized....");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if (fulldump) {
- debug_log("##### [ThreadPool] max threads=[%d], max unused=[%d], max idle time=[%d]",
- g_thread_pool_get_max_threads(g_pool),
- g_thread_pool_get_max_unused_threads(),
- g_thread_pool_get_max_idle_time());
- }
- debug_log("***** [ThreadPool] running=[%d], unused=[%d]",
- g_thread_pool_get_num_threads(g_pool),
- g_thread_pool_get_num_unused_threads());
-
- return MM_ERROR_NONE;
-}
-
-int MMSoundThreadPoolInit()
-{
- int i = 0;
- GError *error = NULL;
-
- debug_enter();
-
- /* Create thread pool (non-exclude mode with infinite max threads) */
- g_pool = g_thread_pool_new(__ThreadWork, NULL, -1, FALSE, &error);
- if (g_pool == NULL && error != NULL) {
- debug_error("thread pool created failed : %s", error->message);
- g_error_free(error);
- return MM_ERROR_SOUND_INTERNAL;
- }
- debug_msg("thread pool created successfully");
-
- MMSoundThreadPoolDump(TRUE);
-
- /* Thread pool setting : this will maintain at least 10 unused threads and this will be reused. */
- /* If no unused thread left, new thread will be created, but always maintain 10 unused thread */
- debug_msg("thread pool set max unused threads to %d", MAX_UNUSED_THREADS_IN_THREADPOOL);
- g_thread_pool_set_max_unused_threads(MAX_UNUSED_THREADS_IN_THREADPOOL);
-
- /* To reserve unused threads, let's start some threads for beginning
- his dummy thread will be remained unused as soon as it started */
- debug_msg("run threads to reserve minimum thread");
- for (i = 0; i < MAX_UNUSED_THREADS_IN_THREADPOOL; i++)
- if (MMSoundThreadPoolRun((void *)i, __DummyWork))
- return MM_ERROR_SOUND_INTERNAL;
-
- MMSoundThreadPoolDump(TRUE);
-
- debug_leave();
-
- return MM_ERROR_NONE;
-}
-
-int MMSoundThreadPoolRun(void *param, void (*func)(void*))
-{
- GError *error = NULL;
-
- debug_enter();
-
- if (g_pool == NULL) {
- debug_error("No thread pool initialized....");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- /* Dump current thread pool */
- MMSoundThreadPoolDump(FALSE);
-
- /* Create thread info structure.
- This thread info data will be free in __ThreadWork(), after use. */
- THREAD_INFO *thread_info = (THREAD_INFO *)malloc(sizeof(THREAD_INFO));
- if (thread_info) {
- thread_info->func = func;
- thread_info->param = param;
- debug_log("alloc thread_info = %p", thread_info);
-
- /* Add thread to queue of thread pool */
- g_thread_pool_push(g_pool, thread_info, &error);
- if (error) {
- debug_error("g_thread_pool_push failed : %s", error->message);
- g_error_free(error);
- free(thread_info);
- return MM_ERROR_SOUND_INTERNAL;
- }
- } else {
- debug_error("failed to alloc thread info");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- debug_leave();
-
- return MM_ERROR_NONE;
-}
-
-int MMSoundThreadPoolFini(void)
-{
- /* If immediate is TRUE, no new task is processed for pool.
- Otherwise pool is not freed before the last task is processed.
- Note however, that no thread of this pool is interrupted, while processing a task.
- Instead at least all still running threads can finish their tasks before the pool is freed.
-
- If wait_ is TRUE, the functions does not return before all tasks to be processed
- (dependent on immediate, whether all or only the currently running) are ready.
- Otherwise the function returns immediately. */
- debug_enter();
-
- if (g_pool) {
- debug_msg("thread pool will be free");
- g_thread_pool_free(g_pool, TRUE, FALSE);
- g_pool = NULL;
- }
-
- debug_leave();
- return MM_ERROR_NONE;
-}
+++ /dev/null
-SUBDIRS = wav tone
+++ /dev/null
-lib_LTLIBRARIES = libsoundplugintone.la
-
-libsoundplugintone_la_SOURCES = mm_sound_plugin_codec_tone.c
-libdir = $(PLUGIN_DIR)
-
-libsoundplugintone_la_CFLAGS = \
- $(MMCOMMON_CFLAGS) \
- -I$(srcdir)/../../../../common/include \
- -I$(srcdir)/../../../include \
- $(PA_CFLAGS) \
- $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x002 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\"
-
-libsoundplugintone_la_LIBADD = \
- $(MMCOMMON_LIBS) \
- $(PA_LIBS) \
- $(srcdir)/../../../libmmfsound.la \
- $(srcdir)/../../../common/libmmfsoundcommon.la \
- $(MMLOGSVR_LIBS)
-
-libsoundplugintone_la_LDFLAGS = -avoid-version
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <semaphore.h>
-
-#include "../../include/mm_sound_plugin_codec.h"
-#include <mm_error.h>
-#include <mm_debug.h>
-#include <mm_sound.h>
-#include <unistd.h>
-
-/* For Beep */
-#include <math.h>
-#include <glib.h>
-
-#include <pulse/sample.h>
-#include "../../../include/mm_sound_pa_client.h"
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#ifndef M_PI_2
-#define M_PI_2 1.57079632679489661923
-#endif
-
-#define SAMPLERATE 44100
-
-#define SAMPLE_SIZE 16
-#define CHANNELS 1
-#define MAX_DURATION 100
-#define TONE_COLUMN 6
-#define WAIT_THREAD_WAIT_CNT 100
-#define WAIT_THREAD_WAIT_TIME 10 /* ms */
-
-typedef enum {
- STATE_NONE = 0,
- STATE_READY,
- STATE_BEGIN,
- STATE_PLAY,
- STATE_STOP,
-} state_e;
-
-typedef enum {
- THREAD_STATE_NONE = 0,
- THREAD_STATE_START,
- THREAD_STATE_STOP,
-} thread_state_e;
-
-
-typedef enum {
- CONTROL_STOPPED,
- CONTROL_READY,
- CONTROL_STARTING,
- CONTROL_PLAYING,
-} control_e;
-
-#if 0
-typedef struct {
- pthread_mutex_t syncker;
- pthread_cond_t cond;
- int state;
-} tone_control_t;
-#endif
-
-typedef struct {
- /* AMR Buffer */
- int size; /* sizeof hole amr data */
- pthread_mutex_t mutex;
-
- /* Audio Infomations */
- int handle;
-
- /* control Informations */
- int repeat_count;
- int (*stop_cb)(int, bool);
- int cb_param;
- int state;
- int number;
- double volume;
- int time;
- int pid;
-
- int thread_state;
- bool *is_stop_request_done;
-} tone_info_t;
-
-typedef enum {
- LOW_FREQUENCY = 0,
- MIDDLE_FREQUENCY,
- HIGH_FREQUENCY,
- PLAYING_TIME,
- LOOP_COUNT,
- LOOP_INDEX,
-} volume_type_e;
-
-typedef struct st_tone {
- float low_frequency;
- float middle_frequency;
- float high_frequency;
- int playingTime;
- int loopCnt;
- int loopIndx;
-} TONE;
-
-static const int TONE_SEGMENT[][MM_SOUND_TONE_NUM] = {
- {941, 1336, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// 0 key: 1336Hz, 941Hz
-
- {697, 1209, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// 1 key: 1209Hz, 697Hz
-
- {697, 1336, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// 2 key: 1336Hz, 697Hz
-
- {697, 1477, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0}, // 3 key: 1477Hz, 697Hz
-
- {770, 1209, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// 4 key: 1209Hz, 770Hz
-
- {770, 1336, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// 5 key: 1336Hz, 770Hz
-
- {770, 1477, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// 6 key: 1477Hz, 770Hz
-
- {852, 1209, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// 7 key: 1209Hz, 852Hz
-
- {852, 1336, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// 8 key: 1336Hz, 852Hz
-
- {852, 1477, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// 9 key: 1477Hz, 852Hz
-
- {941, 1209, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// * key: 1209Hz, 941Hz
-
- {941, 1477, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// # key: 1477Hz, 941Hz
-
- {697, 1633, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// A key: 1633Hz, 697Hz
-
- {770, 1633, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// B key: 1633Hz, 770Hz
-
- {852, 1633, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0},// C key: 1633Hz, 852Hz
-
- {941, 1633, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0}, // D key: 1633Hz, 941Hz
-
- {425, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Dial tone: CEPT: 425Hz, continuous
-
- {350, 440, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous
-
- {400, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Dial tone: JAPAN: 400Hz, continuous
-
- {425, 0, 0, 500, 0, 0,
- 0, 0, 0, 500, 0, 0,
- -1, -1, -1, -1, 0, 0},//Call supervisory tone, Busy: CEPT: 425Hz, 500ms ON, 500ms OFF...
-
- {480, 620, 0, 500, 0, 0,
- 0, 0, 0, 500, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Busy: ANSI (IS-95): 480Hz+620Hz, 500ms ON, 500ms OFF...
-
- {400, 0, 0, 500, 0, 0,
- 0, 0, 0, 500, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Busy: JAPAN: 400Hz, 500ms ON, 500ms OFF...
-
- {425, 0, 0, 200, 0, 0,
- 0, 0, 0, 200, 0, 0,
- -1, -1, -1, -1, 1, 0}, //Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF
-
- {480, 620, 0, 250, 0, 0,
- 0, 0, 0, 250, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Congestion: ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF...
-
- {425, 0, 0, 200, 0, 0,
- -1, -1, -1, -1, 1, 0}, //Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON
-
- {400, 0, 0, 1000, 0, 0,
- 0, 0, 0, 2000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Radio path acknowlegment : JAPAN: 400Hz, 1s ON, 2s OFF...
-
- {425, 0, 0, 200, 0, 0,
- 0, 0, 0, 200, 0, 0,
- -1, -1, -1, -1, 3, 0}, //Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts
-
- {950, 1400, 1800, 330, 0, 0,
- 0, 0, 0, 1000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF...
-
- {425, 0, 0, 200, 0, 0,
- 0, 0, 0, 600, 0, 0,
- 425, 0, 0, 200, 0, 0,
- 0, 0, 0, 3000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Call Waiting: CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF...
-
- {440, 0, 0, 300, 0, 0,
- 0, 0, 0, 9700, 0, 0,
- 440, 0, 0, 100, 0, 0,
- 0, 0, 0, 100, 0, 0,
- 440, 0, 0, 100, 0, 0,
- 0, 0, 0, 9700, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Call Waiting: ANSI (IS-95): 440 Hz, 300 ms ON, 9.7 s OFF, (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...)
-
- {425, 0, 0, 1000, 0, 0,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Ring Tone: CEPT, JAPAN: 425Hz, 1s ON, 4s OFF...
-
- {440, 480, 0, 2000, 0, 0,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Ring Tone: ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF...
-
- {400, 1200, 0, 35, 0, 0,
- -1, -1, -1, -1, 1, 0}, // General beep: 400Hz+1200Hz, 35ms ON
-
- {1200, 0, 0, 100, 0, 0,
- 0, 0, 0, 100, 0, 0,
- -1, -1, -1, -1, 2, 0}, //Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts
-
- {300, 400, 500, 400, 0, 0,
- -1, -1, -1, -1, 1, 0}, //Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON
-
- {400, 1200, 0, 200, 0, 0,
- -1, -1, -1, -1, 1, 0}, //Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON
-
- {400, 1200, 0, 35, 0, 0,
- 0, 0, 0, 200, 0, 0,
- 400, 1200, 0, 35, 0, 0,
- -1, -1, -1, -1, 1, 0}, //Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON
-
- {440, 0, 0, 250, 0, 0,
- 620, 0, 0, 250, 0, 0,
- -1, -1, -1, -1, 1, 0}, //Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms
-
- {440, 0, 0, 250, 0, 0,
- 620, 0, 0, 250, 0, 0,
- -1, -1, -1, -1, 8, 0}, //Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds
-
- {480, 620, 0, 250, 0, 0,
- 0, 0, 0, 250, 0, 0,
- -1, -1, -1, -1, 8, 0}, //Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds
-
- {350, 440, 0, 100, 0, 0,
- 0, 0, 0, 100, 0, 0,
- -1, -1, -1, -1, 3, 0}, //Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone repeated 3 times in a 100 ms on, 100 ms off cycle
-
- {480, 0, 0, 100, 0, 0,
- 0, 0, 0, 100, 0, 0,
- -1, -1, -1, -1, 4, 0}, //Call supervisory tone (IS-95), pip tone: four bursts of 480 Hz tone (0.1 s on, 0.1 s off).
-
- { 425, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0}, //425Hz continuous
-
- {440, 480, 0, 2000, 0, 0,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...
-
- {440, 0, 0, 250, 0, 0,
- 620, 0, 0, 250, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...
-
- {440, 0, 0, 250, 0, 0,
- 620, 0, 0, 250, 0, 0,
- -1, -1, -1, -1, 1, 0 }, //CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON
-
- {480, 620, 0, 250, 0, 0,
- 0, 0, 0, 250, 0, 0,
- -1, -1, -1, -1, 0, 0 }, //CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF...
-
- {480, 620, 0, 250, 0, 0,
- 0, 0, 0, 250, 0, 0,
- -1, -1, -1, -1, 8, 0}, //CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times
-
- {480, 620, 0, 500, 0, 0,
- 0, 0, 0, 500, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous
-
- {350, 440, 0, 100, 0, 0,
- 0, 0, 0, 100, 0, 0,
- -1, -1, -1, -1, 3, 0}, //CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times
-
- {660, 1000, 0, 500, 0, 0,
- 0, 0, 0, 100, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF
-
- {440, 0, 0, 300, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA Network Callwaiting tone: 440Hz 300ms ON
-
- {480, 0, 0, 100, 0, 0,
- 0, 0, 0, 100, 0, 0,
- -1, -1, -1, -1, 4, 0}, //CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times
-
- {2090, 0, 0, 32, 0, 0,
- 2556, 0, 0, 64, 19, 0,
- 2090, 0, 0, 32, 0, 0,
- 2556, 0, 0, 48, 0, 0,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 1, 0}, //ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times, 2091 32ms ON, 2556 48ms ON, 4s OFF
-
- {2091, 0, 0, 32, 0, 0,
- 2556, 0, 0, 64, 7, 0,
- 2091, 0, 0, 32, 0, 0,
- 0, 0, 0, 400, 0, 0,
- 2091, 0, 0, 32, 0, 0,
- 2556, 0, 0, 64, 7, 4,
- 2091, 0, 0, 32, 0, 0,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 1, 0}, //ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times, 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 8times, 2091Hz 32ms ON, 4s OFF
-
- {2091, 0, 0, 32, 0, 0,
- 2556, 0, 0, 64, 3, 0,
- 2091, 0, 0, 32, 0, 0,
- 0, 0, 0, 200, 0, 0,
- 2091, 0, 0, 32, 0, 0,
- 2556, 0, 0, 64, 3, 4,
- 2091, 0, 0, 32, 0, 0,
- 0, 0, 0, 200, 0, 0,
- -1, -1, -1, -1, 1, 0},//ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times, 2091Hz 16ms ON, 200ms OFF
-
- {0, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 1, 0}, //ISDN Call sign PAT3 tone: silent tone
-
- {2091, 0, 0, 32, 0, 0,
- 2556, 0, 0, 64, 4, 0,
- 2091, 0, 0, 20, 0, 0,
- -1, -1, -1, -1, 1, 0}, //ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON
-
- {0, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 1, 0}, //ISDN Pat5 tone: silent tone
-
- {0, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 1, 0}, //ISDN Pat6 tone: silent tone
-
- {0, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 1, 0}, //ISDN Pat7 tone: silent tone
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 39, 0,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times 4000ms OFF, Repeat ....
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 39, 0,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 0, 0},//TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times 4000ms OFF, Repeat ....
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 39, 0,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, 4000ms OFF, Repeat ....
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 15, 0,
- 0, 0, 0, 400, 0, 0,
- -1, -1, -1, -1, 0, 0},//CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 400ms OFF, repeat ....
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 15, 0,
- 0, 0, 0, 400, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 400ms OFF, repeat ....
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 15, 0,
- 0, 0, 0, 400, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, 400ms OFF, repeat ....
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 3,
- 0, 0, 0, 200, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 15, 6,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA HIGH SSL tone: {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 4000ms OFF, repeat ...
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 3,
- 0, 0, 0, 200, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 15, 6,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA MED SSL tone: {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 4000ms OFF, repeat ...
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 3,
- 0, 0, 0, 200, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 15, 6,
- 0, 0, 0, 4000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA LOW SSL tone: {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 16 times, 4000ms OFF, repeat ...
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 19, 0,
- 0, 0, 0, 1000, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 19, 3,
- 0, 0, 0, 3000, 0, 0,
- -1, -1, -1, -1, 0, 0 },//CDMA HIGH SS2 tone: {3700Hz 25ms, 4000Hz 25ms} 20 times, 1000ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 3000ms OFF, repeat ....
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 19, 0,
- 0, 0, 0, 1000, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 19, 3,
- 0, 0, 0, 3000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA MED SS2 tone: {2600Hz 25ms, 2900Hz 25ms} 20 times, 1000ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 3000ms OFF, repeat ....
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 19, 0,
- 0, 0, 0, 1000, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 19, 3,
- 0, 0, 0, 3000, 0, 0,
- -1, -1, -1, -1, 0, 0 }, //CDMA LOW SS2 tone: {1300Hz 25ms, 1450Hz 25ms} 20 times, 1000ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 3000ms OFF, repeat ....
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 9, 0,
- 0, 0, 0, 500, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 19, 3,
- 0, 0, 0, 500, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 9, 6,
- 0, 0, 0, 3000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT....
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 9, 0,
- 0, 0, 0, 500, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 19, 3,
- 0, 0, 0, 500, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 9, 6,
- 0, 0, 0, 3000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA MED SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT....
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 9, 0,
- 0, 0, 0, 500, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 19, 3,
- 0, 0, 0, 500, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 9, 6,
- 0, 0, 0, 3000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT....
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 9, 0,
- 0, 0, 0, 500, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 9, 3,
- 0, 0, 0, 500, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 9, 6,
- 0, 0, 0, 2500, 0, 0,
- -1, -1, -1, -1, 0, 0}, ////CDMA HIGH S X4 tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 2500ms OFF, REPEAT....
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 9, 0,
- 0, 0, 0, 500, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 9, 4,
- 0, 0, 0, 500, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 9, 6,
- 0, 0, 0, 2500, 0, 0,
- -1, -1, -1, -1, 0, 0 },//CDMA MED S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT....
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 9, 0,
- 0, 0, 0, 500, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 9, 3,
- 0, 0, 0, 500, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 9, 6,
- 0, 0, 0, 2500, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA LOW S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT....
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 19, 0,
- 0, 0, 0, 2000, 0, 0,
- -1, -1, -1, -1, 0, 0 },//CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, 2000ms OFF, REPEAT....
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 19, 0,
- 0, 0, 0, 2000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, 2000ms OFF, REPEAT....
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 19, 0,
- 0, 0, 0, 2000, 0, 0,
- -1, -1, -1, -1, 0, 0 },//CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, 2000ms OFF, REPEAT....
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 3,
- 0, 0, 0, 2000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA HIGH PBX SS tone: {3700Hz 25ms, 4000Hz 25ms} 8 times 200 ms OFF, {3700Hz 25ms 4000Hz 25ms}8 times, 2000ms OFF, REPEAT....
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 3,
- 0, 0, 0, 2000, 0, 0,
- -1, -1, -1, -1, 0, 0 }, //CDMA MED PBX SS tone: {2600Hz 25ms, 2900Hz 25ms} 8 times 200 ms OFF, {2600Hz 25ms 2900Hz 25ms}8 times, 2000ms OFF, REPEAT....
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 3,
- 0, 0, 0, 2000, 0, 0,
- -1, -1, -1, -1, 0, 0 },//CDMA LOW PBX SS tone: {1300Hz 25ms, 1450Hz 25ms} 8 times 200 ms OFF, {1300Hz 25ms 1450Hz 25ms}8 times, 2000ms OFF, REPEAT....
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 3,
- 0, 0, 0, 200, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 15, 6,
- 0, 0, 0, 1000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 1000ms OFF, REPEAT....//
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 3,
- 0, 0, 0, 200, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 15, 6,
- 0, 0, 0, 1000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA MED PBX SSL tone:{2600Hz 25ms, 2900Hz 25ms} 8 times 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 1000ms OFF, REPEAT....//
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 3,
- 0, 0, 0, 200, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 15, 6,
- 0, 0, 0, 1000, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA LOW PBX SSL tone:{1300Hz 25ms, 1450Hz 25ms} 8 times 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 1000ms OFF, REPEAT....//
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 15, 0,
- 0, 0, 0, 200, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 3,
- 0, 0, 0, 1000, 0, 0,
- -1, -1, -1, -1, 0, 0 },//CDMA HIGH PBX SLS tone:{3700Hz 25ms, 4000Hz 25ms} 8 times 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 1000ms OFF, REPEAT.... //
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 15, 0,
- 0, 0, 0, 200, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 3,
- 0, 0, 0, 1000, 0, 0,
- -1, -1, -1, -1, 0, 0 }, //CDMA HIGH PBX SLS tone:{2600Hz 25ms, 2900Hz 25ms} 8 times 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 1000ms OFF, REPEAT....//
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 15, 0,
- 0, 0, 0, 200, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 3,
- 0, 0, 0, 1000, 0, 0,
- -1, -1, -1, -1, 0, 0 }, //CDMA HIGH PBX SLS tone:{1300Hz 25ms, 1450Hz 25ms} 8 times 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 1000ms OFF, REPEAT....//
-
- {3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 3,
- 0, 0, 0, 200, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 6,
- 0, 0, 0, 200, 0, 0,
- 3700, 0, 0, 25, 0, 0,
- 4000, 0, 0, 25, 7, 9,
- 0, 0, 0, 800, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA HIGH PBX X S4 tone: {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 800ms OFF, REPEAT...
-
- {2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 3,
- 0, 0, 0, 200, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 6,
- 0, 0, 0, 200, 0, 0,
- 2600, 0, 0, 25, 0, 0,
- 2900, 0, 0, 25, 7, 9,
- 0, 0, 0, 800, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA MED PBX X S4 tone: {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 800ms OFF, REPEAT...
-
- {1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 0,
- 0, 0, 0, 200, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 3,
- 0, 0, 0, 200, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 6,
- 0, 0, 0, 200, 0, 0,
- 1300, 0, 0, 25, 0, 0,
- 1450, 0, 0, 25, 7, 9,
- 0, 0, 0, 800, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA LOW PBX X S4 tone: {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 800ms OFF, REPEAT...
-
- {1109, 0, 0, 62, 0, 0,
- 784, 0, 0, 62, 0, 0,
- 740, 0, 0, 62, 0, 0,
- 622, 0, 0, 62, 0, 0,
- 1109, 0, 0, 62, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON 622Hz 62ms ON, 1109Hz 62ms ON
-
- {1245, 0, 0, 62, 0, 0,
- 659, 0, 0, 62, 0, 0,
- 1245, 0, 0, 62, 0, 0,
- 659, 0, 0, 62, 0, 0,
- 1245, 0, 0, 62, 0, 0,
- 659, 0, 0, 62, 0, 0,
- 1245, 0, 0, 62, 0, 0,
- -1, -1, -1, -1, 1, 0},//CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON//
-
- {1150, 770, 0, 400, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON//
-
- {941, 1477, 0, 120, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON
-
- {587, 0, 0, 375, 0, 0,
- 1175, 0, 0, 125, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON
-
- {587, 0, 0, 62, 0, 0,
- 784, 0, 0, 62, 0, 0,
- 831, 0, 0, 62, 0, 0,
- 784, 0, 0, 62, 0, 0,
- 1109, 0, 0, 62, 0, 0,
- 784, 0, 0, 62, 0, 0,
- 831, 0, 0, 62, 0, 0,
- 784, 0, 0, 62, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms, 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms
-
- {941, 0, 0, 125, 0, 0,
- 0, 0, 0, 10, 0, 0,
- 941, 0, 0, 125, 0, 0,
- 0, 0, 0, 10, 0, 0,
- 1245, 0, 0, 62, 0, 0,
- 0, 0, 0, 10, 0, 0,
- 0, 0, 0, 4990, 0, 0,
- -1, -1, -1, -1, 0, 0}, //CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times 4990ms OFF, REPEAT...
-
- {1319, 0, 0, 125, 0, 0,
- 0, 0, 0, 125, 0, 0,
- -1, -1, -1, -1, 3, 0 }, //CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times
-
- {1047, 0, 0, 125, 0, 0,
- 370, 0, 0, 125, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms
-
- {1480, 0, 0, 125, 0, 0,
- 1397, 0, 0, 125, 0, 0,
- 784, 0, 0, 125, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms//
-
- {425, 0, 0, 125, 0, 0,
- 0, 0, 0, 125, 0, 0,
- -1, -1, -1, -1, 1, 0},//CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF
-
- {1150, 770, 0, 400, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON
-
- {0, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 1, 0}, //CDMA_SIGNAL_OFF - silent tone
-
- {100, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0}, //100Hz continuous
-
- {200, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0}, //200Hz continuous
-
- {300, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, 0, 0}, //300Hz continuous
-};
-
-#if 0
-static tone_control_t g_control;
-#endif
-
-static int (*g_thread_pool_func)(void*, void (*)(void*)) = NULL;
-#if 0
-static int _MMSoundToneInit(void);
-static int _MMSoundToneFini(void);
-#endif
-static void _running_tone(void *param);
-
-
-
-int* MMSoundPlugCodecToneGetSupportTypes(void)
-{
- debug_enter();
- static int suported[2] = {MM_SOUND_SUPPORTED_CODEC_DTMF, 0};
- debug_leave();
- return suported;
-}
-
-int MMSoundPlugCodecToneCreate(mmsound_codec_param_t *param, mmsound_codec_info_t *info, MMHandleType *handle)
-{
- tone_info_t *toneInfo;
- pa_sample_spec ss;
-
- int size;
-
- int result = MM_ERROR_NONE;
- int wait_count = 0;
-
- debug_enter();
-
- toneInfo = (tone_info_t *)malloc(sizeof(tone_info_t));
- if (toneInfo == NULL) {
- debug_error("memory allocation error");
- return MM_ERROR_OUT_OF_MEMORY;
- }
-
- memset(toneInfo, 0, sizeof(tone_info_t));
-
- pthread_mutex_init(&toneInfo->mutex, NULL);
- pthread_mutex_lock(&toneInfo->mutex);
- toneInfo->state = STATE_READY;
- toneInfo->thread_state = THREAD_STATE_NONE;
- pthread_mutex_unlock(&toneInfo->mutex);
-
- ss.rate = SAMPLERATE;
- ss.channels = CHANNELS;
- ss.format = PA_SAMPLE_S16LE;
-
- toneInfo->handle = mm_sound_pa_open(HANDLE_MODE_OUTPUT, param->volume_config, &ss, NULL, &size, param->stream_type, param->stream_index);
- if (!toneInfo->handle) {
- debug_error("Device Open Error 0x%x", result);
- goto Error;
- }
- debug_log("Create audio_handle is %d", toneInfo->handle);
-
- debug_msg("tone : %d", param->tone);
- debug_msg("repeat : %d", param->repeat_count);
- debug_msg("volume config : %x", param->volume_config);
- debug_msg("callback : %p", param->stop_cb);
- debug_msg("pid : %d", param->pid);
-
- toneInfo->number = param->tone;
- toneInfo->time = param->repeat_count;
- toneInfo->stop_cb = param->stop_cb;
- toneInfo->cb_param = param->param;
- toneInfo->pid = param->pid;
- toneInfo->volume = param->volume;
-
- result = g_thread_pool_func(toneInfo, _running_tone);
- if (result != 0) {
- debug_error("pthread_create() fail in pcm thread");
- result = MM_ERROR_SOUND_INTERNAL;
- goto Error;
- }
-
- *handle = (MMHandleType)toneInfo;
-
- debug_msg("wait until thread_stare THREAD_STATE_START");
- while ((toneInfo->thread_state == THREAD_STATE_NONE) && (wait_count < WAIT_THREAD_WAIT_CNT)) {
- usleep(WAIT_THREAD_WAIT_TIME * 1000);
- wait_count++;
- }
-
- if (wait_count >= WAIT_THREAD_WAIT_CNT)
- debug_error("timeout for thread pool. wait_count: %d ms ", WAIT_THREAD_WAIT_CNT * WAIT_THREAD_WAIT_TIME);
- else
- debug_msg("_running_tone thread is started");
-
- debug_leave();
- return MM_ERROR_NONE;
-
-Error:
- if (toneInfo) {
- if (toneInfo->handle) {
- if (MM_ERROR_NONE != mm_sound_pa_close(toneInfo->handle))
- debug_error("mm_sound_pa_close() fail. handle(%d)", toneInfo->handle);
- }
- free(toneInfo);
- }
-
- return result;
-
-}
-
-int MMSoundPlugCodecToneDestroy(MMHandleType handle)
-{
- tone_info_t *toneInfo = (tone_info_t*) handle;
- int err = MM_ERROR_NONE;
- if (!toneInfo) {
- debug_critical("Confirm the hadle (is NULL)");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- debug_enter("(handle %p)", handle);
-
- /* if the stop is request done ptr is valid, then inform the result */
- if (toneInfo->is_stop_request_done)
- *(toneInfo->is_stop_request_done) = true;
-
- pthread_mutex_destroy(&toneInfo->mutex);
- if (toneInfo)
- free(toneInfo);
-
- debug_leave();
- return err;
-}
-
-static
-int MMSoundPlugCodecTonePlay(MMHandleType handle)
-{
- tone_info_t *toneInfo = (tone_info_t *) handle;
-
- debug_enter("(handle %p)", handle);
- pthread_mutex_lock(&toneInfo->mutex);
- toneInfo->state = STATE_BEGIN;
- pthread_mutex_unlock(&toneInfo->mutex);
- debug_msg("sent start signal");
-
- debug_leave();
-
- return MM_ERROR_NONE;
-}
-
-static char*
-_create_tone(double *sample, TONE _TONE, double volume, int *toneSize, gboolean is_cycle_ended)
-{
- short *pbuf;
- double i = 0;
- double amplitude, f1, f2, f3;
- int quota = 0;
- float low_frequency;
- float middle_frequency;
- float high_frequency;
- int sample_size = 0;
- char* buffer;
-
- if (is_cycle_ended) {
- low_frequency = 0;
- middle_frequency = 0;
- high_frequency = 0;
- } else {
- low_frequency = _TONE.low_frequency;
- middle_frequency = _TONE.middle_frequency;
- high_frequency = _TONE.high_frequency;
- }
-
- if (sample == NULL) {
- debug_error("Sample buffer is not allocated");
- return NULL;
- }
-
- /* Create a buffer for the tone */
- if ((_TONE.playingTime > MAX_DURATION) || (_TONE.playingTime == -1))
- *toneSize = ((MAX_DURATION / 1000.) * SAMPLERATE * SAMPLE_SIZE * CHANNELS) / 8;
- else
- *toneSize = ((_TONE.playingTime / 1000.) * SAMPLERATE * SAMPLE_SIZE * CHANNELS) / 8;
-
- *toneSize = ((*toneSize + 1) >> 1) << 1;
- sample_size = (*toneSize) / (SAMPLE_SIZE / 8);
-
- debug_log("%0.f, %0.f, %0.f _TONE.playing_time: %d toneSize: %d",
- low_frequency, middle_frequency, high_frequency, _TONE.playingTime, *toneSize);
-
- buffer = g_malloc(*toneSize);
- if (buffer == NULL) {
- debug_error("Buffer is not allocated");
- return NULL;
- } else {
- pbuf = (short*)buffer;
-
- if (_TONE.low_frequency > 0)
- quota++;
-
- if (_TONE.middle_frequency > 0)
- quota++;
-
- if (_TONE.high_frequency > 0)
- quota++;
-
- for (i = 0; i < sample_size; i++) {
- /*
- * We add the fundamental frequencies together.
- */
-
- f1 = sin(2 * M_PI * low_frequency * ((*sample) / SAMPLERATE));
- f2 = sin(2 * M_PI * middle_frequency * ((*sample) / SAMPLERATE));
- f3 = sin(2 * M_PI * high_frequency * ((*sample) / SAMPLERATE));
-
- if (f1 + f2 + f3 != 0) {
- amplitude = (f1 + f2 + f3) / quota;
- /* Adjust the volume */
- amplitude *= volume;
-
- /* Make the [-1:1] interval into a [-32767:32767] interval */
- amplitude *= 32767;
- } else {
- amplitude = 0;
- }
-
- /* Store it in the data buffer */
- *(pbuf++) = (short) amplitude;
-
- (*sample)++;
- }
- }
- return buffer;
-}
-
-static TONE
-_mm_get_tone(int key, int CurIndex)
-{
- TONE _TONE;
-
- _TONE.low_frequency = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + LOW_FREQUENCY];
- _TONE.middle_frequency = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + MIDDLE_FREQUENCY];
- _TONE.high_frequency = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + HIGH_FREQUENCY];
- _TONE.playingTime = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + PLAYING_TIME];
- _TONE.loopCnt = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + LOOP_COUNT];
- _TONE.loopIndx = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + LOOP_INDEX];
-
- return _TONE;
-}
-
-static int
-_mm_get_waveCnt_PlayingTime(int toneTime, TONE _TONE, int *waveCnt, int *waveRestPlayTime)
-{
- int ret = MM_ERROR_NONE;
- if (waveCnt == NULL || waveRestPlayTime == NULL) {
- debug_error("waveCnt || waveRestPlayTime buffer is NULL");
- return MM_ERROR_SOUND_INTERNAL;
- }
- /*Set wave count and wave playing time*/
- if (_TONE.playingTime == -1) {
- *waveCnt = abs(toneTime) /MAX_DURATION;
- *waveRestPlayTime = abs(toneTime) % MAX_DURATION;
- } else {
- *waveCnt = _TONE.playingTime /MAX_DURATION;
- *waveRestPlayTime = _TONE.playingTime % MAX_DURATION;
- }
- return ret;
-}
-
-static int
-_mm_get_CurIndex(TONE _TONE, int *CurArrayPlayCnt, int *CurIndex)
-{
- int ret = MM_ERROR_NONE;
- if (CurArrayPlayCnt == NULL || CurIndex == NULL) {
- debug_error("CurArrayPlayCnt || CurIndex buffer is NULL");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if (_TONE.loopCnt != 0 && *CurArrayPlayCnt <= _TONE.loopCnt) {
- (*CurArrayPlayCnt)++;
- if (*CurArrayPlayCnt > _TONE.loopCnt) {
- (*CurIndex)++;
- *CurArrayPlayCnt = 0;
- } else {
- *CurIndex = _TONE.loopIndx;
- }
- } else {
- (*CurIndex)++;
- }
- debug_log("[%d] CurIndex: %d", *CurArrayPlayCnt, *CurIndex);
- return ret;
-}
-
-static void _running_tone(void *param)
-{
- char *ptoneBuf = NULL;
- char filename[100];
-
- if (param == NULL) {
- debug_error("param Buffer is not allocated");
- return;
- }
- tone_info_t *toneInfo = (tone_info_t*) param;
- int toneKey = 0;
- int toneTime = 0;
- int prePlayingTime = 0;
- int duration = 0;
- int playingTime = 0;
- int toneSize = 0;
- int CurWaveIndex = 0;
- int numWave = 0;
- int waveRestPlayTime = 0;
- int CurIndex = 0;
- int CurArrayPlayCnt = 0;
- gboolean is_cycle_ended = FALSE;
-
- debug_enter();
- pthread_mutex_lock(&toneInfo->mutex);
- toneInfo->thread_state = THREAD_STATE_START;
- debug_msg("set thread_state as THREAD_STATE_START");
- pthread_mutex_unlock(&toneInfo->mutex);
- double sample = 0;
- toneTime = toneInfo->time;
- if (toneTime != 0) {
- toneKey = toneInfo->number;
- debug_msg("toneKey number = %d", toneKey);
-
- /* Set pid check file */
- snprintf(filename, sizeof(filename), "/proc/%d/cmdline", toneInfo->pid);
-
- debug_msg("Wait start signal");
- while (toneInfo->state == STATE_READY)
- usleep(10);
- debug_msg("Recv start signal");
- pthread_mutex_lock(&toneInfo->mutex);
-
- if ((toneInfo->state == STATE_STOP) || (toneInfo->thread_state == THREAD_STATE_STOP)) {
- debug_msg("state is stop. state(%d) thread_state(%d) goto exit.", toneInfo->state, toneInfo->thread_state);
- pthread_mutex_unlock(&toneInfo->mutex);
- goto exit;
- } else {
- debug_msg("set state STATE_PLAY");
- toneInfo->state = STATE_PLAY;
- }
- pthread_mutex_unlock(&toneInfo->mutex);
-
- } else {
- return;
- }
-
- while (toneInfo->thread_state == THREAD_STATE_START) {
- TONE _TONE = _mm_get_tone(toneKey, CurIndex); /*Pop one of Tone Set */
- if (_mm_get_waveCnt_PlayingTime(toneTime, _TONE, &numWave, &waveRestPlayTime) != MM_ERROR_NONE) {
- debug_error("_mm_get_waveCnt_PlayingTime return value error");
- goto exit;
- }
-
- if (_mm_get_CurIndex(_TONE, &CurArrayPlayCnt, &CurIndex) != MM_ERROR_NONE) {
- debug_error("_mm_get_CurIndex return value error");
- goto exit;
- }
-
- debug_log("Predefined Tone[%d] Total Play time (ms) : %d, _TONE.playing_time: %d _numWave = %d low_frequency: %0.f, middle_frequency: %0.f, high_frequency: %0.f",
- CurIndex, toneTime, _TONE.playingTime, numWave, _TONE.low_frequency, _TONE.middle_frequency, _TONE.high_frequency);
-
-
- if (_TONE.low_frequency == -1) { /* skip frequency which's value is -1*/
- if ((_TONE.loopCnt > 0) && (CurArrayPlayCnt == _TONE.loopCnt)) {
- is_cycle_ended = TRUE;
- debug_log("[is_cycle_ended]");
- }
- CurIndex = _TONE.loopIndx;
- continue;
- }
-
- /* Write pcm data */
- for (CurWaveIndex = 0; CurWaveIndex < numWave+1; CurWaveIndex++) {
- if (CurWaveIndex == numWave) /* play the last tone set*/
- playingTime = waveRestPlayTime;
- else
- playingTime = MAX_DURATION;
-
- duration = playingTime;
-
- if (playingTime == 0)
- break;
-
- if (prePlayingTime + playingTime > toneTime && toneTime != -1)
- playingTime = toneTime - prePlayingTime;
-
- ptoneBuf = _create_tone(&sample, _TONE, toneInfo->volume, &toneSize, is_cycle_ended);
- if (ptoneBuf == NULL) {
- debug_error("Tone Buffer is not allocated");
- goto exit;
- }
- debug_log("[TONE] Play.....%dth %dms", CurWaveIndex, playingTime);
- mm_sound_pa_write(toneInfo->handle, ptoneBuf, ((toneSize * playingTime /duration + 1)>>1)<<1);
- prePlayingTime += playingTime;
- debug_log("previous_sum: %d", prePlayingTime);
- g_free(ptoneBuf);
- ptoneBuf = NULL;
-
- if (prePlayingTime == toneTime || toneInfo->state != STATE_PLAY) {
- debug_log("Finished.....on Total Playing Time : %d _TONE.playing_time: %d", prePlayingTime, _TONE.playingTime);
- mm_sound_pa_drain(toneInfo->handle);
- debug_log("Finished.....quit loop");
- goto exit;
- }
- debug_log("[%d] CurIndex: %d previous_sum: %d", CurArrayPlayCnt, CurIndex, prePlayingTime);
- }
- }
-
-exit:
- if (MM_ERROR_NONE != mm_sound_pa_close(toneInfo->handle))
- debug_error("mm_sound_pa_close() fail. handle(%d)", toneInfo->handle);
-
-#if 0
- pthread_mutex_destroy(&g_control.syncker);
-#endif
-
- debug_msg("Play end");
- pthread_mutex_lock(&toneInfo->mutex);
- toneInfo->state = STATE_NONE;
- pthread_mutex_unlock(&toneInfo->mutex);
-
- if (toneInfo->stop_cb)
- toneInfo->stop_cb(toneInfo->cb_param, toneInfo->thread_state == THREAD_STATE_STOP);
-
- debug_leave();
-}
-
-static
-int MMSoundPlugCodecToneStop(MMHandleType handle)
-{
- tone_info_t *toneInfo = (tone_info_t*) handle;
- bool is_stop_request_done = false;
-
- debug_enter("(handle %p)", handle);
- pthread_mutex_lock(&toneInfo->mutex);
- /*If stopped why stop again*/
- if (toneInfo->state == STATE_NONE || toneInfo->state == STATE_STOP) {
- pthread_mutex_unlock(&toneInfo->mutex);
- debug_msg("state(%d) is already STOP or NONE. return", toneInfo->state);
- return MM_ERROR_NONE;
- }
- toneInfo->is_stop_request_done = &is_stop_request_done;
- toneInfo->state = STATE_STOP;
- toneInfo->thread_state = THREAD_STATE_STOP;
- pthread_mutex_unlock(&toneInfo->mutex);
- debug_msg("sent stop signal");
-
- /* check whether stop is actually finished */
- while (is_stop_request_done == false)
- usleep(30000);
-
- debug_leave();
-
- return MM_ERROR_NONE;
-}
-
-static
-int MMSoundPlugCodecToneSetThreadPool(int (*func)(void*, void (*)(void*)))
-{
- debug_enter("(func : %p)", func);
- g_thread_pool_func = func;
- debug_leave();
- return MM_ERROR_NONE;
-}
-
-#if 0
-static int _MMSoundToneInit(void)
-{
- memset(&g_control, 0, sizeof(tone_control_t));
- pthread_mutex_init(&g_control.syncker, NULL);
- return MM_ERROR_NONE;
-}
-
-static int _MMSoundToneFini(void)
-{
- pthread_mutex_destroy(&g_control.syncker);
- return MM_ERROR_NONE;
-}
-#endif
-
-EXPORT_API
-int MMSoundGetPluginType(void)
-{
- debug_enter();
- debug_leave();
- return MM_SOUND_PLUGIN_TYPE_CODEC;
-}
-
-EXPORT_API
-int MMSoundPlugCodecGetInterface(mmsound_codec_interface_t *intf)
-{
- debug_enter();
-
- intf->GetSupportTypes = MMSoundPlugCodecToneGetSupportTypes;
- intf->Create = MMSoundPlugCodecToneCreate;
- intf->Destroy = MMSoundPlugCodecToneDestroy;
- intf->Play = MMSoundPlugCodecTonePlay;
- intf->Stop = MMSoundPlugCodecToneStop;
- intf->SetThreadPool = MMSoundPlugCodecToneSetThreadPool;
-
- debug_leave();
-
- return MM_ERROR_NONE;
-}
-
+++ /dev/null
-lib_LTLIBRARIES = libsoundpluginwave.la
-
-libsoundpluginwave_la_SOURCES = mm_sound_plugin_codec_wave.c
-
-libdir = $(PLUGIN_DIR)
-
-libsoundpluginwave_la_CFLAGS = \
- $(MMCOMMON_CFLAGS) \
- -I$(srcdir)/../../../include \
- -I$(srcdir)/../../include \
- $(PA_CFLAGS) \
- $(SNDFILE_CFLAGS) \
- $(MMLOGSVR_CFLAGS) -DMMF_LOG_OWNER=0x002 -DMMF_DEBUG_PREFIX=\"MMF-SOUND\"
-
-libsoundpluginwave_la_LIBADD = $(MMCOMMON_LIBS) \
- $(MMLOGSVR_LIBS) \
- $(PA_LIBS) \
- $(SNDFILE_LIBS) \
- $(srcdir)/../../../libmmfsound.la \
- $(srcdir)/../../../common/libmmfsoundcommon.la
-
-libsoundpluginwave_la_LDFLAGS = -avoid-version
+++ /dev/null
-/*
- * libmm-sound
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-
-
-#include <mm_error.h>
-#include <mm_debug.h>
-#include <mm_sound_pa_client.h>
-
-#include "../../include/mm_sound_plugin_codec.h"
-#include "../../../include/mm_sound_common.h"
-#include <unistd.h>
-
-#include <sndfile.h>
-#include <pthread.h>
-#include <pulse/pulseaudio.h>
-
-typedef struct {
- int handle;
- int repeat_count;
- int (*stop_cb)(int, bool);
- char filename[MM_SOUND_MAX_FILENAME];
- int cb_param;
- char stream_type[MAX_STREAM_TYPE_LEN];
- int stream_index;
- int client_pid;
-
- pa_threaded_mainloop *m;
- pa_context *c;
- pa_stream *s;
- pa_sample_spec spec;
- SNDFILE *sf;
- SF_INFO si;
-
- size_t written;
-} wave_info_t;
-
-static int _sound_prepare(wave_info_t *h)
-{
- memset(&h->si, 0, sizeof(SF_INFO));
-
- h->sf = sf_open(h->filename, SFM_READ, &h->si);
- if (!h->sf) {
- debug_error("sf_open error. path(%s), error(%d,%s)", h->filename, sf_error(h->sf), sf_strerror(h->sf));
- return (sf_error(h->sf) == SF_ERR_SYSTEM) ? MM_ERROR_SOUND_INTERNAL : MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE;
- }
-
- sf_command(h->sf, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE);
-
- h->spec.rate = h->si.samplerate;
- h->spec.channels = h->si.channels;
- h->spec.format = PA_SAMPLE_S16LE;
-
- debug_msg("SF_INFO : frames = %"PRId64", samplerate = %d, channels = %d, format = 0x%X, sections = %d, seekable = %d",
- h->si.frames, h->si.samplerate, h->si.channels, h->si.format, h->si.sections, h->si.seekable);
-
- return 0;
-}
-
-static int _sound_rewind(wave_info_t *h)
-{
- return (sf_seek(h->sf, 0, SEEK_SET) != -1) ? 0 : -1;
-}
-
-static int _sound_is_rewind_needed(wave_info_t *h)
-{
- return (h->repeat_count == -1 || h->repeat_count > 1);
-}
-
-static void _sound_unprepare(wave_info_t *h)
-{
- if (h->sf) {
- sf_close(h->sf);
- h->sf = NULL;
- }
-}
-
-/* Context Callbacks */
-static void _pa_context_state_callback(pa_context *c, void *userdata)
-{
- pa_threaded_mainloop *m = (pa_threaded_mainloop *)userdata;
- assert(c);
-
- switch (pa_context_get_state(c)) {
- case PA_CONTEXT_CONNECTING:
- case PA_CONTEXT_AUTHORIZING:
- case PA_CONTEXT_SETTING_NAME:
- debug_log("context(%p), state(%d)", c, pa_context_get_state(c));
- break;
-
- case PA_CONTEXT_READY:
- case PA_CONTEXT_TERMINATED:
- case PA_CONTEXT_FAILED:
- debug_warning("context(%p), state(%d)", c, pa_context_get_state(c));
- pa_threaded_mainloop_signal(m, 0);
- break;
-
- default:
- break;
- }
-}
-
-static void *_cleanup_thread_func(void *userdata)
-{
- pa_threaded_mainloop *m = (pa_threaded_mainloop *)userdata;
-
- if (m) {
- debug_error("now stop and free threaded_mainloop(%p) here", m);
- pa_threaded_mainloop_stop(m);
- pa_threaded_mainloop_free(m);
- } else {
- debug_warning("thread mainloop is already null");
- }
-
- pthread_exit(NULL);
-}
-
-static void _cleanup_threaded_mainloop(pa_threaded_mainloop *m)
-{
- int ret = 0;
- pthread_t thread_id;
- pthread_attr_t attr;
-
- ret = pthread_attr_init(&attr);
- if (ret != 0) {
- debug_error("failed to init pthread attr!!! errno=%d", ret);
- return;
- }
-
- ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if (ret != 0) {
- debug_error("failed to set detach state!!! errno=%d", ret);
- goto finish;
- }
-
- ret = pthread_create(&thread_id, &attr, _cleanup_thread_func, m);
- if (ret != 0)
- debug_error("failed to create _cleanup_thread_func!!! errno=%d", ret);
-
-finish:
- ret = pthread_attr_destroy(&attr);
- if (ret != 0)
- debug_error("failed to destroy pthread attr!!! errno=%d", ret);
-
- return;
-}
-
-
-static void _pa_context_drain_complete_callback(pa_context *c, void *userdata)
-{
- debug_msg("context drain completed, cleanup context and mainloop");
-
- pa_context_disconnect(c);
- pa_context_unref(c);
-
- _cleanup_threaded_mainloop((pa_threaded_mainloop *)userdata);
-}
-
-/* Stream Callbacks */
-static void _pa_stream_state_callback(pa_stream *s, void *userdata)
-{
- pa_threaded_mainloop *m = (pa_threaded_mainloop *)userdata;
-
- assert(s);
-
- switch (pa_stream_get_state(s)) {
- case PA_STREAM_CREATING:
- debug_log("stream(%p), state(%d)", s, pa_stream_get_state(s));
- break;
- case PA_STREAM_READY:
- case PA_STREAM_FAILED:
- case PA_STREAM_TERMINATED:
- debug_warning("stream(%p), state(%d)", s, pa_stream_get_state(s));
- pa_threaded_mainloop_signal(m, 0);
- break;
- default:
- break;
- }
-}
-
-static void _pa_stream_drain_complete_callback(pa_stream *s, int success, void *userdata)
-{
- pa_operation *o = NULL;
- wave_info_t *h = (wave_info_t *)userdata;
-
- debug_msg("stream(%p) : drain completed(%d)", s, success);
-
- if (!success) {
- debug_error("stream(%p) : drain failed(%d)", s, success);
- //pa_threaded_mainloop_signal(h->m, 0);
- }
-
- pa_stream_disconnect(h->s);
- pa_stream_unref(h->s);
- h->s = NULL;
-
- if (!(o = pa_context_drain(h->c, _pa_context_drain_complete_callback, h->m))) {
- debug_error("context(%p) failed to drain context!", h->c);
- pa_context_disconnect(h->c);
- pa_context_unref(h->c);
- h->c = NULL;
- } else {
- pa_operation_unref(o);
- }
-
- debug_msg("Invoke stop callback(%p, %d) of mgr_codec", h->stop_cb, h->cb_param);
- if (h->stop_cb)
- h->stop_cb(h->cb_param, false);
-}
-
-static void _pa_stream_moved_callback(pa_stream *s, void *userdata)
-{
- assert(s);
- debug_msg("stream(%p)", s);
-}
-
-static void _pa_stream_underflow_callback(pa_stream *s, void *userdata)
-{
- wave_info_t *h = (wave_info_t *)userdata;
- assert(s);
-
- debug_msg("stream(%p) : file(%s)", s, h->filename);
-}
-
-static void _pa_stream_buffer_attr_callback(pa_stream *s, void *userdata)
-{
- assert(s);
- debug_msg("stream(%p)", s);
-}
-
-static void _pa_stream_started_callback(pa_stream *s, void *userdata)
-{
- assert(s);
- debug_msg("stream(%p)", s);
-}
-
-static void _pa_stream_write_callback(pa_stream *s, size_t length, void *userdata)
-{
- sf_count_t bytes = 0;
- void *data = NULL;
- size_t data_length = 0;
- size_t frame_size;
- pa_operation *o = NULL;
- wave_info_t *h = (wave_info_t *)userdata;
-
- if (!s || length <= 0) {
- debug_error("stream(%p) : length(%zu)", s, length);
- return;
- }
-
- frame_size = pa_frame_size(&h->spec);
- data_length = length;
-
- if (frame_size == 0) {
- debug_error("stream(%p) : frame size can't be 0", s);
- return;
- }
-
- if (pa_stream_begin_write(s, &data, &data_length) < 0) {
- debug_error("stream(%p) : failed to pa_stream_begin_write()", s);
- return;
- }
-
- if ((bytes = sf_readf_short(h->sf, data, (sf_count_t)(data_length / frame_size))) > 0)
- bytes *= (sf_count_t)frame_size;
-
- debug_msg("stream(%p) : === %"PRId64" / %zu / %zu ===", s, bytes, data_length, h->written);
-
- if (bytes > 0)
- pa_stream_write(s, data, (size_t)bytes, NULL, 0, PA_SEEK_RELATIVE);
- else
- pa_stream_cancel_write(s);
-
- h->written += bytes;
-
- /* If No more data, drain stream */
- if (bytes < (sf_count_t)data_length) {
- debug_msg("stream(%p) : End Of Stream", s);
-
- /* Handle loop */
- if (_sound_is_rewind_needed(h)) {
- debug_msg("stream(%p) : repeat count = %d", s, h->repeat_count);
- /* do not decrease it in case of -1 for infinite play */
- if (h->repeat_count != -1)
- h->repeat_count--;
-
- if (_sound_rewind(h) == 0)
- return;
-
- debug_error("stream(%p) : REWIND failed....", s);
- /* can't loop anymore, fallback and do drain */
- }
-
- /* EOS callback will be notified after drain is completed */
- pa_stream_set_write_callback(s, NULL, NULL);
- o = pa_stream_drain(s, _pa_stream_drain_complete_callback, h);
- if (o)
- pa_operation_unref(o);
- else
- debug_error("stream(%p) : failed to drain", s);
- debug_msg("stream(%p) : reset write callback and drain requested", s);
- }
-}
-
-static int _pa_context_connect(wave_info_t *h)
-{
- pa_threaded_mainloop *m = NULL;
- pa_context *c = NULL;
-
- /* Mainloop */
- if (!(m = pa_threaded_mainloop_new())) {
- debug_error("mainloop create failed");
- return -1;
- }
-
- /* Context */
- if (!(c = pa_context_new(pa_threaded_mainloop_get_api(m), NULL))) {
- debug_error("context create failed");
- goto error_context_new;
- }
-
- pa_context_set_state_callback(c, _pa_context_state_callback, m);
-
- pa_threaded_mainloop_lock(m);
-
- if (pa_threaded_mainloop_start(m) < 0) {
- debug_error("mainloop start failed");
- goto error;
- }
-
- if (pa_context_connect(c, NULL, 0, NULL) < 0) {
- debug_error("context connect failed");
- goto error;
- }
-
- for (;;) {
- pa_context_state_t state = pa_context_get_state(c);
- if (state == PA_CONTEXT_READY)
- break;
-
- if (!PA_CONTEXT_IS_GOOD(state)) {
- debug_error("Context error!!!! %d", pa_context_errno(c));
- goto error;
- }
-
- pa_threaded_mainloop_wait(m);
- }
-
- h->m = m;
- h->c = c;
-
- pa_threaded_mainloop_unlock(m);
-
- return 0;
-
-error:
- pa_context_unref(c);
- pa_threaded_mainloop_unlock(m);
-error_context_new:
- pa_threaded_mainloop_free(m);
-
- return -1;
-}
-
-static int _pa_stream_connect(wave_info_t *h)
-{
- int ret = PA_OK;
- pa_stream *s = NULL;
- pa_proplist *proplist = NULL;
- pa_stream_state_t state;
-
- proplist = pa_proplist_new();
- if (!proplist)
- return -1;
- pa_proplist_sets(proplist, PA_PROP_MEDIA_ROLE, h->stream_type);
- pa_proplist_setf(proplist, PA_PROP_APPLICATION_PROCESS_ID_ORIGIN, "%d", h->client_pid);
- if (h->stream_index != -1)
- pa_proplist_setf(proplist, PA_PROP_MEDIA_PARENT_ID, "%d", h->stream_index);
-
- pa_threaded_mainloop_lock(h->m);
-
- s = pa_stream_new_with_proplist(h->c, "wav-player", &h->spec, NULL, proplist);
- pa_proplist_free(proplist);
- if (!s) {
- debug_error("pa_stream_new failed. file(%s)", h->filename);
- goto error;
- }
-
- pa_stream_set_state_callback(s, _pa_stream_state_callback, h->m);
- pa_stream_set_write_callback(s, _pa_stream_write_callback, h);
- pa_stream_set_moved_callback(s, _pa_stream_moved_callback, h);
- pa_stream_set_underflow_callback(s, _pa_stream_underflow_callback, h);
- pa_stream_set_buffer_attr_callback(s, _pa_stream_buffer_attr_callback, h);
- pa_stream_set_started_callback(s, _pa_stream_started_callback, h);
-
- ret = pa_stream_connect_playback(s, NULL, NULL,
- PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_START_CORKED,
- NULL, NULL);
- if (ret < 0) {
- debug_error("stream(%p) : failed to connect playback, ret(%d)", s, ret);
- goto error;
- }
- for (;;) {
- state = pa_stream_get_state(s);
-
- if (state == PA_STREAM_READY)
- break;
-
- if (!PA_STREAM_IS_GOOD(state)) {
- debug_error("stream(%p) : state(%d)", s, state);
- goto error;
- }
-
- /* Wait until the stream is ready */
- pa_threaded_mainloop_wait(h->m);
- }
-
- h->s = s;
-
- pa_threaded_mainloop_unlock(h->m);
-
- return 0;
-
-error:
- if (s)
- pa_stream_unref(s);
-
- pa_threaded_mainloop_unlock(h->m);
-
- return -1;
-}
-
-static void _pa_stream_uncork(wave_info_t *h)
-{
- pa_operation *o = NULL;
-
- assert(h);
- assert(h->m);
- assert(h->s);
-
- pa_threaded_mainloop_lock(h->m);
-
- if ((o = pa_stream_cork(h->s, 0, NULL, NULL)))
- pa_operation_unref(o);
- else
- debug_error("stream(%p) : uncork failed", h->s);
-
- pa_threaded_mainloop_unlock(h->m);
-}
-
-static void _pa_stream_stop_disconnect(wave_info_t *h)
-{
- assert(h);
- assert(h->m);
-
- pa_threaded_mainloop_lock(h->m);
- if (h->s) {
- pa_stream_disconnect(h->s);
- pa_stream_unref(h->s);
- h->s = NULL;
- }
- if (h->c) {
- pa_context_disconnect(h->c);
- pa_context_unref(h->c);
- h->c = NULL;
- }
- pa_threaded_mainloop_unlock(h->m);
-
- pa_threaded_mainloop_free(h->m);
- h->m = NULL;
-}
-
-static int * _mm_sound_plug_codec_wave_get_supported_types(void)
-{
- static int suported[2] = { MM_SOUND_SUPPORTED_CODEC_WAVE, 0 };
- return suported;
-}
-
-static int _mm_sound_plug_codec_wave_parse(const char *filename, mmsound_codec_info_t *info)
-{
- SNDFILE *sf = NULL;
- SF_INFO si;
-
- if (!filename || !info) {
- debug_error("filename(%p) or info(%p) is invalid...", filename, info);
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- /* FIXME : following sndfile code should be encapsulated */
- memset(&si, 0, sizeof(SF_INFO));
- sf = sf_open(filename, SFM_READ, &si);
- if (!sf) {
- debug_error("sf_open error. path(%s), error(%d, %s)", filename, sf_error(sf), sf_strerror(sf));
- if (sf_error(sf) == SF_ERR_SYSTEM)
- return MM_ERROR_SOUND_INTERNAL;
- else
- return MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE;
- }
-
- info->codec = MM_SOUND_SUPPORTED_CODEC_WAVE;
- info->channels = si.channels;
- info->samplerate = si.samplerate;
-
- debug_msg("filename[%s], frames[%"PRId64"], samplerate[%d], channels[%d], format[%x], sections[%d], seekable[%d]",
- filename, si.frames, si.samplerate, si.channels, si.format, si.sections, si.seekable);
- sf_close(sf);
-
- return MM_ERROR_NONE;
-}
-
-static int _mm_sound_plug_codec_wave_create(mmsound_codec_param_t *param, mmsound_codec_info_t *info, MMHandleType *handle)
-{
- wave_info_t *h = NULL;
- int ret = 0;
-
-#ifdef DEBUG_DETAIL
- debug_enter();
-#endif
-
- h = (wave_info_t *)calloc(1, sizeof(wave_info_t));
- if (h == NULL) {
- debug_error("memory allocation failed");
- return MM_ERROR_OUT_OF_MEMORY;
- }
-
- h->handle = 0;
- h->repeat_count = param->repeat_count;
- h->stop_cb = param->stop_cb;
- h->cb_param = param->param;
- MMSOUND_STRNCPY(h->filename, param->pfilename, MM_SOUND_MAX_FILENAME);
- h->client_pid = param->pid;
- h->stream_index = param->stream_index;
- MMSOUND_STRNCPY(h->stream_type, param->stream_type, MAX_STREAM_TYPE_LEN);
-
- ret = _sound_prepare(h);
- if (ret < 0) {
- debug_error("failed to prepare sound");
- goto error;
- }
-
- ret = _pa_context_connect(h);
- if (ret < 0) {
- debug_error("failed to connect context...");
- goto error;
- }
-
- ret = _pa_stream_connect(h);
- if (ret < 0) {
- debug_error("failed to connect stream...");
- goto error;
- }
-
- *handle = (MMHandleType)h;
-
-#ifdef DEBUG_DETAIL
- debug_leave("%p", h);
-#endif
- return MM_ERROR_NONE;
-
-error:
- _sound_unprepare(h);
- free(h);
- return MM_ERROR_SOUND_INTERNAL;
-}
-
-
-static int _mm_sound_plug_codec_wave_play(MMHandleType handle)
-{
- wave_info_t *h = (wave_info_t *)handle;
-
- debug_msg("Start handle(%p), stream(%p), written(%zu)", h, h->s, h->written);
- _pa_stream_uncork(h);
-
- return MM_ERROR_NONE;
-}
-
-static int _mm_sound_plug_codec_wave_stop(MMHandleType handle)
-{
- wave_info_t *h = (wave_info_t *)handle;
- if (!h) {
- debug_error("The handle is null");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- debug_msg("Handle %p stop requested", h);
-
- _pa_stream_stop_disconnect(h);
-
- if (h->stop_cb)
- h->stop_cb(h->cb_param, true);
-
- return MM_ERROR_NONE;
-}
-
-static int _mm_sound_plug_codec_wave_destroy(MMHandleType handle)
-{
- wave_info_t *h = (wave_info_t *)handle;
-
- if (!h) {
- debug_error("Can not destroy handle :: handle is invalid");
- return MM_ERROR_SOUND_INVALID_POINTER;
- }
-
- _sound_unprepare(h);
-
- free(h);
- h = NULL;
-
- return MM_ERROR_NONE;
-}
-
-EXPORT_API
-int MMSoundPlugCodecGetInterface(mmsound_codec_interface_t *intf)
-{
- assert(intf);
-
- intf->GetSupportTypes = _mm_sound_plug_codec_wave_get_supported_types;
- intf->Parse = _mm_sound_plug_codec_wave_parse;
- intf->Create = _mm_sound_plug_codec_wave_create;
- intf->Play = _mm_sound_plug_codec_wave_play;
- intf->Stop = _mm_sound_plug_codec_wave_stop;
- intf->Destroy = _mm_sound_plug_codec_wave_destroy;
- intf->SetThreadPool = NULL;
-
- return MM_ERROR_NONE;
-}
-
-EXPORT_API
-int MMSoundGetPluginType(void)
-{
- return MM_SOUND_PLUGIN_TYPE_CODEC;
-}
-
-
#include <vconf.h>
#define POWERON_FILE "/usr/share/keysound/poweron.ogg"
-#define KEYTONE_FILE "/usr/share/sounds/sound-server/Tizen_HW_Touch.ogg"
+#define KEYTONE_FILE "/usr/share/sounds/mm-sound/Tizen_HW_Touch.ogg"
#define KEYTONE_NOTI_FILE "/usr/share/sounds/alsa/Front_Center.wav"
enum {
g_print("kn : Play Keysound (Notification) \t");
g_print("ksn : Stop Keysound (Notification) \t");
g_print("ksa : Stop Keysound (All) \n");
- g_print("as : play sound with stream type\n");
- g_print("FS : Play DTMF with stream type\t");
- g_print("b : Play directory\n");
- g_print("s : Stop play \n");
g_print("==================================================================\n");
g_print(" Volume APIs\n");
g_print("==================================================================\n");
g_print("Current Voice volume is %d\n", value);
}
- } else if (strncmp(cmd, "as", 2) == 0) {
- debug_log("stream %s type, %d", "media", g_volume_value);
- ret = mm_sound_play_sound_with_stream_info(g_file_name, "media", -1, 1, mycallback, "USERDATA", &handle);
- if (ret < 0)
- debug_log("mm_sound_play_sound() failed with 0x%x", ret);
-
- } else if (strncmp(cmd, "FS", 2) == 0) {
- char num = 0;
- char input_string[128] = "";
- char *tok = NULL;
- char *ptr = NULL;
- char *stream_type = NULL;
- int tonetime = 0;
- double volume = 1.0;
- MMSoundTone_t tone = MM_SOUND_TONE_DTMF_0;
-
- while (num != 'q') {
- fflush(stdin);
- g_print("enter number(0~H exit:q), stream type(media, system, ...), volume(0.0~1.0), time(ms):\t ");
- if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- tok = strtok_r(input_string, " ", &ptr);
- if (!tok)
- continue;
- if (tok[0] == 'q') {
- break;
- } else if (tok[0] < '0' || tok[0] > '~') {
- if (tok[0] != '*' && tok[0] != '#')
- continue;
- }
- num = tok[0];
- if (num >= '0' && num <= '9')
- tone = (MMSoundTone_t)(num - '0');
- else if (num == '*')
- tone = MM_SOUND_TONE_DTMF_S;
- else if (num == '#')
- tone = MM_SOUND_TONE_DTMF_P;
- else if (num == 'A')
- tone = MM_SOUND_TONE_DTMF_A;
- else if (num == 'B')
- tone = MM_SOUND_TONE_DTMF_B;
- else if (num == 'C')
- tone = MM_SOUND_TONE_DTMF_C;
- else if (num == 'D')
- tone = MM_SOUND_TONE_DTMF_D;
- else if (num == 'E')
- tone = MM_SOUND_TONE_SUP_DIAL;
- else if (num == 'F')
- tone = MM_SOUND_TONE_ANSI_DIAL;
- else if (num == 'G')
- tone = MM_SOUND_TONE_JAPAN_DIAL;
- else if (num == 'H')
- tone = MM_SOUND_TONE_SUP_BUSY;
- else if (num == 'I')
- tone = MM_SOUND_TONE_ANSI_BUSY;
- else if (num == 'J')
- tone = MM_SOUND_TONE_JAPAN_BUSY;
- else if (num == 'K')
- tone = MM_SOUND_TONE_SUP_CONGESTION;
- else if (num == 'L')
- tone = MM_SOUND_TONE_ANSI_CONGESTION;
- else if (num == 'M')
- tone = MM_SOUND_TONE_SUP_RADIO_ACK;
- else if (num == 'N')
- tone = MM_SOUND_TONE_JAPAN_RADIO_ACK;
- else if (num == 'O')
- tone = MM_SOUND_TONE_SUP_RADIO_NOTAVAIL;
- else if (num == 'P')
- tone = MM_SOUND_TONE_SUP_ERROR;
- else if (num == 'Q')
- tone = MM_SOUND_TONE_SUP_CALL_WAITING;
- else if (num == 'R')
- tone = MM_SOUND_TONE_ANSI_CALL_WAITING;
- else if (num == 'S')
- tone = MM_SOUND_TONE_SUP_RINGTONE;
- else if (num == 'T')
- tone = MM_SOUND_TONE_ANSI_RINGTONE;
- else if (num == 'U')
- tone = MM_SOUND_TONE_PROP_BEEP;
- else if (num == 'V')
- tone = MM_SOUND_TONE_PROP_ACK;
- else if (num == 'W')
- tone = MM_SOUND_TONE_PROP_NACK;
- else if (num == 'X')
- tone = MM_SOUND_TONE_PROP_PROMPT;
- else if (num == 'Y')
- tone = MM_SOUND_TONE_PROP_BEEP2;
- else if (num == 'Z')
- tone = MM_SOUND_TONE_CDMA_HIGH_SLS;
- else if (num == '[')
- tone = MM_SOUND_TONE_CDMA_MED_SLS;
- else if (num == ']')
- tone = MM_SOUND_TONE_CDMA_LOW_SLS;
- else if (num == '^')
- tone = MM_SOUND_TONE_CDMA_HIGH_S_X4;
- else if (num == '_')
- tone = MM_SOUND_TONE_CDMA_MED_S_X4;
- else if (num == 'a')
- tone = MM_SOUND_TONE_CDMA_LOW_S_X4;
- else if (num == 'b')
- tone = MM_SOUND_TONE_CDMA_HIGH_PBX_L;
- else if (num == 'c')
- tone = MM_SOUND_TONE_CDMA_MED_PBX_L;
- else if (num == 'd')
- tone = MM_SOUND_TONE_CDMA_LOW_PBX_L;
- else if (num == 'e')
- tone = MM_SOUND_TONE_CDMA_HIGH_PBX_SS;
- else if (num == 'f')
- tone = MM_SOUND_TONE_CDMA_MED_PBX_SS;
- else if (num == 'g')
- tone = MM_SOUND_TONE_CDMA_LOW_PBX_SS;
- else if (num == 'h')
- tone = MM_SOUND_TONE_CDMA_HIGH_PBX_SSL;
- else if (num == 'i')
- tone = MM_SOUND_TONE_CDMA_MED_PBX_SSL;
- else if (num == 'j')
- tone = MM_SOUND_TONE_CDMA_LOW_PBX_SSL;
- else if (num == 'k')
- tone = MM_SOUND_TONE_CDMA_HIGH_PBX_SLS;
- else if (num == 'l')
- tone = MM_SOUND_TONE_CDMA_MED_PBX_SLS;
- else if (num == 'm')
- tone = MM_SOUND_TONE_CDMA_LOW_PBX_SLS;
- else if (num == 'n')
- tone = MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4;
- else if (num == 'o')
- tone = MM_SOUND_TONE_CDMA_MED_PBX_S_X4;
- else if (num == 'p')
- tone = MM_SOUND_TONE_CDMA_LOW_PBX_S_X4;
- else if (num == 'q')
- tone = MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE;
- else if (num == 'r')
- tone = MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE;
- else if (num == 's')
- tone = MM_SOUND_TONE_CDMA_ONE_MIN_BEEP;
- else if (num == 't')
- tone = MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE;
- else if (num == 'u')
- tone = MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE;
- else if (num == 'v')
- tone = MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE;
- else if (num == 'w')
- tone = MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK;
- else if (num == 'x')
- tone = MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD;
- else if (num == 'y')
- tone = MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE;
- else if (num == 'z')
- tone = MM_SOUND_TONE_CDMA_CALLDROP_LITE;
- else if (num == '{')
- tone = MM_SOUND_TONE_LOW_FRE;
- else if (num == '}')
- tone = MM_SOUND_TONE_MED_FRE;
- else if (num == '~')
- tone = MM_SOUND_TONE_HIGH_FRE;
-
- stream_type = strtok_r(NULL, " ", &ptr);
-
- tok = strtok_r(NULL, " ", &ptr);
- if (tok)
- volume = (double)atof(tok);
-
- tok = strtok_r(NULL, " ", &ptr);
- if (tok)
- tonetime = atoi(tok);
- else
- tonetime = MIN_TONE_PLAY_TIME;
-
- debug_log("stream type: %s\t volume is %f\t tonetime: %d", stream_type, volume, tonetime);
- ret = mm_sound_play_tone_with_stream_info(tone, stream_type, -1, volume, tonetime, &handle);
- if (ret < 0)
- debug_log("failed to mm_sound_play_tone_with_stream_info(), ret[0x%x]", ret);
- } else {
- g_print("### fgets return NULL\n");
- }
- }
-
- } else if (strncmp(cmd, "b", 1) == 0) {
- DIR *basedir;
- struct dirent *entry = NULL;
- struct dirent *prev_entry = NULL;
- int entry_len;
- int ret;
- struct stat file_stat;
- char fullpath[MAX_PATH_LEN] = "";
- struct timespec start_time = {0,};
- struct timespec current_time = {0,};
-
- if (g_dir_name[strlen(g_dir_name)-1] == '/')
- g_dir_name[strlen(g_dir_name)-1] = '\0';
-
- basedir = opendir(g_dir_name);
- if (basedir != NULL) {
- entry_len = offsetof(struct dirent, d_name) + fpathconf(dirfd(basedir), MAX_STRING_LEN) + 1;
- prev_entry = malloc(entry_len);
- if (prev_entry == NULL) {
- debug_error("malloc error");
- closedir(basedir);
- break;
- }
-
- while (1) {
- int playfail = 0;
- int mywait = 0;
-
- ret = readdir_r(basedir, prev_entry, &entry);
- if (ret == 0) {
- debug_error("error on readdir_r(%p)", basedir);
- break;
- }
- if (entry == NULL)
- break;
-
- if (entry->d_name[0] == '.')
- continue;
- memset(fullpath, '\0', sizeof(fullpath));
- snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", g_dir_name, entry->d_name);
- debug_log("Try %s", fullpath);
-
- if (lstat(fullpath, &file_stat) == -1)
- continue;
-
- if (S_ISREG(file_stat.st_mode)) {
- test_callback_done = 0 ;
- start_time.tv_sec = (long int)(time(NULL));
- start_time.tv_nsec = 0;
-
- ret = mm_sound_play_sound_with_stream_info(fullpath, "media", -1, 1, test_callback, "USERDATA", &handle);
- if (ret != MM_ERROR_NONE) {
- debug_log("Play file error : %s", fullpath);
- sleep(4);
- playfail = 1;
- }
- } else {
- debug_log("this is not regular file : %s", fullpath);
- playfail = 1;
- }
- while ((test_callback_done == 0) && (playfail == 0)) {
- current_time.tv_sec = (long int)(time(NULL));
- current_time.tv_nsec = 0;
- if (current_time.tv_sec - start_time.tv_sec > 200) {
- if ((++mywait)%5 == 0) {
- debug_log("I'm waiting callback for %d seconds after play %s",
- (int)(current_time.tv_sec - start_time.tv_sec), fullpath);
- }
- }
- sleep(2);
- }
- debug_log("goto next file");
- }
- free(prev_entry);
- closedir(basedir);
- } else {
- debug_log("Cannot Open such a directory %s", g_dir_name);
- }
-
} else if (strncmp(cmd, "f", 1) == 0) {
g_menu_state = CURRENT_STATUS_FILENAME;
} else if (strncmp(cmd, "d", 1) == 0) {
g_menu_state = CURRENT_STATUS_DIRNAME;
- } else if (strncmp(cmd, "s", 1) == 0) {
- if (mm_sound_stop_sound(handle))
- debug_log(" Cannot stop sound !!! %d ", handle);
-
} else if (strncmp(cmd, "L", 1) == 0) {
int ret = 0;
mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG;