Get allocated device list and add deallocate interface
[platform/core/multimedia/libmm-sound.git] / include / mm_sound.h
1 /*
2  * libmm-sound
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Seungbae Shin <seungbae.shin@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22 /**
23  * @file                mm_sound.h
24  * @brief               Application interface library for sound module.
25  * @date
26  * @version             Release
27  *
28  * Application interface library for sound module.
29  */
30
31 #ifndef __MM_SOUND_H__
32 #define __MM_SOUND_H__
33
34 #include <mm_types.h>
35 #include <mm_error.h>
36 #include <mm_message.h>
37
38 #ifdef __cplusplus
39         extern "C" {
40 #endif
41
42 /**
43         @addtogroup SOUND
44         @{
45         @par
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.
49
50         @par
51         There is six different volume type for normal usage. application should set proper volume type to multimedia playback APIs.
52         <div> <table>
53         <tr>
54         <td><B>Type</B></td>
55         <td><B>Description</B></td>
56         </tr>
57         <tr>
58         <td>VOLUME_TYPE_SYSTEM</td>
59         <td>volume for normal system sound (e.g. keysound, camera shutter)</td>
60         </tr>
61         <tr>
62         <td>VOLUME_TYPE_NOTIFICATION</td>
63         <td>volume for notification (e.g. message, email notification)</td>
64         </tr>
65         <tr>
66         <td>VOLUME_TYPE_RINGTONE</td>
67         <td>volume for incoming call ring</td>
68         </tr>
69         <tr>
70         <td>VOLUME_TYPE_MEDIA</td>
71         <td>volume for media playback (e.g. music, video playback)</td>
72         </tr>
73         <tr>
74         <td>VOLUME_TYPE_CALL</td>
75         <td>volume for call</td>
76         </tr>
77         </table> </div>
78
79         @par
80         application can change audio route policy with mm-sound API.
81         Audio route is input and output of audio stream.
82
83         @par
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
86
87         @par
88         Default audio route policy is like follows
89         @par
90         for playback
91         <div><table>
92         <tr>
93         <td><B>Bluetooth headset</B></td>
94         <td><B>Wired headset</B></td>
95         <td><B>Playback Device</B></td>
96         </tr>
97         <tr>
98         <td>connected</td>
99         <td>plugged</td>
100         <td>Bluetooth headset</td>
101         </tr>
102         <tr>
103         <td>connected</td>
104         <td>unplugged</td>
105         <td>Bluetooth headset</td>
106         </tr>
107         <tr>
108         <td>disconnected</td>
109         <td>plugged</td>
110         <td>Wired headset</td>
111         </tr>
112         <tr>
113         <td>disconnected</td>
114         <td>unplugged</td>
115         <td>Loud speaker</td>
116         </tr>
117         </table></div>
118
119         @par
120         for capture (bluetooth headset mic used only in call mode)
121         <div><table>
122         <tr>
123         <td><B>Bluetooth headset mic</B></td>
124         <td><B>Wired headset mic</B></td>
125         <td><B>Capture Device</B></td>
126         </tr>
127         <tr>
128         <td>connected</td>
129         <td>plugged</td>
130         <td>Wired headset mic</td>
131         </tr>
132         <tr>
133         <td>connected</td>
134         <td>unplugged</td>
135         <td>microphone</td>
136         </tr>
137         <tr>
138         <td>disconnected</td>
139         <td>plugged</td>
140         <td>Wired headset mic</td>
141         </tr>
142         <tr>
143         <td>disconnected</td>
144         <td>unplugged</td>
145         <td>Wired headset mic</td>
146         </tr>
147         </table></div>
148
149         @par
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.
152         @par
153         for playback
154         <div><table>
155         <tr>
156         <td><B>Bluetooth headset</B></td>
157         <td><B>Wired headset</B></td>
158         <td><B>Playback Device</B></td>
159         </tr>
160         <tr>
161         <td>connected</td>
162         <td>plugged</td>
163         <td>Wired headset</td>
164         </tr>
165         <tr>
166         <td>connected</td>
167         <td>unplugged</td>
168         <td>Loud speaker</td>
169         </tr>
170         <tr>
171         <td>disconnected</td>
172         <td>plugged</td>
173         <td>Wired headset</td>
174         </tr>
175         <tr>
176         <td>disconnected</td>
177         <td>unplugged</td>
178         <td>Loud speaker</td>
179         </tr>
180         </table></div>
181
182         @par
183         for capture (bluetooth headset mic used only in call mode)
184         <div><table>
185         <tr>
186         <td><B>Bluetooth headset mic</B></td>
187         <td><B>Wired headset mic</B></td>
188         <td><B>Capture Device</B></td>
189         </tr>
190         <tr>
191         <td>connected</td>
192         <td>plugged</td>
193         <td>Wired headset mic</td>
194         </tr>
195         <tr>
196         <td>connected</td>
197         <td>unplugged</td>
198         <td>microphone</td>
199         </tr>
200         <tr>
201         <td>disconnected</td>
202         <td>plugged</td>
203         <td>Wired headset mic</td>
204         </tr>
205         <tr>
206         <td>disconnected</td>
207         <td>unplugged</td>
208         <td>Wired headset mic</td>
209         </tr>
210         </table></div>
211
212         @par
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.
215         @par
216         for playback
217         <div><table>
218         <tr>
219         <td><B>Bluetooth headset</B></td>
220         <td><B>Wired headset</B></td>
221         <td><B>Playback Device</B></td>
222         </tr>
223         <tr>
224         <td>connected</td>
225         <td>plugged</td>
226         <td>Loud speaker</td>
227         </tr>
228         <tr>
229         <td>connected</td>
230         <td>unplugged</td>
231         <td>Loud speaker</td>
232         </tr>
233         <tr>
234         <td>disconnected</td>
235         <td>plugged</td>
236         <td>Loud speaker</td>
237         </tr>
238         <tr>
239         <td>disconnected</td>
240         <td>unplugged</td>
241         <td>Loud speaker</td>
242         </tr>
243         </table></div>
244
245         @par
246         for capture (bluetooth headset mic used only in call mode)
247         <div><table>
248         <tr>
249         <td><B>Bluetooth headset mic</B></td>
250         <td><B>Wired headset mic</B></td>
251         <td><B>Capture Device</B></td>
252         </tr>
253         <tr>
254         <td>connected</td>
255         <td>plugged</td>
256         <td>microphone</td>
257         </tr>
258         <tr>
259         <td>connected</td>
260         <td>unplugged</td>
261         <td>microphone</td>
262         </tr>
263         <tr>
264         <td>disconnected</td>
265         <td>plugged</td>
266         <td>microphone</td>
267         </tr>
268         <tr>
269         <td>disconnected</td>
270         <td>unplugged</td>
271         <td>microphone</td>
272         </tr>
273         </table></div>
274
275  */
276 #define MM_SOUND_STREAM_TYPE_LEN 64
277
278 /*
279  * MMSound Volume APIs
280  */
281
282 /**
283  * Enumerations of Volume type.
284  */
285
286 typedef enum {
287         VOLUME_TYPE_SYSTEM,                             /**< System volume type */
288         VOLUME_TYPE_NOTIFICATION,               /**< Notification volume type */
289         VOLUME_TYPE_ALARM,                              /**< Alarm volume type */
290         VOLUME_TYPE_RINGTONE,                   /**< Ringtone volume type */
291         VOLUME_TYPE_MEDIA,                              /**< Media volume type */
292         VOLUME_TYPE_CALL,                               /**< Call volume type */
293         VOLUME_TYPE_VOIP,                               /**< VOIP volume type */
294         VOLUME_TYPE_VOICE,                              /**< VOICE volume type */
295         VOLUME_TYPE_FIXED,                              /**< Volume type for fixed acoustic level */
296         VOLUME_TYPE_MAX,                                /**< Volume type count */
297         VOLUME_TYPE_UNKNOWN = -1,       /**< volume type is not determined */
298 } volume_type_t;
299
300 typedef enum {
301         VOLUME_GAIN_DEFAULT             = 0,
302         VOLUME_GAIN_DIALER              = 1<<8,
303         VOLUME_GAIN_TOUCH               = 2<<8,
304         VOLUME_GAIN_AF                  = 3<<8,
305         VOLUME_GAIN_SHUTTER1    = 4<<8,
306         VOLUME_GAIN_SHUTTER2    = 5<<8,
307         VOLUME_GAIN_CAMCORDING  = 6<<8,
308         VOLUME_GAIN_MIDI                = 7<<8,
309         VOLUME_GAIN_BOOTING             = 8<<8,
310         VOLUME_GAIN_VIDEO               = 9<<8,
311         VOLUME_GAIN_TTS                 = 10<<8,
312 } volume_gain_t;
313
314 /**
315  * @brief Enumerations of supporting source_type
316  */
317 typedef enum {
318     SUPPORT_SOURCE_TYPE_DEFAULT,
319     SUPPORT_SOURCE_TYPE_MIRRORING,
320     SUPPORT_SOURCE_TYPE_VOICECONTROL,
321     SUPPORT_SOURCE_TYPE_SVR,
322     SUPPORT_SOURCE_TYPE_VIDEOCALL,
323     SUPPORT_SOURCE_TYPE_VOICERECORDING,
324     SUPPORT_SOURCE_TYPE_VOIP, /* Supporting VoIP source*/
325     SUPPORT_SOURCE_TYPE_CALL_FORWARDING,
326     SUPPORT_SOURCE_TYPE_FMRADIO,
327     SUPPORT_SOURCE_TYPE_LOOPBACK,
328 } mm_sound_source_type_e;
329
330 /**
331  * Volume change callback function type.
332  *
333  * @param       user_data               [in]    Argument passed when callback has called
334  *
335  * @return      No return value
336  * @remark      None.
337  * @see         mm_sound_volume_add_callback mm_sound_volume_remove_callback
338  */
339 typedef void (*volume_callback_fn)(void* user_data);
340
341 /**
342  * Active volume change callback function type.
343  *
344  * @param       type                    [in]    The sound type of changed volume
345  * @param       volume                  [in]    The new volume value
346  * @param       user_data               [in]    Argument passed when callback has called
347  *
348  * @return      No return value
349  * @remark      None.
350  * @see         mm_sound_add_volume_changed_callback mm_sound_remove_volume_changed_callback
351  */
352 typedef void (*mm_sound_volume_changed_cb) (volume_type_t type, unsigned int volume, void *user_data);
353
354
355 /**
356  * This function is to retrieve number of volume level.
357  *
358  * @param       type                    [in]    volume type to query
359  * @param       step                    [out]   number of volume steps
360  *
361  * @return      This function returns MM_ERROR_NONE on success, or negative value
362  *                      with error code.
363  * @remark      step means number of steps. so actual volume step can be 0 ~ step-1
364  * @see         volume_type_t
365  * @pre         None.
366  * @post        None.
367  * @par Example
368  * @code
369 int step = 0;
370 int ret = 0;
371 int max = 0;
372
373 ret = mm_sound_volume_get_step(VOLUME_TYPE_SYSTEM, &step);
374 if(ret < 0)
375 {
376         printf("Can not get volume step\n");
377 }
378 else
379 {
380         max = step - 1;
381         //set system volume to max value
382         mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, max);
383 }
384  * @endcode
385  */
386 int mm_sound_volume_get_step(volume_type_t type, int *step);
387
388
389 /**
390  * This function is to add volume changed callback.
391  *
392  * @param       type                    [in]    volume type to set change callback function
393  * @param       func                    [in]    callback function pointer
394  * @param       user_data               [in]    user data passing to callback function
395  *
396  * @return      This function returns MM_ERROR_NONE on success, or negative value
397  *                      with error code.
398  * @remark      Only one callback function per volume type will be registered.
399  *                      if you want to change callback function for certain volume type,
400  *                      remove callback first via mm_sound_volume_remove_callback().
401  * @see         volume_type_t volume_callback_fn
402  * @pre         There should be not be pre-registered callback fuction to given volume type.
403  * @post        Callback function will be registered to given volume type
404  * @par Example
405  * @code
406 volume_type_t g_vol_type = VOLUME_TYPE_MEDIA;
407
408 void _volume_callback(void *data)
409 {
410         unsigned int value = 0;
411         int result = 0;
412         volume_type_t *type = (volume_type_t*)data;
413
414         result = mm_sound_volume_get_value(*type, &value);
415         if(result == MM_ERROR_NONE)
416         {
417                 printf("Current volume value is %d\n", value);
418         }
419         else
420         {
421                 printf("Can not get volume\n");
422         }
423 }
424
425 int volume_control()
426 {
427         int ret = 0;
428
429         ret = mm_sound_volume_add_callback(g_vol_type, _volume_callback, (void*)&g_vol_type);
430         if ( MM_ERROR_NONE != ret)
431         {
432                 printf("Can not add callback\n");
433         }
434         else
435         {
436                 printf("Add callback success\n");
437         }
438
439         return 0;
440 }
441
442  * @endcode
443  */
444 int mm_sound_volume_add_callback(volume_type_t type, volume_callback_fn func, void* user_data);
445 int mm_sound_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data, unsigned int *subs_id);
446
447
448 /**
449  * This function is to remove volume changed callback.
450  *
451  * @param       type                    [in]    volume type to set change callback function
452  *
453  * @return      This function returns MM_ERROR_NONE on success, or negative value
454  *                      with error code.
455  * @remark      None.
456  * @pre         Callback function should be registered previously for given volume type.
457  * @post        Callback function will not be called anymore.
458  * @see         volume_type_t
459  * @par Example
460  * @code
461 void _volume_callback(void *data)
462 {
463         printf("Callback function\n");
464 }
465
466 int volume_callback()
467 {
468         int ret = 0;
469         int vol_type = VOLUME_TYPE_MEDIA;
470
471         mm_sound_volume_add_callback(vol_type, _volume_callback, NULL);
472
473         ret = mm_sound_volume_remove_callback(vol_type);
474         if ( MM_ERROR_NONE == ret)
475         {
476                 printf("Remove callback success\n");
477         }
478         else
479         {
480                 printf("Remove callback failed\n");
481         }
482
483         return ret;
484 }
485
486  * @endcode
487  */
488 int mm_sound_volume_remove_callback(volume_type_t type);
489
490 /**
491  * This function is to remove volume change callback.
492  *
493  * @return      This function returns MM_ERROR_NONE on success, or negative value
494  *                      with error code.
495  **/
496 int mm_sound_remove_volume_changed_callback(unsigned int subs_id);
497
498 /**
499  * This function is to set volume level of certain volume type.
500  *
501  * @param       type                    [in]    volume type to set value.
502  * @param       value                   [in]    volume value.
503  *
504  * @return      This function returns MM_ERROR_NONE on success, or negative value
505  *                      with error code.
506  * @remark      value should be 0 ~ mm_sound_volume_get_step() -1
507  * @see         mm_sound_volume_get_step, mm_sound_volume_get_value volume_type_t
508  * @pre         None.
509  * @post        Volume value will be changed to given value for given volume type.
510  * @par Example
511  * @code
512 int step = 0;
513 int ret = 0;
514 int max = 0;
515
516 ret = mm_sound_volume_get_step(VOLUME_TYPE_SYSTEM, &step);
517 if(ret < 0)
518 {
519         printf("Can not get volume step\n");
520 }
521 else
522 {
523         max = step - 1;
524         //set system volume to max value
525         ret = mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, max);
526         if(ret < 0)
527         {
528                 printf("Can not set volume value\n");
529         }
530 }
531  * @endcode
532  */
533 int mm_sound_volume_set_value(volume_type_t type, const unsigned int volume_level);
534
535
536 /**
537  * This function is to get volume level of certain volume type.
538  *
539  * @param       type                    [in]    volume type to get value.
540  * @param       value                   [out]   volume value.
541  *
542  * @return      This function returns MM_ERROR_NONE on success, or negative value
543  *                      with error code.
544  * @remark      None.
545  * @pre         None.
546  * @post        None.
547  * @see         volume_type_t mm_sound_volume_set_value
548  * @par Example
549  * @code
550 int value = 0;
551 int ret = 0;
552
553 ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
554 if(ret < 0)
555 {
556         printf("Can not get volume\n");
557 }
558 else
559 {
560         printf("System type volume is %d\n", value);
561 }
562  * @endcode
563  * @see         mm_sound_volume_set_value
564  */
565 int mm_sound_volume_get_value(volume_type_t type, unsigned int *value);
566
567
568
569 /**
570  * This function is to set primary volume type.
571  *
572  * @param       type                    [in]    volume type to set as primary volume type.
573  *
574  * @return      This function returns MM_ERROR_NONE on success, or negative value
575  *                      with error code.
576  * @remark      Application should use this function during foreground.
577  *                      Application should clear primary volume type by mm_sound_volume_primary_type_clear() when it goes background.
578  * @pre         None.
579  * @post        Volume app. will be update given volume type when H/W volume control key pressed.
580  * @see         mm_sound_volume_primary_type_clear volume_type_t
581  * @par Example
582  * @code
583 static int _resume(void *data)
584 {
585         int ret = 0;
586
587         ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_MEDIA);
588         if(ret < 0)
589         {
590                 printf("Can not set primary volume type\n");
591         }
592         ...
593 }
594
595 static int _pause(void* data)
596 {
597         int ret = 0;
598
599         ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_UNKNOWN);
600         if(ret < 0)
601         {
602                 printf("Can not clear primary volume type\n");
603         }
604         ...
605 }
606
607 int main()
608 {
609         ...
610         struct appcore_ops ops = {
611                 .create = _create,
612                 .terminate = _terminate,
613                 .pause = _pause,
614                 .resume = _resume,
615                 .reset = _reset,
616         };
617         ...
618         return appcore_efl_main(PACKAGE, ..., &ops);
619 }
620  * @endcode
621  */
622 int mm_sound_volume_primary_type_set(volume_type_t type);
623 int mm_sound_volume_primary_type_get(volume_type_t *type);
624 int mm_sound_volume_primary_type_clear(void);
625
626 int mm_sound_set_call_mute(volume_type_t type, int mute);
627 int mm_sound_get_call_mute(volume_type_t type, int *mute);
628
629 typedef enum {
630         MM_SOUND_FACTORY_MIC_TEST_STATUS_OFF = 0,
631         MM_SOUND_FACTORY_MIC_TEST_STATUS_MAIN_MIC,
632         MM_SOUND_FACTORY_MIC_TEST_STATUS_SUB_MIC,
633         MM_SOUND_FACTORY_MIC_TEST_STATUS_NUM,
634 } mm_sound_factory_mic_test_status_t;/* device in for factory mic test */
635
636 int mm_sound_set_factory_mic_test(mm_sound_factory_mic_test_status_t mic_test);
637
638 int mm_sound_get_factory_mic_test(mm_sound_factory_mic_test_status_t *mic_test);
639
640 typedef enum {
641         MMSOUND_DHA_OFF,
642         MMSOUND_DHA_SOFT_SOUND,
643         MMSOUND_DHA_CLEAR_SOUND,
644         MMSOUND_DHA_PERSNOL_LEFT,
645         MMSOUND_DHA_PERSNOL_RIGHT,
646         MMSOUND_DHA_INVALID,
647 } MMSoundDHAMode_t;
648
649
650
651 /*
652  * MMSound PCM APIs
653  */
654 typedef void*   MMSoundPcmHandle_t;     /**< MMsound PCM handle type */
655
656 /**
657  * Enumerations of Format used in MMSoundPcm operation.
658  */
659 typedef enum {
660         MMSOUND_PCM_U8 = 0x70, /**< unsigned 8bit audio */
661         MMSOUND_PCM_S16_LE,   /**< signed 16bit audio */
662 } MMSoundPcmFormat_t;
663
664 /**
665  * Enumerations of Channel count used in MMSoundPcm operation.
666  */
667 typedef enum {
668         MMSOUND_PCM_MONO = 0x80,        /**< Mono channel */
669         MMSOUND_PCM_STEREO,                     /**< Stereo channel */
670 }MMSoundPcmChannel_t;
671
672 /**
673  * Get audio stream latency value.
674  *
675  * @param       handle                  [in]    handle to get latency
676  * @param       latency                 [out]   Stream latency value(millisecond).
677  *
678  * @return      This function returns MM_ERROR_NONE on success, or negative value
679  *                      with error code.
680  * @remark
681  * @see
682  */
683 int mm_sound_pcm_get_latency(MMSoundPcmHandle_t handle, int *latency);
684
685 /**
686  * Get started status of pcm stream.
687  *
688  * @param       handle                  [in]    handle to check pcm start
689  * @param       is_started                      [out]   retrieve started status of pcm stream.
690  *
691  * @return      This function returns MM_ERROR_NONE on success, or negative value
692  *                      with error code.
693  * @remark
694  * @see
695  */
696 int mm_sound_pcm_is_started(MMSoundPcmHandle_t handle, bool *is_started);
697
698 int mm_sound_pcm_play_open_no_session(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config);
699
700 /**
701  * This function is to create handle for PCM playback.
702  *
703  * @param       handle                  [out] handle to play pcm data
704  * @param       rate                    [in] sample rate (8000Hz ~ 44100Hz)
705  * @param       channel                 [in] number of channels (mono or stereo)
706  * @param       format                  [in] S8 or S16LE
707  * @param       volume config   [in] Volume type & volume gain
708  *
709  * @return      This function returns suggested buffer size (in bytes) on success, or negative value
710  *                      with error code.
711  * @remark      use mm_sound_volume_set_value() function to change volume
712  * @see         mm_sound_pcm_play_write, mm_sound_pcm_play_close, mm_sound_volume_set_value, MMSoundPcmFormat_t, MMSoundPcmChannel_t volume_type_t
713  * @pre         None.
714  * @post        PCM play handle will be created.
715  * @par Example
716  * @code
717 #include <mm_sound.h>
718 #include <stdio.h>
719 #include <alloca.h>
720
721 int main(int argc, char* argv[])
722 {
723         FILE *fp = NULL;
724         char *buffer = NULL;
725         int ret = 0;
726         int size = 0;
727         int readed = 0;
728         MMSoundPcmHandle_t handle;
729         char *filename = NULL;
730
731         if(argc !=2 )
732         {
733                 printf("Usage) %s filename\n", argv[0]);
734                 return -1;
735         }
736         filename = argv[1];
737
738         fp = fopen(filename,"r");
739         if(fp ==NULL)
740         {
741                 printf("Can not open file %s\n", filename);
742                 return -1;
743         }
744
745         size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
746         if(size < 0)
747         {
748                 printf("Can not open playback handle\n");
749                 return -2;
750         }
751
752         buffer = alloca(size);
753         while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
754         {
755                 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
756                 if(ret < 0)
757                 {
758                         printf("write fail\n");
759                         break;
760                 }
761                 memset(buffer, '\0', sizeof(buffer));
762         }
763
764         fclose(fp);
765         mm_sound_pcm_play_close(handle);
766         return 0;
767 }
768  * @endcode
769  */
770 int mm_sound_pcm_play_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config);
771
772 /**
773  * This function start pcm playback
774  *
775  * @param       handle  [in] handle to start playback
776  *
777  * @return      This function returns MM_ERROR_NONE on success, or negative value
778  *                      with error code.
779  * @remark
780  * @see
781  * @pre         PCM playback handle should be allocated.
782  * @post        PCM playback is ready to write.
783  */
784 int mm_sound_pcm_play_start(MMSoundPcmHandle_t handle);
785
786 /**
787  * This function stop pcm playback
788  *
789  * @param       handle  [in] handle to stop playback
790  *
791  * @return      This function returns MM_ERROR_NONE on success, or negative value
792  *                      with error code.
793  * @remark
794  * @see
795  * @pre         PCM playback handle should be allocated.
796  * @post        PCM playback data will not be buffered.
797  */
798 int mm_sound_pcm_play_stop(MMSoundPcmHandle_t handle);
799
800 /**
801  * This function flush pcm playback
802  *
803  * @param       handle  [in] handle to flush playback
804  *
805  * @return      This function returns MM_ERROR_NONE on success, or negative value
806  *                      with error code.
807  * @remark
808  * @see
809  * @pre         PCM playback handle should be allocated.
810  * @post        PCM playback data will not be buffered.
811  */
812 int mm_sound_pcm_play_drain(MMSoundPcmHandle_t handle);
813
814 /**
815  * This function flush pcm playback
816  *
817  * @param       handle  [in] handle to flush playback
818  *
819  * @return      This function returns MM_ERROR_NONE on success, or negative value
820  *                      with error code.
821  * @remark
822  * @see
823  * @pre         PCM playback handle should be allocated.
824  * @post        PCM playback data will not be buffered.
825  */
826 int mm_sound_pcm_play_flush(MMSoundPcmHandle_t handle);
827
828 /**
829  * This function is to play PCM memory buffer.
830  *
831  * @param       handle  [in] handle to play pcm data
832  * @param       ptr             [in] pcm buffer address
833  * @param       length_byte     [in] size of pcm buffer (in bytes)
834  *
835  * @return      This function returns written data size on success, or negative value
836  *                      with error code.
837  * @remark      Make pcm buffer size with returned value of mm_sound_pcm_play_open()
838  * @see         mm_sound_pcm_play_open, mm_sound_pcm_play_close
839  * @pre         PCM play handle should be created.
840  * @post        Sound will be generated with given PCM buffer data.
841  * @par Example
842  * @code
843 #include <mm_sound.h>
844 #include <stdio.h>
845 #include <alloca.h>
846
847 int main(int argc, char* argv[])
848 {
849         FILE *fp = NULL;
850         char *buffer = NULL;
851         int ret = 0;
852         int size = 0;
853         int readed = 0;
854         MMSoundPcmHandle_t handle;
855         char *filename = NULL;
856
857         if(argc !=2 )
858         {
859                 printf("Usage) %s filename\n", argv[0]);
860                 return -1;
861         }
862         filename = argv[1];
863
864         fp = fopen(filename,"r");
865         if(fp ==NULL)
866         {
867                 printf("Can not open file %s\n", filename);
868                 return -1;
869         }
870
871         size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
872         if(size < 0)
873         {
874                 printf("Can not open playback handle\n");
875                 return -2;
876         }
877
878         buffer = alloca(size);
879         while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
880         {
881                 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
882                 if(ret < 0)
883                 {
884                         printf("write fail\n");
885                         break;
886                 }
887                 memset(buffer, '\0', sizeof(buffer));
888         }
889
890         fclose(fp);
891         mm_sound_pcm_play_close(handle);
892         return 0;
893 }
894  * @endcode
895  */
896 int mm_sound_pcm_play_write(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte);
897
898
899
900 /**
901  * This function is to close PCM memory playback handle
902  *
903  * @param       handle  [in] handle to play pcm data
904  *
905  * @return      This function returns MM_ERROR_NONE on success, or negative value
906  *                      with error code.
907  * @remark      None
908  * @see         mm_sound_pcm_play_open, mm_sound_pcm_play_write
909  * @pre         PCM play handle should be created
910  * @post        PCM play handle will be terminated.
911  * @par Example
912  * @code
913 #include <mm_sound.h>
914 #include <stdio.h>
915 #include <alloca.h>
916
917 int main(int argc, char* argv[])
918 {
919         FILE *fp = NULL;
920         char *buffer = NULL;
921         int ret = 0;
922         int size = 0;
923         int readed = 0;
924         MMSoundPcmHandle_t handle;
925         char *filename = NULL;
926
927         if(argc !=2 )
928         {
929                 printf("Usage) %s filename\n", argv[0]);
930                 return -1;
931         }
932         filename = argv[1];
933
934         fp = fopen(filename,"r");
935         if(fp ==NULL)
936         {
937                 printf("Can not open file %s\n", filename);
938                 return -1;
939         }
940
941         size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
942         if(size < 0)
943         {
944                 printf("Can not open playback handle\n");
945                 return -2;
946         }
947
948         buffer = alloca(size);
949         while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
950         {
951                 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
952                 if(ret < 0)
953                 {
954                         printf("write fail\n");
955                         break;
956                 }
957                 memset(buffer, '\0', sizeof(buffer));
958         }
959
960         fclose(fp);
961         mm_sound_pcm_play_close(handle);
962         return 0;
963 }
964  * @endcode
965  */
966 int mm_sound_pcm_play_close(MMSoundPcmHandle_t handle);
967
968 /**
969  * This function is to ignore session for playback
970  *
971  * @param       handle  [in] handle to play pcm data
972  *
973  * @return      This function returns MM_ERROR_NONE on success, or negative value
974  *                      with error code.
975  * @remark      This function only works for not started pcm handle and can't be reversed.
976  * @see
977  * @pre         PCM play handle should be created and not started.
978  * @post        PCM play session will be set to mix.
979  */
980 int mm_sound_pcm_play_ignore_session(MMSoundPcmHandle_t *handle);
981
982 /**
983  * This function is to create handle for PCM capture.
984  *
985  * @param       handle  [out] handle to capture pcm data
986  * @param       rate    [in] sample rate (8000Hz ~ 44100Hz)
987  * @param       channel [in] number of channels (mono or stereo)
988  * @param       format  [in] S8 or S16LE
989  *
990  * @return      This function returns suggested buffer size (in bytes) on success, or negative value
991  *                      with error code.
992  * @remark      only mono channel is valid for now.
993  * @see         mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
994  * @pre         None.
995  * @post        PCM capture handle will be allocated.
996  * @par Example
997  * @code
998 #include <mm_sound.h>
999 #include <stdio.h>
1000 #include <alloca.h>
1001
1002 int main(int argc, char* argv[])
1003 {
1004         FILE *fp = NULL;
1005         char *buffer = NULL;
1006         int ret = 0;
1007         int size = 0;
1008         int count = 0;
1009         MMSoundPcmHandle_t handle;
1010         char *filename = NULL;
1011
1012         if(argc !=2 )
1013         {
1014                 printf("Usage) %s filename\n", argv[0]);
1015                 return -1;
1016         }
1017         filename = argv[1];
1018
1019         fp = fopen(filename,"w");
1020         if(fp ==NULL)
1021         {
1022                 printf("Can not open file %s\n", filename);
1023                 return -1;
1024         }
1025
1026         size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1027         if(size < 0)
1028         {
1029                 printf("Can not open capture handle\n");
1030                 return -2;
1031         }
1032
1033         buffer = alloca(size);
1034         while(1)
1035         {
1036                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1037                 if(ret < 0)
1038                 {
1039                         printf("read fail\n");
1040                         break;
1041                 }
1042                 fwrite(buffer, ret, sizeof(char), fp);
1043                 if(count++ > 20) {
1044                         break;
1045                 }
1046         }
1047
1048         fclose(fp);
1049         mm_sound_pcm_capture_close(handle);
1050         return 0;
1051 }
1052
1053  * @endcode
1054  */
1055 int mm_sound_pcm_capture_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format);
1056
1057 /**
1058  * This function is to create handle for PCM capture of source_type.
1059  *
1060  * @param       handle  [out] handle to capture pcm data
1061  * @param       rate    [in] sample rate (8000Hz ~ 44100Hz)
1062  * @param       channel [in] number of channels (mono or stereo)
1063  * @param       format  [in] S8 or S16LE
1064  * @param       source_type             [in]  The source_type,mm_sound_source_type_e
1065  *
1066  * @return      This function returns suggested buffer size (in bytes) on success, or negative value
1067  *                      with error code.
1068  * @remark      only mono channel is valid for now.
1069  * @see         mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
1070  * @pre         None.
1071  * @post        PCM capture handle will be allocated.
1072  * @par Example
1073  * @code
1074 #include <mm_sound.h>
1075 #include <stdio.h>
1076 #include <alloca.h>
1077
1078 int main(int argc, char* argv[])
1079 {
1080         FILE *fp = NULL;
1081         char *buffer = NULL;
1082         int ret = 0;
1083         int size = 0;
1084         int count = 0;
1085         MMSoundPcmHandle_t handle;
1086         char *filename = NULL;
1087
1088         if(argc !=2 )
1089         {
1090                 printf("Usage) %s filename\n", argv[0]);
1091                 return -1;
1092         }
1093         filename = argv[1];
1094
1095         fp = fopen(filename,"w");
1096         if(fp ==NULL)
1097         {
1098                 printf("Can not open file %s\n", filename);
1099                 return -1;
1100         }
1101
1102         size = mm_sound_pcm_capture_open_ex(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE,1);
1103         if(size < 0)
1104         {
1105                 printf("Can not open capture handle\n");
1106                 return -2;
1107         }
1108
1109         buffer = alloca(size);
1110         while(1)
1111         {
1112                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1113                 if(ret < 0)
1114                 {
1115                         printf("read fail\n");
1116                         break;
1117                 }
1118                 fwrite(buffer, ret, sizeof(char), fp);
1119                 if(count++ > 20) {
1120                         break;
1121                 }
1122         }
1123
1124         fclose(fp);
1125         mm_sound_pcm_capture_close(handle);
1126         return 0;
1127 }
1128
1129  * @endcode
1130  */
1131 int mm_sound_pcm_capture_open_ex(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, mm_sound_source_type_e source_type);
1132
1133 /**
1134  * This function start pcm capture
1135  *
1136  * @param       handle  [in] handle to start capture
1137  *
1138  * @return      This function returns read data size on success, or negative value
1139  *                      with error code.
1140  * @remark
1141  * @see
1142  * @pre         PCM capture handle should be allocated.
1143  * @post        PCM capture data will be buffered.
1144  */
1145 int mm_sound_pcm_capture_start(MMSoundPcmHandle_t handle);
1146
1147 /**
1148  * This function stop pcm capture
1149  *
1150  * @param       handle  [in] handle to stop capture
1151  *
1152  * @return      This function returns read data size on success, or negative value
1153  *                      with error code.
1154  * @remark
1155  * @see
1156  * @pre         PCM capture handle should be allocated.
1157  * @post        PCM capture data will not be buffered.
1158  */
1159 int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle);
1160
1161 /**
1162  * This function flush pcm capture
1163  *
1164  * @param       handle  [in] handle to flush capture
1165  *
1166  * @return      This function returns MM_ERROR_NONE on success, or negative value
1167  *                      with error code.
1168  * @remark
1169  * @see
1170  * @pre         PCM capture handle should be allocated.
1171  * @post        PCM capture data will not be buffered.
1172  */
1173 int mm_sound_pcm_capture_flush(MMSoundPcmHandle_t handle);
1174
1175 /**
1176  * This function captures PCM to memory buffer. (Samsung extension)
1177  *
1178  * @param       handle  [in] handle to play pcm data
1179  * @param       buffer  [in] pcm buffer address
1180  * @param       length  [in] size of pcm buffer (in bytes)
1181  *
1182  * @return      This function returns read data size on success, or negative value
1183  *                      with error code.
1184  * @remark      Make pcm buffer size with returned value of mm_sound_pcm_capture_open()
1185  * @see         mm_sound_pcm_capture_open, mm_sound_pcm_capture_close
1186  * @pre         PCM capture handle should be allcated.
1187  * @post        PCM data will be filled to given memory pointer.
1188  * @par Example
1189  * @code
1190 #include <mm_sound.h>
1191 #include <stdio.h>
1192 #include <alloca.h>
1193
1194 int main(int argc, char* argv[])
1195 {
1196         FILE *fp = NULL;
1197         char *buffer = NULL;
1198         int ret = 0;
1199         int size = 0;
1200         int count = 0;
1201         MMSoundPcmHandle_t handle;
1202         char *filename = NULL;
1203
1204         if(argc !=2 )
1205         {
1206                 printf("Usage) %s filename\n", argv[0]);
1207                 return -1;
1208         }
1209         filename = argv[1];
1210
1211         fp = fopen(filename,"w");
1212         if(fp ==NULL)
1213         {
1214                 printf("Can not open file %s\n", filename);
1215                 return -1;
1216         }
1217
1218         size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1219         if(size < 0)
1220         {
1221                 printf("Can not open capture handle\n");
1222                 return -2;
1223         }
1224
1225         buffer = alloca(size);
1226         while(1)
1227         {
1228                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1229                 if(ret < 0)
1230                 {
1231                         printf("read fail\n");
1232                         break;
1233                 }
1234                 fwrite(buffer, ret, sizeof(char), fp);
1235                 if(count++ > 20) {
1236                         break;
1237                 }
1238         }
1239
1240         fclose(fp);
1241         mm_sound_pcm_capture_close(handle);
1242         return 0;
1243 }
1244
1245  * @endcode
1246  */
1247 int mm_sound_pcm_capture_read(MMSoundPcmHandle_t handle, void *buffer, const unsigned int length );
1248
1249 /**
1250  * This function captures PCM memory to memory buffer (Samsung extension)
1251  *
1252  * @param       handle  [in] handle to capture pcm data
1253  *
1254  * @return      This function returns MM_ERROR_NONE on success, or negative value
1255  *                      with error code.
1256  * @remark      None.
1257  * @see         mm_sound_pcm_capture_open, mm_sound_pcm_capture_read
1258  * @pre         PCM capture handle should be opend.
1259  * @post        PCM capture handle will be freed.
1260  * @par Example
1261  * @code
1262 #include <mm_sound.h>
1263 #include <stdio.h>
1264 #include <alloca.h>
1265
1266 int main(int argc, char* argv[])
1267 {
1268         FILE *fp = NULL;
1269         char *buffer = NULL;
1270         int ret = 0;
1271         int size = 0;
1272         int count = 0;
1273         MMSoundPcmHandle_t handle;
1274         char *filename = NULL;
1275
1276         if(argc !=2 )
1277         {
1278                 printf("Usage) %s filename\n", argv[0]);
1279                 return -1;
1280         }
1281         filename = argv[1];
1282
1283         fp = fopen(filename,"w");
1284         if(fp ==NULL)
1285         {
1286                 printf("Can not open file %s\n", filename);
1287                 return -1;
1288         }
1289
1290         size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1291         if(size < 0)
1292         {
1293                 printf("Can not open capture handle\n");
1294                 return -2;
1295         }
1296
1297         buffer = alloca(size);
1298         while(1)
1299         {
1300                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1301                 if(ret < 0)
1302                 {
1303                         printf("read fail\n");
1304                         break;
1305                 }
1306                 fwrite(buffer, ret, sizeof(char), fp);
1307                 if(count++ > 20) {
1308                         break;
1309                 }
1310         }
1311
1312         fclose(fp);
1313         mm_sound_pcm_capture_close(handle);
1314         return 0;
1315 }
1316
1317  * @endcode
1318  */
1319 int mm_sound_pcm_capture_close(MMSoundPcmHandle_t handle);
1320
1321 /**
1322  * This function is to ignore session for capture
1323  *
1324  * @param       handle  [in] handle to capture pcm data
1325  *
1326  * @return      This function returns MM_ERROR_NONE on success, or negative value
1327  *                      with error code.
1328  * @remark      This function only works for not started pcm handle and can't be reversed.
1329  * @see
1330  * @pre         PCM capture handle should be created and not started.
1331  * @post        PCM capture session will be set to mix.
1332  */
1333 int mm_sound_pcm_capture_ignore_session(MMSoundPcmHandle_t *handle);
1334
1335 /**
1336  * This function sets callback function for receiving messages from pcm API.
1337  *
1338  * @param       handle          [in]    Handle of pcm.
1339  * @param       callback        [in]    Message callback function.
1340  * @param       user_param      [in]    User parameter which is passed to callback function.
1341  *
1342  * @return      This function returns MM_ERROR_NONE on success, or negative value with error code.
1343  * @see         MMMessageCallback
1344  * @remark      None
1345  * @par Example
1346  * @code
1347 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1348 {
1349         switch (message)
1350         {
1351                 case MM_MESSAGE_SOUND_PCM_CAPTURE_RESTRICTED:
1352                         //do something
1353                         break;
1354
1355                 case MM_MESSAGE_SOUND_PCM_INTERRUPTED:
1356                         //do something
1357                         break;
1358
1359                 default:
1360                         break;
1361         }
1362         return TRUE;
1363 }
1364
1365 mm_sound_pcm_set_message_callback(pcmHandle, msg_callback, (void *)pcmHandle);
1366  * @endcode
1367  */
1368 int mm_sound_pcm_set_message_callback (MMSoundPcmHandle_t handle, MMMessageCallback callback, void *user_param);
1369
1370 /**
1371  * Terminate callback function type.
1372  *
1373  * @param       data            [in]    Argument passed when callback was set
1374  * @param       id              [in]    handle which has completed playing
1375  *
1376  * @return      No return value
1377  * @remark      It is not allowed to call MMSound API recursively or do time-consuming
1378  *                      task in this callback because this callback is called synchronously.
1379  * @see         mm_sound_play_sound
1380  */
1381 typedef void (*mm_sound_stop_callback_func) (void *data, int id);
1382
1383 /*
1384  * MMSound Play APIs
1385  */
1386
1387 /**
1388  * This function is to play system sound.
1389  *
1390  * @param       filename                [in] Sound filename to play
1391  * @param       volume config   [in] Volume type & volume gain
1392  * @param       callback                [in] Callback function pointer when playing is terminated.
1393  * @param       data                    [in] Pointer to user data when callback is called.
1394  * @param       handle                  [out] Handle of sound play.
1395  *
1396  * @return      This function returns MM_ERROR_NONE on success, or negative value
1397  *                      with error code.
1398  * @remark      When the stop callback is set, it will be called when system sound is
1399  *                      terminated. If mm_sound_stop_sound() is called apparently before
1400  *                      system sound is terminated, stop_callback will not be called.
1401  * @see         mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1402  * @pre         None.
1403  * @post        Sound will be generated with given filename.
1404  * @par Example
1405  * @code
1406 int g_stop=0;
1407 void _stop_callback(void* data)
1408 {
1409         printf("Stop callback\n");
1410         g_stop = 1;
1411 }
1412
1413 int play_file()
1414 {
1415         char filename[] ="/opt/media/Sound/testfile.wav";
1416         volume_type_t volume = VOLUME_TYPE_SYSTEM;
1417         int ret = 0;
1418         int handle = -1;
1419
1420         ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1421         if(ret < 0)
1422         {
1423                 printf("play file failed\n");
1424         }
1425         else
1426         {
1427                 printf("play file success\n");
1428         }
1429         while(g_stop == 0)
1430         {
1431                 sleep(1);
1432         }
1433         printf("play stopped\n");
1434         return 0;
1435 }
1436  * @endcode
1437  */
1438 int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1439
1440 int mm_sound_play_sound_without_session(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1441
1442 int mm_sound_play_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1443
1444 /**
1445  * This function is to play system sound. And other audio stream will be mute during playing time
1446  *
1447  * @param       filename                [in] Sound filename to play
1448  * @param       volume config   [in] Volume type & volume gain
1449  * @param       callback                [in] Callback function pointer when playing is terminated.
1450  * @param       data                    [in] Pointer to user data when callback is called.
1451  * @param       handle                  [out] Handle of sound play.
1452  *
1453  * @return      This function returns MM_ERROR_NONE on success, or negative value
1454  *                      with error code.
1455  * @remark      This function is almost same with mm_sound_play_sound,
1456  *                      but this make other audio playback stream to mute during playing time.
1457  * @see         mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1458  * @pre         None.
1459  * @post        Sound will be generated with given filename.
1460  * @par Example
1461  * @code
1462 int g_stop=0;
1463 void _stop_callback(void* data)
1464 {
1465         printf("Stop callback\n");
1466         g_stop = 1;
1467 }
1468
1469 int play_file()
1470 {
1471         char filename[] ="/opt/media/Sound/testfile.wav";
1472         volume_type_t volume = VOLUME_TYPE_SYSTEM;
1473         int ret = 0;
1474         int handle = -1;
1475
1476         ret = mm_sound_play_loud_solo_sound(filename, volume, _stop_callback, NULL, &handle);
1477         if(ret < 0)
1478         {
1479                 printf("play file failed\n");
1480         }
1481         else
1482         {
1483                 printf("play file success\n");
1484         }
1485         while(g_stop == 0)
1486         {
1487                 sleep(1);
1488         }
1489         printf("play stopped\n");
1490         return 0;
1491 }
1492  * @endcode
1493  */
1494 int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1495
1496 int mm_sound_play_loud_solo_sound_no_restore(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1497
1498 /**
1499  * This function is to stop playing system sound.
1500  *
1501  * @param       handle  [in] Handle of mm_sound_play_sound
1502  *
1503  * @return      This function returns MM_ERROR_NONE on success, or negative value
1504  *                      with error code.
1505  *
1506  * @remark      When system sound is terminated with this function call, it does not
1507  *                      call stop callback which was set when start playing system sound.
1508  * @see         mm_sound_play_sound
1509  * @pre         An sound play handle should be valid.
1510  * @post        Playing sound file will be stopped.
1511  * @par Example
1512  * @code
1513 int g_stop=0;
1514 void _stop_callback(void* data)
1515 {
1516         printf("Stop callback\n");
1517         g_stop = 1;
1518 }
1519
1520 int play_file_one_second()
1521 {
1522         char filename[] ="/opt/media/Sound/testfile.wav";
1523         volume_type_t volume = VOLUME_TYPE_SYSTEM;
1524         int ret = 0;
1525         int handle = -1;
1526
1527         ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1528         if(ret < 0)
1529         {
1530                 printf("play file failed\n");
1531         }
1532         else
1533         {
1534                 printf("play file success\n");
1535         }
1536
1537         sleep(1); //wait 1 second
1538
1539         ret = mm_sound_stop_sound(handle);
1540         if(ret < 0)
1541         {
1542                 printf("stop failed\n");
1543         }
1544         else
1545         {
1546                 printf("play stopped\n");
1547         }
1548         return 0;
1549 }
1550  * @endcode
1551  */
1552 int mm_sound_stop_sound(int handle);
1553
1554
1555 /**
1556  * Enumerations for TONE
1557  */
1558
1559 typedef enum  {
1560         MM_SOUND_TONE_DTMF_0 = 0,                       /**< Predefined DTMF 0 */
1561         MM_SOUND_TONE_DTMF_1,                           /**< Predefined DTMF 1 */
1562         MM_SOUND_TONE_DTMF_2,                           /**< Predefined DTMF 2 */
1563         MM_SOUND_TONE_DTMF_3,                           /**< Predefined DTMF 3 */
1564         MM_SOUND_TONE_DTMF_4,                           /**< Predefined DTMF 4 */
1565         MM_SOUND_TONE_DTMF_5,                           /**< Predefined DTMF 5 */
1566         MM_SOUND_TONE_DTMF_6,                           /**< Predefined DTMF 6 */
1567         MM_SOUND_TONE_DTMF_7,                           /**< Predefined DTMF 7 */
1568         MM_SOUND_TONE_DTMF_8,                           /**< Predefined DTMF 8 */
1569         MM_SOUND_TONE_DTMF_9,                           /**< Predefined DTMF 9 */
1570         MM_SOUND_TONE_DTMF_S,                           /**< Predefined DTMF Star - Asterisk (*) */
1571         MM_SOUND_TONE_DTMF_P,                           /**< Predefined DTMF sharP (#) */
1572         MM_SOUND_TONE_DTMF_A,                           /**< Predefined DTMF A (A) */
1573         MM_SOUND_TONE_DTMF_B,                           /**< Predefined DTMF B (B) */
1574         MM_SOUND_TONE_DTMF_C,                           /**< Predefined DTMF C (C) */
1575         MM_SOUND_TONE_DTMF_D,                           /**< Predefined DTMF D (D) */
1576
1577         /**< Pre-defined TONE */
1578         MM_SOUND_TONE_SUP_DIAL,                                 /**Call supervisory tone, Dial tone: CEPT: 425Hz, continuous */
1579         MM_SOUND_TONE_ANSI_DIAL,                                /**Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous */
1580         MM_SOUND_TONE_JAPAN_DIAL,                               /**Call supervisory tone, Dial tone: JAPAN: 400Hz, continuous*/
1581         MM_SOUND_TONE_SUP_BUSY,                         /**Call supervisory tone, Busy: CEPT: 425Hz, 500ms ON, 500ms OFF... */
1582         MM_SOUND_TONE_ANSI_BUSY,                                /**Call supervisory tone, Busy: ANSI (IS-95): 480Hz+620Hz, 500ms ON, 500ms OFF... */
1583         MM_SOUND_TONE_JAPAN_BUSY,                               /**Call supervisory tone, Busy: JAPAN: 400Hz, 500ms ON, 500ms OFF...*/
1584         MM_SOUND_TONE_SUP_CONGESTION,           /**Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF */
1585         MM_SOUND_TONE_ANSI_CONGESTION,          /**Call supervisory tone, Congestion: ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF... */
1586         MM_SOUND_TONE_SUP_RADIO_ACK,                    /**Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON  */
1587         MM_SOUND_TONE_JAPAN_RADIO_ACK,          /**Call supervisory tone, Radio path acknowlegment : JAPAN: 400Hz, 1s ON, 2s OFF...*/
1588         MM_SOUND_TONE_SUP_RADIO_NOTAVAIL,               /**Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts */
1589         MM_SOUND_TONE_SUP_ERROR,                                /**Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF... */
1590         MM_SOUND_TONE_SUP_CALL_WAITING,         /**Call supervisory tone, Call Waiting: CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF...  */
1591         MM_SOUND_TONE_ANSI_CALL_WAITING,                /**Call supervisory tone, Call Waiting: ANSI (IS-95): 440 Hz, 300 ms ON, 9.7 s OFF, (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...) */
1592         MM_SOUND_TONE_SUP_RINGTONE,                     /**Call supervisory tone, Ring Tone: CEPT, JAPAN: 425Hz, 1s ON, 4s OFF... */
1593         MM_SOUND_TONE_ANSI_RINGTONE,                    /**Call supervisory tone, Ring Tone: ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF... */
1594         MM_SOUND_TONE_PROP_BEEP,                                /**General beep: 400Hz+1200Hz, 35ms ON */
1595         MM_SOUND_TONE_PROP_ACK,                                 /**Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts */
1596         MM_SOUND_TONE_PROP_NACK,                                /**Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON */
1597         MM_SOUND_TONE_PROP_PROMPT,                      /**Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON         */
1598         MM_SOUND_TONE_PROP_BEEP2,                               /**Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON */
1599         MM_SOUND_TONE_SUP_INTERCEPT,                                            /**Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms */
1600         MM_SOUND_TONE_SUP_INTERCEPT_ABBREV,                             /**Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds */
1601         MM_SOUND_TONE_SUP_CONGESTION_ABBREV,                            /**Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds */
1602         MM_SOUND_TONE_SUP_CONFIRM,                                              /**Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone repeated 3 times in a 100 ms on, 100 ms off cycle */
1603         MM_SOUND_TONE_SUP_PIP,                                                  /**Call supervisory tone (IS-95), pip tone: four bursts of 480 Hz tone (0.1 s on, 0.1 s off). */
1604         MM_SOUND_TONE_CDMA_DIAL_TONE_LITE,                              /**425Hz continuous */
1605         MM_SOUND_TONE_CDMA_NETWORK_USA_RINGBACK,                /**CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...*/
1606         MM_SOUND_TONE_CDMA_INTERCEPT,                                   /**CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...*/
1607         MM_SOUND_TONE_CDMA_ABBR_INTERCEPT,                              /**CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON */
1608         MM_SOUND_TONE_CDMA_REORDER,                                             /**CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF... */
1609         MM_SOUND_TONE_CDMA_ABBR_REORDER,                                /**CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times */
1610         MM_SOUND_TONE_CDMA_NETWORK_BUSY,                                /**CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous */
1611         MM_SOUND_TONE_CDMA_CONFIRM,                                             /**CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times */
1612         MM_SOUND_TONE_CDMA_ANSWER,                                              /**CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF */
1613         MM_SOUND_TONE_CDMA_NETWORK_CALLWAITING,                         /**CDMA Network Callwaiting tone: 440Hz 300ms ON */
1614         MM_SOUND_TONE_CDMA_PIP,                                                         /**CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times */
1615         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL,             /**ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times, 2091 32ms ON, 2556 48ms ON, 4s OFF */
1616         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP,         /**ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times, 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 8times, 2091Hz 32ms ON, 4s OFF.*/
1617         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI,             /**ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times, 2091Hz 16ms ON, 200ms OFF */
1618         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT3,               /**SDN Call sign PAT3 tone: silent tone */
1619         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING,  /**ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON */
1620         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT5,               /**ISDN Pat5 tone: silent tone */
1621         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT6,               /**ISDN Pat6 tone: silent tone */
1622         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT7,               /**ISDN Pat7 tone: silent tone */
1623         MM_SOUND_TONE_CDMA_HIGH_L,                                              /**TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1624         MM_SOUND_TONE_CDMA_MED_L,                                               /**TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1625         MM_SOUND_TONE_CDMA_LOW_L,                                               /**TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, 4000ms OFF, Repeat .... */
1626         MM_SOUND_TONE_CDMA_HIGH_SS,                                             /**CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1627         MM_SOUND_TONE_CDMA_MED_SS,                                              /**CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1628         MM_SOUND_TONE_CDMA_LOW_SS,                                              /**CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1629         MM_SOUND_TONE_CDMA_HIGH_SSL,                                            /**CDMA HIGH SSL tone: {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
1630         MM_SOUND_TONE_CDMA_MED_SSL,                                             /**CDMA MED SSL tone: {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
1631         MM_SOUND_TONE_CDMA_LOW_SSL,                                             /**CDMA LOW SSL tone: {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
1632         MM_SOUND_TONE_CDMA_HIGH_SS_2,                                   /**CDMA HIGH SS2 tone: {3700Hz 25ms, 4000Hz 25ms} 20 times, 1000ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 3000ms OFF, repeat .... */
1633         MM_SOUND_TONE_CDMA_MED_SS_2,                                            /**CDMA MED SS2 tone: {2600Hz 25ms, 2900Hz 25ms} 20 times, 1000ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 3000ms OFF, repeat .... */
1634         MM_SOUND_TONE_CDMA_LOW_SS_2,                                            /**CDMA LOW SS2 tone: {1300Hz 25ms, 1450Hz 25ms} 20 times, 1000ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 3000ms OFF, repeat .... */
1635         MM_SOUND_TONE_CDMA_HIGH_SLS,                                            /**CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT */
1636         MM_SOUND_TONE_CDMA_MED_SLS,                                             /**CDMA MED SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT */
1637         MM_SOUND_TONE_CDMA_LOW_SLS,                                             /**CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT */
1638         MM_SOUND_TONE_CDMA_HIGH_S_X4,                                   /**CDMA HIGH S X4 tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 2500ms OFF, REPEAT.... */
1639         MM_SOUND_TONE_CDMA_MED_S_X4,                                            /**CDMA MED S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT.... */
1640         MM_SOUND_TONE_CDMA_LOW_S_X4,                                            /**CDMA LOW S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT....*/
1641         MM_SOUND_TONE_CDMA_HIGH_PBX_L,                                  /**CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1642         MM_SOUND_TONE_CDMA_MED_PBX_L,                                   /**CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1643         MM_SOUND_TONE_CDMA_LOW_PBX_L,                                   /**CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1644         MM_SOUND_TONE_CDMA_HIGH_PBX_SS,                                         /**CDMA HIGH PBX SS tone: {3700Hz 25ms, 4000Hz 25ms} 8 times 200 ms OFF, {3700Hz 25ms 4000Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
1645         MM_SOUND_TONE_CDMA_MED_PBX_SS,                                  /**CDMA MED PBX SS tone: {2600Hz 25ms, 2900Hz 25ms} 8 times 200 ms OFF, {2600Hz 25ms 2900Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
1646         MM_SOUND_TONE_CDMA_LOW_PBX_SS,                                  /**CDMA LOW PBX SS tone: {1300Hz 25ms, 1450Hz 25ms} 8 times 200 ms OFF, {1300Hz 25ms 1450Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
1647         MM_SOUND_TONE_CDMA_HIGH_PBX_SSL,                                        /**CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
1648         MM_SOUND_TONE_CDMA_MED_PBX_SSL,                                         /**CDMA MED PBX SSL tone:{2600Hz 25ms, 2900Hz 25ms} 8 times 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
1649         MM_SOUND_TONE_CDMA_LOW_PBX_SSL,                                         /**CDMA LOW PBX SSL tone:{1300Hz 25ms, 1450Hz 25ms} 8 times 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
1650         MM_SOUND_TONE_CDMA_HIGH_PBX_SLS,                                        /**CDMA HIGH PBX SLS tone:{3700Hz 25ms, 4000Hz 25ms} 8 times 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 1000ms OFF, REPEAT....  */
1651         MM_SOUND_TONE_CDMA_MED_PBX_SLS,                                         /**CDMA MED PBX SLS tone:{2600Hz 25ms, 2900Hz 25ms} 8 times 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 1000ms OFF, REPEAT.... */
1652         MM_SOUND_TONE_CDMA_LOW_PBX_SLS,                                         /**CDMA LOW PBX SLS tone:{1300Hz 25ms, 1450Hz 25ms} 8 times 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 1000ms OFF, REPEAT.... */
1653         MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4,                               /**CDMA HIGH PBX X S4 tone: {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 800ms OFF, REPEAT... */
1654         MM_SOUND_TONE_CDMA_MED_PBX_S_X4,                                        /**CDMA MED PBX X S4 tone: {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 800ms OFF, REPEAT... */
1655         MM_SOUND_TONE_CDMA_LOW_PBX_S_X4,                                        /**CDMA LOW PBX X S4 tone: {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 800ms OFF, REPEAT... */
1656         MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE,                  /**CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON 622Hz 62ms ON, 1109Hz 62ms ON */
1657         MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE,               /**CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON */
1658         MM_SOUND_TONE_CDMA_ONE_MIN_BEEP,                                        /**CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON */
1659         MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE,              /**CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON */
1660         MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE,                   /**CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON */
1661         MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE,                           /**CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms, 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms*/
1662         MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK,                  /**CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times 4990ms OFF, REPEAT... */
1663         MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD,                    /**CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times */
1664         MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE,                             /**CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms */
1665         MM_SOUND_TONE_CDMA_CALLDROP_LITE,                               /**CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms */
1666         MM_SOUND_TONE_CDMA_NETWORK_BUSY_ONE_SHOT,               /**CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. */
1667         MM_SOUND_TONE_CDMA_ABBR_ALERT,                                  /**CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON */
1668         MM_SOUND_TONE_CDMA_SIGNAL_OFF,                                  /**CDMA_SIGNAL_OFF - silent tone */
1669         MM_SOUND_TONE_LOW_FRE,                                  /**100Hz continuous */
1670         MM_SOUND_TONE_MED_FRE,                                  /**200Hz continuous */
1671         MM_SOUND_TONE_HIGH_FRE,                                 /**300Hz continuous */
1672         MM_SOUND_TONE_NUM,
1673 }MMSoundTone_t;
1674
1675 typedef unsigned long sound_time_msec_t;                /**< millisecond unit */
1676
1677 /**
1678  * This function is to play tone sound.
1679  *
1680  * @param       num                             [in] predefined tone type (MMSoundTone_t)
1681  *                      volume config   [in] volume type & volume gain
1682  *                      volume                  [in] volume ratio (0.0 ~1.0)
1683  *                      duration                [in] millisecond (-1 for infinite)
1684  *                      handle                  [in] Handle of mm_sound_play_tone
1685  *                      enable_session  [in] set enable/unable session
1686  *
1687  * @return      This function returns MM_ERROR_NONE on success, or negative value
1688  *                      with error code.
1689  *
1690  * @remark      It doesn't provide stop
1691  * @see volume_type_t volume_gain_t MMSoundTone_t
1692  * @pre         None.
1693  * @post        TONE sound will be played.
1694  * @par Example
1695  * @code
1696 int ret = 0;
1697
1698 ret = mm_sound_play_tone_ex(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle, TRUE); //play 1 second with volume ratio 1.0
1699 if(ret < 0)
1700 {
1701         printf("play tone failed\n");
1702 }
1703 else
1704 {
1705         printf("play tone success\n");
1706 }
1707  * @endcode
1708  */
1709 int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session);
1710
1711 /**
1712  * This function is to play tone sound.
1713  *
1714  * @param       num                             [in] predefined tone type (MMSoundTone_t)
1715  *                      volume config   [in] volume type & volume gain
1716  *                      volume                  [in] volume ratio (0.0 ~1.0)
1717  *                      duration                [in] millisecond (-1 for infinite)
1718  *                      handle                  [in] Handle of mm_sound_play_tone
1719  *
1720  * @return      This function returns MM_ERROR_NONE on success, or negative value
1721  *                      with error code.
1722  *
1723  * @remark      It doesn't provide stop
1724  * @see volume_type_t volume_gain_t MMSoundTone_t
1725  * @pre         None.
1726  * @post        TONE sound will be played.
1727  * @par Example
1728  * @code
1729 int ret = 0;
1730
1731 ret = mm_sound_play_tone(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle); //play 1 second with volume ratio 1.0
1732 if(ret < 0)
1733 {
1734         printf("play tone failed\n");
1735 }
1736 else
1737 {
1738         printf("play tone success\n");
1739 }
1740  * @endcode
1741  */
1742 int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle);
1743
1744 int mm_sound_play_tone_with_stream_info(MMSoundTone_t tone, char *stream_type, int stream_id, const double volume, const int duration, int *handle);
1745
1746 /*
1747  * Enumerations of System audio route policy
1748  */
1749
1750 /**
1751  * This function get a2dp activation information.
1752  *
1753  * @param        connected                  [out] is Bluetooth A2DP connected (1:connected, 0:not connected)
1754  *              bt_name         [out] Bluetooth A2DP connected device name (allocated by internal when connected=1 otherwise set to null)
1755  *
1756  *
1757  * @return      This function returns MM_ERROR_NONE on success, or negative value
1758  *                      with error code.
1759  * @remark      This function allocation memory to given bt_name pointer internally.
1760  *          So application should free given memory pointer later after use.
1761  *          bt_name will be null if there's no a2dp device is connected (connected is 0)
1762  * @see         mm_sound_route_set_system_policy mm_sound_route_get_system_policy
1763  * @pre         None.
1764  * @post        memory buffer will be allocated and fill with bluetooth device name.
1765  * @par Example
1766  * @code
1767 int ret;
1768 int connected = 0;
1769 char* bt_name = NULL;
1770 ret = mm_sound_route_get_a2dp_status (&connected, &bt_name);
1771
1772 if (ret == MM_ERROR_NONE) {
1773         g_print ("### Is Bluetooth A2DP On Success : connected=[%d] name=[%s]\n", connected, bt_name);
1774         if (bt_name)
1775                 free (bt_name);
1776 } else {
1777         g_print ("### Is Bluetooth A2DP On Error : errno [%d]\n", ret);
1778
1779  * @endcode
1780  */
1781 int mm_sound_route_get_a2dp_status (bool* connected, char** bt_name);
1782
1783
1784 /*
1785  * Enumerations of device & route
1786  */
1787
1788 typedef enum{
1789         MM_SOUND_DIRECTION_NONE,
1790         MM_SOUND_DIRECTION_IN,                                                  /**< Capture */
1791         MM_SOUND_DIRECTION_OUT,                                                 /**< Playback */
1792 } mm_sound_direction;
1793
1794 typedef enum{
1795         MM_SOUND_DEVICE_IN_NONE                         = 0x00,
1796         MM_SOUND_DEVICE_IN_MIC                          = 0x01,         /**< Device builtin mic. */
1797         MM_SOUND_DEVICE_IN_WIRED_ACCESSORY      = 0x02,         /**< Wired input devices */
1798         MM_SOUND_DEVICE_IN_BT_SCO       = 0x08,         /**< Bluetooth SCO device */
1799 } mm_sound_device_in;
1800
1801 typedef enum{
1802         MM_SOUND_DEVICE_OUT_NONE                        = 0x000,
1803         MM_SOUND_DEVICE_OUT_SPEAKER             = 0x001<<8,     /**< Device builtin speaker */
1804         MM_SOUND_DEVICE_OUT_RECEIVER            = 0x002<<8,     /**< Device builtin receiver */
1805         MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY     = 0x004<<8,     /**< Wired output devices such as headphone, headset, and so on. */
1806         MM_SOUND_DEVICE_OUT_BT_SCO                      = 0x008<<8,     /**< Bluetooth SCO device */
1807         MM_SOUND_DEVICE_OUT_BT_A2DP             = 0x010<<8,     /**< Bluetooth A2DP device */
1808         MM_SOUND_DEVICE_OUT_DOCK                        = 0x020<<8,     /**< DOCK device */
1809         MM_SOUND_DEVICE_OUT_HDMI                        = 0x040<<8,     /**< HDMI device */
1810         MM_SOUND_DEVICE_OUT_MIRRORING           = 0x080<<8, /**< MIRRORING device */
1811         MM_SOUND_DEVICE_OUT_USB_AUDIO           = 0x100<<8,     /**< USB Audio device */
1812         MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK     = 0x200<<8,     /**< Multimedia DOCK device */
1813 } mm_sound_device_out;
1814
1815 typedef enum {
1816         MM_SOUND_VOLUME_DEVICE_OUT_SPEAKER,                             /**< Device builtin speaker */
1817         MM_SOUND_VOLUME_DEVICE_OUT_RECEIVER,                    /**< Device builtin receiver */
1818         MM_SOUND_VOLUME_DEVICE_OUT_WIRED_ACCESSORY,             /**< Wired output devices such as headphone, headset, and so on. */
1819         MM_SOUND_VOLUME_DEVICE_OUT_BT_SCO,                              /**< Bluetooth SCO device */
1820         MM_SOUND_VOLUME_DEVICE_OUT_BT_A2DP,                             /**< Bluetooth A2DP device */
1821         MM_SOUND_VOLUME_DEVICE_OUT_DOCK,                                /**< DOCK device */
1822         MM_SOUND_VOLUME_DEVICE_OUT_HDMI,                                /**< HDMI device */
1823         MM_SOUND_VOLUME_DEVICE_OUT_MIRRORING,                   /**< MIRRORING device */
1824         MM_SOUND_VOLUME_DEVICE_OUT_USB_AUDIO,                   /**< USB Audio device */
1825         MM_SOUND_VOLUME_DEVICE_OUT_MULTIMEDIA_DOCK,             /**< Multimedia DOCK device */
1826 } mm_sound_volume_device_out_t;
1827
1828 #define MM_SOUND_ROUTE_NUM 16
1829 #define MM_SOUND_NAME_NUM 32
1830
1831 typedef enum{
1832         MM_SOUND_ROUTE_OUT_SPEAKER = MM_SOUND_DEVICE_OUT_SPEAKER, /**< Routing audio output to builtin device such as internal speaker. */
1833         MM_SOUND_ROUTE_OUT_RECEIVER = MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio output to builtin device such as internal receiver. */
1834         MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY = MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio output to wired accessory such as headphone, headset, and so on. */
1835         MM_SOUND_ROUTE_OUT_BLUETOOTH_SCO = MM_SOUND_DEVICE_OUT_BT_SCO, /**< Routing audio output to bluetooth SCO. */
1836         MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP = MM_SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */
1837         MM_SOUND_ROUTE_OUT_DOCK = MM_SOUND_DEVICE_OUT_DOCK, /**< Routing audio output to DOCK */
1838         MM_SOUND_ROUTE_OUT_HDMI = MM_SOUND_DEVICE_OUT_HDMI, /**< Routing audio output to HDMI */
1839         MM_SOUND_ROUTE_OUT_MIRRORING = MM_SOUND_DEVICE_OUT_MIRRORING, /**< Routing audio output to MIRRORING */
1840         MM_SOUND_ROUTE_OUT_USB_AUDIO = MM_SOUND_DEVICE_OUT_USB_AUDIO, /**< Routing audio output to USB Audio */
1841         MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK = MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Routing audio output to Multimedia DOCK */
1842         MM_SOUND_ROUTE_IN_MIC = MM_SOUND_DEVICE_IN_MIC, /**< Routing audio input to device builtin mic. */
1843         MM_SOUND_ROUTE_IN_WIRED_ACCESSORY = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY, /**< Routing audio input to wired accessory. */
1844         MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio input to device builtin mic and routing audio output to builtin receiver*/
1845         MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_SPEAKER , /**< Routing audio input to device builtin mic and routing audio output to builtin speaker */
1846         MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio input to device builtin mic and routing audio output to headphone */
1847         MM_SOUND_ROUTE_INOUT_HEADSET = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,        /**< Routing audio input and output to headset*/
1848         MM_SOUND_ROUTE_INOUT_BLUETOOTH = MM_SOUND_DEVICE_IN_BT_SCO | MM_SOUND_DEVICE_OUT_BT_SCO /**< Routing audio input and output to bluetooth SCO */
1849 } mm_sound_route;
1850
1851 /*
1852  * MMSound Device APIs
1853  */
1854
1855 typedef enum {
1856         MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG      = 0x0001,  /**< Flag for input devices */
1857         MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG     = 0x0002,  /**< Flag for output devices */
1858         MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG    = 0x0004,  /**< Flag for input/output devices (both directions are available) */
1859         MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG        = 0x0010,  /**< Flag for built-in devices */
1860         MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG        = 0x0020,  /**< Flag for external devices */
1861         MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG    = 0x1000,  /**< Flag for deactivated devices */
1862         MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG      = 0x2000,  /**< Flag for activated devices */
1863         MM_SOUND_DEVICE_ALL_FLAG                  = 0xFFFF,  /**< Flag for all devices */
1864 } mm_sound_device_flags_e;
1865
1866 typedef enum {
1867         MM_SOUND_DEVICE_IO_DIRECTION_IN           = 0x1,
1868         MM_SOUND_DEVICE_IO_DIRECTION_OUT          = 0x2,
1869         MM_SOUND_DEVICE_IO_DIRECTION_BOTH         = MM_SOUND_DEVICE_IO_DIRECTION_IN | MM_SOUND_DEVICE_IO_DIRECTION_OUT,
1870 } mm_sound_device_io_direction_e;
1871
1872 typedef enum {
1873         MM_SOUND_DEVICE_STATE_DEACTIVATED,
1874         MM_SOUND_DEVICE_STATE_ACTIVATED,
1875 } mm_sound_device_state_e;
1876
1877 typedef enum
1878 {
1879         MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER,   /**< Built-in speaker. */
1880         MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER,  /**< Built-in receiver. */
1881         MM_SOUND_DEVICE_TYPE_BUILTIN_MIC,       /**< Built-in mic. */
1882         MM_SOUND_DEVICE_TYPE_AUDIOJACK,         /**< Audio jack such as headphone, headset, and so on. */
1883         MM_SOUND_DEVICE_TYPE_BLUETOOTH,         /**< Bluetooth */
1884         MM_SOUND_DEVICE_TYPE_HDMI,              /**< HDMI. */
1885         MM_SOUND_DEVICE_TYPE_MIRRORING,         /**< MIRRORING. */
1886         MM_SOUND_DEVICE_TYPE_USB_AUDIO,         /**< USB Audio. */
1887 } mm_sound_device_type_e;
1888
1889 typedef void *MMSoundDevice_t;          /**< MMsound Device handle */
1890 typedef void *MMSoundDeviceList_t;      /**< MMsound Device list handle */
1891 typedef void (*mm_sound_device_connected_cb) (MMSoundDevice_t device_h, bool is_connected, void *user_data);
1892 typedef void (*mm_sound_device_info_changed_cb) (MMSoundDevice_t device_h, int changed_info_type, void *user_data);
1893
1894 int mm_sound_add_device_connected_callback(mm_sound_device_flags_e flags, mm_sound_device_connected_cb func, void *user_data, unsigned int *subs_id);
1895 int mm_sound_remove_device_connected_callback(unsigned int subs_id);
1896 int mm_sound_add_device_information_changed_callback(mm_sound_device_flags_e flags, mm_sound_device_info_changed_cb func, void *user_data, unsigned int *subs_id);
1897 int mm_sound_remove_device_information_changed_callback(unsigned int subs_id);
1898
1899 int mm_sound_get_current_device_list(mm_sound_device_flags_e device_mask, MMSoundDeviceList_t *device_list);
1900 int mm_sound_free_device_list(MMSoundDeviceList_t device_list);
1901 int mm_sound_get_next_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
1902 int mm_sound_get_prev_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
1903 int mm_sound_get_device_type(MMSoundDevice_t device_h, mm_sound_device_type_e *type);
1904 int mm_sound_get_device_io_direction(MMSoundDevice_t device_h, mm_sound_device_io_direction_e *io_direction);
1905 int mm_sound_get_device_id(MMSoundDevice_t device_h, int *id);
1906 int mm_sound_get_device_state(MMSoundDevice_t device_h, mm_sound_device_state_e *state);
1907 int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name);
1908
1909 /* below APIs are for product */
1910 typedef int (*mm_sound_available_route_cb)(mm_sound_route route, void *user_data);
1911 int mm_sound_is_route_available(mm_sound_route route, bool *is_available);
1912 int mm_sound_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data);
1913 int mm_sound_set_active_route(mm_sound_route route);
1914 int mm_sound_set_active_route_auto(void);
1915
1916
1917 /**
1918  * This function is to set active route without callback to client.
1919  *
1920  * @param       route                   [IN]    route
1921  * @return      This function returns MM_ERROR_NONE on success, or negative value
1922  *                      with error code.
1923  * @remark      None.
1924  * @pre         None.
1925  * @post        None.
1926  * @see         mm_sound_set_active_route_without_broadcast mm_sound_route
1927  */
1928 int mm_sound_set_active_route_without_broadcast(mm_sound_route route);
1929
1930 /**
1931  * This function is to get active playback device and capture device.
1932  *
1933  * @param       playback_device                 [out]   playback device.
1934  * @param       capture_device                  [out]   capture device.
1935  *
1936  * @return      This function returns MM_ERROR_NONE on success, or negative value
1937  *                      with error code.
1938  * @remark      None.
1939  * @pre         None.
1940  * @post        None.
1941  * @see         mm_sound_set_active_route mm_sound_device_in mm_sound_device_out
1942  */
1943 int mm_sound_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
1944
1945 /**
1946  * Active device changed callback function type.
1947  *
1948  * @param       user_data               [in]    Argument passed when callback has called
1949  *
1950  * @return      No return value
1951  * @remark      None.
1952  * @see         mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
1953  */
1954 typedef void (*mm_sound_active_device_changed_cb) (mm_sound_device_in device_in, mm_sound_device_out device_out, void *user_data);
1955
1956 /**
1957  * This function is to add active device callback.
1958  *
1959  * @param       name                    [in]    plugin name (name max size : MM_SOUND_NAME_NUM 32)
1960  * @param       func                    [in]    callback function pointer
1961  * @param       user_data               [in]    user data passing to callback function
1962  *
1963  * @return      This function returns MM_ERROR_NONE on success, or negative value
1964  *                      with error code.
1965  * @remark      None.
1966  * @see         mm_sound_remove_active_device_changed_callback mm_sound_active_device_changed_cb
1967  * @pre         None.
1968  * @post        None.
1969  * @par Example
1970  * @code
1971
1972 void __active_device_callback(void *user_data)
1973 {
1974         printf("Callback function\n");
1975 }
1976
1977 int active_device_control()
1978 {
1979         int ret = 0;
1980
1981         ret = mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
1982         if ( MM_ERROR_NONE != ret)
1983         {
1984                 printf("Can not add callback\n");
1985         }
1986         else
1987         {
1988                 printf("Add callback success\n");
1989         }
1990
1991         return ret;
1992 }
1993
1994  * @endcode
1995  */
1996 int mm_sound_add_active_device_changed_callback(const char *name,mm_sound_active_device_changed_cb func, void *user_data);
1997 /**
1998  * This function is to remove active device callback.
1999  *
2000  * @param       name                    [in]    plugin name (name max size : MM_SOUND_NAME_NUM 32)
2001  * @return      This function returns MM_ERROR_NONE on success, or negative value
2002  *                      with error code.
2003  * @remark      None.
2004  * @pre         Active device callback should be registered.
2005  * @post        Active device callback deregistered and does not be called anymore.
2006  * @see         mm_sound_add_active_device_changed_callback mm_sound_active_device_changed_cb
2007  * @par Example
2008  * @code
2009 void __active_device_callback(void *data)
2010 {
2011         printf("Callback function\n");
2012 }
2013
2014 int active_device_control()
2015 {
2016         int ret = 0;
2017
2018         mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
2019
2020         ret = mm_sound_remove_active_device_changed_callback();
2021         if ( MM_ERROR_NONE == ret)
2022         {
2023                 printf("Remove callback success\n");
2024         }
2025         else
2026         {
2027                 printf("Remove callback failed\n");
2028         }
2029
2030         return ret;
2031 }
2032
2033  * @endcode
2034  */
2035 int mm_sound_remove_active_device_changed_callback(const char *name);
2036 /**
2037  * Available route changed callback function type.
2038  *
2039  * @param       user_data               [in]    Argument passed when callback has called
2040  *
2041  * @return      No return value
2042  * @remark      None.
2043  * @see         mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
2044  */
2045 typedef void (*mm_sound_available_route_changed_cb) (mm_sound_route route, bool available, void *user_data);
2046
2047 /**
2048  * This function is to add available device callback.
2049  *
2050  * @param       func                    [in]    callback function pointer
2051  * @param       user_data               [in]    user data passing to callback function
2052  *
2053  * @return      This function returns MM_ERROR_NONE on success, or negative value
2054  *                      with error code.
2055  * @remark      None.
2056  * @see         mm_sound_remove_available_route_changed_callback mm_sound_active_device_changed_cb
2057  * @pre         None.
2058  * @post        None.
2059  * @par Example
2060  * @code
2061
2062 void __available_device_callback(void *user_data)
2063 {
2064         printf("Callback function\n");
2065 }
2066
2067 int available_device_control()
2068 {
2069         int ret = 0;
2070
2071         ret = mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2072         if ( MM_ERROR_NONE != ret)
2073         {
2074                 printf("Can not add callback\n");
2075         }
2076         else
2077         {
2078                 printf("Add callback success\n");
2079         }
2080
2081         return ret;
2082 }
2083
2084  * @endcode
2085  */
2086 int mm_sound_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void *user_data);
2087
2088 /**
2089  * This function is to remove available device callback.
2090  *
2091  * @return      This function returns MM_ERROR_NONE on success, or negative value
2092  *                      with error code.
2093  * @remark      None.
2094  * @pre         available device callback should be registered.
2095  * @post        available device callback deregistered and does not be called anymore.
2096  * @see         mm_sound_add_available_route_changed_callback mm_sound_active_device_changed_cb
2097  * @par Example
2098  * @code
2099 void __available_device_callback(void *data)
2100 {
2101         printf("Callback function\n");
2102 }
2103
2104 int available_device_control()
2105 {
2106         int ret = 0;
2107
2108         mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2109
2110         ret = mm_sound_remove_available_route_changed_callback();
2111         if ( MM_ERROR_NONE == ret)
2112         {
2113                 printf("Remove callback success\n");
2114         }
2115         else
2116         {
2117                 printf("Remove callback failed\n");
2118         }
2119
2120         return ret;
2121 }
2122
2123  * @endcode
2124  */
2125 int mm_sound_remove_available_route_changed_callback(void);
2126
2127  /**
2128  * This function is to set path for active device.
2129  *
2130  * @param       device_out              [in]    active playback device
2131  * @param       device_in               [in]    active capture device
2132  *
2133  * @return      This function returns MM_ERROR_NONE on success, or negative value
2134  *                      with error code.
2135  * @remark      None.
2136  * @see         None
2137  * @pre         None.
2138  * @post        None.
2139  * @par Example
2140  * @*/
2141 int mm_sound_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in);
2142
2143 /**
2144 * This function is to get current audio path.
2145 *
2146 * @param   device_out      [in]    active playback device
2147 * @param   device_in       [in]    active capture device
2148 *
2149 * @return  This function returns MM_ERROR_NONE on success, or negative value
2150 *                  with error code.
2151 * @remark  None.
2152 * @see     None
2153 * @pre     None.
2154 * @post    None.
2155 * @par Example
2156 * @*/
2157
2158 int mm_sound_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
2159
2160
2161
2162 typedef void (*mm_sound_test_cb) (int a, void *user_data);
2163 int mm_sound_test(int a, int b, int* get);
2164 int mm_sound_add_test_callback(mm_sound_test_cb func, void *user_data, unsigned int *subs_id);
2165 int mm_sound_remove_test_callback(unsigned int sub_id);
2166
2167 void mm_sound_convert_volume_type_to_stream_type(int volume_type, char *stream_type);
2168
2169 typedef enum {
2170         MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS,
2171         MM_SOUND_SIGNAL_MAX,
2172 } mm_sound_signal_name_t;
2173
2174 typedef void (* mm_sound_signal_callback) (mm_sound_signal_name_t signal, int value, void *user_data);
2175 int mm_sound_subscribe_signal(mm_sound_signal_name_t signal, unsigned int* subscribe_id, mm_sound_signal_callback callback, void *user_data);
2176 void mm_sound_unsubscribe_signal(unsigned int subscribe_id);
2177 int mm_sound_send_signal(mm_sound_signal_name_t signal, int value);
2178 int mm_sound_get_signal_value(mm_sound_signal_name_t signal, int *value);
2179
2180 /**
2181         @}
2182  */
2183
2184 #ifdef __cplusplus
2185 }
2186 #endif
2187
2188 #endif  /* __MM_SOUND_H__ */
2189