4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungbae Shin <seungbae.shin@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 * @brief Application interface library for sound module.
28 * Application interface library for sound module.
31 #ifndef __MM_SOUND_H__
32 #define __MM_SOUND_H__
36 #include <mm_message.h>
46 This part is describes the sound module of multimedia framework. Sound
47 module provides APIs to implement play wav file with simple api, to handle volume information,
48 to handle audio route policy.
51 There is six different volume type for normal usage. application should set proper volume type to multimedia playback APIs.
55 <td><B>Description</B></td>
58 <td>VOLUME_TYPE_SYSTEM</td>
59 <td>volume for normal system sound (e.g. keysound, camera shutter)</td>
62 <td>VOLUME_TYPE_NOTIFICATION</td>
63 <td>volume for notification (e.g. message, email notification)</td>
66 <td>VOLUME_TYPE_RINGTONE</td>
67 <td>volume for incoming call ring</td>
70 <td>VOLUME_TYPE_MEDIA</td>
71 <td>volume for media playback (e.g. music, video playback)</td>
74 <td>VOLUME_TYPE_CALL</td>
75 <td>volume for call</td>
80 application can change audio route policy with mm-sound API.
81 Audio route is input and output of audio stream.
84 @image html audio_device.png "Figure1. Audio Devices of mobile phone" width=12cm
85 @image latex audio_device.png "Figure1. Audio Devices of mobile phone" width=12cm
88 Default audio route policy is like follows
93 <td><B>Bluetooth headset</B></td>
94 <td><B>Wired headset</B></td>
95 <td><B>Playback Device</B></td>
100 <td>Bluetooth headset</td>
105 <td>Bluetooth headset</td>
108 <td>disconnected</td>
110 <td>Wired headset</td>
113 <td>disconnected</td>
115 <td>Loud speaker</td>
120 for capture (bluetooth headset mic used only in call mode)
123 <td><B>Bluetooth headset mic</B></td>
124 <td><B>Wired headset mic</B></td>
125 <td><B>Capture Device</B></td>
130 <td>Wired headset mic</td>
138 <td>disconnected</td>
140 <td>Wired headset mic</td>
143 <td>disconnected</td>
145 <td>Wired headset mic</td>
150 If application changes routing policy to SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP with mm_sound_route_set_system_policy
151 audio routing policy has changed to ignore bluetooth headset connection.
156 <td><B>Bluetooth headset</B></td>
157 <td><B>Wired headset</B></td>
158 <td><B>Playback Device</B></td>
163 <td>Wired headset</td>
168 <td>Loud speaker</td>
171 <td>disconnected</td>
173 <td>Wired headset</td>
176 <td>disconnected</td>
178 <td>Loud speaker</td>
183 for capture (bluetooth headset mic used only in call mode)
186 <td><B>Bluetooth headset mic</B></td>
187 <td><B>Wired headset mic</B></td>
188 <td><B>Capture Device</B></td>
193 <td>Wired headset mic</td>
201 <td>disconnected</td>
203 <td>Wired headset mic</td>
206 <td>disconnected</td>
208 <td>Wired headset mic</td>
213 If application changes routing policy to SYSTEM_AUDIO_ROUTE_POLICY_HANDSET_ONLY with mm_sound_route_set_system_policy
214 audio routing policy has changed to use only loud speaker and microphone.
219 <td><B>Bluetooth headset</B></td>
220 <td><B>Wired headset</B></td>
221 <td><B>Playback Device</B></td>
226 <td>Loud speaker</td>
231 <td>Loud speaker</td>
234 <td>disconnected</td>
236 <td>Loud speaker</td>
239 <td>disconnected</td>
241 <td>Loud speaker</td>
246 for capture (bluetooth headset mic used only in call mode)
249 <td><B>Bluetooth headset mic</B></td>
250 <td><B>Wired headset mic</B></td>
251 <td><B>Capture Device</B></td>
264 <td>disconnected</td>
269 <td>disconnected</td>
276 #define MM_SOUND_STREAM_TYPE_LEN 64
279 * MMSound Volume APIs
283 * Enumerations of Volume type.
287 VOLUME_TYPE_SYSTEM, /**< System volume type */
288 VOLUME_TYPE_NOTIFICATION, /**< Notification volume type */
289 VOLUME_TYPE_ALARM, /**< Alarm volume type */
290 VOLUME_TYPE_RINGTONE, /**< Ringtone volume type */
291 VOLUME_TYPE_MEDIA, /**< Media volume type */
292 VOLUME_TYPE_CALL, /**< Call volume type */
293 VOLUME_TYPE_VOIP, /**< VOIP volume type */
294 VOLUME_TYPE_VOICE, /**< VOICE volume type */
295 VOLUME_TYPE_FIXED, /**< Volume type for fixed acoustic level */
296 VOLUME_TYPE_MAX, /**< Volume type count */
297 VOLUME_TYPE_UNKNOWN = -1, /**< volume type is not determined */
301 VOLUME_GAIN_DEFAULT = 0,
302 VOLUME_GAIN_DIALER = 1<<8,
303 VOLUME_GAIN_TOUCH = 2<<8,
304 VOLUME_GAIN_AF = 3<<8,
305 VOLUME_GAIN_SHUTTER1 = 4<<8,
306 VOLUME_GAIN_SHUTTER2 = 5<<8,
307 VOLUME_GAIN_CAMCORDING = 6<<8,
308 VOLUME_GAIN_MIDI = 7<<8,
309 VOLUME_GAIN_BOOTING = 8<<8,
310 VOLUME_GAIN_VIDEO = 9<<8,
311 VOLUME_GAIN_TTS = 10<<8,
315 * @brief Enumerations of supporting source_type
318 SUPPORT_SOURCE_TYPE_DEFAULT,
319 SUPPORT_SOURCE_TYPE_MIRRORING,
320 SUPPORT_SOURCE_TYPE_VOICECONTROL,
321 SUPPORT_SOURCE_TYPE_SVR,
322 SUPPORT_SOURCE_TYPE_VIDEOCALL,
323 SUPPORT_SOURCE_TYPE_VOICERECORDING,
324 SUPPORT_SOURCE_TYPE_VOIP, /* Supporting VoIP source*/
325 SUPPORT_SOURCE_TYPE_CALL_FORWARDING,
326 SUPPORT_SOURCE_TYPE_FMRADIO,
327 SUPPORT_SOURCE_TYPE_LOOPBACK,
328 } mm_sound_source_type_e;
331 * Volume change callback function type.
333 * @param user_data [in] Argument passed when callback has called
335 * @return No return value
337 * @see mm_sound_volume_add_callback mm_sound_volume_remove_callback
339 typedef void (*volume_callback_fn)(void* user_data);
342 * Active volume change callback function type.
344 * @param type [in] The sound type of changed volume
345 * @param volume [in] The new volume value
346 * @param user_data [in] Argument passed when callback has called
348 * @return No return value
350 * @see mm_sound_add_volume_changed_callback mm_sound_remove_volume_changed_callback
352 typedef void (*mm_sound_volume_changed_cb) (volume_type_t type, unsigned int volume, void *user_data);
356 * This function is to retrieve number of volume level.
358 * @param type [in] volume type to query
359 * @param step [out] number of volume steps
361 * @return This function returns MM_ERROR_NONE on success, or negative value
363 * @remark step means number of steps. so actual volume step can be 0 ~ step-1
373 ret = mm_sound_volume_get_step(VOLUME_TYPE_SYSTEM, &step);
376 printf("Can not get volume step\n");
381 //set system volume to max value
382 mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, max);
386 int mm_sound_volume_get_step(volume_type_t type, int *step);
390 * This function is to add volume changed callback.
392 * @param type [in] volume type to set change callback function
393 * @param func [in] callback function pointer
394 * @param user_data [in] user data passing to callback function
396 * @return This function returns MM_ERROR_NONE on success, or negative value
398 * @remark Only one callback function per volume type will be registered.
399 * if you want to change callback function for certain volume type,
400 * remove callback first via mm_sound_volume_remove_callback().
401 * @see volume_type_t volume_callback_fn
402 * @pre There should be not be pre-registered callback fuction to given volume type.
403 * @post Callback function will be registered to given volume type
406 volume_type_t g_vol_type = VOLUME_TYPE_MEDIA;
408 void _volume_callback(void *data)
410 unsigned int value = 0;
412 volume_type_t *type = (volume_type_t*)data;
414 result = mm_sound_volume_get_value(*type, &value);
415 if(result == MM_ERROR_NONE)
417 printf("Current volume value is %d\n", value);
421 printf("Can not get volume\n");
429 ret = mm_sound_volume_add_callback(g_vol_type, _volume_callback, (void*)&g_vol_type);
430 if ( MM_ERROR_NONE != ret)
432 printf("Can not add callback\n");
436 printf("Add callback success\n");
444 int mm_sound_volume_add_callback(volume_type_t type, volume_callback_fn func, void* user_data);
445 int mm_sound_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data);
449 * This function is to remove volume changed callback.
451 * @param type [in] volume type to set change callback function
453 * @return This function returns MM_ERROR_NONE on success, or negative value
456 * @pre Callback function should be registered previously for given volume type.
457 * @post Callback function will not be called anymore.
461 void _volume_callback(void *data)
463 printf("Callback function\n");
466 int volume_callback()
469 int vol_type = VOLUME_TYPE_MEDIA;
471 mm_sound_volume_add_callback(vol_type, _volume_callback, NULL);
473 ret = mm_sound_volume_remove_callback(vol_type);
474 if ( MM_ERROR_NONE == ret)
476 printf("Remove callback success\n");
480 printf("Remove callback failed\n");
488 int mm_sound_volume_remove_callback(volume_type_t type);
491 * This function is to remove volume change callback.
493 * @return This function returns MM_ERROR_NONE on success, or negative value
496 int mm_sound_remove_volume_changed_callback(void);
499 * This function is to set volume level of certain volume type.
501 * @param type [in] volume type to set value.
502 * @param value [in] volume value.
504 * @return This function returns MM_ERROR_NONE on success, or negative value
506 * @remark value should be 0 ~ mm_sound_volume_get_step() -1
507 * @see mm_sound_volume_get_step, mm_sound_volume_get_value volume_type_t
509 * @post Volume value will be changed to given value for given volume type.
516 ret = mm_sound_volume_get_step(VOLUME_TYPE_SYSTEM, &step);
519 printf("Can not get volume step\n");
524 //set system volume to max value
525 ret = mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, max);
528 printf("Can not set volume value\n");
533 int mm_sound_volume_set_value(volume_type_t type, const unsigned int volume_level);
537 * This function is to get volume level of certain volume type.
539 * @param type [in] volume type to get value.
540 * @param value [out] volume value.
542 * @return This function returns MM_ERROR_NONE on success, or negative value
547 * @see volume_type_t mm_sound_volume_set_value
553 ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
556 printf("Can not get volume\n");
560 printf("System type volume is %d\n", value);
563 * @see mm_sound_volume_set_value
565 int mm_sound_volume_get_value(volume_type_t type, unsigned int *value);
570 * This function is to set primary volume type.
572 * @param type [in] volume type to set as primary volume type.
574 * @return This function returns MM_ERROR_NONE on success, or negative value
576 * @remark Application should use this function during foreground.
577 * Application should clear primary volume type by mm_sound_volume_primary_type_clear() when it goes background.
579 * @post Volume app. will be update given volume type when H/W volume control key pressed.
580 * @see mm_sound_volume_primary_type_clear volume_type_t
583 static int _resume(void *data)
587 ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_MEDIA);
590 printf("Can not set primary volume type\n");
595 static int _pause(void* data)
599 ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_UNKNOWN);
602 printf("Can not clear primary volume type\n");
610 struct appcore_ops ops = {
612 .terminate = _terminate,
618 return appcore_efl_main(PACKAGE, ..., &ops);
622 int mm_sound_volume_primary_type_set(volume_type_t type);
623 int mm_sound_volume_primary_type_get(volume_type_t *type);
624 int mm_sound_volume_primary_type_clear(void);
626 int mm_sound_set_call_mute(volume_type_t type, int mute);
627 int mm_sound_get_call_mute(volume_type_t type, int *mute);
630 MM_SOUND_FACTORY_MIC_TEST_STATUS_OFF = 0,
631 MM_SOUND_FACTORY_MIC_TEST_STATUS_MAIN_MIC,
632 MM_SOUND_FACTORY_MIC_TEST_STATUS_SUB_MIC,
633 MM_SOUND_FACTORY_MIC_TEST_STATUS_NUM,
634 } mm_sound_factory_mic_test_status_t;/* device in for factory mic test */
636 int mm_sound_set_factory_mic_test(mm_sound_factory_mic_test_status_t mic_test);
638 int mm_sound_get_factory_mic_test(mm_sound_factory_mic_test_status_t *mic_test);
642 MMSOUND_DHA_SOFT_SOUND,
643 MMSOUND_DHA_CLEAR_SOUND,
644 MMSOUND_DHA_PERSNOL_LEFT,
645 MMSOUND_DHA_PERSNOL_RIGHT,
654 typedef void* MMSoundPcmHandle_t; /**< MMsound PCM handle type */
657 * Enumerations of Format used in MMSoundPcm operation.
660 MMSOUND_PCM_U8 = 0x70, /**< unsigned 8bit audio */
661 MMSOUND_PCM_S16_LE, /**< signed 16bit audio */
662 } MMSoundPcmFormat_t;
665 * Enumerations of Channel count used in MMSoundPcm operation.
668 MMSOUND_PCM_MONO = 0x80, /**< Mono channel */
669 MMSOUND_PCM_STEREO, /**< Stereo channel */
670 }MMSoundPcmChannel_t;
673 * Get audio stream latency value.
675 * @param handle [in] handle to get latency
676 * @param latency [out] Stream latency value(millisecond).
678 * @return This function returns MM_ERROR_NONE on success, or negative value
683 int mm_sound_pcm_get_latency(MMSoundPcmHandle_t handle, int *latency);
686 * Get started status of pcm stream.
688 * @param handle [in] handle to check pcm start
689 * @param is_started [out] retrieve started status of pcm stream.
691 * @return This function returns MM_ERROR_NONE on success, or negative value
696 int mm_sound_pcm_is_started(MMSoundPcmHandle_t handle, bool *is_started);
698 int mm_sound_pcm_play_open_no_session(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config);
701 * This function is to create handle for PCM playback.
703 * @param handle [out] handle to play pcm data
704 * @param rate [in] sample rate (8000Hz ~ 44100Hz)
705 * @param channel [in] number of channels (mono or stereo)
706 * @param format [in] S8 or S16LE
707 * @param volume config [in] Volume type & volume gain
709 * @return This function returns suggested buffer size (in bytes) on success, or negative value
711 * @remark use mm_sound_volume_set_value() function to change volume
712 * @see mm_sound_pcm_play_write, mm_sound_pcm_play_close, mm_sound_volume_set_value, MMSoundPcmFormat_t, MMSoundPcmChannel_t volume_type_t
714 * @post PCM play handle will be created.
717 #include <mm_sound.h>
721 int main(int argc, char* argv[])
728 MMSoundPcmHandle_t handle;
729 char *filename = NULL;
733 printf("Usage) %s filename\n", argv[0]);
738 fp = fopen(filename,"r");
741 printf("Can not open file %s\n", filename);
745 size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
748 printf("Can not open playback handle\n");
752 buffer = alloca(size);
753 while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
755 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
758 printf("write fail\n");
761 memset(buffer, '\0', sizeof(buffer));
765 mm_sound_pcm_play_close(handle);
770 int mm_sound_pcm_play_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config);
773 * This function start pcm playback
775 * @param handle [in] handle to start playback
777 * @return This function returns MM_ERROR_NONE on success, or negative value
781 * @pre PCM playback handle should be allocated.
782 * @post PCM playback is ready to write.
784 int mm_sound_pcm_play_start(MMSoundPcmHandle_t handle);
787 * This function stop pcm playback
789 * @param handle [in] handle to stop playback
791 * @return This function returns MM_ERROR_NONE on success, or negative value
795 * @pre PCM playback handle should be allocated.
796 * @post PCM playback data will not be buffered.
798 int mm_sound_pcm_play_stop(MMSoundPcmHandle_t handle);
801 * This function flush pcm playback
803 * @param handle [in] handle to flush playback
805 * @return This function returns MM_ERROR_NONE on success, or negative value
809 * @pre PCM playback handle should be allocated.
810 * @post PCM playback data will not be buffered.
812 int mm_sound_pcm_play_drain(MMSoundPcmHandle_t handle);
815 * This function flush pcm playback
817 * @param handle [in] handle to flush playback
819 * @return This function returns MM_ERROR_NONE on success, or negative value
823 * @pre PCM playback handle should be allocated.
824 * @post PCM playback data will not be buffered.
826 int mm_sound_pcm_play_flush(MMSoundPcmHandle_t handle);
829 * This function is to play PCM memory buffer.
831 * @param handle [in] handle to play pcm data
832 * @param ptr [in] pcm buffer address
833 * @param length_byte [in] size of pcm buffer (in bytes)
835 * @return This function returns written data size on success, or negative value
837 * @remark Make pcm buffer size with returned value of mm_sound_pcm_play_open()
838 * @see mm_sound_pcm_play_open, mm_sound_pcm_play_close
839 * @pre PCM play handle should be created.
840 * @post Sound will be generated with given PCM buffer data.
843 #include <mm_sound.h>
847 int main(int argc, char* argv[])
854 MMSoundPcmHandle_t handle;
855 char *filename = NULL;
859 printf("Usage) %s filename\n", argv[0]);
864 fp = fopen(filename,"r");
867 printf("Can not open file %s\n", filename);
871 size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
874 printf("Can not open playback handle\n");
878 buffer = alloca(size);
879 while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
881 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
884 printf("write fail\n");
887 memset(buffer, '\0', sizeof(buffer));
891 mm_sound_pcm_play_close(handle);
896 int mm_sound_pcm_play_write(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte);
901 * This function is to close PCM memory playback handle
903 * @param handle [in] handle to play pcm data
905 * @return This function returns MM_ERROR_NONE on success, or negative value
908 * @see mm_sound_pcm_play_open, mm_sound_pcm_play_write
909 * @pre PCM play handle should be created
910 * @post PCM play handle will be terminated.
913 #include <mm_sound.h>
917 int main(int argc, char* argv[])
924 MMSoundPcmHandle_t handle;
925 char *filename = NULL;
929 printf("Usage) %s filename\n", argv[0]);
934 fp = fopen(filename,"r");
937 printf("Can not open file %s\n", filename);
941 size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
944 printf("Can not open playback handle\n");
948 buffer = alloca(size);
949 while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
951 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
954 printf("write fail\n");
957 memset(buffer, '\0', sizeof(buffer));
961 mm_sound_pcm_play_close(handle);
966 int mm_sound_pcm_play_close(MMSoundPcmHandle_t handle);
969 * This function is to ignore session for playback
971 * @param handle [in] handle to play pcm data
973 * @return This function returns MM_ERROR_NONE on success, or negative value
975 * @remark This function only works for not started pcm handle and can't be reversed.
977 * @pre PCM play handle should be created and not started.
978 * @post PCM play session will be set to mix.
980 int mm_sound_pcm_play_ignore_session(MMSoundPcmHandle_t *handle);
983 * This function is to create handle for PCM capture.
985 * @param handle [out] handle to capture pcm data
986 * @param rate [in] sample rate (8000Hz ~ 44100Hz)
987 * @param channel [in] number of channels (mono or stereo)
988 * @param format [in] S8 or S16LE
990 * @return This function returns suggested buffer size (in bytes) on success, or negative value
992 * @remark only mono channel is valid for now.
993 * @see mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
995 * @post PCM capture handle will be allocated.
998 #include <mm_sound.h>
1002 int main(int argc, char* argv[])
1005 char *buffer = NULL;
1009 MMSoundPcmHandle_t handle;
1010 char *filename = NULL;
1014 printf("Usage) %s filename\n", argv[0]);
1019 fp = fopen(filename,"w");
1022 printf("Can not open file %s\n", filename);
1026 size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1029 printf("Can not open capture handle\n");
1033 buffer = alloca(size);
1036 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1039 printf("read fail\n");
1042 fwrite(buffer, ret, sizeof(char), fp);
1049 mm_sound_pcm_capture_close(handle);
1055 int mm_sound_pcm_capture_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format);
1058 * This function is to create handle for PCM capture of source_type.
1060 * @param handle [out] handle to capture pcm data
1061 * @param rate [in] sample rate (8000Hz ~ 44100Hz)
1062 * @param channel [in] number of channels (mono or stereo)
1063 * @param format [in] S8 or S16LE
1064 * @param source_type [in] The source_type,mm_sound_source_type_e
1066 * @return This function returns suggested buffer size (in bytes) on success, or negative value
1068 * @remark only mono channel is valid for now.
1069 * @see mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
1071 * @post PCM capture handle will be allocated.
1074 #include <mm_sound.h>
1078 int main(int argc, char* argv[])
1081 char *buffer = NULL;
1085 MMSoundPcmHandle_t handle;
1086 char *filename = NULL;
1090 printf("Usage) %s filename\n", argv[0]);
1095 fp = fopen(filename,"w");
1098 printf("Can not open file %s\n", filename);
1102 size = mm_sound_pcm_capture_open_ex(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE,1);
1105 printf("Can not open capture handle\n");
1109 buffer = alloca(size);
1112 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1115 printf("read fail\n");
1118 fwrite(buffer, ret, sizeof(char), fp);
1125 mm_sound_pcm_capture_close(handle);
1131 int mm_sound_pcm_capture_open_ex(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, mm_sound_source_type_e source_type);
1134 * This function start pcm capture
1136 * @param handle [in] handle to start capture
1138 * @return This function returns read data size on success, or negative value
1142 * @pre PCM capture handle should be allocated.
1143 * @post PCM capture data will be buffered.
1145 int mm_sound_pcm_capture_start(MMSoundPcmHandle_t handle);
1148 * This function stop pcm capture
1150 * @param handle [in] handle to stop capture
1152 * @return This function returns read data size on success, or negative value
1156 * @pre PCM capture handle should be allocated.
1157 * @post PCM capture data will not be buffered.
1159 int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle);
1162 * This function flush pcm capture
1164 * @param handle [in] handle to flush capture
1166 * @return This function returns MM_ERROR_NONE on success, or negative value
1170 * @pre PCM capture handle should be allocated.
1171 * @post PCM capture data will not be buffered.
1173 int mm_sound_pcm_capture_flush(MMSoundPcmHandle_t handle);
1176 * This function captures PCM to memory buffer. (Samsung extension)
1178 * @param handle [in] handle to play pcm data
1179 * @param buffer [in] pcm buffer address
1180 * @param length [in] size of pcm buffer (in bytes)
1182 * @return This function returns read data size on success, or negative value
1184 * @remark Make pcm buffer size with returned value of mm_sound_pcm_capture_open()
1185 * @see mm_sound_pcm_capture_open, mm_sound_pcm_capture_close
1186 * @pre PCM capture handle should be allcated.
1187 * @post PCM data will be filled to given memory pointer.
1190 #include <mm_sound.h>
1194 int main(int argc, char* argv[])
1197 char *buffer = NULL;
1201 MMSoundPcmHandle_t handle;
1202 char *filename = NULL;
1206 printf("Usage) %s filename\n", argv[0]);
1211 fp = fopen(filename,"w");
1214 printf("Can not open file %s\n", filename);
1218 size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1221 printf("Can not open capture handle\n");
1225 buffer = alloca(size);
1228 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1231 printf("read fail\n");
1234 fwrite(buffer, ret, sizeof(char), fp);
1241 mm_sound_pcm_capture_close(handle);
1247 int mm_sound_pcm_capture_read(MMSoundPcmHandle_t handle, void *buffer, const unsigned int length );
1250 * This function captures PCM memory to memory buffer (Samsung extension)
1252 * @param handle [in] handle to capture pcm data
1254 * @return This function returns MM_ERROR_NONE on success, or negative value
1257 * @see mm_sound_pcm_capture_open, mm_sound_pcm_capture_read
1258 * @pre PCM capture handle should be opend.
1259 * @post PCM capture handle will be freed.
1262 #include <mm_sound.h>
1266 int main(int argc, char* argv[])
1269 char *buffer = NULL;
1273 MMSoundPcmHandle_t handle;
1274 char *filename = NULL;
1278 printf("Usage) %s filename\n", argv[0]);
1283 fp = fopen(filename,"w");
1286 printf("Can not open file %s\n", filename);
1290 size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1293 printf("Can not open capture handle\n");
1297 buffer = alloca(size);
1300 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1303 printf("read fail\n");
1306 fwrite(buffer, ret, sizeof(char), fp);
1313 mm_sound_pcm_capture_close(handle);
1319 int mm_sound_pcm_capture_close(MMSoundPcmHandle_t handle);
1322 * This function is to ignore session for capture
1324 * @param handle [in] handle to capture pcm data
1326 * @return This function returns MM_ERROR_NONE on success, or negative value
1328 * @remark This function only works for not started pcm handle and can't be reversed.
1330 * @pre PCM capture handle should be created and not started.
1331 * @post PCM capture session will be set to mix.
1333 int mm_sound_pcm_capture_ignore_session(MMSoundPcmHandle_t *handle);
1336 * This function sets callback function for receiving messages from pcm API.
1338 * @param handle [in] Handle of pcm.
1339 * @param callback [in] Message callback function.
1340 * @param user_param [in] User parameter which is passed to callback function.
1342 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
1343 * @see MMMessageCallback
1347 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1351 case MM_MESSAGE_SOUND_PCM_CAPTURE_RESTRICTED:
1355 case MM_MESSAGE_SOUND_PCM_INTERRUPTED:
1365 mm_sound_pcm_set_message_callback(pcmHandle, msg_callback, (void *)pcmHandle);
1368 int mm_sound_pcm_set_message_callback (MMSoundPcmHandle_t handle, MMMessageCallback callback, void *user_param);
1371 * Terminate callback function type.
1373 * @param data [in] Argument passed when callback was set
1374 * @param id [in] handle which has completed playing
1376 * @return No return value
1377 * @remark It is not allowed to call MMSound API recursively or do time-consuming
1378 * task in this callback because this callback is called synchronously.
1379 * @see mm_sound_play_sound
1381 typedef void (*mm_sound_stop_callback_func) (void *data, int id);
1388 * This function is to play system sound.
1390 * @param filename [in] Sound filename to play
1391 * @param volume config [in] Volume type & volume gain
1392 * @param callback [in] Callback function pointer when playing is terminated.
1393 * @param data [in] Pointer to user data when callback is called.
1394 * @param handle [out] Handle of sound play.
1396 * @return This function returns MM_ERROR_NONE on success, or negative value
1398 * @remark When the stop callback is set, it will be called when system sound is
1399 * terminated. If mm_sound_stop_sound() is called apparently before
1400 * system sound is terminated, stop_callback will not be called.
1401 * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1403 * @post Sound will be generated with given filename.
1407 void _stop_callback(void* data)
1409 printf("Stop callback\n");
1415 char filename[] ="/opt/media/Sound/testfile.wav";
1416 volume_type_t volume = VOLUME_TYPE_SYSTEM;
1420 ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1423 printf("play file failed\n");
1427 printf("play file success\n");
1433 printf("play stopped\n");
1438 int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1440 int mm_sound_play_sound_without_session(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1442 int mm_sound_play_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1445 * This function is to play system sound. And other audio stream will be mute during playing time
1447 * @param filename [in] Sound filename to play
1448 * @param volume config [in] Volume type & volume gain
1449 * @param callback [in] Callback function pointer when playing is terminated.
1450 * @param data [in] Pointer to user data when callback is called.
1451 * @param handle [out] Handle of sound play.
1453 * @return This function returns MM_ERROR_NONE on success, or negative value
1455 * @remark This function is almost same with mm_sound_play_sound,
1456 * but this make other audio playback stream to mute during playing time.
1457 * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1459 * @post Sound will be generated with given filename.
1463 void _stop_callback(void* data)
1465 printf("Stop callback\n");
1471 char filename[] ="/opt/media/Sound/testfile.wav";
1472 volume_type_t volume = VOLUME_TYPE_SYSTEM;
1476 ret = mm_sound_play_loud_solo_sound(filename, volume, _stop_callback, NULL, &handle);
1479 printf("play file failed\n");
1483 printf("play file success\n");
1489 printf("play stopped\n");
1494 int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1496 int mm_sound_play_loud_solo_sound_no_restore(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1499 * This function is to stop playing system sound.
1501 * @param handle [in] Handle of mm_sound_play_sound
1503 * @return This function returns MM_ERROR_NONE on success, or negative value
1506 * @remark When system sound is terminated with this function call, it does not
1507 * call stop callback which was set when start playing system sound.
1508 * @see mm_sound_play_sound
1509 * @pre An sound play handle should be valid.
1510 * @post Playing sound file will be stopped.
1514 void _stop_callback(void* data)
1516 printf("Stop callback\n");
1520 int play_file_one_second()
1522 char filename[] ="/opt/media/Sound/testfile.wav";
1523 volume_type_t volume = VOLUME_TYPE_SYSTEM;
1527 ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1530 printf("play file failed\n");
1534 printf("play file success\n");
1537 sleep(1); //wait 1 second
1539 ret = mm_sound_stop_sound(handle);
1542 printf("stop failed\n");
1546 printf("play stopped\n");
1552 int mm_sound_stop_sound(int handle);
1556 * Enumerations for TONE
1560 MM_SOUND_TONE_DTMF_0 = 0, /**< Predefined DTMF 0 */
1561 MM_SOUND_TONE_DTMF_1, /**< Predefined DTMF 1 */
1562 MM_SOUND_TONE_DTMF_2, /**< Predefined DTMF 2 */
1563 MM_SOUND_TONE_DTMF_3, /**< Predefined DTMF 3 */
1564 MM_SOUND_TONE_DTMF_4, /**< Predefined DTMF 4 */
1565 MM_SOUND_TONE_DTMF_5, /**< Predefined DTMF 5 */
1566 MM_SOUND_TONE_DTMF_6, /**< Predefined DTMF 6 */
1567 MM_SOUND_TONE_DTMF_7, /**< Predefined DTMF 7 */
1568 MM_SOUND_TONE_DTMF_8, /**< Predefined DTMF 8 */
1569 MM_SOUND_TONE_DTMF_9, /**< Predefined DTMF 9 */
1570 MM_SOUND_TONE_DTMF_S, /**< Predefined DTMF Star - Asterisk (*) */
1571 MM_SOUND_TONE_DTMF_P, /**< Predefined DTMF sharP (#) */
1572 MM_SOUND_TONE_DTMF_A, /**< Predefined DTMF A (A) */
1573 MM_SOUND_TONE_DTMF_B, /**< Predefined DTMF B (B) */
1574 MM_SOUND_TONE_DTMF_C, /**< Predefined DTMF C (C) */
1575 MM_SOUND_TONE_DTMF_D, /**< Predefined DTMF D (D) */
1577 /**< Pre-defined TONE */
1578 MM_SOUND_TONE_SUP_DIAL, /**Call supervisory tone, Dial tone: CEPT: 425Hz, continuous */
1579 MM_SOUND_TONE_ANSI_DIAL, /**Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous */
1580 MM_SOUND_TONE_JAPAN_DIAL, /**Call supervisory tone, Dial tone: JAPAN: 400Hz, continuous*/
1581 MM_SOUND_TONE_SUP_BUSY, /**Call supervisory tone, Busy: CEPT: 425Hz, 500ms ON, 500ms OFF... */
1582 MM_SOUND_TONE_ANSI_BUSY, /**Call supervisory tone, Busy: ANSI (IS-95): 480Hz+620Hz, 500ms ON, 500ms OFF... */
1583 MM_SOUND_TONE_JAPAN_BUSY, /**Call supervisory tone, Busy: JAPAN: 400Hz, 500ms ON, 500ms OFF...*/
1584 MM_SOUND_TONE_SUP_CONGESTION, /**Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF */
1585 MM_SOUND_TONE_ANSI_CONGESTION, /**Call supervisory tone, Congestion: ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF... */
1586 MM_SOUND_TONE_SUP_RADIO_ACK, /**Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON */
1587 MM_SOUND_TONE_JAPAN_RADIO_ACK, /**Call supervisory tone, Radio path acknowlegment : JAPAN: 400Hz, 1s ON, 2s OFF...*/
1588 MM_SOUND_TONE_SUP_RADIO_NOTAVAIL, /**Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts */
1589 MM_SOUND_TONE_SUP_ERROR, /**Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF... */
1590 MM_SOUND_TONE_SUP_CALL_WAITING, /**Call supervisory tone, Call Waiting: CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF... */
1591 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 ...) */
1592 MM_SOUND_TONE_SUP_RINGTONE, /**Call supervisory tone, Ring Tone: CEPT, JAPAN: 425Hz, 1s ON, 4s OFF... */
1593 MM_SOUND_TONE_ANSI_RINGTONE, /**Call supervisory tone, Ring Tone: ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF... */
1594 MM_SOUND_TONE_PROP_BEEP, /**General beep: 400Hz+1200Hz, 35ms ON */
1595 MM_SOUND_TONE_PROP_ACK, /**Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts */
1596 MM_SOUND_TONE_PROP_NACK, /**Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON */
1597 MM_SOUND_TONE_PROP_PROMPT, /**Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON */
1598 MM_SOUND_TONE_PROP_BEEP2, /**Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON */
1599 MM_SOUND_TONE_SUP_INTERCEPT, /**Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms */
1600 MM_SOUND_TONE_SUP_INTERCEPT_ABBREV, /**Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds */
1601 MM_SOUND_TONE_SUP_CONGESTION_ABBREV, /**Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds */
1602 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 */
1603 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). */
1604 MM_SOUND_TONE_CDMA_DIAL_TONE_LITE, /**425Hz continuous */
1605 MM_SOUND_TONE_CDMA_NETWORK_USA_RINGBACK, /**CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...*/
1606 MM_SOUND_TONE_CDMA_INTERCEPT, /**CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...*/
1607 MM_SOUND_TONE_CDMA_ABBR_INTERCEPT, /**CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON */
1608 MM_SOUND_TONE_CDMA_REORDER, /**CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF... */
1609 MM_SOUND_TONE_CDMA_ABBR_REORDER, /**CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times */
1610 MM_SOUND_TONE_CDMA_NETWORK_BUSY, /**CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous */
1611 MM_SOUND_TONE_CDMA_CONFIRM, /**CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times */
1612 MM_SOUND_TONE_CDMA_ANSWER, /**CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF */
1613 MM_SOUND_TONE_CDMA_NETWORK_CALLWAITING, /**CDMA Network Callwaiting tone: 440Hz 300ms ON */
1614 MM_SOUND_TONE_CDMA_PIP, /**CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times */
1615 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 */
1616 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.*/
1617 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 */
1618 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT3, /**SDN Call sign PAT3 tone: silent tone */
1619 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING, /**ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON */
1620 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT5, /**ISDN Pat5 tone: silent tone */
1621 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT6, /**ISDN Pat6 tone: silent tone */
1622 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT7, /**ISDN Pat7 tone: silent tone */
1623 MM_SOUND_TONE_CDMA_HIGH_L, /**TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1624 MM_SOUND_TONE_CDMA_MED_L, /**TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1625 MM_SOUND_TONE_CDMA_LOW_L, /**TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, 4000ms OFF, Repeat .... */
1626 MM_SOUND_TONE_CDMA_HIGH_SS, /**CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1627 MM_SOUND_TONE_CDMA_MED_SS, /**CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1628 MM_SOUND_TONE_CDMA_LOW_SS, /**CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1629 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 ... */
1630 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 ... */
1631 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 ... */
1632 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 .... */
1633 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 .... */
1634 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 .... */
1635 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 */
1636 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 */
1637 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 */
1638 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.... */
1639 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.... */
1640 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....*/
1641 MM_SOUND_TONE_CDMA_HIGH_PBX_L, /**CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1642 MM_SOUND_TONE_CDMA_MED_PBX_L, /**CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1643 MM_SOUND_TONE_CDMA_LOW_PBX_L, /**CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1644 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.... */
1645 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.... */
1646 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.... */
1647 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.... */
1648 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.... */
1649 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.... */
1650 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.... */
1651 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.... */
1652 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.... */
1653 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... */
1654 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... */
1655 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... */
1656 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 */
1657 MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE, /**CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON */
1658 MM_SOUND_TONE_CDMA_ONE_MIN_BEEP, /**CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON */
1659 MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE, /**CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON */
1660 MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE, /**CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON */
1661 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*/
1662 MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK, /**CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times 4990ms OFF, REPEAT... */
1663 MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD, /**CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times */
1664 MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE, /**CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms */
1665 MM_SOUND_TONE_CDMA_CALLDROP_LITE, /**CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms */
1666 MM_SOUND_TONE_CDMA_NETWORK_BUSY_ONE_SHOT, /**CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. */
1667 MM_SOUND_TONE_CDMA_ABBR_ALERT, /**CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON */
1668 MM_SOUND_TONE_CDMA_SIGNAL_OFF, /**CDMA_SIGNAL_OFF - silent tone */
1669 MM_SOUND_TONE_LOW_FRE, /**100Hz continuous */
1670 MM_SOUND_TONE_MED_FRE, /**200Hz continuous */
1671 MM_SOUND_TONE_HIGH_FRE, /**300Hz continuous */
1675 typedef unsigned long sound_time_msec_t; /**< millisecond unit */
1678 * This function is to play tone sound.
1680 * @param num [in] predefined tone type (MMSoundTone_t)
1681 * volume config [in] volume type & volume gain
1682 * volume [in] volume ratio (0.0 ~1.0)
1683 * duration [in] millisecond (-1 for infinite)
1684 * handle [in] Handle of mm_sound_play_tone
1685 * enable_session [in] set enable/unable session
1687 * @return This function returns MM_ERROR_NONE on success, or negative value
1690 * @remark It doesn't provide stop
1691 * @see volume_type_t volume_gain_t MMSoundTone_t
1693 * @post TONE sound will be played.
1698 ret = mm_sound_play_tone_ex(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle, TRUE); //play 1 second with volume ratio 1.0
1701 printf("play tone failed\n");
1705 printf("play tone success\n");
1709 int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session);
1712 * This function is to play tone sound.
1714 * @param num [in] predefined tone type (MMSoundTone_t)
1715 * volume config [in] volume type & volume gain
1716 * volume [in] volume ratio (0.0 ~1.0)
1717 * duration [in] millisecond (-1 for infinite)
1718 * handle [in] Handle of mm_sound_play_tone
1720 * @return This function returns MM_ERROR_NONE on success, or negative value
1723 * @remark It doesn't provide stop
1724 * @see volume_type_t volume_gain_t MMSoundTone_t
1726 * @post TONE sound will be played.
1731 ret = mm_sound_play_tone(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle); //play 1 second with volume ratio 1.0
1734 printf("play tone failed\n");
1738 printf("play tone success\n");
1742 int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle);
1744 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);
1747 * Enumerations of System audio route policy
1751 * This function get a2dp activation information.
1753 * @param connected [out] is Bluetooth A2DP connected (1:connected, 0:not connected)
1754 * bt_name [out] Bluetooth A2DP connected device name (allocated by internal when connected=1 otherwise set to null)
1757 * @return This function returns MM_ERROR_NONE on success, or negative value
1759 * @remark This function allocation memory to given bt_name pointer internally.
1760 * So application should free given memory pointer later after use.
1761 * bt_name will be null if there's no a2dp device is connected (connected is 0)
1762 * @see mm_sound_route_set_system_policy mm_sound_route_get_system_policy
1764 * @post memory buffer will be allocated and fill with bluetooth device name.
1769 char* bt_name = NULL;
1770 ret = mm_sound_route_get_a2dp_status (&connected, &bt_name);
1772 if (ret == MM_ERROR_NONE) {
1773 g_print ("### Is Bluetooth A2DP On Success : connected=[%d] name=[%s]\n", connected, bt_name);
1777 g_print ("### Is Bluetooth A2DP On Error : errno [%d]\n", ret);
1781 int mm_sound_route_get_a2dp_status (bool* connected, char** bt_name);
1785 * Enumerations of device & route
1789 MM_SOUND_DIRECTION_NONE,
1790 MM_SOUND_DIRECTION_IN, /**< Capture */
1791 MM_SOUND_DIRECTION_OUT, /**< Playback */
1792 } mm_sound_direction;
1795 MM_SOUND_DEVICE_IN_NONE = 0x00,
1796 MM_SOUND_DEVICE_IN_MIC = 0x01, /**< Device builtin mic. */
1797 MM_SOUND_DEVICE_IN_WIRED_ACCESSORY = 0x02, /**< Wired input devices */
1798 MM_SOUND_DEVICE_IN_BT_SCO = 0x08, /**< Bluetooth SCO device */
1799 } mm_sound_device_in;
1802 MM_SOUND_DEVICE_OUT_NONE = 0x000,
1803 MM_SOUND_DEVICE_OUT_SPEAKER = 0x001<<8, /**< Device builtin speaker */
1804 MM_SOUND_DEVICE_OUT_RECEIVER = 0x002<<8, /**< Device builtin receiver */
1805 MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY = 0x004<<8, /**< Wired output devices such as headphone, headset, and so on. */
1806 MM_SOUND_DEVICE_OUT_BT_SCO = 0x008<<8, /**< Bluetooth SCO device */
1807 MM_SOUND_DEVICE_OUT_BT_A2DP = 0x010<<8, /**< Bluetooth A2DP device */
1808 MM_SOUND_DEVICE_OUT_DOCK = 0x020<<8, /**< DOCK device */
1809 MM_SOUND_DEVICE_OUT_HDMI = 0x040<<8, /**< HDMI device */
1810 MM_SOUND_DEVICE_OUT_MIRRORING = 0x080<<8, /**< MIRRORING device */
1811 MM_SOUND_DEVICE_OUT_USB_AUDIO = 0x100<<8, /**< USB Audio device */
1812 MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK = 0x200<<8, /**< Multimedia DOCK device */
1813 } mm_sound_device_out;
1816 MM_SOUND_VOLUME_DEVICE_OUT_SPEAKER, /**< Device builtin speaker */
1817 MM_SOUND_VOLUME_DEVICE_OUT_RECEIVER, /**< Device builtin receiver */
1818 MM_SOUND_VOLUME_DEVICE_OUT_WIRED_ACCESSORY, /**< Wired output devices such as headphone, headset, and so on. */
1819 MM_SOUND_VOLUME_DEVICE_OUT_BT_SCO, /**< Bluetooth SCO device */
1820 MM_SOUND_VOLUME_DEVICE_OUT_BT_A2DP, /**< Bluetooth A2DP device */
1821 MM_SOUND_VOLUME_DEVICE_OUT_DOCK, /**< DOCK device */
1822 MM_SOUND_VOLUME_DEVICE_OUT_HDMI, /**< HDMI device */
1823 MM_SOUND_VOLUME_DEVICE_OUT_MIRRORING, /**< MIRRORING device */
1824 MM_SOUND_VOLUME_DEVICE_OUT_USB_AUDIO, /**< USB Audio device */
1825 MM_SOUND_VOLUME_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Multimedia DOCK device */
1826 } mm_sound_volume_device_out_t;
1828 #define MM_SOUND_ROUTE_NUM 16
1829 #define MM_SOUND_NAME_NUM 32
1832 MM_SOUND_ROUTE_OUT_SPEAKER = MM_SOUND_DEVICE_OUT_SPEAKER, /**< Routing audio output to builtin device such as internal speaker. */
1833 MM_SOUND_ROUTE_OUT_RECEIVER = MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio output to builtin device such as internal receiver. */
1834 MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY = MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio output to wired accessory such as headphone, headset, and so on. */
1835 MM_SOUND_ROUTE_OUT_BLUETOOTH_SCO = MM_SOUND_DEVICE_OUT_BT_SCO, /**< Routing audio output to bluetooth SCO. */
1836 MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP = MM_SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */
1837 MM_SOUND_ROUTE_OUT_DOCK = MM_SOUND_DEVICE_OUT_DOCK, /**< Routing audio output to DOCK */
1838 MM_SOUND_ROUTE_OUT_HDMI = MM_SOUND_DEVICE_OUT_HDMI, /**< Routing audio output to HDMI */
1839 MM_SOUND_ROUTE_OUT_MIRRORING = MM_SOUND_DEVICE_OUT_MIRRORING, /**< Routing audio output to MIRRORING */
1840 MM_SOUND_ROUTE_OUT_USB_AUDIO = MM_SOUND_DEVICE_OUT_USB_AUDIO, /**< Routing audio output to USB Audio */
1841 MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK = MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Routing audio output to Multimedia DOCK */
1842 MM_SOUND_ROUTE_IN_MIC = MM_SOUND_DEVICE_IN_MIC, /**< Routing audio input to device builtin mic. */
1843 MM_SOUND_ROUTE_IN_WIRED_ACCESSORY = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY, /**< Routing audio input to wired accessory. */
1844 MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio input to device builtin mic and routing audio output to builtin receiver*/
1845 MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_SPEAKER , /**< Routing audio input to device builtin mic and routing audio output to builtin speaker */
1846 MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio input to device builtin mic and routing audio output to headphone */
1847 MM_SOUND_ROUTE_INOUT_HEADSET = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY, /**< Routing audio input and output to headset*/
1848 MM_SOUND_ROUTE_INOUT_BLUETOOTH = MM_SOUND_DEVICE_IN_BT_SCO | MM_SOUND_DEVICE_OUT_BT_SCO /**< Routing audio input and output to bluetooth SCO */
1852 * MMSound Device APIs
1856 MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG = 0x0001, /**< Flag for input devices */
1857 MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG = 0x0002, /**< Flag for output devices */
1858 MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG = 0x0004, /**< Flag for input/output devices (both directions are available) */
1859 MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG = 0x0010, /**< Flag for built-in devices */
1860 MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG = 0x0020, /**< Flag for external devices */
1861 MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG = 0x1000, /**< Flag for deactivated devices */
1862 MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG = 0x2000, /**< Flag for activated devices */
1863 MM_SOUND_DEVICE_ALL_FLAG = 0xFFFF, /**< Flag for all devices */
1864 } mm_sound_device_flags_e;
1867 MM_SOUND_DEVICE_IO_DIRECTION_IN = 0x1,
1868 MM_SOUND_DEVICE_IO_DIRECTION_OUT = 0x2,
1869 MM_SOUND_DEVICE_IO_DIRECTION_BOTH = MM_SOUND_DEVICE_IO_DIRECTION_IN | MM_SOUND_DEVICE_IO_DIRECTION_OUT,
1870 } mm_sound_device_io_direction_e;
1873 MM_SOUND_DEVICE_STATE_DEACTIVATED,
1874 MM_SOUND_DEVICE_STATE_ACTIVATED,
1875 } mm_sound_device_state_e;
1879 MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER, /**< Built-in speaker. */
1880 MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER, /**< Built-in receiver. */
1881 MM_SOUND_DEVICE_TYPE_BUILTIN_MIC, /**< Built-in mic. */
1882 MM_SOUND_DEVICE_TYPE_AUDIOJACK, /**< Audio jack such as headphone, headset, and so on. */
1883 MM_SOUND_DEVICE_TYPE_BLUETOOTH, /**< Bluetooth */
1884 MM_SOUND_DEVICE_TYPE_HDMI, /**< HDMI. */
1885 MM_SOUND_DEVICE_TYPE_MIRRORING, /**< MIRRORING. */
1886 MM_SOUND_DEVICE_TYPE_USB_AUDIO, /**< USB Audio. */
1887 } mm_sound_device_type_e;
1889 typedef void *MMSoundDevice_t; /**< MMsound Device handle */
1890 typedef void *MMSoundDeviceList_t; /**< MMsound Device list handle */
1891 typedef void (*mm_sound_device_connected_cb) (MMSoundDevice_t device_h, bool is_connected, void *user_data);
1892 typedef void (*mm_sound_device_info_changed_cb) (MMSoundDevice_t device_h, int changed_info_type, void *user_data);
1894 int mm_sound_add_device_connected_callback(mm_sound_device_flags_e flags, mm_sound_device_connected_cb func, void *user_data);
1895 int mm_sound_remove_device_connected_callback(void);
1896 int mm_sound_add_device_information_changed_callback(mm_sound_device_flags_e flags, mm_sound_device_info_changed_cb func, void *user_data);
1897 int mm_sound_remove_device_information_changed_callback(void);
1899 int mm_sound_get_current_device_list(mm_sound_device_flags_e device_mask, MMSoundDeviceList_t *device_list);
1900 int mm_sound_get_next_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
1901 int mm_sound_get_prev_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
1902 int mm_sound_get_device_type(MMSoundDevice_t device_h, mm_sound_device_type_e *type);
1903 int mm_sound_get_device_io_direction(MMSoundDevice_t device_h, mm_sound_device_io_direction_e *io_direction);
1904 int mm_sound_get_device_id(MMSoundDevice_t device_h, int *id);
1905 int mm_sound_get_device_state(MMSoundDevice_t device_h, mm_sound_device_state_e *state);
1906 int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name);
1908 /* below APIs are for product */
1909 typedef int (*mm_sound_available_route_cb)(mm_sound_route route, void *user_data);
1910 int mm_sound_is_route_available(mm_sound_route route, bool *is_available);
1911 int mm_sound_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data);
1912 int mm_sound_set_active_route(mm_sound_route route);
1913 int mm_sound_set_active_route_auto(void);
1917 * This function is to set active route without callback to client.
1919 * @param route [IN] route
1920 * @return This function returns MM_ERROR_NONE on success, or negative value
1925 * @see mm_sound_set_active_route_without_broadcast mm_sound_route
1927 int mm_sound_set_active_route_without_broadcast(mm_sound_route route);
1930 * This function is to get active playback device and capture device.
1932 * @param playback_device [out] playback device.
1933 * @param capture_device [out] capture device.
1935 * @return This function returns MM_ERROR_NONE on success, or negative value
1940 * @see mm_sound_set_active_route mm_sound_device_in mm_sound_device_out
1942 int mm_sound_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
1945 * Active device changed callback function type.
1947 * @param user_data [in] Argument passed when callback has called
1949 * @return No return value
1951 * @see mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
1953 typedef void (*mm_sound_active_device_changed_cb) (mm_sound_device_in device_in, mm_sound_device_out device_out, void *user_data);
1956 * This function is to add active device callback.
1958 * @param name [in] plugin name (name max size : MM_SOUND_NAME_NUM 32)
1959 * @param func [in] callback function pointer
1960 * @param user_data [in] user data passing to callback function
1962 * @return This function returns MM_ERROR_NONE on success, or negative value
1965 * @see mm_sound_remove_active_device_changed_callback mm_sound_active_device_changed_cb
1971 void __active_device_callback(void *user_data)
1973 printf("Callback function\n");
1976 int active_device_control()
1980 ret = mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
1981 if ( MM_ERROR_NONE != ret)
1983 printf("Can not add callback\n");
1987 printf("Add callback success\n");
1995 int mm_sound_add_active_device_changed_callback(const char *name,mm_sound_active_device_changed_cb func, void *user_data);
1997 * This function is to remove active device callback.
1999 * @param name [in] plugin name (name max size : MM_SOUND_NAME_NUM 32)
2000 * @return This function returns MM_ERROR_NONE on success, or negative value
2003 * @pre Active device callback should be registered.
2004 * @post Active device callback deregistered and does not be called anymore.
2005 * @see mm_sound_add_active_device_changed_callback mm_sound_active_device_changed_cb
2008 void __active_device_callback(void *data)
2010 printf("Callback function\n");
2013 int active_device_control()
2017 mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
2019 ret = mm_sound_remove_active_device_changed_callback();
2020 if ( MM_ERROR_NONE == ret)
2022 printf("Remove callback success\n");
2026 printf("Remove callback failed\n");
2034 int mm_sound_remove_active_device_changed_callback(const char *name);
2036 * Available route changed callback function type.
2038 * @param user_data [in] Argument passed when callback has called
2040 * @return No return value
2042 * @see mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
2044 typedef void (*mm_sound_available_route_changed_cb) (mm_sound_route route, bool available, void *user_data);
2047 * This function is to add available device callback.
2049 * @param func [in] callback function pointer
2050 * @param user_data [in] user data passing to callback function
2052 * @return This function returns MM_ERROR_NONE on success, or negative value
2055 * @see mm_sound_remove_available_route_changed_callback mm_sound_active_device_changed_cb
2061 void __available_device_callback(void *user_data)
2063 printf("Callback function\n");
2066 int available_device_control()
2070 ret = mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2071 if ( MM_ERROR_NONE != ret)
2073 printf("Can not add callback\n");
2077 printf("Add callback success\n");
2085 int mm_sound_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void *user_data);
2088 * This function is to remove available device callback.
2090 * @return This function returns MM_ERROR_NONE on success, or negative value
2093 * @pre available device callback should be registered.
2094 * @post available device callback deregistered and does not be called anymore.
2095 * @see mm_sound_add_available_route_changed_callback mm_sound_active_device_changed_cb
2098 void __available_device_callback(void *data)
2100 printf("Callback function\n");
2103 int available_device_control()
2107 mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2109 ret = mm_sound_remove_available_route_changed_callback();
2110 if ( MM_ERROR_NONE == ret)
2112 printf("Remove callback success\n");
2116 printf("Remove callback failed\n");
2124 int mm_sound_remove_available_route_changed_callback(void);
2127 * This function is to set path for active device.
2129 * @param device_out [in] active playback device
2130 * @param device_in [in] active capture device
2132 * @return This function returns MM_ERROR_NONE on success, or negative value
2140 int mm_sound_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in);
2143 * This function is to get current audio path.
2145 * @param device_out [in] active playback device
2146 * @param device_in [in] active capture device
2148 * @return This function returns MM_ERROR_NONE on success, or negative value
2157 int mm_sound_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
2161 typedef void (*mm_sound_test_cb) (int a, void *user_data);
2162 int mm_sound_test(int a, int b, int* get);
2163 int mm_sound_add_test_callback(mm_sound_test_cb func, void *user_data);
2164 int mm_sound_remove_test_callback(void);
2166 void mm_sound_convert_volume_type_to_stream_type(int volume_type, char *stream_type);
2169 MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS,
2170 MM_SOUND_SIGNAL_MAX,
2171 } mm_sound_signal_name_t;
2173 typedef void (* mm_sound_signal_callback) (mm_sound_signal_name_t signal, int value, void *user_data);
2174 int mm_sound_subscribe_signal(mm_sound_signal_name_t signal, unsigned int *subscribe_id, mm_sound_signal_callback callback, void *user_data);
2175 void mm_sound_unsubscribe_signal(unsigned int subscribe_id);
2176 int mm_sound_send_signal(mm_sound_signal_name_t signal, int value);
2177 int mm_sound_get_signal_value(mm_sound_signal_name_t signal, int *value);
2187 #endif /* __MM_SOUND_H__ */