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 flush pcm playback
1023 * @param handle [in] handle to flush playback
1025 * @return This function returns MM_ERROR_NONE on success, or negative value
1029 * @pre PCM playback handle should be allocated.
1030 * @post PCM playback data will not be buffered.
1032 int mm_sound_pcm_play_drain(MMSoundPcmHandle_t handle);
1035 * This function flush pcm playback
1037 * @param handle [in] handle to flush playback
1039 * @return This function returns MM_ERROR_NONE on success, or negative value
1043 * @pre PCM playback handle should be allocated.
1044 * @post PCM playback data will not be buffered.
1046 int mm_sound_pcm_play_flush(MMSoundPcmHandle_t handle);
1049 * This function is to play PCM memory buffer.
1051 * @param handle [in] handle to play pcm data
1052 * @param ptr [in] pcm buffer address
1053 * @param length_byte [in] size of pcm buffer (in bytes)
1055 * @return This function returns written data size on success, or negative value
1057 * @remark Make pcm buffer size with returned value of mm_sound_pcm_play_open()
1058 * @see mm_sound_pcm_play_open, mm_sound_pcm_play_close
1059 * @pre PCM play handle should be created.
1060 * @post Sound will be generated with given PCM buffer data.
1063 #include <mm_sound.h>
1067 int main(int argc, char* argv[])
1070 char *buffer = NULL;
1074 MMSoundPcmHandle_t handle;
1075 char *filename = NULL;
1079 printf("Usage) %s filename\n", argv[0]);
1084 fp = fopen(filename,"r");
1087 printf("Can not open file %s\n", filename);
1091 size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
1094 printf("Can not open playback handle\n");
1098 buffer = alloca(size);
1099 while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
1101 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
1104 printf("write fail\n");
1107 memset(buffer, '\0', sizeof(buffer));
1111 mm_sound_pcm_play_close(handle);
1116 int mm_sound_pcm_play_write(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte);
1121 * This function is to close PCM memory playback handle
1123 * @param handle [in] handle to play pcm data
1125 * @return This function returns MM_ERROR_NONE on success, or negative value
1128 * @see mm_sound_pcm_play_open, mm_sound_pcm_play_write
1129 * @pre PCM play handle should be created
1130 * @post PCM play handle will be terminated.
1133 #include <mm_sound.h>
1137 int main(int argc, char* argv[])
1140 char *buffer = NULL;
1144 MMSoundPcmHandle_t handle;
1145 char *filename = NULL;
1149 printf("Usage) %s filename\n", argv[0]);
1154 fp = fopen(filename,"r");
1157 printf("Can not open file %s\n", filename);
1161 size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
1164 printf("Can not open playback handle\n");
1168 buffer = alloca(size);
1169 while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
1171 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
1174 printf("write fail\n");
1177 memset(buffer, '\0', sizeof(buffer));
1181 mm_sound_pcm_play_close(handle);
1186 int mm_sound_pcm_play_close(MMSoundPcmHandle_t handle);
1189 * This function is to ignore session for playback
1191 * @param handle [in] handle to play pcm data
1193 * @return This function returns MM_ERROR_NONE on success, or negative value
1195 * @remark This function only works for not started pcm handle and can't be reversed.
1197 * @pre PCM play handle should be created and not started.
1198 * @post PCM play session will be set to mix.
1200 int mm_sound_pcm_play_ignore_session(MMSoundPcmHandle_t *handle);
1203 * This function is to create handle for PCM capture.
1205 * @param handle [out] handle to capture pcm data
1206 * @param rate [in] sample rate (8000Hz ~ 44100Hz)
1207 * @param channel [in] number of channels (mono or stereo)
1208 * @param format [in] S8 or S16LE
1210 * @return This function returns suggested buffer size (in bytes) on success, or negative value
1212 * @remark only mono channel is valid for now.
1213 * @see mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
1215 * @post PCM capture handle will be allocated.
1218 #include <mm_sound.h>
1222 int main(int argc, char* argv[])
1225 char *buffer = NULL;
1229 MMSoundPcmHandle_t handle;
1230 char *filename = NULL;
1234 printf("Usage) %s filename\n", argv[0]);
1239 fp = fopen(filename,"w");
1242 printf("Can not open file %s\n", filename);
1246 size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1249 printf("Can not open capture handle\n");
1253 buffer = alloca(size);
1256 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1259 printf("read fail\n");
1262 fwrite(buffer, ret, sizeof(char), fp);
1269 mm_sound_pcm_capture_close(handle);
1275 int mm_sound_pcm_capture_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format);
1278 * This function is to create handle for PCM capture of source_type.
1280 * @param handle [out] handle to capture pcm data
1281 * @param rate [in] sample rate (8000Hz ~ 44100Hz)
1282 * @param channel [in] number of channels (mono or stereo)
1283 * @param format [in] S8 or S16LE
1284 * @param source_type [in] The source_type,mm_sound_source_type_e
1286 * @return This function returns suggested buffer size (in bytes) on success, or negative value
1288 * @remark only mono channel is valid for now.
1289 * @see mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
1291 * @post PCM capture handle will be allocated.
1294 #include <mm_sound.h>
1298 int main(int argc, char* argv[])
1301 char *buffer = NULL;
1305 MMSoundPcmHandle_t handle;
1306 char *filename = NULL;
1310 printf("Usage) %s filename\n", argv[0]);
1315 fp = fopen(filename,"w");
1318 printf("Can not open file %s\n", filename);
1322 size = mm_sound_pcm_capture_open_ex(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE,1);
1325 printf("Can not open capture handle\n");
1329 buffer = alloca(size);
1332 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1335 printf("read fail\n");
1338 fwrite(buffer, ret, sizeof(char), fp);
1345 mm_sound_pcm_capture_close(handle);
1351 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);
1354 * This function start pcm capture
1356 * @param handle [in] handle to start capture
1358 * @return This function returns read data size on success, or negative value
1362 * @pre PCM capture handle should be allocated.
1363 * @post PCM capture data will be buffered.
1365 int mm_sound_pcm_capture_start(MMSoundPcmHandle_t handle);
1368 * This function stop pcm capture
1370 * @param handle [in] handle to stop capture
1372 * @return This function returns read data size on success, or negative value
1376 * @pre PCM capture handle should be allocated.
1377 * @post PCM capture data will not be buffered.
1379 int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle);
1382 * This function flush pcm capture
1384 * @param handle [in] handle to flush capture
1386 * @return This function returns MM_ERROR_NONE on success, or negative value
1390 * @pre PCM capture handle should be allocated.
1391 * @post PCM capture data will not be buffered.
1393 int mm_sound_pcm_capture_flush(MMSoundPcmHandle_t handle);
1396 * This function captures PCM to memory buffer. (Samsung extension)
1398 * @param handle [in] handle to play pcm data
1399 * @param buffer [in] pcm buffer address
1400 * @param length [in] size of pcm buffer (in bytes)
1402 * @return This function returns read data size on success, or negative value
1404 * @remark Make pcm buffer size with returned value of mm_sound_pcm_capture_open()
1405 * @see mm_sound_pcm_capture_open, mm_sound_pcm_capture_close
1406 * @pre PCM capture handle should be allcated.
1407 * @post PCM data will be filled to given memory pointer.
1410 #include <mm_sound.h>
1414 int main(int argc, char* argv[])
1417 char *buffer = NULL;
1421 MMSoundPcmHandle_t handle;
1422 char *filename = NULL;
1426 printf("Usage) %s filename\n", argv[0]);
1431 fp = fopen(filename,"w");
1434 printf("Can not open file %s\n", filename);
1438 size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1441 printf("Can not open capture handle\n");
1445 buffer = alloca(size);
1448 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1451 printf("read fail\n");
1454 fwrite(buffer, ret, sizeof(char), fp);
1461 mm_sound_pcm_capture_close(handle);
1467 int mm_sound_pcm_capture_read(MMSoundPcmHandle_t handle, void *buffer, const unsigned int length );
1470 * This function captures PCM memory to memory buffer (Samsung extension)
1472 * @param handle [in] handle to capture pcm data
1474 * @return This function returns MM_ERROR_NONE on success, or negative value
1477 * @see mm_sound_pcm_capture_open, mm_sound_pcm_capture_read
1478 * @pre PCM capture handle should be opend.
1479 * @post PCM capture handle will be freed.
1482 #include <mm_sound.h>
1486 int main(int argc, char* argv[])
1489 char *buffer = NULL;
1493 MMSoundPcmHandle_t handle;
1494 char *filename = NULL;
1498 printf("Usage) %s filename\n", argv[0]);
1503 fp = fopen(filename,"w");
1506 printf("Can not open file %s\n", filename);
1510 size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1513 printf("Can not open capture handle\n");
1517 buffer = alloca(size);
1520 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1523 printf("read fail\n");
1526 fwrite(buffer, ret, sizeof(char), fp);
1533 mm_sound_pcm_capture_close(handle);
1539 int mm_sound_pcm_capture_close(MMSoundPcmHandle_t handle);
1542 * This function is to ignore session for capture
1544 * @param handle [in] handle to capture pcm data
1546 * @return This function returns MM_ERROR_NONE on success, or negative value
1548 * @remark This function only works for not started pcm handle and can't be reversed.
1550 * @pre PCM capture handle should be created and not started.
1551 * @post PCM capture session will be set to mix.
1553 int mm_sound_pcm_capture_ignore_session(MMSoundPcmHandle_t *handle);
1556 * This function sets callback function for receiving messages from pcm API.
1558 * @param handle [in] Handle of pcm.
1559 * @param callback [in] Message callback function.
1560 * @param user_param [in] User parameter which is passed to callback function.
1562 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
1563 * @see MMMessageCallback
1567 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1571 case MM_MESSAGE_SOUND_PCM_CAPTURE_RESTRICTED:
1575 case MM_MESSAGE_SOUND_PCM_INTERRUPTED:
1585 mm_sound_pcm_set_message_callback(pcmHandle, msg_callback, (void *)pcmHandle);
1588 int mm_sound_pcm_set_message_callback (MMSoundPcmHandle_t handle, MMMessageCallback callback, void *user_param);
1591 * Terminate callback function type.
1593 * @param data [in] Argument passed when callback was set
1594 * @param id [in] handle which has completed playing
1596 * @return No return value
1597 * @remark It is not allowed to call MMSound API recursively or do time-consuming
1598 * task in this callback because this callback is called synchronously.
1599 * @see mm_sound_play_sound
1601 typedef void (*mm_sound_stop_callback_func) (void *data, int id);
1608 * This function is to play system sound.
1610 * @param filename [in] Sound filename to play
1611 * @param volume config [in] Volume type & volume gain
1612 * @param callback [in] Callback function pointer when playing is terminated.
1613 * @param data [in] Pointer to user data when callback is called.
1614 * @param handle [out] Handle of sound play.
1616 * @return This function returns MM_ERROR_NONE on success, or negative value
1618 * @remark When the stop callback is set, it will be called when system sound is
1619 * terminated. If mm_sound_stop_sound() is called apparently before
1620 * system sound is terminated, stop_callback will not be called.
1621 * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1623 * @post Sound will be generated with given filename.
1627 void _stop_callback(void* data)
1629 printf("Stop callback\n");
1635 char filename[] ="/opt/media/Sound/testfile.wav";
1636 volume_type_t volume = VOLUME_TYPE_SYSTEM;
1640 ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1643 printf("play file failed\n");
1647 printf("play file success\n");
1653 printf("play stopped\n");
1658 int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1660 int mm_sound_play_sound_without_session(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1662 int mm_sound_play_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1665 * This function is to play system sound. And other audio stream will be mute during playing time
1667 * @param filename [in] Sound filename to play
1668 * @param volume config [in] Volume type & volume gain
1669 * @param callback [in] Callback function pointer when playing is terminated.
1670 * @param data [in] Pointer to user data when callback is called.
1671 * @param handle [out] Handle of sound play.
1673 * @return This function returns MM_ERROR_NONE on success, or negative value
1675 * @remark This function is almost same with mm_sound_play_sound,
1676 * but this make other audio playback stream to mute during playing time.
1677 * @see mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1679 * @post Sound will be generated with given filename.
1683 void _stop_callback(void* data)
1685 printf("Stop callback\n");
1691 char filename[] ="/opt/media/Sound/testfile.wav";
1692 volume_type_t volume = VOLUME_TYPE_SYSTEM;
1696 ret = mm_sound_play_loud_solo_sound(filename, volume, _stop_callback, NULL, &handle);
1699 printf("play file failed\n");
1703 printf("play file success\n");
1709 printf("play stopped\n");
1714 int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1716 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);
1719 * This function is to stop playing system sound.
1721 * @param handle [in] Handle of mm_sound_play_sound
1723 * @return This function returns MM_ERROR_NONE on success, or negative value
1726 * @remark When system sound is terminated with this function call, it does not
1727 * call stop callback which was set when start playing system sound.
1728 * @see mm_sound_play_sound
1729 * @pre An sound play handle should be valid.
1730 * @post Playing sound file will be stopped.
1734 void _stop_callback(void* data)
1736 printf("Stop callback\n");
1740 int play_file_one_second()
1742 char filename[] ="/opt/media/Sound/testfile.wav";
1743 volume_type_t volume = VOLUME_TYPE_SYSTEM;
1747 ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1750 printf("play file failed\n");
1754 printf("play file success\n");
1757 sleep(1); //wait 1 second
1759 ret = mm_sound_stop_sound(handle);
1762 printf("stop failed\n");
1766 printf("play stopped\n");
1772 int mm_sound_stop_sound(int handle);
1776 * Enumerations for TONE
1780 MM_SOUND_TONE_DTMF_0 = 0, /**< Predefined DTMF 0 */
1781 MM_SOUND_TONE_DTMF_1, /**< Predefined DTMF 1 */
1782 MM_SOUND_TONE_DTMF_2, /**< Predefined DTMF 2 */
1783 MM_SOUND_TONE_DTMF_3, /**< Predefined DTMF 3 */
1784 MM_SOUND_TONE_DTMF_4, /**< Predefined DTMF 4 */
1785 MM_SOUND_TONE_DTMF_5, /**< Predefined DTMF 5 */
1786 MM_SOUND_TONE_DTMF_6, /**< Predefined DTMF 6 */
1787 MM_SOUND_TONE_DTMF_7, /**< Predefined DTMF 7 */
1788 MM_SOUND_TONE_DTMF_8, /**< Predefined DTMF 8 */
1789 MM_SOUND_TONE_DTMF_9, /**< Predefined DTMF 9 */
1790 MM_SOUND_TONE_DTMF_S, /**< Predefined DTMF Star - Asterisk (*) */
1791 MM_SOUND_TONE_DTMF_P, /**< Predefined DTMF sharP (#) */
1792 MM_SOUND_TONE_DTMF_A, /**< Predefined DTMF A (A) */
1793 MM_SOUND_TONE_DTMF_B, /**< Predefined DTMF B (B) */
1794 MM_SOUND_TONE_DTMF_C, /**< Predefined DTMF C (C) */
1795 MM_SOUND_TONE_DTMF_D, /**< Predefined DTMF D (D) */
1797 /**< Pre-defined TONE */
1798 MM_SOUND_TONE_SUP_DIAL, /**Call supervisory tone, Dial tone: CEPT: 425Hz, continuous */
1799 MM_SOUND_TONE_ANSI_DIAL, /**Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous */
1800 MM_SOUND_TONE_JAPAN_DIAL, /**Call supervisory tone, Dial tone: JAPAN: 400Hz, continuous*/
1801 MM_SOUND_TONE_SUP_BUSY, /**Call supervisory tone, Busy: CEPT: 425Hz, 500ms ON, 500ms OFF... */
1802 MM_SOUND_TONE_ANSI_BUSY, /**Call supervisory tone, Busy: ANSI (IS-95): 480Hz+620Hz, 500ms ON, 500ms OFF... */
1803 MM_SOUND_TONE_JAPAN_BUSY, /**Call supervisory tone, Busy: JAPAN: 400Hz, 500ms ON, 500ms OFF...*/
1804 MM_SOUND_TONE_SUP_CONGESTION, /**Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF */
1805 MM_SOUND_TONE_ANSI_CONGESTION, /**Call supervisory tone, Congestion: ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF... */
1806 MM_SOUND_TONE_SUP_RADIO_ACK, /**Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON */
1807 MM_SOUND_TONE_JAPAN_RADIO_ACK, /**Call supervisory tone, Radio path acknowlegment : JAPAN: 400Hz, 1s ON, 2s OFF...*/
1808 MM_SOUND_TONE_SUP_RADIO_NOTAVAIL, /**Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts */
1809 MM_SOUND_TONE_SUP_ERROR, /**Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF... */
1810 MM_SOUND_TONE_SUP_CALL_WAITING, /**Call supervisory tone, Call Waiting: CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF... */
1811 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 ...) */
1812 MM_SOUND_TONE_SUP_RINGTONE, /**Call supervisory tone, Ring Tone: CEPT, JAPAN: 425Hz, 1s ON, 4s OFF... */
1813 MM_SOUND_TONE_ANSI_RINGTONE, /**Call supervisory tone, Ring Tone: ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF... */
1814 MM_SOUND_TONE_PROP_BEEP, /**General beep: 400Hz+1200Hz, 35ms ON */
1815 MM_SOUND_TONE_PROP_ACK, /**Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts */
1816 MM_SOUND_TONE_PROP_NACK, /**Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON */
1817 MM_SOUND_TONE_PROP_PROMPT, /**Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON */
1818 MM_SOUND_TONE_PROP_BEEP2, /**Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON */
1819 MM_SOUND_TONE_SUP_INTERCEPT, /**Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms */
1820 MM_SOUND_TONE_SUP_INTERCEPT_ABBREV, /**Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds */
1821 MM_SOUND_TONE_SUP_CONGESTION_ABBREV, /**Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds */
1822 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 */
1823 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). */
1824 MM_SOUND_TONE_CDMA_DIAL_TONE_LITE, /**425Hz continuous */
1825 MM_SOUND_TONE_CDMA_NETWORK_USA_RINGBACK, /**CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...*/
1826 MM_SOUND_TONE_CDMA_INTERCEPT, /**CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...*/
1827 MM_SOUND_TONE_CDMA_ABBR_INTERCEPT, /**CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON */
1828 MM_SOUND_TONE_CDMA_REORDER, /**CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF... */
1829 MM_SOUND_TONE_CDMA_ABBR_REORDER, /**CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times */
1830 MM_SOUND_TONE_CDMA_NETWORK_BUSY, /**CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous */
1831 MM_SOUND_TONE_CDMA_CONFIRM, /**CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times */
1832 MM_SOUND_TONE_CDMA_ANSWER, /**CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF */
1833 MM_SOUND_TONE_CDMA_NETWORK_CALLWAITING, /**CDMA Network Callwaiting tone: 440Hz 300ms ON */
1834 MM_SOUND_TONE_CDMA_PIP, /**CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times */
1835 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 */
1836 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.*/
1837 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 */
1838 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT3, /**SDN Call sign PAT3 tone: silent tone */
1839 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING, /**ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON */
1840 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT5, /**ISDN Pat5 tone: silent tone */
1841 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT6, /**ISDN Pat6 tone: silent tone */
1842 MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT7, /**ISDN Pat7 tone: silent tone */
1843 MM_SOUND_TONE_CDMA_HIGH_L, /**TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1844 MM_SOUND_TONE_CDMA_MED_L, /**TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1845 MM_SOUND_TONE_CDMA_LOW_L, /**TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, 4000ms OFF, Repeat .... */
1846 MM_SOUND_TONE_CDMA_HIGH_SS, /**CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1847 MM_SOUND_TONE_CDMA_MED_SS, /**CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1848 MM_SOUND_TONE_CDMA_LOW_SS, /**CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1849 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 ... */
1850 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 ... */
1851 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 ... */
1852 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 .... */
1853 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 .... */
1854 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 .... */
1855 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 */
1856 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 */
1857 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 */
1858 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.... */
1859 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.... */
1860 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....*/
1861 MM_SOUND_TONE_CDMA_HIGH_PBX_L, /**CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1862 MM_SOUND_TONE_CDMA_MED_PBX_L, /**CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1863 MM_SOUND_TONE_CDMA_LOW_PBX_L, /**CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1864 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.... */
1865 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.... */
1866 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.... */
1867 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.... */
1868 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.... */
1869 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.... */
1870 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.... */
1871 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.... */
1872 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.... */
1873 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... */
1874 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... */
1875 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... */
1876 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 */
1877 MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE, /**CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON */
1878 MM_SOUND_TONE_CDMA_ONE_MIN_BEEP, /**CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON */
1879 MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE, /**CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON */
1880 MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE, /**CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON */
1881 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*/
1882 MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK, /**CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times 4990ms OFF, REPEAT... */
1883 MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD, /**CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times */
1884 MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE, /**CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms */
1885 MM_SOUND_TONE_CDMA_CALLDROP_LITE, /**CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms */
1886 MM_SOUND_TONE_CDMA_NETWORK_BUSY_ONE_SHOT, /**CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. */
1887 MM_SOUND_TONE_CDMA_ABBR_ALERT, /**CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON */
1888 MM_SOUND_TONE_CDMA_SIGNAL_OFF, /**CDMA_SIGNAL_OFF - silent tone */
1889 MM_SOUND_TONE_LOW_FRE, /**100Hz continuous */
1890 MM_SOUND_TONE_MED_FRE, /**200Hz continuous */
1891 MM_SOUND_TONE_HIGH_FRE, /**300Hz continuous */
1895 typedef unsigned long sound_time_msec_t; /**< millisecond unit */
1898 * This function is to play tone sound.
1900 * @param num [in] predefined tone type (MMSoundTone_t)
1901 * volume config [in] volume type & volume gain
1902 * volume [in] volume ratio (0.0 ~1.0)
1903 * duration [in] millisecond (-1 for infinite)
1904 * handle [in] Handle of mm_sound_play_tone
1905 * enable_session [in] set enable/unable session
1907 * @return This function returns MM_ERROR_NONE on success, or negative value
1910 * @remark It doesn't provide stop
1911 * @see volume_type_t volume_gain_t MMSoundTone_t
1913 * @post TONE sound will be played.
1918 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
1921 printf("play tone failed\n");
1925 printf("play tone success\n");
1929 int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session);
1932 * This function is to play tone sound.
1934 * @param num [in] predefined tone type (MMSoundTone_t)
1935 * volume config [in] volume type & volume gain
1936 * volume [in] volume ratio (0.0 ~1.0)
1937 * duration [in] millisecond (-1 for infinite)
1938 * handle [in] Handle of mm_sound_play_tone
1940 * @return This function returns MM_ERROR_NONE on success, or negative value
1943 * @remark It doesn't provide stop
1944 * @see volume_type_t volume_gain_t MMSoundTone_t
1946 * @post TONE sound will be played.
1951 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
1954 printf("play tone failed\n");
1958 printf("play tone success\n");
1962 int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle);
1965 * Enumerations of System audio route policy
1968 SYSTEM_AUDIO_ROUTE_POLICY_DEFAULT, /**< Play via a2dp headset if connected. or play via headset if connected. or play via speaker.
1969 And capture via 4pole headset-mic if connected. or capture via mic */
1970 SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP, /**< Play via headset if connected. or play via speaker
1971 And capture via 4pole headset-mic if connected. or capture via mic */
1972 SYSTEM_AUDIO_ROUTE_POLICY_HANDSET_ONLY, /**< Play via speaker. and capture via mic */
1973 SYSTEM_AUDIO_ROUTE_POLICY_MAX
1974 }system_audio_route_t;
1977 SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_NONE, /**< Abnormal case */
1978 SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_HANDSET, /**< Speaker or Headset or Earpiece */
1979 SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_BLUETOOTH, /**< Bluetooth */
1980 SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_EARPHONE, /**< Earphone */
1981 SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_MAX,
1982 }system_audio_route_device_t;
1985 SYSTEM_AUDIO_CAPTURE_NONE, /**< Capture device is not in use */
1986 SYSTEM_AUDIO_CAPTURE_ACTIVE, /**< Capture device is in use */
1987 SYSTEM_AUDIO_CAPTURE_MAX,
1988 }system_audio_capture_status_t;
1992 * This function set system route policy.
1994 * @param route [in] audio route type
1996 * @return This function returns MM_ERROR_NONE on success, or negative value
1998 * @remark If bluetooth has disconnected during SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP policy,
1999 * The audio route policy will be changed to SYSTEM_AUDIO_ROUTE_POLICY_DEFAULT.
2000 * @see mm_sound_route_get_system_policy system_audio_route_t mm_sound_route_is_a2dp_on
2002 * @post Audio routing policy will be changed with given type. And route change callback function will be called if registered.
2006 void _stop_callback()
2011 int play_file_via_speaker()
2014 system_audio_route_t route, original_route;
2016 //get backup current policy
2017 ret = mm_sound_route_get_system_policy(&original_route);
2020 printf("Can not get system audio route policy\n");
2024 //set route policy to ignore a2dp
2025 route = SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP;
2026 ret = mm_sound_route_set_system_policy(route);
2029 printf("Ca not set route policy\n");
2035 ret = mm_sound_play_sound("/opt/media/Sound/alert.wav", VOLUME_TYPE_SYSTEM, NULL, NULL, &handle);
2038 printf("Can not play wav file\n");
2046 //restore original policy
2047 mm_sound_route_set_system_policy(original_route);
2055 int mm_sound_route_set_system_policy (system_audio_route_t route);
2058 * This function get sysytem route policy.
2060 * @param route [out] audio route type
2062 * @return This function returns MM_ERROR_NONE on success, or negative value
2065 * @see mm_sound_route_set_system_policy system_audio_route_t mm_sound_route_is_a2dp_on
2071 void _stop_callback()
2076 int play_file_via_speaker()
2079 system_audio_route_t route, original_route;
2081 //get backup current policy
2082 ret = mm_sound_route_get_system_policy(&original_route);
2085 printf("Can not get system audio route policy\n");
2089 //set route policy to ignore a2dp
2090 route = SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP;
2091 ret = mm_sound_route_set_system_policy(route);
2094 printf("Can not set route policy\n");
2100 ret = mm_sound_play_sound("/opt/media/Sound/alert.wav", VOLUME_TYPE_SYSTEM, NULL, NULL, &handle);
2103 printf("Can not play wav file\n");
2111 //restore original policy
2112 mm_sound_route_set_system_policy(original_route);
2120 int mm_sound_route_get_system_policy (system_audio_route_t *route);
2125 * This function get a2dp activation information.
2127 * @param connected [out] is Bluetooth A2DP connected (1:connected, 0:not connected)
2128 * bt_name [out] Bluetooth A2DP connected device name (allocated by internal when connected=1 otherwise set to null)
2131 * @return This function returns MM_ERROR_NONE on success, or negative value
2133 * @remark This function allocation memory to given bt_name pointer internally.
2134 * So application should free given memory pointer later after use.
2135 * bt_name will be null if there's no a2dp device is connected (connected is 0)
2136 * @see mm_sound_route_set_system_policy mm_sound_route_get_system_policy
2138 * @post memory buffer will be allocated and fill with bluetooth device name.
2143 char* bt_name = NULL;
2144 ret = mm_sound_route_get_a2dp_status (&connected, &bt_name);
2146 if (ret == MM_ERROR_NONE) {
2147 g_print ("### Is Bluetooth A2DP On Success : connected=[%d] name=[%s]\n", connected, bt_name);
2151 g_print ("### Is Bluetooth A2DP On Error : errno [%d]\n", ret);
2155 int mm_sound_route_get_a2dp_status (bool* connected, char** bt_name);
2159 * This function get current playing device.
2161 * @param dev [out] current playing device information
2163 * @return This function returns MM_ERROR_NONE on success, or negative value
2165 * @remark if there is no running instance in system,
2166 * output parameter dev can be SYSTEM_AUDIO_ROUTE_PLAYING_DEVICE_NONE.
2168 * @see system_audio_route_device_t
2174 system_audio_route_device_t dev;
2176 ret = mm_sound_route_get_playing_device (&dev);
2177 if(ret == MM_ERROR_NONE)
2181 case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_HANDSET:
2182 printf("Handset is playing\n");
2184 case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_BLUETOOTH:
2185 printf("Bluetooth is playing\n");
2187 case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_NONE:
2189 printf("Unexptected\n");
2195 printf ("Can not get current running device\n");
2200 int mm_sound_route_get_playing_device(system_audio_route_device_t *dev);
2203 * Audio route policy change callback function type.
2205 * @param user_data [in] Argument passed when callback has called
2206 * @param policy [in] changed policy type
2208 * @return No return value
2210 * @see mm_sound_volume_add_callback mm_sound_volume_remove_callback
2212 typedef void (*audio_route_policy_changed_callback_fn)(void* user_data, system_audio_route_t policy);
2215 * This function set system audio policy changed callback function.
2217 * @param func [in] callback function pointer
2218 * @param user_data [in] user data will be called with func
2220 * @return This function returns MM_ERROR_NONE on success, or negative value
2223 * @see mm_sound_route_remove_change_callback mm_sound_route_set_system_policy mm_sound_route_get_system_policy system_audio_route_t
2228 void audio_route_policy_changed_callback(void* data, system_audio_route_t policy)
2230 int value = (int) data;
2231 system_audio_route_t lv_policy;
2232 char *str_route[SYSTEM_AUDIO_ROUTE_POLICY_MAX] = {
2233 "DEFAULT","IGN_A2DP","HANDSET"
2235 printf("Audio Route Policy has changed to [%s]\n", str_route[policy]);
2236 printf("user data : %d\n", value);
2237 if(0 > mm_sound_route_get_system_policy(&lv_policy)) {
2238 printf("Can not get policy...in callback function\n");
2241 printf("readed policy [%s]\n", str_route[lv_policy]);
2247 ret = mm_sound_route_add_change_callback(audio_route_policy_changed_callback, (void*)111);
2250 printf("Can not add callback\n");
2256 int mm_sound_route_add_change_callback(audio_route_policy_changed_callback_fn func, void* user_data);
2259 * This function remove system audio policy changed callback function.
2261 * @return This function returns MM_ERROR_NONE on success, or negative value
2264 * @see mm_sound_route_add_change_callback mm_sound_route_set_system_policy mm_sound_route_get_system_policy system_audio_route_t
2265 * @pre Sound route change callback should be registered.
2266 * @post Sound route change callback deregistered and does not be called anymore.
2269 void audio_route_policy_changed_callback(void* data, system_audio_route_t policy)
2271 int value = (int) data;
2272 system_audio_route_t lv_policy;
2273 char *str_route[SYSTEM_AUDIO_ROUTE_POLICY_MAX] = {
2274 "DEFAULT","IGN_A2DP","HANDSET"
2276 printf("Audio Route Policy has changed to [%s]\n", str_route[policy]);
2277 printf("user data : %d\n", value);
2278 if(0 > mm_sound_route_get_system_policy(&lv_policy)) {
2279 printf("Can not get policy...in callback function\n");
2282 printf("readed policy [%s]\n", str_route[lv_policy]);
2288 ret = mm_sound_route_add_change_callback(audio_route_policy_changed_callback, (void*)111);
2291 printf("Can not add callback\n");
2295 ret = mm_sound_route_remove_change_callback();
2298 printf("Can not remove callback\n");
2305 int mm_sound_route_remove_change_callback(void);
2308 * Enumerations of device & route
2312 MM_SOUND_DIRECTION_NONE,
2313 MM_SOUND_DIRECTION_IN, /**< Capture */
2314 MM_SOUND_DIRECTION_OUT, /**< Playback */
2315 } mm_sound_direction;
2318 MM_SOUND_DEVICE_IN_NONE = 0x00,
2319 MM_SOUND_DEVICE_IN_MIC = 0x01, /**< Device builtin mic. */
2320 MM_SOUND_DEVICE_IN_WIRED_ACCESSORY = 0x02, /**< Wired input devices */
2321 MM_SOUND_DEVICE_IN_BT_SCO = 0x08, /**< Bluetooth SCO device */
2322 } mm_sound_device_in;
2325 MM_SOUND_DEVICE_OUT_NONE = 0x000,
2326 MM_SOUND_DEVICE_OUT_SPEAKER = 0x001<<8, /**< Device builtin speaker */
2327 MM_SOUND_DEVICE_OUT_RECEIVER = 0x002<<8, /**< Device builtin receiver */
2328 MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY = 0x004<<8, /**< Wired output devices such as headphone, headset, and so on. */
2329 MM_SOUND_DEVICE_OUT_BT_SCO = 0x008<<8, /**< Bluetooth SCO device */
2330 MM_SOUND_DEVICE_OUT_BT_A2DP = 0x010<<8, /**< Bluetooth A2DP device */
2331 MM_SOUND_DEVICE_OUT_DOCK = 0x020<<8, /**< DOCK device */
2332 MM_SOUND_DEVICE_OUT_HDMI = 0x040<<8, /**< HDMI device */
2333 MM_SOUND_DEVICE_OUT_MIRRORING = 0x080<<8, /**< MIRRORING device */
2334 MM_SOUND_DEVICE_OUT_USB_AUDIO = 0x100<<8, /**< USB Audio device */
2335 MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK = 0x200<<8, /**< Multimedia DOCK device */
2336 } mm_sound_device_out;
2339 MM_SOUND_VOLUME_DEVICE_OUT_SPEAKER, /**< Device builtin speaker */
2340 MM_SOUND_VOLUME_DEVICE_OUT_RECEIVER, /**< Device builtin receiver */
2341 MM_SOUND_VOLUME_DEVICE_OUT_WIRED_ACCESSORY, /**< Wired output devices such as headphone, headset, and so on. */
2342 MM_SOUND_VOLUME_DEVICE_OUT_BT_SCO, /**< Bluetooth SCO device */
2343 MM_SOUND_VOLUME_DEVICE_OUT_BT_A2DP, /**< Bluetooth A2DP device */
2344 MM_SOUND_VOLUME_DEVICE_OUT_DOCK, /**< DOCK device */
2345 MM_SOUND_VOLUME_DEVICE_OUT_HDMI, /**< HDMI device */
2346 MM_SOUND_VOLUME_DEVICE_OUT_MIRRORING, /**< MIRRORING device */
2347 MM_SOUND_VOLUME_DEVICE_OUT_USB_AUDIO, /**< USB Audio device */
2348 MM_SOUND_VOLUME_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Multimedia DOCK device */
2349 } mm_sound_volume_device_out_t;
2351 #define MM_SOUND_ROUTE_NUM 16
2352 #define MM_SOUND_NAME_NUM 32
2355 MM_SOUND_ROUTE_OUT_SPEAKER = MM_SOUND_DEVICE_OUT_SPEAKER, /**< Routing audio output to builtin device such as internal speaker. */
2356 MM_SOUND_ROUTE_OUT_RECEIVER = MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio output to builtin device such as internal receiver. */
2357 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. */
2358 MM_SOUND_ROUTE_OUT_BLUETOOTH_SCO = MM_SOUND_DEVICE_OUT_BT_SCO, /**< Routing audio output to bluetooth SCO. */
2359 MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP = MM_SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */
2360 MM_SOUND_ROUTE_OUT_DOCK = MM_SOUND_DEVICE_OUT_DOCK, /**< Routing audio output to DOCK */
2361 MM_SOUND_ROUTE_OUT_HDMI = MM_SOUND_DEVICE_OUT_HDMI, /**< Routing audio output to HDMI */
2362 MM_SOUND_ROUTE_OUT_MIRRORING = MM_SOUND_DEVICE_OUT_MIRRORING, /**< Routing audio output to MIRRORING */
2363 MM_SOUND_ROUTE_OUT_USB_AUDIO = MM_SOUND_DEVICE_OUT_USB_AUDIO, /**< Routing audio output to USB Audio */
2364 MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK = MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Routing audio output to Multimedia DOCK */
2365 MM_SOUND_ROUTE_IN_MIC = MM_SOUND_DEVICE_IN_MIC, /**< Routing audio input to device builtin mic. */
2366 MM_SOUND_ROUTE_IN_WIRED_ACCESSORY = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY, /**< Routing audio input to wired accessory. */
2367 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*/
2368 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 */
2369 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 */
2370 MM_SOUND_ROUTE_INOUT_HEADSET = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY, /**< Routing audio input and output to headset*/
2371 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 */
2375 * MMSound Device APIs
2379 MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG = 0x0001, /**< Flag for input devices */
2380 MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG = 0x0002, /**< Flag for output devices */
2381 MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG = 0x0004, /**< Flag for input/output devices (both directions are available) */
2382 MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG = 0x0010, /**< Flag for built-in devices */
2383 MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG = 0x0020, /**< Flag for external devices */
2384 MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG = 0x1000, /**< Flag for deactivated devices */
2385 MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG = 0x2000, /**< Flag for activated devices */
2386 MM_SOUND_DEVICE_ALL_FLAG = 0xFFFF, /**< Flag for all devices */
2387 } mm_sound_device_flags_e;
2390 MM_SOUND_DEVICE_IO_DIRECTION_IN,
2391 MM_SOUND_DEVICE_IO_DIRECTION_OUT,
2392 MM_SOUND_DEVICE_IO_DIRECTION_BOTH,
2393 } mm_sound_device_io_direction_e;
2396 MM_SOUND_DEVICE_STATE_DEACTIVATED,
2397 MM_SOUND_DEVICE_STATE_ACTIVATED,
2398 } mm_sound_device_state_e;
2402 MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER, /**< Built-in speaker. */
2403 MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER, /**< Built-in receiver. */
2404 MM_SOUND_DEVICE_TYPE_BUILTIN_MIC, /**< Built-in mic. */
2405 MM_SOUND_DEVICE_TYPE_AUDIOJACK, /**< Audio jack such as headphone, headset, and so on. */
2406 MM_SOUND_DEVICE_TYPE_BLUETOOTH, /**< Bluetooth */
2407 MM_SOUND_DEVICE_TYPE_HDMI, /**< HDMI. */
2408 MM_SOUND_DEVICE_TYPE_MIRRORING, /**< MIRRORING. */
2409 MM_SOUND_DEVICE_TYPE_USB_AUDIO, /**< USB Audio. */
2410 } mm_sound_device_type_e;
2412 typedef void *MMSoundDevice_t; /**< MMsound Device handle */
2413 typedef void *MMSoundDeviceList_t; /**< MMsound Device list handle */
2414 typedef void (*mm_sound_device_connected_cb) (MMSoundDevice_t device_h, bool is_connected, void *user_data);
2415 typedef void (*mm_sound_device_info_changed_cb) (MMSoundDevice_t device_h, int changed_info_type, void *user_data);
2417 int mm_sound_add_device_connected_callback(mm_sound_device_flags_e flags, mm_sound_device_connected_cb func, void *user_data);
2418 int mm_sound_remove_device_connected_callback(void);
2419 int mm_sound_add_device_information_changed_callback(mm_sound_device_flags_e flags, mm_sound_device_info_changed_cb func, void *user_data);
2420 int mm_sound_remove_device_information_changed_callback(void);
2422 int mm_sound_get_current_device_list(mm_sound_device_flags_e device_mask, MMSoundDeviceList_t *device_list);
2423 int mm_sound_get_next_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
2424 int mm_sound_get_prev_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
2425 int mm_sound_get_device_type(MMSoundDevice_t device_h, mm_sound_device_type_e *type);
2426 int mm_sound_get_device_io_direction(MMSoundDevice_t device_h, mm_sound_device_io_direction_e *io_direction);
2427 int mm_sound_get_device_id(MMSoundDevice_t device_h, int *id);
2428 int mm_sound_get_device_state(MMSoundDevice_t device_h, mm_sound_device_state_e *state);
2429 int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name);
2431 /* below APIs are for product */
2432 typedef int (*mm_sound_available_route_cb)(mm_sound_route route, void *user_data);
2433 int mm_sound_is_route_available(mm_sound_route route, bool *is_available);
2434 int mm_sound_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data);
2435 int mm_sound_set_active_route(mm_sound_route route);
2436 int mm_sound_set_active_route_auto(void);
2440 * This function is to set active route without callback to client.
2442 * @param route [IN] route
2443 * @return This function returns MM_ERROR_NONE on success, or negative value
2448 * @see mm_sound_set_active_route_without_broadcast mm_sound_route
2450 int mm_sound_set_active_route_without_broadcast(mm_sound_route route);
2453 * This function is to get active playback device and capture device.
2455 * @param playback_device [out] playback device.
2456 * @param capture_device [out] capture device.
2458 * @return This function returns MM_ERROR_NONE on success, or negative value
2463 * @see mm_sound_set_active_route mm_sound_device_in mm_sound_device_out
2465 int mm_sound_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
2468 * Active device changed callback function type.
2470 * @param user_data [in] Argument passed when callback has called
2472 * @return No return value
2474 * @see mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
2476 typedef void (*mm_sound_active_device_changed_cb) (mm_sound_device_in device_in, mm_sound_device_out device_out, void *user_data);
2479 * This function is to add active device callback.
2481 * @param name [in] plugin name (name max size : MM_SOUND_NAME_NUM 32)
2482 * @param func [in] callback function pointer
2483 * @param user_data [in] user data passing to callback function
2485 * @return This function returns MM_ERROR_NONE on success, or negative value
2488 * @see mm_sound_remove_active_device_changed_callback mm_sound_active_device_changed_cb
2494 void __active_device_callback(void *user_data)
2496 printf("Callback function\n");
2499 int active_device_control()
2503 ret = mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
2504 if ( MM_ERROR_NONE != ret)
2506 printf("Can not add callback\n");
2510 printf("Add callback success\n");
2518 int mm_sound_add_active_device_changed_callback(const char *name,mm_sound_active_device_changed_cb func, void *user_data);
2520 * This function is to remove active device callback.
2522 * @param name [in] plugin name (name max size : MM_SOUND_NAME_NUM 32)
2523 * @return This function returns MM_ERROR_NONE on success, or negative value
2526 * @pre Active device callback should be registered.
2527 * @post Active device callback deregistered and does not be called anymore.
2528 * @see mm_sound_add_active_device_changed_callback mm_sound_active_device_changed_cb
2531 void __active_device_callback(void *data)
2533 printf("Callback function\n");
2536 int active_device_control()
2540 mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
2542 ret = mm_sound_remove_active_device_changed_callback();
2543 if ( MM_ERROR_NONE == ret)
2545 printf("Remove callback success\n");
2549 printf("Remove callback failed\n");
2557 int mm_sound_remove_active_device_changed_callback(const char *name);
2559 * Available route changed callback function type.
2561 * @param user_data [in] Argument passed when callback has called
2563 * @return No return value
2565 * @see mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
2567 typedef void (*mm_sound_available_route_changed_cb) (mm_sound_route route, bool available, void *user_data);
2570 * This function is to add available device callback.
2572 * @param func [in] callback function pointer
2573 * @param user_data [in] user data passing to callback function
2575 * @return This function returns MM_ERROR_NONE on success, or negative value
2578 * @see mm_sound_remove_available_route_changed_callback mm_sound_active_device_changed_cb
2584 void __available_device_callback(void *user_data)
2586 printf("Callback function\n");
2589 int available_device_control()
2593 ret = mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2594 if ( MM_ERROR_NONE != ret)
2596 printf("Can not add callback\n");
2600 printf("Add callback success\n");
2608 int mm_sound_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void *user_data);
2611 * This function is to remove available device callback.
2613 * @return This function returns MM_ERROR_NONE on success, or negative value
2616 * @pre available device callback should be registered.
2617 * @post available device callback deregistered and does not be called anymore.
2618 * @see mm_sound_add_available_route_changed_callback mm_sound_active_device_changed_cb
2621 void __available_device_callback(void *data)
2623 printf("Callback function\n");
2626 int available_device_control()
2630 mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2632 ret = mm_sound_remove_available_route_changed_callback();
2633 if ( MM_ERROR_NONE == ret)
2635 printf("Remove callback success\n");
2639 printf("Remove callback failed\n");
2647 int mm_sound_remove_available_route_changed_callback(void);
2650 * This function is to set path for active device.
2652 * @param device_out [in] active playback device
2653 * @param device_in [in] active capture device
2655 * @return This function returns MM_ERROR_NONE on success, or negative value
2663 int mm_sound_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in);
2666 * This function is to get current audio path.
2668 * @param device_out [in] active playback device
2669 * @param device_in [in] active capture device
2671 * @return This function returns MM_ERROR_NONE on success, or negative value
2680 int mm_sound_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
2690 #endif /* __MM_SOUND_H__ */