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>
278 * MMSound Volume APIs
282 * Enumerations of Volume type.
286 VOLUME_TYPE_SYSTEM, /**< System volume type */
287 VOLUME_TYPE_NOTIFICATION, /**< Notification volume type */
288 VOLUME_TYPE_ALARM, /**< Alarm volume type */
289 VOLUME_TYPE_RINGTONE, /**< Ringtone volume type */
290 VOLUME_TYPE_MEDIA, /**< Media volume type */
291 VOLUME_TYPE_CALL, /**< Call volume type */
292 VOLUME_TYPE_VOIP, /**< VOIP volume type */
293 VOLUME_TYPE_VOICE, /**< VOICE volume type */
294 VOLUME_TYPE_FIXED, /**< Volume type for fixed acoustic level */
295 VOLUME_TYPE_MAX, /**< Volume type count */
296 VOLUME_TYPE_EXT_ANDROID = VOLUME_TYPE_FIXED, /**< External system volume for Android */
300 VOLUME_GAIN_DEFAULT = 0,
301 VOLUME_GAIN_DIALER = 1<<8,
302 VOLUME_GAIN_TOUCH = 2<<8,
303 VOLUME_GAIN_AF = 3<<8,
304 VOLUME_GAIN_SHUTTER1 = 4<<8,
305 VOLUME_GAIN_SHUTTER2 = 5<<8,
306 VOLUME_GAIN_CAMCORDING = 6<<8,
307 VOLUME_GAIN_MIDI = 7<<8,
308 VOLUME_GAIN_BOOTING = 8<<8,
309 VOLUME_GAIN_VIDEO = 9<<8,
310 VOLUME_GAIN_TTS = 10<<8,
314 * @brief Enumerations of supporting source_type
317 SUPPORT_SOURCE_TYPE_DEFAULT,
318 SUPPORT_SOURCE_TYPE_MIRRORING,
319 SUPPORT_SOURCE_TYPE_VOICECONTROL,
320 SUPPORT_SOURCE_TYPE_SVR,
321 SUPPORT_SOURCE_TYPE_VIDEOCALL,
322 SUPPORT_SOURCE_TYPE_VOICERECORDING,
323 SUPPORT_SOURCE_TYPE_VOIP, /* Supporting VoIP source*/
324 SUPPORT_SOURCE_TYPE_CALL_FORWARDING,
325 SUPPORT_SOURCE_TYPE_FMRADIO,
326 SUPPORT_SOURCE_TYPE_LOOPBACK,
327 } mm_sound_source_type_e;
330 * Volume change callback function type.
332 * @param user_data [in] Argument passed when callback has called
334 * @return No return value
336 * @see mm_sound_volume_add_callback mm_sound_volume_remove_callback
338 typedef void (*volume_callback_fn)(void* user_data);
341 * Active volume change callback function type.
343 * @param type [in] The sound type of changed volume
344 * @param volume [in] The new volume value
345 * @param user_data [in] Argument passed when callback has called
347 * @return No return value
349 * @see mm_sound_add_volume_changed_callback mm_sound_remove_volume_changed_callback
351 typedef void (*mm_sound_volume_changed_cb) (volume_type_t type, unsigned int volume, void *user_data);
355 * Muteall state change callback function type.
357 * @param user_data [in] Argument passed when callback has called
359 * @return No return value
361 * @see mm_sound_muteall_add_callback mm_sound_muteall_remove_callback
363 typedef void (*muteall_callback_fn)(void* user_data);
366 * This function is to retrieve number of volume level.
368 * @param type [in] volume type to query
369 * @param step [out] number of volume steps
371 * @return This function returns MM_ERROR_NONE on success, or negative value
373 * @remark step means number of steps. so actual volume step can be 0 ~ step-1
383 ret = mm_sound_volume_get_step(VOLUME_TYPE_SYSTEM, &step);
386 printf("Can not get volume step\n");
391 //set system volume to max value
392 mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, max);
396 int mm_sound_volume_get_step(volume_type_t type, int *step);
400 * This function is to add volume changed callback.
402 * @param type [in] volume type to set change callback function
403 * @param func [in] callback function pointer
404 * @param user_data [in] user data passing to callback function
406 * @return This function returns MM_ERROR_NONE on success, or negative value
408 * @remark Only one callback function per volume type will be registered.
409 * if you want to change callback function for certain volume type,
410 * remove callback first via mm_sound_volume_remove_callback().
411 * @see volume_type_t volume_callback_fn
412 * @pre There should be not be pre-registered callback fuction to given volume type.
413 * @post Callback function will be registered to given volume type
416 volume_type_t g_vol_type = VOLUME_TYPE_MEDIA;
418 void _volume_callback(void *data)
420 unsigned int value = 0;
422 volume_type_t *type = (volume_type_t*)data;
424 result = mm_sound_volume_get_value(*type, &value);
425 if(result == MM_ERROR_NONE)
427 printf("Current volume value is %d\n", value);
431 printf("Can not get volume\n");
439 ret = mm_sound_volume_add_callback(g_vol_type, _volume_callback, (void*)&g_vol_type);
440 if ( MM_ERROR_NONE != ret)
442 printf("Can not add callback\n");
446 printf("Add callback success\n");
454 int mm_sound_volume_add_callback(volume_type_t type, volume_callback_fn func, void* user_data);
455 int mm_sound_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data);
459 * This function is to remove volume changed callback.
461 * @param type [in] volume type to set change callback function
463 * @return This function returns MM_ERROR_NONE on success, or negative value
466 * @pre Callback function should be registered previously for given volume type.
467 * @post Callback function will not be called anymore.
471 void _volume_callback(void *data)
473 printf("Callback function\n");
476 int volume_callback()
479 int vol_type = VOLUME_TYPE_MEDIA;
481 mm_sound_volume_add_callback(vol_type, _volume_callback, NULL);
483 ret = mm_sound_volume_remove_callback(vol_type);
484 if ( MM_ERROR_NONE == ret)
486 printf("Remove callback success\n");
490 printf("Remove callback failed\n");
498 int mm_sound_volume_remove_callback(volume_type_t type);
501 * This function is to remove volume change callback.
503 * @return This function returns MM_ERROR_NONE on success, or negative value
506 int mm_sound_remove_volume_changed_callback(void);
509 * This function is to add muteall changed callback.
511 * @param func [in] callback function pointer
512 * @param user_data [in] user data passing to callback function
514 * @return This function returns MM_ERROR_NONE on success, or negative value
516 * @see muteall_callback_fn
518 void _muteall_callback(void *data)
522 mm_sound_get_muteall(&muteall);
523 g_print("Muteall Callback Runs :::: muteall value = %d\n", muteall);
526 int muteall_callback()
530 ret = mm_sound_muteall_add_callback( _muteall_callback);
532 if ( MM_ERROR_NONE != ret)
534 printf("Can not add callback\n");
538 printf("Add callback success\n");
546 int mm_sound_muteall_add_callback(muteall_callback_fn func);
550 * This function is to remove muteall changed callback.
552 * @param func [in] callback function pointer
554 * @return This function returns MM_ERROR_NONE on success, or negative value
557 * @post Callback function will not be called anymore.
558 * @see muteall_callback_fn
560 void _muteall_callback(void *data)
562 printf("Callback function\n");
565 int muteall_callback()
569 mm_sound_muteall_add_callback( _muteall_callback);
571 ret = mm_sound_muteall_remove_callback(_muteall_callback);
572 if ( MM_ERROR_NONE == ret)
574 printf("Remove callback success\n");
578 printf("Remove callback failed\n");
586 int mm_sound_muteall_remove_callback(muteall_callback_fn func);
589 * This function is to set volume level of certain volume type.
591 * @param type [in] volume type to set value.
592 * @param value [in] volume value.
594 * @return This function returns MM_ERROR_NONE on success, or negative value
596 * @remark value should be 0 ~ mm_sound_volume_get_step() -1
597 * @see mm_sound_volume_get_step, mm_sound_volume_get_value volume_type_t
599 * @post Volume value will be changed to given value for given volume type.
606 ret = mm_sound_volume_get_step(VOLUME_TYPE_SYSTEM, &step);
609 printf("Can not get volume step\n");
614 //set system volume to max value
615 ret = mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, max);
618 printf("Can not set volume value\n");
623 int mm_sound_volume_set_value(volume_type_t type, const unsigned int value);
631 * This function is to set all volume type to mute or unmute.
633 * @param muteall [in] the switch to control mute or unmute.
635 * @return This function returns MM_ERROR_NONE on success, or negative value
641 int mm_sound_mute_all(int muteall);
646 * This function is to get volume level of certain volume type.
648 * @param type [in] volume type to get value.
649 * @param value [out] volume value.
651 * @return This function returns MM_ERROR_NONE on success, or negative value
656 * @see volume_type_t mm_sound_volume_set_value
662 ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
665 printf("Can not get volume\n");
669 printf("System type volume is %d\n", value);
672 * @see mm_sound_volume_set_value
674 int mm_sound_volume_get_value(volume_type_t type, unsigned int *value);
679 * This function is to set primary volume type.
681 * @param type [in] volume type to set as primary volume type.
683 * @return This function returns MM_ERROR_NONE on success, or negative value
685 * @remark Application should use this function during foreground.
686 * Application should clear primary volume type by mm_sound_volume_primary_type_clear() when it goes background.
688 * @post Volume app. will be update given volume type when H/W volume control key pressed.
689 * @see mm_sound_volume_primary_type_clear volume_type_t
692 static int _resume(void *data)
696 ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_MEDIA);
699 printf("Can not set primary volume type\n");
704 static int _pause(void* data)
708 ret = mm_sound_volume_primary_type_clear();
711 printf("Can not clear primary volume type\n");
719 struct appcore_ops ops = {
721 .terminate = _terminate,
727 return appcore_efl_main(PACKAGE, ..., &ops);
731 int mm_sound_volume_primary_type_set(volume_type_t type);
736 * This function is to clear primary volume type.
739 * @return This function returns MM_ERROR_NONE on success, or negative value
741 * @remark mm_sound_volume_primary_type_set() and mm_sound_volume_primary_type_clear() should be used as pair
742 * @see mm_sound_volume_primary_type_set
743 * @pre primary volume should be set at same process.
744 * @post primary volume will be cleared.
747 static int _resume(void *data)
751 ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_MEDIA);
754 printf("Can not set primary volume type\n");
759 static int _pause(void* data)
763 ret = mm_sound_volume_primary_type_clear();
766 printf("Can not clear primary volume type\n");
774 struct appcore_ops ops = {
776 .terminate = _terminate,
782 return appcore_efl_main(PACKAGE, ..., &ops);
786 int mm_sound_volume_primary_type_clear(void);
791 * This function is to get current playing volume type
793 * @param type [out] current playing volume type
795 * @return This function returns MM_ERROR_NONE on success,
796 * or MM_ERROR_SOUND_VOLUME_NO_INSTANCE when there is no existing playing instance,
797 * or MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY when only capture audio instances are exist.
798 * or negative value with error code for other errors.
802 * @see mm_sound_volume_get_value, mm_sound_volume_set_value
806 volume_type_t type = 0;
808 ret = mm_sound_volume_get_current_playing_type(&type);
812 printf("Current playing is %d\n", type);
814 case MM_ERROR_SOUND_VOLUME_NO_INSTANCE:
815 printf("No sound instance\n");
817 case MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY:
818 printf("Only sound capture instances are exist\n");
827 int mm_sound_volume_get_current_playing_type(volume_type_t *type);
829 int mm_sound_volume_set_balance (float balance);
831 int mm_sound_volume_get_balance (float *balance);
833 int mm_sound_set_muteall (int muteall);
835 int mm_sound_get_muteall (int *muteall);
837 int mm_sound_set_stereo_to_mono (int ismono);
839 int mm_sound_get_stereo_to_mono (int *ismono);
841 int mm_sound_set_call_mute(volume_type_t type, int mute);
843 int mm_sound_get_call_mute(volume_type_t type, int *mute);
845 int mm_sound_set_factory_loopback_test(int loopback);
847 int mm_sound_get_factory_loopback_test(int *loopback);
850 MM_SOUND_FACTORY_MIC_TEST_STATUS_OFF = 0,
851 MM_SOUND_FACTORY_MIC_TEST_STATUS_MAIN_MIC,
852 MM_SOUND_FACTORY_MIC_TEST_STATUS_SUB_MIC,
853 MM_SOUND_FACTORY_MIC_TEST_STATUS_NUM,
854 } mm_sound_factory_mic_test_status_t;/* device in for factory mic test */
856 int mm_sound_set_factory_mic_test(mm_sound_factory_mic_test_status_t mic_test);
858 int mm_sound_get_factory_mic_test(mm_sound_factory_mic_test_status_t *mic_test);
862 MMSOUND_DHA_SOFT_SOUND,
863 MMSOUND_DHA_CLEAR_SOUND,
864 MMSOUND_DHA_PERSNOL_LEFT,
865 MMSOUND_DHA_PERSNOL_RIGHT,
874 typedef void* MMSoundPcmHandle_t; /**< MMsound PCM handle type */
877 * Enumerations of Format used in MMSoundPcm operation.
880 MMSOUND_PCM_U8 = 0x70, /**< unsigned 8bit audio */
881 MMSOUND_PCM_S16_LE, /**< signed 16bit audio */
882 } MMSoundPcmFormat_t;
885 * Enumerations of Channel count used in MMSoundPcm operation.
888 MMSOUND_PCM_MONO = 0x80, /**< Mono channel */
889 MMSOUND_PCM_STEREO, /**< Stereo channel */
890 }MMSoundPcmChannel_t;
893 * Get audio stream latency value.
895 * @param handle [in] handle to get latency
896 * @param latency [out] Stream latency value(millisecond).
898 * @return This function returns MM_ERROR_NONE on success, or negative value
903 int mm_sound_pcm_get_latency(MMSoundPcmHandle_t handle, int *latency);
906 * Get started status of pcm stream.
908 * @param handle [in] handle to check pcm start
909 * @param is_started [out] retrieve started status of pcm stream.
911 * @return This function returns MM_ERROR_NONE on success, or negative value
916 int mm_sound_pcm_is_started(MMSoundPcmHandle_t handle, bool *is_started);
918 int mm_sound_pcm_play_open_no_session(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config);
921 * This function is to create handle for PCM playback.
923 * @param handle [out] handle to play pcm data
924 * @param rate [in] sample rate (8000Hz ~ 44100Hz)
925 * @param channel [in] number of channels (mono or stereo)
926 * @param format [in] S8 or S16LE
927 * @param volume config [in] Volume type & volume gain
929 * @return This function returns suggested buffer size (in bytes) on success, or negative value
931 * @remark use mm_sound_volume_set_value() function to change volume
932 * @see mm_sound_pcm_play_write, mm_sound_pcm_play_close, mm_sound_volume_set_value, MMSoundPcmFormat_t, MMSoundPcmChannel_t volume_type_t
934 * @post PCM play handle will be created.
937 #include <mm_sound.h>
941 int main(int argc, char* argv[])
948 MMSoundPcmHandle_t handle;
949 char *filename = NULL;
953 printf("Usage) %s filename\n", argv[0]);
958 fp = fopen(filename,"r");
961 printf("Can not open file %s\n", filename);
965 size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
968 printf("Can not open playback handle\n");
972 buffer = alloca(size);
973 while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
975 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
978 printf("write fail\n");
981 memset(buffer, '\0', sizeof(buffer));
985 mm_sound_pcm_play_close(handle);
990 int mm_sound_pcm_play_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config);
993 * This function start pcm playback
995 * @param handle [in] handle to start playback
997 * @return This function returns MM_ERROR_NONE on success, or negative value
1001 * @pre PCM playback handle should be allocated.
1002 * @post PCM playback is ready to write.
1004 int mm_sound_pcm_play_start(MMSoundPcmHandle_t handle);
1007 * This function stop pcm playback
1009 * @param handle [in] handle to stop playback
1011 * @return This function returns MM_ERROR_NONE on success, or negative value
1015 * @pre PCM playback handle should be allocated.
1016 * @post PCM playback data will not be buffered.
1018 int mm_sound_pcm_play_stop(MMSoundPcmHandle_t handle);
1021 * This function is to play PCM memory buffer.
1023 * @param handle [in] handle to play pcm data
1024 * @param ptr [in] pcm buffer address
1025 * @param length_byte [in] size of pcm buffer (in bytes)
1027 * @return This function returns written data size on success, or negative value
1029 * @remark Make pcm buffer size with returned value of mm_sound_pcm_play_open()
1030 * @see mm_sound_pcm_play_open, mm_sound_pcm_play_close
1031 * @pre PCM play handle should be created.
1032 * @post Sound will be generated with given PCM buffer data.
1035 #include <mm_sound.h>
1039 int main(int argc, char* argv[])
1042 char *buffer = NULL;
1046 MMSoundPcmHandle_t handle;
1047 char *filename = NULL;
1051 printf("Usage) %s filename\n", argv[0]);
1056 fp = fopen(filename,"r");
1059 printf("Can not open file %s\n", filename);
1063 size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
1066 printf("Can not open playback handle\n");
1070 buffer = alloca(size);
1071 while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
1073 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
1076 printf("write fail\n");
1079 memset(buffer, '\0', sizeof(buffer));
1083 mm_sound_pcm_play_close(handle);
1088 int mm_sound_pcm_play_write(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte);
1093 * This function is to close PCM memory playback handle
1095 * @param handle [in] handle to play pcm data
1097 * @return This function returns MM_ERROR_NONE on success, or negative value
1100 * @see mm_sound_pcm_play_open, mm_sound_pcm_play_write
1101 * @pre PCM play handle should be created
1102 * @post PCM play handle will be terminated.
1105 #include <mm_sound.h>
1109 int main(int argc, char* argv[])
1112 char *buffer = NULL;
1116 MMSoundPcmHandle_t handle;
1117 char *filename = NULL;
1121 printf("Usage) %s filename\n", argv[0]);
1126 fp = fopen(filename,"r");
1129 printf("Can not open file %s\n", filename);
1133 size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
1136 printf("Can not open playback handle\n");
1140 buffer = alloca(size);
1141 while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
1143 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
1146 printf("write fail\n");
1149 memset(buffer, '\0', sizeof(buffer));
1153 mm_sound_pcm_play_close(handle);
1158 int mm_sound_pcm_play_close(MMSoundPcmHandle_t handle);
1161 * This function is to ignore session for playback
1163 * @param handle [in] handle to play pcm data
1165 * @return This function returns MM_ERROR_NONE on success, or negative value
1167 * @remark This function only works for not started pcm handle and can't be reversed.
1169 * @pre PCM play handle should be created and not started.
1170 * @post PCM play session will be set to mix.
1172 int mm_sound_pcm_play_ignore_session(MMSoundPcmHandle_t *handle);
1175 * This function is to create handle for PCM capture.
1177 * @param handle [out] handle to capture pcm data
1178 * @param rate [in] sample rate (8000Hz ~ 44100Hz)
1179 * @param channel [in] number of channels (mono or stereo)
1180 * @param format [in] S8 or S16LE
1182 * @return This function returns suggested buffer size (in bytes) on success, or negative value
1184 * @remark only mono channel is valid for now.
1185 * @see mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
1187 * @post PCM capture handle will be allocated.
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_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format);
1250 * This function is to create handle for PCM capture of source_type.
1252 * @param handle [out] handle to capture pcm data
1253 * @param rate [in] sample rate (8000Hz ~ 44100Hz)
1254 * @param channel [in] number of channels (mono or stereo)
1255 * @param format [in] S8 or S16LE
1256 * @param source_type [in] The source_type,mm_sound_source_type_e
1258 * @return This function returns suggested buffer size (in bytes) on success, or negative value
1260 * @remark only mono channel is valid for now.
1261 * @see mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
1263 * @post PCM capture handle will be allocated.
1266 #include <mm_sound.h>
1270 int main(int argc, char* argv[])
1273 char *buffer = NULL;
1277 MMSoundPcmHandle_t handle;
1278 char *filename = NULL;
1282 printf("Usage) %s filename\n", argv[0]);
1287 fp = fopen(filename,"w");
1290 printf("Can not open file %s\n", filename);
1294 size = mm_sound_pcm_capture_open_ex(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE,1);
1297 printf("Can not open capture handle\n");
1301 buffer = alloca(size);
1304 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1307 printf("read fail\n");
1310 fwrite(buffer, ret, sizeof(char), fp);
1317 mm_sound_pcm_capture_close(handle);
1323 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);
1326 * This function start pcm capture
1328 * @param handle [in] handle to start capture
1330 * @return This function returns read data size on success, or negative value
1334 * @pre PCM capture handle should be allocated.
1335 * @post PCM capture data will be buffered.
1337 int mm_sound_pcm_capture_start(MMSoundPcmHandle_t handle);
1340 * This function stop pcm capture
1342 * @param handle [in] handle to stop capture
1344 * @return This function returns read data size on success, or negative value
1348 * @pre PCM capture handle should be allocated.
1349 * @post PCM capture data will not be buffered.
1351 int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle);
1354 * This function captures PCM to memory buffer. (Samsung extension)
1356 * @param handle [in] handle to play pcm data
1357 * @param buffer [in] pcm buffer address
1358 * @param length [in] size of pcm buffer (in bytes)
1360 * @return This function returns read data size on success, or negative value
1362 * @remark Make pcm buffer size with returned value of mm_sound_pcm_capture_open()
1363 * @see mm_sound_pcm_capture_open, mm_sound_pcm_capture_close
1364 * @pre PCM capture handle should be allcated.
1365 * @post PCM data will be filled to given memory pointer.
1368 #include <mm_sound.h>
1372 int main(int argc, char* argv[])
1375 char *buffer = NULL;
1379 MMSoundPcmHandle_t handle;
1380 char *filename = NULL;
1384 printf("Usage) %s filename\n", argv[0]);
1389 fp = fopen(filename,"w");
1392 printf("Can not open file %s\n", filename);
1396 size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1399 printf("Can not open capture handle\n");
1403 buffer = alloca(size);
1406 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1409 printf("read fail\n");
1412 fwrite(buffer, ret, sizeof(char), fp);
1419 mm_sound_pcm_capture_close(handle);
1425 int mm_sound_pcm_capture_read(MMSoundPcmHandle_t handle, void *buffer, const unsigned int length );
1428 * This function captures PCM memory to memory buffer (Samsung extension)
1430 * @param handle [in] handle to capture pcm data
1432 * @return This function returns MM_ERROR_NONE on success, or negative value
1435 * @see mm_sound_pcm_capture_open, mm_sound_pcm_capture_read
1436 * @pre PCM capture handle should be opend.
1437 * @post PCM capture handle will be freed.
1440 #include <mm_sound.h>
1444 int main(int argc, char* argv[])
1447 char *buffer = NULL;
1451 MMSoundPcmHandle_t handle;
1452 char *filename = NULL;
1456 printf("Usage) %s filename\n", argv[0]);
1461 fp = fopen(filename,"w");
1464 printf("Can not open file %s\n", filename);
1468 size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1471 printf("Can not open capture handle\n");
1475 buffer = alloca(size);
1478 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1481 printf("read fail\n");
1484 fwrite(buffer, ret, sizeof(char), fp);
1491 mm_sound_pcm_capture_close(handle);
1497 int mm_sound_pcm_capture_close(MMSoundPcmHandle_t handle);
1500 * This function is to ignore session for capture
1502 * @param handle [in] handle to capture pcm data
1504 * @return This function returns MM_ERROR_NONE on success, or negative value
1506 * @remark This function only works for not started pcm handle and can't be reversed.
1508 * @pre PCM capture handle should be created and not started.
1509 * @post PCM capture session will be set to mix.
1511 int mm_sound_pcm_capture_ignore_session(MMSoundPcmHandle_t *handle);
1514 * This function sets callback function for receiving messages from pcm API.
1516 * @param handle [in] Handle of pcm.
1517 * @param callback [in] Message callback function.
1518 * @param user_param [in] User parameter which is passed to callback function.
1520 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
1521 * @see MMMessageCallback
1525 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1529 case MM_MESSAGE_SOUND_PCM_CAPTURE_RESTRICTED:
1533 case MM_MESSAGE_SOUND_PCM_INTERRUPTED:
1543 mm_sound_pcm_set_message_callback(pcmHandle, msg_callback, (void *)pcmHandle);
1546 int mm_sound_pcm_set_message_callback (MMSoundPcmHandle_t handle, MMMessageCallback callback, void *user_param);
1549 * Terminate callback function type.
1551 * @param data [in] Argument passed when callback was set
1552 * @param id [in] handle which has completed playing
1554 * @return No return value
1555 * @remark It is not allowed to call MMSound API recursively or do time-consuming
1556 * task in this callback because this callback is called synchronously.
1557 * @see mm_sound_play_sound
1559 typedef void (*mm_sound_stop_callback_func) (void *data, int id);
1566 * This function is to play system sound.
1568 * @param filename [in] Sound filename to play
1569 * @param volume config [in] Volume type & volume gain
1570 * @param callback [in] Callback function pointer when playing is terminated.
1571 * @param data [in] Pointer to user data when callback is called.
1572 * @param handle [out] Handle of sound play.
1574 * @return This function returns MM_ERROR_NONE on success, or negative value
1576 * @remark When the stop callback is set, it will be called when system sound is
1577 * terminated. If mm_sound_stop_sound() is called apparently before
1578 * system sound is terminated, stop_callback will not be called.
1579 * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1581 * @post Sound will be generated with given filename.
1585 void _stop_callback(void* data)
1587 printf("Stop callback\n");
1593 char filename[] ="/opt/media/Sound/testfile.wav";
1594 volume_type_t volume = VOLUME_TYPE_SYSTEM;
1598 ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1601 printf("play file failed\n");
1605 printf("play file success\n");
1611 printf("play stopped\n");
1616 int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1618 int mm_sound_play_sound_without_session(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1620 int mm_sound_play_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1623 * This function is to play system sound. And other audio stream will be mute during playing time
1625 * @param filename [in] Sound filename to play
1626 * @param volume config [in] Volume type & volume gain
1627 * @param callback [in] Callback function pointer when playing is terminated.
1628 * @param data [in] Pointer to user data when callback is called.
1629 * @param handle [out] Handle of sound play.
1631 * @return This function returns MM_ERROR_NONE on success, or negative value
1633 * @remark This function is almost same with mm_sound_play_sound,
1634 * but this make other audio playback stream to mute during playing time.
1635 * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1637 * @post Sound will be generated with given filename.
1641 void _stop_callback(void* data)
1643 printf("Stop callback\n");
1649 char filename[] ="/opt/media/Sound/testfile.wav";
1650 volume_type_t volume = VOLUME_TYPE_SYSTEM;
1654 ret = mm_sound_play_loud_solo_sound(filename, volume, _stop_callback, NULL, &handle);
1657 printf("play file failed\n");
1661 printf("play file success\n");
1667 printf("play stopped\n");
1672 int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1674 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);
1677 * This function is to stop playing system sound.
1679 * @param handle [in] Handle of mm_sound_play_sound
1681 * @return This function returns MM_ERROR_NONE on success, or negative value
1684 * @remark When system sound is terminated with this function call, it does not
1685 * call stop callback which was set when start playing system sound.
1686 * @see mm_sound_play_sound
1687 * @pre An sound play handle should be valid.
1688 * @post Playing sound file will be stopped.
1692 void _stop_callback(void* data)
1694 printf("Stop callback\n");
1698 int play_file_one_second()
1700 char filename[] ="/opt/media/Sound/testfile.wav";
1701 volume_type_t volume = VOLUME_TYPE_SYSTEM;
1705 ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1708 printf("play file failed\n");
1712 printf("play file success\n");
1715 sleep(1); //wait 1 second
1717 ret = mm_sound_stop_sound(handle);
1720 printf("stop failed\n");
1724 printf("play stopped\n");
1730 int mm_sound_stop_sound(int handle);
1734 * Enumerations for TONE
1738 MM_SOUND_TONE_DTMF_0 = 0, /**< Predefined DTMF 0 */
1739 MM_SOUND_TONE_DTMF_1, /**< Predefined DTMF 1 */
1740 MM_SOUND_TONE_DTMF_2, /**< Predefined DTMF 2 */
1741 MM_SOUND_TONE_DTMF_3, /**< Predefined DTMF 3 */
1742 MM_SOUND_TONE_DTMF_4, /**< Predefined DTMF 4 */
1743 MM_SOUND_TONE_DTMF_5, /**< Predefined DTMF 5 */
1744 MM_SOUND_TONE_DTMF_6, /**< Predefined DTMF 6 */
1745 MM_SOUND_TONE_DTMF_7, /**< Predefined DTMF 7 */
1746 MM_SOUND_TONE_DTMF_8, /**< Predefined DTMF 8 */
1747 MM_SOUND_TONE_DTMF_9, /**< Predefined DTMF 9 */
1748 MM_SOUND_TONE_DTMF_S, /**< Predefined DTMF Star - Asterisk (*) */
1749 MM_SOUND_TONE_DTMF_P, /**< Predefined DTMF sharP (#) */
1750 MM_SOUND_TONE_DTMF_A, /**< Predefined DTMF A (A) */
1751 MM_SOUND_TONE_DTMF_B, /**< Predefined DTMF B (B) */
1752 MM_SOUND_TONE_DTMF_C, /**< Predefined DTMF C (C) */
1753 MM_SOUND_TONE_DTMF_D, /**< Predefined DTMF D (D) */
1755 /**< Pre-defined TONE */
1756 MM_SOUND_TONE_SUP_DIAL, /**Call supervisory tone, Dial tone: CEPT: 425Hz, continuous */
1757 MM_SOUND_TONE_ANSI_DIAL, /**Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous */
1758 MM_SOUND_TONE_JAPAN_DIAL, /**Call supervisory tone, Dial tone: JAPAN: 400Hz, continuous*/
1759 MM_SOUND_TONE_SUP_BUSY, /**Call supervisory tone, Busy: CEPT: 425Hz, 500ms ON, 500ms OFF... */
1760 MM_SOUND_TONE_ANSI_BUSY, /**Call supervisory tone, Busy: ANSI (IS-95): 480Hz+620Hz, 500ms ON, 500ms OFF... */
1761 MM_SOUND_TONE_JAPAN_BUSY, /**Call supervisory tone, Busy: JAPAN: 400Hz, 500ms ON, 500ms OFF...*/
1762 MM_SOUND_TONE_SUP_CONGESTION, /**Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF */
1763 MM_SOUND_TONE_ANSI_CONGESTION, /**Call supervisory tone, Congestion: ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF... */
1764 MM_SOUND_TONE_SUP_RADIO_ACK, /**Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON */
1765 MM_SOUND_TONE_JAPAN_RADIO_ACK, /**Call supervisory tone, Radio path acknowlegment : JAPAN: 400Hz, 1s ON, 2s OFF...*/
1766 MM_SOUND_TONE_SUP_RADIO_NOTAVAIL, /**Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts */
1767 MM_SOUND_TONE_SUP_ERROR, /**Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF... */
1768 MM_SOUND_TONE_SUP_CALL_WAITING, /**Call supervisory tone, Call Waiting: CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF... */
1769 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 ...) */
1770 MM_SOUND_TONE_SUP_RINGTONE, /**Call supervisory tone, Ring Tone: CEPT, JAPAN: 425Hz, 1s ON, 4s OFF... */
1771 MM_SOUND_TONE_ANSI_RINGTONE, /**Call supervisory tone, Ring Tone: ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF... */
1772 MM_SOUND_TONE_PROP_BEEP, /**General beep: 400Hz+1200Hz, 35ms ON */
1773 MM_SOUND_TONE_PROP_ACK, /**Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts */
1774 MM_SOUND_TONE_PROP_NACK, /**Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON */
1775 MM_SOUND_TONE_PROP_PROMPT, /**Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON */
1776 MM_SOUND_TONE_PROP_BEEP2, /**Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON */
1777 MM_SOUND_TONE_SUP_INTERCEPT, /**Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms */
1778 MM_SOUND_TONE_SUP_INTERCEPT_ABBREV, /**Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds */
1779 MM_SOUND_TONE_SUP_CONGESTION_ABBREV, /**Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds */
1780 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 */
1781 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). */
1782 MM_SOUND_TONE_CDMA_DIAL_TONE_LITE, /**425Hz continuous */
1783 MM_SOUND_TONE_CDMA_NETWORK_USA_RINGBACK, /**CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...*/
1784 MM_SOUND_TONE_CDMA_INTERCEPT, /**CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...*/
1785 MM_SOUND_TONE_CDMA_ABBR_INTERCEPT, /**CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON */
1786 MM_SOUND_TONE_CDMA_REORDER, /**CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF... */
1787 MM_SOUND_TONE_CDMA_ABBR_REORDER, /**CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times */
1788 MM_SOUND_TONE_CDMA_NETWORK_BUSY, /**CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous */
1789 MM_SOUND_TONE_CDMA_CONFIRM, /**CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times */
1790 MM_SOUND_TONE_CDMA_ANSWER, /**CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF */
1791 MM_SOUND_TONE_CDMA_NETWORK_CALLWAITING, /**CDMA Network Callwaiting tone: 440Hz 300ms ON */
1792 MM_SOUND_TONE_CDMA_PIP, /**CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times */
1793 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 */
1794 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.*/
1795 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 */
1796 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT3, /**SDN Call sign PAT3 tone: silent tone */
1797 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING, /**ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON */
1798 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT5, /**ISDN Pat5 tone: silent tone */
1799 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT6, /**ISDN Pat6 tone: silent tone */
1800 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT7, /**ISDN Pat7 tone: silent tone */
1801 MM_SOUND_TONE_CDMA_HIGH_L, /**TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1802 MM_SOUND_TONE_CDMA_MED_L, /**TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1803 MM_SOUND_TONE_CDMA_LOW_L, /**TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, 4000ms OFF, Repeat .... */
1804 MM_SOUND_TONE_CDMA_HIGH_SS, /**CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1805 MM_SOUND_TONE_CDMA_MED_SS, /**CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1806 MM_SOUND_TONE_CDMA_LOW_SS, /**CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1807 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 ... */
1808 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 ... */
1809 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 ... */
1810 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 .... */
1811 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 .... */
1812 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 .... */
1813 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 */
1814 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 */
1815 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 */
1816 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.... */
1817 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.... */
1818 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....*/
1819 MM_SOUND_TONE_CDMA_HIGH_PBX_L, /**CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1820 MM_SOUND_TONE_CDMA_MED_PBX_L, /**CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1821 MM_SOUND_TONE_CDMA_LOW_PBX_L, /**CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1822 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.... */
1823 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.... */
1824 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.... */
1825 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.... */
1826 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.... */
1827 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.... */
1828 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.... */
1829 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.... */
1830 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.... */
1831 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... */
1832 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... */
1833 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... */
1834 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 */
1835 MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE, /**CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON */
1836 MM_SOUND_TONE_CDMA_ONE_MIN_BEEP, /**CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON */
1837 MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE, /**CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON */
1838 MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE, /**CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON */
1839 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*/
1840 MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK, /**CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times 4990ms OFF, REPEAT... */
1841 MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD, /**CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times */
1842 MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE, /**CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms */
1843 MM_SOUND_TONE_CDMA_CALLDROP_LITE, /**CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms */
1844 MM_SOUND_TONE_CDMA_NETWORK_BUSY_ONE_SHOT, /**CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. */
1845 MM_SOUND_TONE_CDMA_ABBR_ALERT, /**CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON */
1846 MM_SOUND_TONE_CDMA_SIGNAL_OFF, /**CDMA_SIGNAL_OFF - silent tone */
1847 MM_SOUND_TONE_LOW_FRE, /**100Hz continuous */
1848 MM_SOUND_TONE_MED_FRE, /**200Hz continuous */
1849 MM_SOUND_TONE_HIGH_FRE, /**300Hz continuous */
1853 typedef unsigned long sound_time_msec_t; /**< millisecond unit */
1856 * This function is to play tone sound.
1858 * @param num [in] predefined tone type (MMSoundTone_t)
1859 * volume config [in] volume type & volume gain
1860 * volume [in] volume ratio (0.0 ~1.0)
1861 * duration [in] millisecond (-1 for infinite)
1862 * handle [in] Handle of mm_sound_play_tone
1863 * enable_session [in] set enable/unable session
1865 * @return This function returns MM_ERROR_NONE on success, or negative value
1868 * @remark It doesn't provide stop
1869 * @see volume_type_t volume_gain_t MMSoundTone_t
1871 * @post TONE sound will be played.
1876 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
1879 printf("play tone failed\n");
1883 printf("play tone success\n");
1887 int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session);
1890 * This function is to play tone sound.
1892 * @param num [in] predefined tone type (MMSoundTone_t)
1893 * volume config [in] volume type & volume gain
1894 * volume [in] volume ratio (0.0 ~1.0)
1895 * duration [in] millisecond (-1 for infinite)
1896 * handle [in] Handle of mm_sound_play_tone
1898 * @return This function returns MM_ERROR_NONE on success, or negative value
1901 * @remark It doesn't provide stop
1902 * @see volume_type_t volume_gain_t MMSoundTone_t
1904 * @post TONE sound will be played.
1909 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
1912 printf("play tone failed\n");
1916 printf("play tone success\n");
1920 int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle);
1923 * Enumerations of System audio route policy
1926 SYSTEM_AUDIO_ROUTE_POLICY_DEFAULT, /**< Play via a2dp headset if connected. or play via headset if connected. or play via speaker.
1927 And capture via 4pole headset-mic if connected. or capture via mic */
1928 SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP, /**< Play via headset if connected. or play via speaker
1929 And capture via 4pole headset-mic if connected. or capture via mic */
1930 SYSTEM_AUDIO_ROUTE_POLICY_HANDSET_ONLY, /**< Play via speaker. and capture via mic */
1931 SYSTEM_AUDIO_ROUTE_POLICY_MAX
1932 }system_audio_route_t;
1935 SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_NONE, /**< Abnormal case */
1936 SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_HANDSET, /**< Speaker or Headset or Earpiece */
1937 SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_BLUETOOTH, /**< Bluetooth */
1938 SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_EARPHONE, /**< Earphone */
1939 SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_MAX,
1940 }system_audio_route_device_t;
1943 SYSTEM_AUDIO_CAPTURE_NONE, /**< Capture device is not in use */
1944 SYSTEM_AUDIO_CAPTURE_ACTIVE, /**< Capture device is in use */
1945 SYSTEM_AUDIO_CAPTURE_MAX,
1946 }system_audio_capture_status_t;
1950 * This function set system route policy.
1952 * @param route [in] audio route type
1954 * @return This function returns MM_ERROR_NONE on success, or negative value
1956 * @remark If bluetooth has disconnected during SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP policy,
1957 * The audio route policy will be changed to SYSTEM_AUDIO_ROUTE_POLICY_DEFAULT.
1958 * @see mm_sound_route_get_system_policy system_audio_route_t mm_sound_route_is_a2dp_on
1960 * @post Audio routing policy will be changed with given type. And route change callback function will be called if registered.
1964 void _stop_callback()
1969 int play_file_via_speaker()
1972 system_audio_route_t route, original_route;
1974 //get backup current policy
1975 ret = mm_sound_route_get_system_policy(&original_route);
1978 printf("Can not get system audio route policy\n");
1982 //set route policy to ignore a2dp
1983 route = SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP;
1984 ret = mm_sound_route_set_system_policy(route);
1987 printf("Ca not set route policy\n");
1993 ret = mm_sound_play_sound("/opt/media/Sound/alert.wav", VOLUME_TYPE_SYSTEM, NULL, NULL, &handle);
1996 printf("Can not play wav file\n");
2004 //restore original policy
2005 mm_sound_route_set_system_policy(original_route);
2013 int mm_sound_route_set_system_policy (system_audio_route_t route);
2016 * This function get sysytem route policy.
2018 * @param route [out] audio route type
2020 * @return This function returns MM_ERROR_NONE on success, or negative value
2023 * @see mm_sound_route_set_system_policy system_audio_route_t mm_sound_route_is_a2dp_on
2029 void _stop_callback()
2034 int play_file_via_speaker()
2037 system_audio_route_t route, original_route;
2039 //get backup current policy
2040 ret = mm_sound_route_get_system_policy(&original_route);
2043 printf("Can not get system audio route policy\n");
2047 //set route policy to ignore a2dp
2048 route = SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP;
2049 ret = mm_sound_route_set_system_policy(route);
2052 printf("Can not set route policy\n");
2058 ret = mm_sound_play_sound("/opt/media/Sound/alert.wav", VOLUME_TYPE_SYSTEM, NULL, NULL, &handle);
2061 printf("Can not play wav file\n");
2069 //restore original policy
2070 mm_sound_route_set_system_policy(original_route);
2078 int mm_sound_route_get_system_policy (system_audio_route_t *route);
2083 * This function get a2dp activation information.
2085 * @param connected [out] is Bluetooth A2DP connected (1:connected, 0:not connected)
2086 * bt_name [out] Bluetooth A2DP connected device name (allocated by internal when connected=1 otherwise set to null)
2089 * @return This function returns MM_ERROR_NONE on success, or negative value
2091 * @remark This function allocation memory to given bt_name pointer internally.
2092 * So application should free given memory pointer later after use.
2093 * bt_name will be null if there's no a2dp device is connected (connected is 0)
2094 * @see mm_sound_route_set_system_policy mm_sound_route_get_system_policy
2096 * @post memory buffer will be allocated and fill with bluetooth device name.
2101 char* bt_name = NULL;
2102 ret = mm_sound_route_get_a2dp_status (&connected, &bt_name);
2104 if (ret == MM_ERROR_NONE) {
2105 g_print ("### Is Bluetooth A2DP On Success : connected=[%d] name=[%s]\n", connected, bt_name);
2109 g_print ("### Is Bluetooth A2DP On Error : errno [%d]\n", ret);
2113 int mm_sound_route_get_a2dp_status (bool* connected, char** bt_name);
2117 * This function get current playing device.
2119 * @param dev [out] current playing device information
2121 * @return This function returns MM_ERROR_NONE on success, or negative value
2123 * @remark if there is no running instance in system,
2124 * output parameter dev can be SYSTEM_AUDIO_ROUTE_PLAYING_DEVICE_NONE.
2126 * @see system_audio_route_device_t
2132 system_audio_route_device_t dev;
2134 ret = mm_sound_route_get_playing_device (&dev);
2135 if(ret == MM_ERROR_NONE)
2139 case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_HANDSET:
2140 printf("Handset is playing\n");
2142 case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_BLUETOOTH:
2143 printf("Bluetooth is playing\n");
2145 case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_NONE:
2147 printf("Unexptected\n");
2153 printf ("Can not get current running device\n");
2158 int mm_sound_route_get_playing_device(system_audio_route_device_t *dev);
2161 * Audio route policy change callback function type.
2163 * @param user_data [in] Argument passed when callback has called
2164 * @param policy [in] changed policy type
2166 * @return No return value
2168 * @see mm_sound_volume_add_callback mm_sound_volume_remove_callback
2170 typedef void (*audio_route_policy_changed_callback_fn)(void* user_data, system_audio_route_t policy);
2173 * This function set system audio policy changed callback function.
2175 * @param func [in] callback function pointer
2176 * @param user_data [in] user data will be called with func
2178 * @return This function returns MM_ERROR_NONE on success, or negative value
2181 * @see mm_sound_route_remove_change_callback mm_sound_route_set_system_policy mm_sound_route_get_system_policy system_audio_route_t
2186 void audio_route_policy_changed_callback(void* data, system_audio_route_t policy)
2188 int value = (int) data;
2189 system_audio_route_t lv_policy;
2190 char *str_route[SYSTEM_AUDIO_ROUTE_POLICY_MAX] = {
2191 "DEFAULT","IGN_A2DP","HANDSET"
2193 printf("Audio Route Policy has changed to [%s]\n", str_route[policy]);
2194 printf("user data : %d\n", value);
2195 if(0 > mm_sound_route_get_system_policy(&lv_policy)) {
2196 printf("Can not get policy...in callback function\n");
2199 printf("readed policy [%s]\n", str_route[lv_policy]);
2205 ret = mm_sound_route_add_change_callback(audio_route_policy_changed_callback, (void*)111);
2208 printf("Can not add callback\n");
2214 int mm_sound_route_add_change_callback(audio_route_policy_changed_callback_fn func, void* user_data);
2217 * This function remove system audio policy changed callback function.
2219 * @return This function returns MM_ERROR_NONE on success, or negative value
2222 * @see mm_sound_route_add_change_callback mm_sound_route_set_system_policy mm_sound_route_get_system_policy system_audio_route_t
2223 * @pre Sound route change callback should be registered.
2224 * @post Sound route change callback deregistered and does not be called anymore.
2227 void audio_route_policy_changed_callback(void* data, system_audio_route_t policy)
2229 int value = (int) data;
2230 system_audio_route_t lv_policy;
2231 char *str_route[SYSTEM_AUDIO_ROUTE_POLICY_MAX] = {
2232 "DEFAULT","IGN_A2DP","HANDSET"
2234 printf("Audio Route Policy has changed to [%s]\n", str_route[policy]);
2235 printf("user data : %d\n", value);
2236 if(0 > mm_sound_route_get_system_policy(&lv_policy)) {
2237 printf("Can not get policy...in callback function\n");
2240 printf("readed policy [%s]\n", str_route[lv_policy]);
2246 ret = mm_sound_route_add_change_callback(audio_route_policy_changed_callback, (void*)111);
2249 printf("Can not add callback\n");
2253 ret = mm_sound_route_remove_change_callback();
2256 printf("Can not remove callback\n");
2263 int mm_sound_route_remove_change_callback(void);
2266 * Enumerations of device & route
2270 MM_SOUND_DIRECTION_NONE,
2271 MM_SOUND_DIRECTION_IN, /**< Capture */
2272 MM_SOUND_DIRECTION_OUT, /**< Playback */
2273 } mm_sound_direction;
2276 MM_SOUND_DEVICE_IN_NONE = 0x00,
2277 MM_SOUND_DEVICE_IN_MIC = 0x01, /**< Device builtin mic. */
2278 MM_SOUND_DEVICE_IN_WIRED_ACCESSORY = 0x02, /**< Wired input devices */
2279 MM_SOUND_DEVICE_IN_BT_SCO = 0x08, /**< Bluetooth SCO device */
2280 } mm_sound_device_in;
2283 MM_SOUND_DEVICE_OUT_NONE = 0x000,
2284 MM_SOUND_DEVICE_OUT_SPEAKER = 0x001<<8, /**< Device builtin speaker */
2285 MM_SOUND_DEVICE_OUT_RECEIVER = 0x002<<8, /**< Device builtin receiver */
2286 MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY = 0x004<<8, /**< Wired output devices such as headphone, headset, and so on. */
2287 MM_SOUND_DEVICE_OUT_BT_SCO = 0x008<<8, /**< Bluetooth SCO device */
2288 MM_SOUND_DEVICE_OUT_BT_A2DP = 0x010<<8, /**< Bluetooth A2DP device */
2289 MM_SOUND_DEVICE_OUT_DOCK = 0x020<<8, /**< DOCK device */
2290 MM_SOUND_DEVICE_OUT_HDMI = 0x040<<8, /**< HDMI device */
2291 MM_SOUND_DEVICE_OUT_MIRRORING = 0x080<<8, /**< MIRRORING device */
2292 MM_SOUND_DEVICE_OUT_USB_AUDIO = 0x100<<8, /**< USB Audio device */
2293 MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK = 0x200<<8, /**< Multimedia DOCK device */
2294 } mm_sound_device_out;
2297 MM_SOUND_VOLUME_DEVICE_OUT_SPEAKER, /**< Device builtin speaker */
2298 MM_SOUND_VOLUME_DEVICE_OUT_RECEIVER, /**< Device builtin receiver */
2299 MM_SOUND_VOLUME_DEVICE_OUT_WIRED_ACCESSORY, /**< Wired output devices such as headphone, headset, and so on. */
2300 MM_SOUND_VOLUME_DEVICE_OUT_BT_SCO, /**< Bluetooth SCO device */
2301 MM_SOUND_VOLUME_DEVICE_OUT_BT_A2DP, /**< Bluetooth A2DP device */
2302 MM_SOUND_VOLUME_DEVICE_OUT_DOCK, /**< DOCK device */
2303 MM_SOUND_VOLUME_DEVICE_OUT_HDMI, /**< HDMI device */
2304 MM_SOUND_VOLUME_DEVICE_OUT_MIRRORING, /**< MIRRORING device */
2305 MM_SOUND_VOLUME_DEVICE_OUT_USB_AUDIO, /**< USB Audio device */
2306 MM_SOUND_VOLUME_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Multimedia DOCK device */
2307 } mm_sound_volume_device_out_t;
2309 #define MM_SOUND_ROUTE_NUM 16
2310 #define MM_SOUND_NAME_NUM 32
2313 MM_SOUND_ROUTE_OUT_SPEAKER = MM_SOUND_DEVICE_OUT_SPEAKER, /**< Routing audio output to builtin device such as internal speaker. */
2314 MM_SOUND_ROUTE_OUT_RECEIVER = MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio output to builtin device such as internal receiver. */
2315 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. */
2316 MM_SOUND_ROUTE_OUT_BLUETOOTH_SCO = MM_SOUND_DEVICE_OUT_BT_SCO, /**< Routing audio output to bluetooth SCO. */
2317 MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP = MM_SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */
2318 MM_SOUND_ROUTE_OUT_DOCK = MM_SOUND_DEVICE_OUT_DOCK, /**< Routing audio output to DOCK */
2319 MM_SOUND_ROUTE_OUT_HDMI = MM_SOUND_DEVICE_OUT_HDMI, /**< Routing audio output to HDMI */
2320 MM_SOUND_ROUTE_OUT_MIRRORING = MM_SOUND_DEVICE_OUT_MIRRORING, /**< Routing audio output to MIRRORING */
2321 MM_SOUND_ROUTE_OUT_USB_AUDIO = MM_SOUND_DEVICE_OUT_USB_AUDIO, /**< Routing audio output to USB Audio */
2322 MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK = MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Routing audio output to Multimedia DOCK */
2323 MM_SOUND_ROUTE_IN_MIC = MM_SOUND_DEVICE_IN_MIC, /**< Routing audio input to device builtin mic. */
2324 MM_SOUND_ROUTE_IN_WIRED_ACCESSORY = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY, /**< Routing audio input to wired accessory. */
2325 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*/
2326 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 */
2327 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 */
2328 MM_SOUND_ROUTE_INOUT_HEADSET = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY, /**< Routing audio input and output to headset*/
2329 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 */
2333 * MMSound Device APIs
2337 MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG = 0x0001, /**< Flag for input devices */
2338 MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG = 0x0002, /**< Flag for output devices */
2339 MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG = 0x0004, /**< Flag for input/output devices (both directions are available) */
2340 MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG = 0x0010, /**< Flag for built-in devices */
2341 MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG = 0x0020, /**< Flag for external devices */
2342 MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG = 0x1000, /**< Flag for deactivated devices */
2343 MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG = 0x2000, /**< Flag for activated devices */
2344 MM_SOUND_DEVICE_ALL_FLAG = 0xFFFF, /**< Flag for all devices */
2345 } mm_sound_device_flags_e;
2348 MM_SOUND_DEVICE_IO_DIRECTION_IN,
2349 MM_SOUND_DEVICE_IO_DIRECTION_OUT,
2350 MM_SOUND_DEVICE_IO_DIRECTION_BOTH,
2351 } mm_sound_device_io_direction_e;
2354 MM_SOUND_DEVICE_STATE_DEACTIVATED,
2355 MM_SOUND_DEVICE_STATE_ACTIVATED,
2356 } mm_sound_device_state_e;
2360 MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER, /**< Built-in speaker. */
2361 MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER, /**< Built-in receiver. */
2362 MM_SOUND_DEVICE_TYPE_BUILTIN_MIC, /**< Built-in mic. */
2363 MM_SOUND_DEVICE_TYPE_AUDIOJACK, /**< Audio jack such as headphone, headset, and so on. */
2364 MM_SOUND_DEVICE_TYPE_BLUETOOTH, /**< Bluetooth */
2365 MM_SOUND_DEVICE_TYPE_HDMI, /**< HDMI. */
2366 MM_SOUND_DEVICE_TYPE_MIRRORING, /**< MIRRORING. */
2367 MM_SOUND_DEVICE_TYPE_USB_AUDIO, /**< USB Audio. */
2368 } mm_sound_device_type_e;
2370 typedef void *MMSoundDevice_t; /**< MMsound Device handle */
2371 typedef void *MMSoundDeviceList_t; /**< MMsound Device list handle */
2372 typedef void (*mm_sound_device_connected_cb) (MMSoundDevice_t device_h, bool is_connected, void *user_data);
2373 typedef void (*mm_sound_device_info_changed_cb) (MMSoundDevice_t device_h, int changed_info_type, void *user_data);
2375 int mm_sound_add_device_connected_callback(mm_sound_device_flags_e flags, mm_sound_device_connected_cb func, void *user_data);
2376 int mm_sound_remove_device_connected_callback(void);
2377 int mm_sound_add_device_information_changed_callback(mm_sound_device_flags_e flags, mm_sound_device_info_changed_cb func, void *user_data);
2378 int mm_sound_remove_device_information_changed_callback(void);
2380 int mm_sound_get_current_device_list(mm_sound_device_flags_e device_mask, MMSoundDeviceList_t *device_list);
2381 int mm_sound_get_next_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
2382 int mm_sound_get_prev_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
2383 int mm_sound_get_device_type(MMSoundDevice_t device_h, mm_sound_device_type_e *type);
2384 int mm_sound_get_device_io_direction(MMSoundDevice_t device_h, mm_sound_device_io_direction_e *io_direction);
2385 int mm_sound_get_device_id(MMSoundDevice_t device_h, int *id);
2386 int mm_sound_get_device_state(MMSoundDevice_t device_h, mm_sound_device_state_e *state);
2387 int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name);
2389 /* below APIs are for product */
2390 typedef int (*mm_sound_available_route_cb)(mm_sound_route route, void *user_data);
2391 int mm_sound_is_route_available(mm_sound_route route, bool *is_available);
2392 int mm_sound_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data);
2393 int mm_sound_set_active_route(mm_sound_route route);
2394 int mm_sound_set_active_route_auto(void);
2398 * This function is to set active route without callback to client.
2400 * @param route [IN] route
2401 * @return This function returns MM_ERROR_NONE on success, or negative value
2406 * @see mm_sound_set_active_route_without_broadcast mm_sound_route
2408 int mm_sound_set_active_route_without_broadcast(mm_sound_route route);
2411 * This function is to get active playback device and capture device.
2413 * @param playback_device [out] playback device.
2414 * @param capture_device [out] capture device.
2416 * @return This function returns MM_ERROR_NONE on success, or negative value
2421 * @see mm_sound_set_active_route mm_sound_device_in mm_sound_device_out
2423 int mm_sound_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
2426 * Active device changed callback function type.
2428 * @param user_data [in] Argument passed when callback has called
2430 * @return No return value
2432 * @see mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
2434 typedef void (*mm_sound_active_device_changed_cb) (mm_sound_device_in device_in, mm_sound_device_out device_out, void *user_data);
2437 * This function is to add active device callback.
2439 * @param name [in] plugin name (name max size : MM_SOUND_NAME_NUM 32)
2440 * @param func [in] callback function pointer
2441 * @param user_data [in] user data passing to callback function
2443 * @return This function returns MM_ERROR_NONE on success, or negative value
2446 * @see mm_sound_remove_active_device_changed_callback mm_sound_active_device_changed_cb
2452 void __active_device_callback(void *user_data)
2454 printf("Callback function\n");
2457 int active_device_control()
2461 ret = mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
2462 if ( MM_ERROR_NONE != ret)
2464 printf("Can not add callback\n");
2468 printf("Add callback success\n");
2476 int mm_sound_add_active_device_changed_callback(const char *name,mm_sound_active_device_changed_cb func, void *user_data);
2478 * This function is to remove active device callback.
2480 * @param name [in] plugin name (name max size : MM_SOUND_NAME_NUM 32)
2481 * @return This function returns MM_ERROR_NONE on success, or negative value
2484 * @pre Active device callback should be registered.
2485 * @post Active device callback deregistered and does not be called anymore.
2486 * @see mm_sound_add_active_device_changed_callback mm_sound_active_device_changed_cb
2489 void __active_device_callback(void *data)
2491 printf("Callback function\n");
2494 int active_device_control()
2498 mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
2500 ret = mm_sound_remove_active_device_changed_callback();
2501 if ( MM_ERROR_NONE == ret)
2503 printf("Remove callback success\n");
2507 printf("Remove callback failed\n");
2515 int mm_sound_remove_active_device_changed_callback(const char *name);
2517 * Available route changed callback function type.
2519 * @param user_data [in] Argument passed when callback has called
2521 * @return No return value
2523 * @see mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
2525 typedef void (*mm_sound_available_route_changed_cb) (mm_sound_route route, bool available, void *user_data);
2528 * This function is to add available device callback.
2530 * @param func [in] callback function pointer
2531 * @param user_data [in] user data passing to callback function
2533 * @return This function returns MM_ERROR_NONE on success, or negative value
2536 * @see mm_sound_remove_available_route_changed_callback mm_sound_active_device_changed_cb
2542 void __available_device_callback(void *user_data)
2544 printf("Callback function\n");
2547 int available_device_control()
2551 ret = mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2552 if ( MM_ERROR_NONE != ret)
2554 printf("Can not add callback\n");
2558 printf("Add callback success\n");
2566 int mm_sound_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void *user_data);
2569 * This function is to remove available device callback.
2571 * @return This function returns MM_ERROR_NONE on success, or negative value
2574 * @pre available device callback should be registered.
2575 * @post available device callback deregistered and does not be called anymore.
2576 * @see mm_sound_add_available_route_changed_callback mm_sound_active_device_changed_cb
2579 void __available_device_callback(void *data)
2581 printf("Callback function\n");
2584 int available_device_control()
2588 mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2590 ret = mm_sound_remove_available_route_changed_callback();
2591 if ( MM_ERROR_NONE == ret)
2593 printf("Remove callback success\n");
2597 printf("Remove callback failed\n");
2605 int mm_sound_remove_available_route_changed_callback(void);
2608 * This function is to set path for active device.
2610 * @param device_out [in] active playback device
2611 * @param device_in [in] active capture device
2613 * @return This function returns MM_ERROR_NONE on success, or negative value
2621 int mm_sound_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in);
2624 * This function is to get current audio path.
2626 * @param device_out [in] active playback device
2627 * @param device_in [in] active capture device
2629 * @return This function returns MM_ERROR_NONE on success, or negative value
2638 int mm_sound_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
2648 #endif /* __MM_SOUND_H__ */