libmm-sound add drain/flush APIs
[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
277 /*
278  * MMSound Volume APIs
279  */
280
281 /**
282  * Enumerations of Volume type.
283  */
284
285 typedef enum {
286         VOLUME_TYPE_SYSTEM,                             /**< System volume type */
287         VOLUME_TYPE_NOTIFICATION,               /**< Notification volume type */
288         VOLUME_TYPE_ALARM,                              /**< Alarm volume type */
289         VOLUME_TYPE_RINGTONE,                   /**< Ringtone volume type */
290         VOLUME_TYPE_MEDIA,                              /**< Media volume type */
291         VOLUME_TYPE_CALL,                               /**< Call volume type */
292         VOLUME_TYPE_VOIP,                               /**< VOIP volume type */
293         VOLUME_TYPE_VOICE,                              /**< VOICE volume type */
294         VOLUME_TYPE_FIXED,                              /**< Volume type for fixed acoustic level */
295         VOLUME_TYPE_MAX,                                /**< Volume type count */
296         VOLUME_TYPE_EXT_ANDROID = VOLUME_TYPE_FIXED,            /**< External system volume for Android */
297 } volume_type_t;
298
299 typedef enum {
300         VOLUME_GAIN_DEFAULT             = 0,
301         VOLUME_GAIN_DIALER              = 1<<8,
302         VOLUME_GAIN_TOUCH               = 2<<8,
303         VOLUME_GAIN_AF                  = 3<<8,
304         VOLUME_GAIN_SHUTTER1    = 4<<8,
305         VOLUME_GAIN_SHUTTER2    = 5<<8,
306         VOLUME_GAIN_CAMCORDING  = 6<<8,
307         VOLUME_GAIN_MIDI                = 7<<8,
308         VOLUME_GAIN_BOOTING             = 8<<8,
309         VOLUME_GAIN_VIDEO               = 9<<8,
310         VOLUME_GAIN_TTS                 = 10<<8,
311 } volume_gain_t;
312
313 /**
314  * @brief Enumerations of supporting source_type
315  */
316 typedef enum {
317     SUPPORT_SOURCE_TYPE_DEFAULT,
318     SUPPORT_SOURCE_TYPE_MIRRORING,
319     SUPPORT_SOURCE_TYPE_VOICECONTROL,
320     SUPPORT_SOURCE_TYPE_SVR,
321     SUPPORT_SOURCE_TYPE_VIDEOCALL,
322     SUPPORT_SOURCE_TYPE_VOICERECORDING,
323     SUPPORT_SOURCE_TYPE_VOIP, /* Supporting VoIP source*/
324     SUPPORT_SOURCE_TYPE_CALL_FORWARDING,
325     SUPPORT_SOURCE_TYPE_FMRADIO,
326     SUPPORT_SOURCE_TYPE_LOOPBACK,
327 } mm_sound_source_type_e;
328
329 /**
330  * Volume change callback function type.
331  *
332  * @param       user_data               [in]    Argument passed when callback has called
333  *
334  * @return      No return value
335  * @remark      None.
336  * @see         mm_sound_volume_add_callback mm_sound_volume_remove_callback
337  */
338 typedef void (*volume_callback_fn)(void* user_data);
339
340 /**
341  * Active volume change callback function type.
342  *
343  * @param       type                    [in]    The sound type of changed volume
344  * @param       volume                  [in]    The new volume value
345  * @param       user_data               [in]    Argument passed when callback has called
346  *
347  * @return      No return value
348  * @remark      None.
349  * @see         mm_sound_add_volume_changed_callback mm_sound_remove_volume_changed_callback
350  */
351 typedef void (*mm_sound_volume_changed_cb) (volume_type_t type, unsigned int volume, void *user_data);
352
353
354 /**
355  * Muteall state change callback function type.
356  *
357  * @param       user_data               [in]    Argument passed when callback has called
358  *
359  * @return      No return value
360  * @remark      None.
361  * @see         mm_sound_muteall_add_callback mm_sound_muteall_remove_callback
362  */
363 typedef void (*muteall_callback_fn)(void* user_data);
364
365 /**
366  * This function is to retrieve number of volume level.
367  *
368  * @param       type                    [in]    volume type to query
369  * @param       step                    [out]   number of volume steps
370  *
371  * @return      This function returns MM_ERROR_NONE on success, or negative value
372  *                      with error code.
373  * @remark      step means number of steps. so actual volume step can be 0 ~ step-1
374  * @see         volume_type_t
375  * @pre         None.
376  * @post        None.
377  * @par Example
378  * @code
379 int step = 0;
380 int ret = 0;
381 int max = 0;
382
383 ret = mm_sound_volume_get_step(VOLUME_TYPE_SYSTEM, &step);
384 if(ret < 0)
385 {
386         printf("Can not get volume step\n");
387 }
388 else
389 {
390         max = step - 1;
391         //set system volume to max value
392         mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, max);
393 }
394  * @endcode
395  */
396 int mm_sound_volume_get_step(volume_type_t type, int *step);
397
398
399 /**
400  * This function is to add volume changed callback.
401  *
402  * @param       type                    [in]    volume type to set change callback function
403  * @param       func                    [in]    callback function pointer
404  * @param       user_data               [in]    user data passing to callback function
405  *
406  * @return      This function returns MM_ERROR_NONE on success, or negative value
407  *                      with error code.
408  * @remark      Only one callback function per volume type will be registered.
409  *                      if you want to change callback function for certain volume type,
410  *                      remove callback first via mm_sound_volume_remove_callback().
411  * @see         volume_type_t volume_callback_fn
412  * @pre         There should be not be pre-registered callback fuction to given volume type.
413  * @post        Callback function will be registered to given volume type
414  * @par Example
415  * @code
416 volume_type_t g_vol_type = VOLUME_TYPE_MEDIA;
417
418 void _volume_callback(void *data)
419 {
420         unsigned int value = 0;
421         int result = 0;
422         volume_type_t *type = (volume_type_t*)data;
423
424         result = mm_sound_volume_get_value(*type, &value);
425         if(result == MM_ERROR_NONE)
426         {
427                 printf("Current volume value is %d\n", value);
428         }
429         else
430         {
431                 printf("Can not get volume\n");
432         }
433 }
434
435 int volume_control()
436 {
437         int ret = 0;
438
439         ret = mm_sound_volume_add_callback(g_vol_type, _volume_callback, (void*)&g_vol_type);
440         if ( MM_ERROR_NONE != ret)
441         {
442                 printf("Can not add callback\n");
443         }
444         else
445         {
446                 printf("Add callback success\n");
447         }
448
449         return 0;
450 }
451
452  * @endcode
453  */
454 int mm_sound_volume_add_callback(volume_type_t type, volume_callback_fn func, void* user_data);
455 int mm_sound_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data);
456
457
458 /**
459  * This function is to remove volume changed callback.
460  *
461  * @param       type                    [in]    volume type to set change callback function
462  *
463  * @return      This function returns MM_ERROR_NONE on success, or negative value
464  *                      with error code.
465  * @remark      None.
466  * @pre         Callback function should be registered previously for given volume type.
467  * @post        Callback function will not be called anymore.
468  * @see         volume_type_t
469  * @par Example
470  * @code
471 void _volume_callback(void *data)
472 {
473         printf("Callback function\n");
474 }
475
476 int volume_callback()
477 {
478         int ret = 0;
479         int vol_type = VOLUME_TYPE_MEDIA;
480
481         mm_sound_volume_add_callback(vol_type, _volume_callback, NULL);
482
483         ret = mm_sound_volume_remove_callback(vol_type);
484         if ( MM_ERROR_NONE == ret)
485         {
486                 printf("Remove callback success\n");
487         }
488         else
489         {
490                 printf("Remove callback failed\n");
491         }
492
493         return ret;
494 }
495
496  * @endcode
497  */
498 int mm_sound_volume_remove_callback(volume_type_t type);
499
500 /**
501  * This function is to remove volume change callback.
502  *
503  * @return      This function returns MM_ERROR_NONE on success, or negative value
504  *                      with error code.
505  **/
506 int mm_sound_remove_volume_changed_callback(void);
507
508 /**
509  * This function is to add muteall changed callback.
510  *
511  * @param       func                    [in]    callback function pointer
512  * @param       user_data               [in]    user data passing to callback function
513  *
514  * @return      This function returns MM_ERROR_NONE on success, or negative value
515  *                      with error code.
516  * @see         muteall_callback_fn
517  * @code
518 void _muteall_callback(void *data)
519 {
520         int  muteall;
521
522         mm_sound_get_muteall(&muteall);
523         g_print("Muteall Callback Runs :::: muteall value = %d\n", muteall);
524 }
525
526 int muteall_callback()
527 {
528         int ret = 0;
529
530         ret = mm_sound_muteall_add_callback( _muteall_callback);
531
532         if ( MM_ERROR_NONE != ret)
533         {
534                 printf("Can not add callback\n");
535         }
536         else
537         {
538                 printf("Add callback success\n");
539         }
540
541         return 0;
542 }
543
544  * @endcode
545  */
546 int mm_sound_muteall_add_callback(muteall_callback_fn func);
547
548
549 /**
550  * This function is to remove muteall changed callback.
551  *
552  * @param       func                    [in]    callback function pointer
553  *
554  * @return      This function returns MM_ERROR_NONE on success, or negative value
555  *                      with error code.
556  * @remark      None.
557  * @post        Callback function will not be called anymore.
558  * @see         muteall_callback_fn
559  * @code
560 void _muteall_callback(void *data)
561 {
562         printf("Callback function\n");
563 }
564
565 int muteall_callback()
566 {
567         int ret = 0;
568
569         mm_sound_muteall_add_callback( _muteall_callback);
570
571         ret = mm_sound_muteall_remove_callback(_muteall_callback);
572         if ( MM_ERROR_NONE == ret)
573         {
574                 printf("Remove callback success\n");
575         }
576         else
577         {
578                 printf("Remove callback failed\n");
579         }
580
581         return ret;
582 }
583
584  * @endcode
585  */
586 int mm_sound_muteall_remove_callback(muteall_callback_fn func);
587
588 /**
589  * This function is to set volume level of certain volume type.
590  *
591  * @param       type                    [in]    volume type to set value.
592  * @param       value                   [in]    volume value.
593  *
594  * @return      This function returns MM_ERROR_NONE on success, or negative value
595  *                      with error code.
596  * @remark      value should be 0 ~ mm_sound_volume_get_step() -1
597  * @see         mm_sound_volume_get_step, mm_sound_volume_get_value volume_type_t
598  * @pre         None.
599  * @post        Volume value will be changed to given value for given volume type.
600  * @par Example
601  * @code
602 int step = 0;
603 int ret = 0;
604 int max = 0;
605
606 ret = mm_sound_volume_get_step(VOLUME_TYPE_SYSTEM, &step);
607 if(ret < 0)
608 {
609         printf("Can not get volume step\n");
610 }
611 else
612 {
613         max = step - 1;
614         //set system volume to max value
615         ret = mm_sound_volume_set_value(VOLUME_TYPE_SYSTEM, max);
616         if(ret < 0)
617         {
618                 printf("Can not set volume value\n");
619         }
620 }
621  * @endcode
622  */
623 int mm_sound_volume_set_value(volume_type_t type, const unsigned int value);
624
625
626
627
628
629
630 /**
631  * This function is to set all volume type to mute or unmute.
632  *
633  * @param       muteall                 [in]    the switch to control  mute or unmute.
634  *
635  * @return      This function returns MM_ERROR_NONE on success, or negative value
636  *                      with error code.
637  * @remark      None.
638  * @pre         None.
639  * @post        None.
640  */
641 int mm_sound_mute_all(int muteall);
642
643
644
645 /**
646  * This function is to get volume level of certain volume type.
647  *
648  * @param       type                    [in]    volume type to get value.
649  * @param       value                   [out]   volume value.
650  *
651  * @return      This function returns MM_ERROR_NONE on success, or negative value
652  *                      with error code.
653  * @remark      None.
654  * @pre         None.
655  * @post        None.
656  * @see         volume_type_t mm_sound_volume_set_value
657  * @par Example
658  * @code
659 int value = 0;
660 int ret = 0;
661
662 ret = mm_sound_volume_get_value(VOLUME_TYPE_SYSTEM, &value);
663 if(ret < 0)
664 {
665         printf("Can not get volume\n");
666 }
667 else
668 {
669         printf("System type volume is %d\n", value);
670 }
671  * @endcode
672  * @see         mm_sound_volume_set_value
673  */
674 int mm_sound_volume_get_value(volume_type_t type, unsigned int *value);
675
676
677
678 /**
679  * This function is to set primary volume type.
680  *
681  * @param       type                    [in]    volume type to set as primary volume type.
682  *
683  * @return      This function returns MM_ERROR_NONE on success, or negative value
684  *                      with error code.
685  * @remark      Application should use this function during foreground.
686  *                      Application should clear primary volume type by mm_sound_volume_primary_type_clear() when it goes background.
687  * @pre         None.
688  * @post        Volume app. will be update given volume type when H/W volume control key pressed.
689  * @see         mm_sound_volume_primary_type_clear volume_type_t
690  * @par Example
691  * @code
692 static int _resume(void *data)
693 {
694         int ret = 0;
695
696         ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_MEDIA);
697         if(ret < 0)
698         {
699                 printf("Can not set primary volume type\n");
700         }
701         ...
702 }
703
704 static int _pause(void* data)
705 {
706         int ret = 0;
707
708         ret = mm_sound_volume_primary_type_clear();
709         if(ret < 0)
710         {
711                 printf("Can not clear primary volume type\n");
712         }
713         ...
714 }
715
716 int main()
717 {
718         ...
719         struct appcore_ops ops = {
720                 .create = _create,
721                 .terminate = _terminate,
722                 .pause = _pause,
723                 .resume = _resume,
724                 .reset = _reset,
725         };
726         ...
727         return appcore_efl_main(PACKAGE, ..., &ops);
728 }
729  * @endcode
730  */
731 int mm_sound_volume_primary_type_set(volume_type_t type);
732
733
734
735 /**
736  * This function is to clear primary volume type.
737  *
738  *
739  * @return      This function returns MM_ERROR_NONE on success, or negative value
740  *                      with error code.
741  * @remark      mm_sound_volume_primary_type_set() and mm_sound_volume_primary_type_clear() should be used as pair
742  * @see         mm_sound_volume_primary_type_set
743  * @pre         primary volume should be set at same process.
744  * @post        primary volume will be cleared.
745  * @par Example
746  * @code
747 static int _resume(void *data)
748 {
749         int ret = 0;
750
751         ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_MEDIA);
752         if(ret < 0)
753         {
754                 printf("Can not set primary volume type\n");
755         }
756         ...
757 }
758
759 static int _pause(void* data)
760 {
761         int ret = 0;
762
763         ret = mm_sound_volume_primary_type_clear();
764         if(ret < 0)
765         {
766                 printf("Can not clear primary volume type\n");
767         }
768         ...
769 }
770
771 int main()
772 {
773         ...
774         struct appcore_ops ops = {
775                 .create = _create,
776                 .terminate = _terminate,
777                 .pause = _pause,
778                 .resume = _resume,
779                 .reset = _reset,
780         };
781         ...
782         return appcore_efl_main(PACKAGE, ..., &ops);
783 }
784  * @endcode
785  */
786 int mm_sound_volume_primary_type_clear(void);
787
788
789
790 /**
791  * This function is to get current playing volume type
792  *
793  * @param       type                    [out]   current playing volume type
794  *
795  * @return      This function returns MM_ERROR_NONE on success,
796  *          or MM_ERROR_SOUND_VOLUME_NO_INSTANCE when there is no existing playing instance,
797  *          or MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY when only capture audio instances are exist.
798  *          or negative value with error code for other errors.
799  * @remark      None.
800  * @pre         None.
801  * @post        None.
802  * @see         mm_sound_volume_get_value, mm_sound_volume_set_value
803  * @par Example
804  * @code
805 int ret=0;
806 volume_type_t type = 0;
807
808 ret = mm_sound_volume_get_current_playing_type(&type);
809 switch(ret)
810 {
811 case MM_ERROR_NONE:
812         printf("Current playing is %d\n", type);
813         break;
814 case MM_ERROR_SOUND_VOLUME_NO_INSTANCE:
815         printf("No sound instance\n");
816         break;
817 case MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY:
818         printf("Only sound capture instances are exist\n");
819         break;
820 default:
821         printf("Error\n");
822         break;
823 }
824
825  * @endcode
826  */
827 int mm_sound_volume_get_current_playing_type(volume_type_t *type);
828
829 int mm_sound_volume_set_balance (float balance);
830
831 int mm_sound_volume_get_balance (float *balance);
832
833 int mm_sound_set_muteall (int muteall);
834
835 int mm_sound_get_muteall (int *muteall);
836
837 int mm_sound_set_stereo_to_mono (int ismono);
838
839 int mm_sound_get_stereo_to_mono (int *ismono);
840
841 int mm_sound_set_call_mute(volume_type_t type, int mute);
842
843 int mm_sound_get_call_mute(volume_type_t type, int *mute);
844
845 int mm_sound_set_factory_loopback_test(int loopback);
846
847 int mm_sound_get_factory_loopback_test(int *loopback);
848
849 typedef enum {
850         MM_SOUND_FACTORY_MIC_TEST_STATUS_OFF = 0,
851         MM_SOUND_FACTORY_MIC_TEST_STATUS_MAIN_MIC,
852         MM_SOUND_FACTORY_MIC_TEST_STATUS_SUB_MIC,
853         MM_SOUND_FACTORY_MIC_TEST_STATUS_NUM,
854 } mm_sound_factory_mic_test_status_t;/* device in for factory mic test */
855
856 int mm_sound_set_factory_mic_test(mm_sound_factory_mic_test_status_t mic_test);
857
858 int mm_sound_get_factory_mic_test(mm_sound_factory_mic_test_status_t *mic_test);
859
860 typedef enum {
861         MMSOUND_DHA_OFF,
862         MMSOUND_DHA_SOFT_SOUND,
863         MMSOUND_DHA_CLEAR_SOUND,
864         MMSOUND_DHA_PERSNOL_LEFT,
865         MMSOUND_DHA_PERSNOL_RIGHT,
866         MMSOUND_DHA_INVALID,
867 } MMSoundDHAMode_t;
868
869
870
871 /*
872  * MMSound PCM APIs
873  */
874 typedef void*   MMSoundPcmHandle_t;     /**< MMsound PCM handle type */
875
876 /**
877  * Enumerations of Format used in MMSoundPcm operation.
878  */
879 typedef enum {
880         MMSOUND_PCM_U8 = 0x70, /**< unsigned 8bit audio */
881         MMSOUND_PCM_S16_LE,   /**< signed 16bit audio */
882 } MMSoundPcmFormat_t;
883
884 /**
885  * Enumerations of Channel count used in MMSoundPcm operation.
886  */
887 typedef enum {
888         MMSOUND_PCM_MONO = 0x80,        /**< Mono channel */
889         MMSOUND_PCM_STEREO,                     /**< Stereo channel */
890 }MMSoundPcmChannel_t;
891
892 /**
893  * Get audio stream latency value.
894  *
895  * @param       handle                  [in]    handle to get latency
896  * @param       latency                 [out]   Stream latency value(millisecond).
897  *
898  * @return      This function returns MM_ERROR_NONE on success, or negative value
899  *                      with error code.
900  * @remark
901  * @see
902  */
903 int mm_sound_pcm_get_latency(MMSoundPcmHandle_t handle, int *latency);
904
905 /**
906  * Get started status of pcm stream.
907  *
908  * @param       handle                  [in]    handle to check pcm start
909  * @param       is_started                      [out]   retrieve started status of pcm stream.
910  *
911  * @return      This function returns MM_ERROR_NONE on success, or negative value
912  *                      with error code.
913  * @remark
914  * @see
915  */
916 int mm_sound_pcm_is_started(MMSoundPcmHandle_t handle, bool *is_started);
917
918 int mm_sound_pcm_play_open_no_session(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config);
919
920 /**
921  * This function is to create handle for PCM playback.
922  *
923  * @param       handle                  [out] handle to play pcm data
924  * @param       rate                    [in] sample rate (8000Hz ~ 44100Hz)
925  * @param       channel                 [in] number of channels (mono or stereo)
926  * @param       format                  [in] S8 or S16LE
927  * @param       volume config   [in] Volume type & volume gain
928  *
929  * @return      This function returns suggested buffer size (in bytes) on success, or negative value
930  *                      with error code.
931  * @remark      use mm_sound_volume_set_value() function to change volume
932  * @see         mm_sound_pcm_play_write, mm_sound_pcm_play_close, mm_sound_volume_set_value, MMSoundPcmFormat_t, MMSoundPcmChannel_t volume_type_t
933  * @pre         None.
934  * @post        PCM play handle will be created.
935  * @par Example
936  * @code
937 #include <mm_sound.h>
938 #include <stdio.h>
939 #include <alloca.h>
940
941 int main(int argc, char* argv[])
942 {
943         FILE *fp = NULL;
944         char *buffer = NULL;
945         int ret = 0;
946         int size = 0;
947         int readed = 0;
948         MMSoundPcmHandle_t handle;
949         char *filename = NULL;
950
951         if(argc !=2 )
952         {
953                 printf("Usage) %s filename\n", argv[0]);
954                 return -1;
955         }
956         filename = argv[1];
957
958         fp = fopen(filename,"r");
959         if(fp ==NULL)
960         {
961                 printf("Can not open file %s\n", filename);
962                 return -1;
963         }
964
965         size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
966         if(size < 0)
967         {
968                 printf("Can not open playback handle\n");
969                 return -2;
970         }
971
972         buffer = alloca(size);
973         while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
974         {
975                 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
976                 if(ret < 0)
977                 {
978                         printf("write fail\n");
979                         break;
980                 }
981                 memset(buffer, '\0', sizeof(buffer));
982         }
983
984         fclose(fp);
985         mm_sound_pcm_play_close(handle);
986         return 0;
987 }
988  * @endcode
989  */
990 int mm_sound_pcm_play_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, int volume_config);
991
992 /**
993  * This function start pcm playback
994  *
995  * @param       handle  [in] handle to start playback
996  *
997  * @return      This function returns MM_ERROR_NONE on success, or negative value
998  *                      with error code.
999  * @remark
1000  * @see
1001  * @pre         PCM playback handle should be allocated.
1002  * @post        PCM playback is ready to write.
1003  */
1004 int mm_sound_pcm_play_start(MMSoundPcmHandle_t handle);
1005
1006 /**
1007  * This function stop pcm playback
1008  *
1009  * @param       handle  [in] handle to stop playback
1010  *
1011  * @return      This function returns MM_ERROR_NONE on success, or negative value
1012  *                      with error code.
1013  * @remark
1014  * @see
1015  * @pre         PCM playback handle should be allocated.
1016  * @post        PCM playback data will not be buffered.
1017  */
1018 int mm_sound_pcm_play_stop(MMSoundPcmHandle_t handle);
1019
1020 /**
1021  * This function flush pcm playback
1022  *
1023  * @param       handle  [in] handle to flush playback
1024  *
1025  * @return      This function returns MM_ERROR_NONE on success, or negative value
1026  *                      with error code.
1027  * @remark
1028  * @see
1029  * @pre         PCM playback handle should be allocated.
1030  * @post        PCM playback data will not be buffered.
1031  */
1032 int mm_sound_pcm_play_drain(MMSoundPcmHandle_t handle);
1033
1034 /**
1035  * This function flush pcm playback
1036  *
1037  * @param       handle  [in] handle to flush playback
1038  *
1039  * @return      This function returns MM_ERROR_NONE on success, or negative value
1040  *                      with error code.
1041  * @remark
1042  * @see
1043  * @pre         PCM playback handle should be allocated.
1044  * @post        PCM playback data will not be buffered.
1045  */
1046 int mm_sound_pcm_play_flush(MMSoundPcmHandle_t handle);
1047
1048 /**
1049  * This function is to play PCM memory buffer.
1050  *
1051  * @param       handle  [in] handle to play pcm data
1052  * @param       ptr             [in] pcm buffer address
1053  * @param       length_byte     [in] size of pcm buffer (in bytes)
1054  *
1055  * @return      This function returns written data size on success, or negative value
1056  *                      with error code.
1057  * @remark      Make pcm buffer size with returned value of mm_sound_pcm_play_open()
1058  * @see         mm_sound_pcm_play_open, mm_sound_pcm_play_close
1059  * @pre         PCM play handle should be created.
1060  * @post        Sound will be generated with given PCM buffer data.
1061  * @par Example
1062  * @code
1063 #include <mm_sound.h>
1064 #include <stdio.h>
1065 #include <alloca.h>
1066
1067 int main(int argc, char* argv[])
1068 {
1069         FILE *fp = NULL;
1070         char *buffer = NULL;
1071         int ret = 0;
1072         int size = 0;
1073         int readed = 0;
1074         MMSoundPcmHandle_t handle;
1075         char *filename = NULL;
1076
1077         if(argc !=2 )
1078         {
1079                 printf("Usage) %s filename\n", argv[0]);
1080                 return -1;
1081         }
1082         filename = argv[1];
1083
1084         fp = fopen(filename,"r");
1085         if(fp ==NULL)
1086         {
1087                 printf("Can not open file %s\n", filename);
1088                 return -1;
1089         }
1090
1091         size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
1092         if(size < 0)
1093         {
1094                 printf("Can not open playback handle\n");
1095                 return -2;
1096         }
1097
1098         buffer = alloca(size);
1099         while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
1100         {
1101                 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
1102                 if(ret < 0)
1103                 {
1104                         printf("write fail\n");
1105                         break;
1106                 }
1107                 memset(buffer, '\0', sizeof(buffer));
1108         }
1109
1110         fclose(fp);
1111         mm_sound_pcm_play_close(handle);
1112         return 0;
1113 }
1114  * @endcode
1115  */
1116 int mm_sound_pcm_play_write(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte);
1117
1118
1119
1120 /**
1121  * This function is to close PCM memory playback handle
1122  *
1123  * @param       handle  [in] handle to play pcm data
1124  *
1125  * @return      This function returns MM_ERROR_NONE on success, or negative value
1126  *                      with error code.
1127  * @remark      None
1128  * @see         mm_sound_pcm_play_open, mm_sound_pcm_play_write
1129  * @pre         PCM play handle should be created
1130  * @post        PCM play handle will be terminated.
1131  * @par Example
1132  * @code
1133 #include <mm_sound.h>
1134 #include <stdio.h>
1135 #include <alloca.h>
1136
1137 int main(int argc, char* argv[])
1138 {
1139         FILE *fp = NULL;
1140         char *buffer = NULL;
1141         int ret = 0;
1142         int size = 0;
1143         int readed = 0;
1144         MMSoundPcmHandle_t handle;
1145         char *filename = NULL;
1146
1147         if(argc !=2 )
1148         {
1149                 printf("Usage) %s filename\n", argv[0]);
1150                 return -1;
1151         }
1152         filename = argv[1];
1153
1154         fp = fopen(filename,"r");
1155         if(fp ==NULL)
1156         {
1157                 printf("Can not open file %s\n", filename);
1158                 return -1;
1159         }
1160
1161         size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
1162         if(size < 0)
1163         {
1164                 printf("Can not open playback handle\n");
1165                 return -2;
1166         }
1167
1168         buffer = alloca(size);
1169         while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
1170         {
1171                 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
1172                 if(ret < 0)
1173                 {
1174                         printf("write fail\n");
1175                         break;
1176                 }
1177                 memset(buffer, '\0', sizeof(buffer));
1178         }
1179
1180         fclose(fp);
1181         mm_sound_pcm_play_close(handle);
1182         return 0;
1183 }
1184  * @endcode
1185  */
1186 int mm_sound_pcm_play_close(MMSoundPcmHandle_t handle);
1187
1188 /**
1189  * This function is to ignore session for playback
1190  *
1191  * @param       handle  [in] handle to play pcm data
1192  *
1193  * @return      This function returns MM_ERROR_NONE on success, or negative value
1194  *                      with error code.
1195  * @remark      This function only works for not started pcm handle and can't be reversed.
1196  * @see
1197  * @pre         PCM play handle should be created and not started.
1198  * @post        PCM play session will be set to mix.
1199  */
1200 int mm_sound_pcm_play_ignore_session(MMSoundPcmHandle_t *handle);
1201
1202 /**
1203  * This function is to create handle for PCM capture.
1204  *
1205  * @param       handle  [out] handle to capture pcm data
1206  * @param       rate    [in] sample rate (8000Hz ~ 44100Hz)
1207  * @param       channel [in] number of channels (mono or stereo)
1208  * @param       format  [in] S8 or S16LE
1209  *
1210  * @return      This function returns suggested buffer size (in bytes) on success, or negative value
1211  *                      with error code.
1212  * @remark      only mono channel is valid for now.
1213  * @see         mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
1214  * @pre         None.
1215  * @post        PCM capture handle will be allocated.
1216  * @par Example
1217  * @code
1218 #include <mm_sound.h>
1219 #include <stdio.h>
1220 #include <alloca.h>
1221
1222 int main(int argc, char* argv[])
1223 {
1224         FILE *fp = NULL;
1225         char *buffer = NULL;
1226         int ret = 0;
1227         int size = 0;
1228         int count = 0;
1229         MMSoundPcmHandle_t handle;
1230         char *filename = NULL;
1231
1232         if(argc !=2 )
1233         {
1234                 printf("Usage) %s filename\n", argv[0]);
1235                 return -1;
1236         }
1237         filename = argv[1];
1238
1239         fp = fopen(filename,"w");
1240         if(fp ==NULL)
1241         {
1242                 printf("Can not open file %s\n", filename);
1243                 return -1;
1244         }
1245
1246         size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1247         if(size < 0)
1248         {
1249                 printf("Can not open capture handle\n");
1250                 return -2;
1251         }
1252
1253         buffer = alloca(size);
1254         while(1)
1255         {
1256                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1257                 if(ret < 0)
1258                 {
1259                         printf("read fail\n");
1260                         break;
1261                 }
1262                 fwrite(buffer, ret, sizeof(char), fp);
1263                 if(count++ > 20) {
1264                         break;
1265                 }
1266         }
1267
1268         fclose(fp);
1269         mm_sound_pcm_capture_close(handle);
1270         return 0;
1271 }
1272
1273  * @endcode
1274  */
1275 int mm_sound_pcm_capture_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format);
1276
1277 /**
1278  * This function is to create handle for PCM capture of source_type.
1279  *
1280  * @param       handle  [out] handle to capture pcm data
1281  * @param       rate    [in] sample rate (8000Hz ~ 44100Hz)
1282  * @param       channel [in] number of channels (mono or stereo)
1283  * @param       format  [in] S8 or S16LE
1284  * @param       source_type             [in]  The source_type,mm_sound_source_type_e
1285  *
1286  * @return      This function returns suggested buffer size (in bytes) on success, or negative value
1287  *                      with error code.
1288  * @remark      only mono channel is valid for now.
1289  * @see         mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
1290  * @pre         None.
1291  * @post        PCM capture handle will be allocated.
1292  * @par Example
1293  * @code
1294 #include <mm_sound.h>
1295 #include <stdio.h>
1296 #include <alloca.h>
1297
1298 int main(int argc, char* argv[])
1299 {
1300         FILE *fp = NULL;
1301         char *buffer = NULL;
1302         int ret = 0;
1303         int size = 0;
1304         int count = 0;
1305         MMSoundPcmHandle_t handle;
1306         char *filename = NULL;
1307
1308         if(argc !=2 )
1309         {
1310                 printf("Usage) %s filename\n", argv[0]);
1311                 return -1;
1312         }
1313         filename = argv[1];
1314
1315         fp = fopen(filename,"w");
1316         if(fp ==NULL)
1317         {
1318                 printf("Can not open file %s\n", filename);
1319                 return -1;
1320         }
1321
1322         size = mm_sound_pcm_capture_open_ex(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE,1);
1323         if(size < 0)
1324         {
1325                 printf("Can not open capture handle\n");
1326                 return -2;
1327         }
1328
1329         buffer = alloca(size);
1330         while(1)
1331         {
1332                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1333                 if(ret < 0)
1334                 {
1335                         printf("read fail\n");
1336                         break;
1337                 }
1338                 fwrite(buffer, ret, sizeof(char), fp);
1339                 if(count++ > 20) {
1340                         break;
1341                 }
1342         }
1343
1344         fclose(fp);
1345         mm_sound_pcm_capture_close(handle);
1346         return 0;
1347 }
1348
1349  * @endcode
1350  */
1351 int mm_sound_pcm_capture_open_ex(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, mm_sound_source_type_e source_type);
1352
1353 /**
1354  * This function start pcm capture
1355  *
1356  * @param       handle  [in] handle to start capture
1357  *
1358  * @return      This function returns read data size on success, or negative value
1359  *                      with error code.
1360  * @remark
1361  * @see
1362  * @pre         PCM capture handle should be allocated.
1363  * @post        PCM capture data will be buffered.
1364  */
1365 int mm_sound_pcm_capture_start(MMSoundPcmHandle_t handle);
1366
1367 /**
1368  * This function stop pcm capture
1369  *
1370  * @param       handle  [in] handle to stop capture
1371  *
1372  * @return      This function returns read data size on success, or negative value
1373  *                      with error code.
1374  * @remark
1375  * @see
1376  * @pre         PCM capture handle should be allocated.
1377  * @post        PCM capture data will not be buffered.
1378  */
1379 int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle);
1380
1381 /**
1382  * This function flush pcm capture
1383  *
1384  * @param       handle  [in] handle to flush capture
1385  *
1386  * @return      This function returns MM_ERROR_NONE on success, or negative value
1387  *                      with error code.
1388  * @remark
1389  * @see
1390  * @pre         PCM capture handle should be allocated.
1391  * @post        PCM capture data will not be buffered.
1392  */
1393 int mm_sound_pcm_capture_flush(MMSoundPcmHandle_t handle);
1394
1395 /**
1396  * This function captures PCM to memory buffer. (Samsung extension)
1397  *
1398  * @param       handle  [in] handle to play pcm data
1399  * @param       buffer  [in] pcm buffer address
1400  * @param       length  [in] size of pcm buffer (in bytes)
1401  *
1402  * @return      This function returns read data size on success, or negative value
1403  *                      with error code.
1404  * @remark      Make pcm buffer size with returned value of mm_sound_pcm_capture_open()
1405  * @see         mm_sound_pcm_capture_open, mm_sound_pcm_capture_close
1406  * @pre         PCM capture handle should be allcated.
1407  * @post        PCM data will be filled to given memory pointer.
1408  * @par Example
1409  * @code
1410 #include <mm_sound.h>
1411 #include <stdio.h>
1412 #include <alloca.h>
1413
1414 int main(int argc, char* argv[])
1415 {
1416         FILE *fp = NULL;
1417         char *buffer = NULL;
1418         int ret = 0;
1419         int size = 0;
1420         int count = 0;
1421         MMSoundPcmHandle_t handle;
1422         char *filename = NULL;
1423
1424         if(argc !=2 )
1425         {
1426                 printf("Usage) %s filename\n", argv[0]);
1427                 return -1;
1428         }
1429         filename = argv[1];
1430
1431         fp = fopen(filename,"w");
1432         if(fp ==NULL)
1433         {
1434                 printf("Can not open file %s\n", filename);
1435                 return -1;
1436         }
1437
1438         size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1439         if(size < 0)
1440         {
1441                 printf("Can not open capture handle\n");
1442                 return -2;
1443         }
1444
1445         buffer = alloca(size);
1446         while(1)
1447         {
1448                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1449                 if(ret < 0)
1450                 {
1451                         printf("read fail\n");
1452                         break;
1453                 }
1454                 fwrite(buffer, ret, sizeof(char), fp);
1455                 if(count++ > 20) {
1456                         break;
1457                 }
1458         }
1459
1460         fclose(fp);
1461         mm_sound_pcm_capture_close(handle);
1462         return 0;
1463 }
1464
1465  * @endcode
1466  */
1467 int mm_sound_pcm_capture_read(MMSoundPcmHandle_t handle, void *buffer, const unsigned int length );
1468
1469 /**
1470  * This function captures PCM memory to memory buffer (Samsung extension)
1471  *
1472  * @param       handle  [in] handle to capture pcm data
1473  *
1474  * @return      This function returns MM_ERROR_NONE on success, or negative value
1475  *                      with error code.
1476  * @remark      None.
1477  * @see         mm_sound_pcm_capture_open, mm_sound_pcm_capture_read
1478  * @pre         PCM capture handle should be opend.
1479  * @post        PCM capture handle will be freed.
1480  * @par Example
1481  * @code
1482 #include <mm_sound.h>
1483 #include <stdio.h>
1484 #include <alloca.h>
1485
1486 int main(int argc, char* argv[])
1487 {
1488         FILE *fp = NULL;
1489         char *buffer = NULL;
1490         int ret = 0;
1491         int size = 0;
1492         int count = 0;
1493         MMSoundPcmHandle_t handle;
1494         char *filename = NULL;
1495
1496         if(argc !=2 )
1497         {
1498                 printf("Usage) %s filename\n", argv[0]);
1499                 return -1;
1500         }
1501         filename = argv[1];
1502
1503         fp = fopen(filename,"w");
1504         if(fp ==NULL)
1505         {
1506                 printf("Can not open file %s\n", filename);
1507                 return -1;
1508         }
1509
1510         size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1511         if(size < 0)
1512         {
1513                 printf("Can not open capture handle\n");
1514                 return -2;
1515         }
1516
1517         buffer = alloca(size);
1518         while(1)
1519         {
1520                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1521                 if(ret < 0)
1522                 {
1523                         printf("read fail\n");
1524                         break;
1525                 }
1526                 fwrite(buffer, ret, sizeof(char), fp);
1527                 if(count++ > 20) {
1528                         break;
1529                 }
1530         }
1531
1532         fclose(fp);
1533         mm_sound_pcm_capture_close(handle);
1534         return 0;
1535 }
1536
1537  * @endcode
1538  */
1539 int mm_sound_pcm_capture_close(MMSoundPcmHandle_t handle);
1540
1541 /**
1542  * This function is to ignore session for capture
1543  *
1544  * @param       handle  [in] handle to capture pcm data
1545  *
1546  * @return      This function returns MM_ERROR_NONE on success, or negative value
1547  *                      with error code.
1548  * @remark      This function only works for not started pcm handle and can't be reversed.
1549  * @see
1550  * @pre         PCM capture handle should be created and not started.
1551  * @post        PCM capture session will be set to mix.
1552  */
1553 int mm_sound_pcm_capture_ignore_session(MMSoundPcmHandle_t *handle);
1554
1555 /**
1556  * This function sets callback function for receiving messages from pcm API.
1557  *
1558  * @param       handle          [in]    Handle of pcm.
1559  * @param       callback        [in]    Message callback function.
1560  * @param       user_param      [in]    User parameter which is passed to callback function.
1561  *
1562  * @return      This function returns MM_ERROR_NONE on success, or negative value with error code.
1563  * @see         MMMessageCallback
1564  * @remark      None
1565  * @par Example
1566  * @code
1567 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1568 {
1569         switch (message)
1570         {
1571                 case MM_MESSAGE_SOUND_PCM_CAPTURE_RESTRICTED:
1572                         //do something
1573                         break;
1574
1575                 case MM_MESSAGE_SOUND_PCM_INTERRUPTED:
1576                         //do something
1577                         break;
1578
1579                 default:
1580                         break;
1581         }
1582         return TRUE;
1583 }
1584
1585 mm_sound_pcm_set_message_callback(pcmHandle, msg_callback, (void *)pcmHandle);
1586  * @endcode
1587  */
1588 int mm_sound_pcm_set_message_callback (MMSoundPcmHandle_t handle, MMMessageCallback callback, void *user_param);
1589
1590 /**
1591  * Terminate callback function type.
1592  *
1593  * @param       data            [in]    Argument passed when callback was set
1594  * @param       id              [in]    handle which has completed playing
1595  *
1596  * @return      No return value
1597  * @remark      It is not allowed to call MMSound API recursively or do time-consuming
1598  *                      task in this callback because this callback is called synchronously.
1599  * @see         mm_sound_play_sound
1600  */
1601 typedef void (*mm_sound_stop_callback_func) (void *data, int id);
1602
1603 /*
1604  * MMSound Play APIs
1605  */
1606
1607 /**
1608  * This function is to play system sound.
1609  *
1610  * @param       filename                [in] Sound filename to play
1611  * @param       volume config   [in] Volume type & volume gain
1612  * @param       callback                [in] Callback function pointer when playing is terminated.
1613  * @param       data                    [in] Pointer to user data when callback is called.
1614  * @param       handle                  [out] Handle of sound play.
1615  *
1616  * @return      This function returns MM_ERROR_NONE on success, or negative value
1617  *                      with error code.
1618  * @remark      When the stop callback is set, it will be called when system sound is
1619  *                      terminated. If mm_sound_stop_sound() is called apparently before
1620  *                      system sound is terminated, stop_callback will not be called.
1621  * @see         mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1622  * @pre         None.
1623  * @post        Sound will be generated with given filename.
1624  * @par Example
1625  * @code
1626 int g_stop=0;
1627 void _stop_callback(void* data)
1628 {
1629         printf("Stop callback\n");
1630         g_stop = 1;
1631 }
1632
1633 int play_file()
1634 {
1635         char filename[] ="/opt/media/Sound/testfile.wav";
1636         volume_type_t volume = VOLUME_TYPE_SYSTEM;
1637         int ret = 0;
1638         int handle = -1;
1639
1640         ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1641         if(ret < 0)
1642         {
1643                 printf("play file failed\n");
1644         }
1645         else
1646         {
1647                 printf("play file success\n");
1648         }
1649         while(g_stop == 0)
1650         {
1651                 sleep(1);
1652         }
1653         printf("play stopped\n");
1654         return 0;
1655 }
1656  * @endcode
1657  */
1658 int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1659
1660 int mm_sound_play_sound_without_session(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1661
1662 int mm_sound_play_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1663
1664 /**
1665  * This function is to play system sound. And other audio stream will be mute during playing time
1666  *
1667  * @param       filename                [in] Sound filename to play
1668  * @param       volume config   [in] Volume type & volume gain
1669  * @param       callback                [in] Callback function pointer when playing is terminated.
1670  * @param       data                    [in] Pointer to user data when callback is called.
1671  * @param       handle                  [out] Handle of sound play.
1672  *
1673  * @return      This function returns MM_ERROR_NONE on success, or negative value
1674  *                      with error code.
1675  * @remark      This function is almost same with mm_sound_play_sound,
1676  *                      but this make other audio playback stream to mute during playing time.
1677  * @see         mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1678  * @pre         None.
1679  * @post        Sound will be generated with given filename.
1680  * @par Example
1681  * @code
1682 int g_stop=0;
1683 void _stop_callback(void* data)
1684 {
1685         printf("Stop callback\n");
1686         g_stop = 1;
1687 }
1688
1689 int play_file()
1690 {
1691         char filename[] ="/opt/media/Sound/testfile.wav";
1692         volume_type_t volume = VOLUME_TYPE_SYSTEM;
1693         int ret = 0;
1694         int handle = -1;
1695
1696         ret = mm_sound_play_loud_solo_sound(filename, volume, _stop_callback, NULL, &handle);
1697         if(ret < 0)
1698         {
1699                 printf("play file failed\n");
1700         }
1701         else
1702         {
1703                 printf("play file success\n");
1704         }
1705         while(g_stop == 0)
1706         {
1707                 sleep(1);
1708         }
1709         printf("play stopped\n");
1710         return 0;
1711 }
1712  * @endcode
1713  */
1714 int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1715
1716 int mm_sound_play_loud_solo_sound_no_restore(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1717
1718 /**
1719  * This function is to stop playing system sound.
1720  *
1721  * @param       handle  [in] Handle of mm_sound_play_sound
1722  *
1723  * @return      This function returns MM_ERROR_NONE on success, or negative value
1724  *                      with error code.
1725  *
1726  * @remark      When system sound is terminated with this function call, it does not
1727  *                      call stop callback which was set when start playing system sound.
1728  * @see         mm_sound_play_sound
1729  * @pre         An sound play handle should be valid.
1730  * @post        Playing sound file will be stopped.
1731  * @par Example
1732  * @code
1733 int g_stop=0;
1734 void _stop_callback(void* data)
1735 {
1736         printf("Stop callback\n");
1737         g_stop = 1;
1738 }
1739
1740 int play_file_one_second()
1741 {
1742         char filename[] ="/opt/media/Sound/testfile.wav";
1743         volume_type_t volume = VOLUME_TYPE_SYSTEM;
1744         int ret = 0;
1745         int handle = -1;
1746
1747         ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1748         if(ret < 0)
1749         {
1750                 printf("play file failed\n");
1751         }
1752         else
1753         {
1754                 printf("play file success\n");
1755         }
1756
1757         sleep(1); //wait 1 second
1758
1759         ret = mm_sound_stop_sound(handle);
1760         if(ret < 0)
1761         {
1762                 printf("stop failed\n");
1763         }
1764         else
1765         {
1766                 printf("play stopped\n");
1767         }
1768         return 0;
1769 }
1770  * @endcode
1771  */
1772 int mm_sound_stop_sound(int handle);
1773
1774
1775 /**
1776  * Enumerations for TONE
1777  */
1778
1779 typedef enum  {
1780         MM_SOUND_TONE_DTMF_0 = 0,                       /**< Predefined DTMF 0 */
1781         MM_SOUND_TONE_DTMF_1,                           /**< Predefined DTMF 1 */
1782         MM_SOUND_TONE_DTMF_2,                           /**< Predefined DTMF 2 */
1783         MM_SOUND_TONE_DTMF_3,                           /**< Predefined DTMF 3 */
1784         MM_SOUND_TONE_DTMF_4,                           /**< Predefined DTMF 4 */
1785         MM_SOUND_TONE_DTMF_5,                           /**< Predefined DTMF 5 */
1786         MM_SOUND_TONE_DTMF_6,                           /**< Predefined DTMF 6 */
1787         MM_SOUND_TONE_DTMF_7,                           /**< Predefined DTMF 7 */
1788         MM_SOUND_TONE_DTMF_8,                           /**< Predefined DTMF 8 */
1789         MM_SOUND_TONE_DTMF_9,                           /**< Predefined DTMF 9 */
1790         MM_SOUND_TONE_DTMF_S,                           /**< Predefined DTMF Star - Asterisk (*) */
1791         MM_SOUND_TONE_DTMF_P,                           /**< Predefined DTMF sharP (#) */
1792         MM_SOUND_TONE_DTMF_A,                           /**< Predefined DTMF A (A) */
1793         MM_SOUND_TONE_DTMF_B,                           /**< Predefined DTMF B (B) */
1794         MM_SOUND_TONE_DTMF_C,                           /**< Predefined DTMF C (C) */
1795         MM_SOUND_TONE_DTMF_D,                           /**< Predefined DTMF D (D) */
1796
1797         /**< Pre-defined TONE */
1798         MM_SOUND_TONE_SUP_DIAL,                                 /**Call supervisory tone, Dial tone: CEPT: 425Hz, continuous */
1799         MM_SOUND_TONE_ANSI_DIAL,                                /**Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous */
1800         MM_SOUND_TONE_JAPAN_DIAL,                               /**Call supervisory tone, Dial tone: JAPAN: 400Hz, continuous*/
1801         MM_SOUND_TONE_SUP_BUSY,                         /**Call supervisory tone, Busy: CEPT: 425Hz, 500ms ON, 500ms OFF... */
1802         MM_SOUND_TONE_ANSI_BUSY,                                /**Call supervisory tone, Busy: ANSI (IS-95): 480Hz+620Hz, 500ms ON, 500ms OFF... */
1803         MM_SOUND_TONE_JAPAN_BUSY,                               /**Call supervisory tone, Busy: JAPAN: 400Hz, 500ms ON, 500ms OFF...*/
1804         MM_SOUND_TONE_SUP_CONGESTION,           /**Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF */
1805         MM_SOUND_TONE_ANSI_CONGESTION,          /**Call supervisory tone, Congestion: ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF... */
1806         MM_SOUND_TONE_SUP_RADIO_ACK,                    /**Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON  */
1807         MM_SOUND_TONE_JAPAN_RADIO_ACK,          /**Call supervisory tone, Radio path acknowlegment : JAPAN: 400Hz, 1s ON, 2s OFF...*/
1808         MM_SOUND_TONE_SUP_RADIO_NOTAVAIL,               /**Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts */
1809         MM_SOUND_TONE_SUP_ERROR,                                /**Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF... */
1810         MM_SOUND_TONE_SUP_CALL_WAITING,         /**Call supervisory tone, Call Waiting: CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF...  */
1811         MM_SOUND_TONE_ANSI_CALL_WAITING,                /**Call supervisory tone, Call Waiting: ANSI (IS-95): 440 Hz, 300 ms ON, 9.7 s OFF, (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...) */
1812         MM_SOUND_TONE_SUP_RINGTONE,                     /**Call supervisory tone, Ring Tone: CEPT, JAPAN: 425Hz, 1s ON, 4s OFF... */
1813         MM_SOUND_TONE_ANSI_RINGTONE,                    /**Call supervisory tone, Ring Tone: ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF... */
1814         MM_SOUND_TONE_PROP_BEEP,                                /**General beep: 400Hz+1200Hz, 35ms ON */
1815         MM_SOUND_TONE_PROP_ACK,                                 /**Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts */
1816         MM_SOUND_TONE_PROP_NACK,                                /**Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON */
1817         MM_SOUND_TONE_PROP_PROMPT,                      /**Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON         */
1818         MM_SOUND_TONE_PROP_BEEP2,                               /**Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON */
1819         MM_SOUND_TONE_SUP_INTERCEPT,                                            /**Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms */
1820         MM_SOUND_TONE_SUP_INTERCEPT_ABBREV,                             /**Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds */
1821         MM_SOUND_TONE_SUP_CONGESTION_ABBREV,                            /**Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds */
1822         MM_SOUND_TONE_SUP_CONFIRM,                                              /**Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone repeated 3 times in a 100 ms on, 100 ms off cycle */
1823         MM_SOUND_TONE_SUP_PIP,                                                  /**Call supervisory tone (IS-95), pip tone: four bursts of 480 Hz tone (0.1 s on, 0.1 s off). */
1824         MM_SOUND_TONE_CDMA_DIAL_TONE_LITE,                              /**425Hz continuous */
1825         MM_SOUND_TONE_CDMA_NETWORK_USA_RINGBACK,                /**CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...*/
1826         MM_SOUND_TONE_CDMA_INTERCEPT,                                   /**CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...*/
1827         MM_SOUND_TONE_CDMA_ABBR_INTERCEPT,                              /**CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON */
1828         MM_SOUND_TONE_CDMA_REORDER,                                             /**CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF... */
1829         MM_SOUND_TONE_CDMA_ABBR_REORDER,                                /**CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times */
1830         MM_SOUND_TONE_CDMA_NETWORK_BUSY,                                /**CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous */
1831         MM_SOUND_TONE_CDMA_CONFIRM,                                             /**CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times */
1832         MM_SOUND_TONE_CDMA_ANSWER,                                              /**CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF */
1833         MM_SOUND_TONE_CDMA_NETWORK_CALLWAITING,                         /**CDMA Network Callwaiting tone: 440Hz 300ms ON */
1834         MM_SOUND_TONE_CDMA_PIP,                                                         /**CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times */
1835         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL,             /**ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times, 2091 32ms ON, 2556 48ms ON, 4s OFF */
1836         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP,         /**ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times, 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 8times, 2091Hz 32ms ON, 4s OFF.*/
1837         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI,             /**ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times, 2091Hz 16ms ON, 200ms OFF */
1838         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT3,               /**SDN Call sign PAT3 tone: silent tone */
1839         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING,  /**ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON */
1840         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT5,               /**ISDN Pat5 tone: silent tone */
1841         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT6,               /**ISDN Pat6 tone: silent tone */
1842         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT7,               /**ISDN Pat7 tone: silent tone */
1843         MM_SOUND_TONE_CDMA_HIGH_L,                                              /**TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1844         MM_SOUND_TONE_CDMA_MED_L,                                               /**TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1845         MM_SOUND_TONE_CDMA_LOW_L,                                               /**TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, 4000ms OFF, Repeat .... */
1846         MM_SOUND_TONE_CDMA_HIGH_SS,                                             /**CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1847         MM_SOUND_TONE_CDMA_MED_SS,                                              /**CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1848         MM_SOUND_TONE_CDMA_LOW_SS,                                              /**CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1849         MM_SOUND_TONE_CDMA_HIGH_SSL,                                            /**CDMA HIGH SSL tone: {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
1850         MM_SOUND_TONE_CDMA_MED_SSL,                                             /**CDMA MED SSL tone: {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
1851         MM_SOUND_TONE_CDMA_LOW_SSL,                                             /**CDMA LOW SSL tone: {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
1852         MM_SOUND_TONE_CDMA_HIGH_SS_2,                                   /**CDMA HIGH SS2 tone: {3700Hz 25ms, 4000Hz 25ms} 20 times, 1000ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 3000ms OFF, repeat .... */
1853         MM_SOUND_TONE_CDMA_MED_SS_2,                                            /**CDMA MED SS2 tone: {2600Hz 25ms, 2900Hz 25ms} 20 times, 1000ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 3000ms OFF, repeat .... */
1854         MM_SOUND_TONE_CDMA_LOW_SS_2,                                            /**CDMA LOW SS2 tone: {1300Hz 25ms, 1450Hz 25ms} 20 times, 1000ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 3000ms OFF, repeat .... */
1855         MM_SOUND_TONE_CDMA_HIGH_SLS,                                            /**CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT */
1856         MM_SOUND_TONE_CDMA_MED_SLS,                                             /**CDMA MED SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT */
1857         MM_SOUND_TONE_CDMA_LOW_SLS,                                             /**CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT */
1858         MM_SOUND_TONE_CDMA_HIGH_S_X4,                                   /**CDMA HIGH S X4 tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 2500ms OFF, REPEAT.... */
1859         MM_SOUND_TONE_CDMA_MED_S_X4,                                            /**CDMA MED S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT.... */
1860         MM_SOUND_TONE_CDMA_LOW_S_X4,                                            /**CDMA LOW S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT....*/
1861         MM_SOUND_TONE_CDMA_HIGH_PBX_L,                                  /**CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1862         MM_SOUND_TONE_CDMA_MED_PBX_L,                                   /**CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1863         MM_SOUND_TONE_CDMA_LOW_PBX_L,                                   /**CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1864         MM_SOUND_TONE_CDMA_HIGH_PBX_SS,                                         /**CDMA HIGH PBX SS tone: {3700Hz 25ms, 4000Hz 25ms} 8 times 200 ms OFF, {3700Hz 25ms 4000Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
1865         MM_SOUND_TONE_CDMA_MED_PBX_SS,                                  /**CDMA MED PBX SS tone: {2600Hz 25ms, 2900Hz 25ms} 8 times 200 ms OFF, {2600Hz 25ms 2900Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
1866         MM_SOUND_TONE_CDMA_LOW_PBX_SS,                                  /**CDMA LOW PBX SS tone: {1300Hz 25ms, 1450Hz 25ms} 8 times 200 ms OFF, {1300Hz 25ms 1450Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
1867         MM_SOUND_TONE_CDMA_HIGH_PBX_SSL,                                        /**CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
1868         MM_SOUND_TONE_CDMA_MED_PBX_SSL,                                         /**CDMA MED PBX SSL tone:{2600Hz 25ms, 2900Hz 25ms} 8 times 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
1869         MM_SOUND_TONE_CDMA_LOW_PBX_SSL,                                         /**CDMA LOW PBX SSL tone:{1300Hz 25ms, 1450Hz 25ms} 8 times 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
1870         MM_SOUND_TONE_CDMA_HIGH_PBX_SLS,                                        /**CDMA HIGH PBX SLS tone:{3700Hz 25ms, 4000Hz 25ms} 8 times 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 1000ms OFF, REPEAT....  */
1871         MM_SOUND_TONE_CDMA_MED_PBX_SLS,                                         /**CDMA MED PBX SLS tone:{2600Hz 25ms, 2900Hz 25ms} 8 times 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 1000ms OFF, REPEAT.... */
1872         MM_SOUND_TONE_CDMA_LOW_PBX_SLS,                                         /**CDMA LOW PBX SLS tone:{1300Hz 25ms, 1450Hz 25ms} 8 times 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 1000ms OFF, REPEAT.... */
1873         MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4,                               /**CDMA HIGH PBX X S4 tone: {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 800ms OFF, REPEAT... */
1874         MM_SOUND_TONE_CDMA_MED_PBX_S_X4,                                        /**CDMA MED PBX X S4 tone: {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 800ms OFF, REPEAT... */
1875         MM_SOUND_TONE_CDMA_LOW_PBX_S_X4,                                        /**CDMA LOW PBX X S4 tone: {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 800ms OFF, REPEAT... */
1876         MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE,                  /**CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON 622Hz 62ms ON, 1109Hz 62ms ON */
1877         MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE,               /**CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON */
1878         MM_SOUND_TONE_CDMA_ONE_MIN_BEEP,                                        /**CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON */
1879         MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE,              /**CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON */
1880         MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE,                   /**CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON */
1881         MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE,                           /**CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms, 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms*/
1882         MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK,                  /**CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times 4990ms OFF, REPEAT... */
1883         MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD,                    /**CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times */
1884         MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE,                             /**CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms */
1885         MM_SOUND_TONE_CDMA_CALLDROP_LITE,                               /**CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms */
1886         MM_SOUND_TONE_CDMA_NETWORK_BUSY_ONE_SHOT,               /**CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. */
1887         MM_SOUND_TONE_CDMA_ABBR_ALERT,                                  /**CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON */
1888         MM_SOUND_TONE_CDMA_SIGNAL_OFF,                                  /**CDMA_SIGNAL_OFF - silent tone */
1889         MM_SOUND_TONE_LOW_FRE,                                  /**100Hz continuous */
1890         MM_SOUND_TONE_MED_FRE,                                  /**200Hz continuous */
1891         MM_SOUND_TONE_HIGH_FRE,                                 /**300Hz continuous */
1892         MM_SOUND_TONE_NUM,
1893 }MMSoundTone_t;
1894
1895 typedef unsigned long sound_time_msec_t;                /**< millisecond unit */
1896
1897 /**
1898  * This function is to play tone sound.
1899  *
1900  * @param       num                             [in] predefined tone type (MMSoundTone_t)
1901  *                      volume config   [in] volume type & volume gain
1902  *                      volume                  [in] volume ratio (0.0 ~1.0)
1903  *                      duration                [in] millisecond (-1 for infinite)
1904  *                      handle                  [in] Handle of mm_sound_play_tone
1905  *                      enable_session  [in] set enable/unable session
1906  *
1907  * @return      This function returns MM_ERROR_NONE on success, or negative value
1908  *                      with error code.
1909  *
1910  * @remark      It doesn't provide stop
1911  * @see volume_type_t volume_gain_t MMSoundTone_t
1912  * @pre         None.
1913  * @post        TONE sound will be played.
1914  * @par Example
1915  * @code
1916 int ret = 0;
1917
1918 ret = mm_sound_play_tone_ex(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle, TRUE); //play 1 second with volume ratio 1.0
1919 if(ret < 0)
1920 {
1921         printf("play tone failed\n");
1922 }
1923 else
1924 {
1925         printf("play tone success\n");
1926 }
1927  * @endcode
1928  */
1929 int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session);
1930
1931 /**
1932  * This function is to play tone sound.
1933  *
1934  * @param       num                             [in] predefined tone type (MMSoundTone_t)
1935  *                      volume config   [in] volume type & volume gain
1936  *                      volume                  [in] volume ratio (0.0 ~1.0)
1937  *                      duration                [in] millisecond (-1 for infinite)
1938  *                      handle                  [in] Handle of mm_sound_play_tone
1939  *
1940  * @return      This function returns MM_ERROR_NONE on success, or negative value
1941  *                      with error code.
1942  *
1943  * @remark      It doesn't provide stop
1944  * @see volume_type_t volume_gain_t MMSoundTone_t
1945  * @pre         None.
1946  * @post        TONE sound will be played.
1947  * @par Example
1948  * @code
1949 int ret = 0;
1950
1951 ret = mm_sound_play_tone(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle); //play 1 second with volume ratio 1.0
1952 if(ret < 0)
1953 {
1954         printf("play tone failed\n");
1955 }
1956 else
1957 {
1958         printf("play tone success\n");
1959 }
1960  * @endcode
1961  */
1962 int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle);
1963
1964 /*
1965  * Enumerations of System audio route policy
1966  */
1967 typedef enum {
1968         SYSTEM_AUDIO_ROUTE_POLICY_DEFAULT,                      /**< Play via a2dp headset if connected. or play via headset if connected. or play via speaker.
1969                                                                                                         And capture via 4pole headset-mic if connected. or capture via mic */
1970         SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP,          /**< Play via headset if connected. or play via speaker
1971                                                                                                          And capture via 4pole headset-mic if connected. or capture via mic */
1972         SYSTEM_AUDIO_ROUTE_POLICY_HANDSET_ONLY,         /**< Play via speaker. and capture via mic  */
1973         SYSTEM_AUDIO_ROUTE_POLICY_MAX
1974 }system_audio_route_t;
1975
1976 typedef enum {
1977         SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_NONE,                        /**< Abnormal case */
1978         SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_HANDSET,             /**< Speaker or Headset or Earpiece */
1979         SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_BLUETOOTH,   /**< Bluetooth */
1980         SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_EARPHONE,    /**< Earphone */
1981         SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_MAX,
1982 }system_audio_route_device_t;
1983
1984 typedef enum {
1985         SYSTEM_AUDIO_CAPTURE_NONE,      /**< Capture device is not in use */
1986         SYSTEM_AUDIO_CAPTURE_ACTIVE,    /**< Capture device is in use */
1987         SYSTEM_AUDIO_CAPTURE_MAX,
1988 }system_audio_capture_status_t;
1989
1990
1991 /**
1992  * This function set system route policy.
1993  *
1994  * @param       route           [in] audio route type
1995  *
1996  * @return      This function returns MM_ERROR_NONE on success, or negative value
1997  *                      with error code.
1998  * @remark      If bluetooth has disconnected during SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP policy,
1999  *                      The audio route policy will be changed to SYSTEM_AUDIO_ROUTE_POLICY_DEFAULT.
2000  * @see         mm_sound_route_get_system_policy system_audio_route_t mm_sound_route_is_a2dp_on
2001  * @pre         None.
2002  * @post        Audio routing policy will be changed with given type. And route change callback function will be called if registered.
2003  * @par Example
2004  * @code
2005 int g_stop = 0;
2006 void _stop_callback()
2007 {
2008         g_stop = 1;
2009 }
2010
2011 int play_file_via_speaker()
2012 {
2013         int ret = 0;
2014         system_audio_route_t route, original_route;
2015
2016         //get backup current policy
2017         ret = mm_sound_route_get_system_policy(&original_route);
2018         if(ret < 0)
2019         {
2020                 printf("Can not get system audio route policy\n");
2021         }
2022         else
2023         {
2024                 //set route policy to ignore a2dp
2025                 route = SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP;
2026                 ret = mm_sound_route_set_system_policy(route);
2027                 if(ret < 0)
2028                 {
2029                         printf("Ca not set route policy\n");
2030                 }
2031                 else
2032                 {
2033                         int handle;
2034                         //play wav file
2035                         ret = mm_sound_play_sound("/opt/media/Sound/alert.wav", VOLUME_TYPE_SYSTEM, NULL, NULL, &handle);
2036                         if(ret < 0)
2037                         {
2038                                 printf("Can not play wav file\n");
2039                         }
2040                         else
2041                         {
2042                                 while(g_stop == 0)
2043                                 {
2044                                         sleep(1);
2045                                 }
2046                                 //restore original policy
2047                                 mm_sound_route_set_system_policy(original_route);
2048                         }
2049                 }
2050         }
2051         return 0;
2052 }
2053  * @endcode
2054  */
2055 int mm_sound_route_set_system_policy (system_audio_route_t route);
2056
2057 /**
2058  * This function get sysytem route policy.
2059  *
2060  * @param       route           [out] audio route type
2061  *
2062  * @return      This function returns MM_ERROR_NONE on success, or negative value
2063  *                      with error code.
2064  * @remark      None.
2065  * @see         mm_sound_route_set_system_policy system_audio_route_t mm_sound_route_is_a2dp_on
2066  * @pre         None.
2067  * @post        None.
2068  * @par Example
2069  * @code
2070 int g_stop = 0;
2071 void _stop_callback()
2072 {
2073         g_stop = 1;
2074 }
2075
2076 int play_file_via_speaker()
2077 {
2078         int ret = 0;
2079         system_audio_route_t route, original_route;
2080
2081         //get backup current policy
2082         ret = mm_sound_route_get_system_policy(&original_route);
2083         if(ret < 0)
2084         {
2085                 printf("Can not get system audio route policy\n");
2086         }
2087         else
2088         {
2089                 //set route policy to ignore a2dp
2090                 route = SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP;
2091                 ret = mm_sound_route_set_system_policy(route);
2092                 if(ret < 0)
2093                 {
2094                         printf("Can not set route policy\n");
2095                 }
2096                 else
2097                 {
2098                         int handle;
2099                         //play wav file
2100                         ret = mm_sound_play_sound("/opt/media/Sound/alert.wav", VOLUME_TYPE_SYSTEM, NULL, NULL, &handle);
2101                         if(ret < 0)
2102                         {
2103                                 printf("Can not play wav file\n");
2104                         }
2105                         else
2106                         {
2107                                 while(g_stop == 0)
2108                                 {
2109                                         sleep(1);
2110                                 }
2111                                 //restore original policy
2112                                 mm_sound_route_set_system_policy(original_route);
2113                         }
2114                 }
2115         }
2116         return 0;
2117 }
2118  * @endcode
2119  */
2120 int mm_sound_route_get_system_policy (system_audio_route_t *route);
2121
2122
2123
2124 /**
2125  * This function get a2dp activation information.
2126  *
2127  * @param        connected                  [out] is Bluetooth A2DP connected (1:connected, 0:not connected)
2128  *              bt_name         [out] Bluetooth A2DP connected device name (allocated by internal when connected=1 otherwise set to null)
2129  *
2130  *
2131  * @return      This function returns MM_ERROR_NONE on success, or negative value
2132  *                      with error code.
2133  * @remark      This function allocation memory to given bt_name pointer internally.
2134  *          So application should free given memory pointer later after use.
2135  *          bt_name will be null if there's no a2dp device is connected (connected is 0)
2136  * @see         mm_sound_route_set_system_policy mm_sound_route_get_system_policy
2137  * @pre         None.
2138  * @post        memory buffer will be allocated and fill with bluetooth device name.
2139  * @par Example
2140  * @code
2141 int ret;
2142 int connected = 0;
2143 char* bt_name = NULL;
2144 ret = mm_sound_route_get_a2dp_status (&connected, &bt_name);
2145
2146 if (ret == MM_ERROR_NONE) {
2147         g_print ("### Is Bluetooth A2DP On Success : connected=[%d] name=[%s]\n", connected, bt_name);
2148         if (bt_name)
2149                 free (bt_name);
2150 } else {
2151         g_print ("### Is Bluetooth A2DP On Error : errno [%d]\n", ret);
2152
2153  * @endcode
2154  */
2155 int mm_sound_route_get_a2dp_status (bool* connected, char** bt_name);
2156
2157
2158 /**
2159  * This function get current playing device.
2160  *
2161  * @param       dev             [out] current playing device information
2162  *
2163  * @return      This function returns MM_ERROR_NONE on success, or negative value
2164  *                      with error code.
2165  * @remark      if there is no running instance in system,
2166  *                      output parameter dev can be SYSTEM_AUDIO_ROUTE_PLAYING_DEVICE_NONE.
2167  *
2168  * @see         system_audio_route_device_t
2169  * @pre         None.
2170  * @post        None.
2171  * @par Example
2172  * @code
2173 int ret = 0;
2174 system_audio_route_device_t dev;
2175
2176 ret = mm_sound_route_get_playing_device (&dev);
2177 if(ret == MM_ERROR_NONE)
2178 {
2179         switch(dev)
2180         {
2181         case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_HANDSET:
2182                 printf("Handset is playing\n");
2183                 break;
2184         case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_BLUETOOTH:
2185                 printf("Bluetooth is playing\n");
2186                 break;
2187         case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_NONE:
2188         default:
2189                 printf("Unexptected\n");
2190                 break;
2191         }
2192 }
2193 else
2194 {
2195         printf ("Can not get current running device\n");
2196 }
2197
2198  * @endcode
2199  */
2200 int mm_sound_route_get_playing_device(system_audio_route_device_t *dev);
2201
2202 /**
2203  * Audio route policy change callback function type.
2204  *
2205  * @param       user_data               [in]    Argument passed when callback has called
2206  * @param       policy                  [in]    changed policy type
2207  *
2208  * @return      No return value
2209  * @remark
2210  * @see         mm_sound_volume_add_callback mm_sound_volume_remove_callback
2211  */
2212 typedef void (*audio_route_policy_changed_callback_fn)(void* user_data, system_audio_route_t policy);
2213
2214 /**
2215  * This function set system audio policy changed callback function.
2216  *
2217  * @param       func            [in] callback function pointer
2218  * @param       user_data       [in] user data will be called with func
2219  *
2220  * @return      This function returns MM_ERROR_NONE on success, or negative value
2221  *                      with error code.
2222  * @remark      None.
2223  * @see         mm_sound_route_remove_change_callback mm_sound_route_set_system_policy mm_sound_route_get_system_policy system_audio_route_t
2224  * @pre         None.
2225  * @post        None.
2226  * @par Example
2227  * @code
2228 void audio_route_policy_changed_callback(void* data, system_audio_route_t policy)
2229 {
2230         int value = (int) data;
2231         system_audio_route_t lv_policy;
2232         char *str_route[SYSTEM_AUDIO_ROUTE_POLICY_MAX] = {
2233                         "DEFAULT","IGN_A2DP","HANDSET"
2234                 };
2235         printf("Audio Route Policy has changed to [%s]\n", str_route[policy]);
2236         printf("user data : %d\n", value);
2237         if(0 > mm_sound_route_get_system_policy(&lv_policy)) {
2238                 printf("Can not get policy...in callback function\n");
2239         }
2240         else {
2241                 printf("readed policy [%s]\n", str_route[lv_policy]);
2242         }
2243 }
2244 int make_callback()
2245 {
2246         int ret = 0;
2247         ret = mm_sound_route_add_change_callback(audio_route_policy_changed_callback, (void*)111);
2248         if(ret < 0)
2249         {
2250                 printf("Can not add callback\n");
2251         }
2252         return 0;
2253 }
2254  * @endcode
2255  */
2256 int mm_sound_route_add_change_callback(audio_route_policy_changed_callback_fn func, void* user_data);
2257
2258 /**
2259  * This function remove system audio policy changed callback function.
2260  *
2261  * @return      This function returns MM_ERROR_NONE on success, or negative value
2262  *                      with error code.
2263  * @remark      None.
2264  * @see         mm_sound_route_add_change_callback mm_sound_route_set_system_policy mm_sound_route_get_system_policy system_audio_route_t
2265  * @pre         Sound route change callback should be registered.
2266  * @post        Sound route change callback deregistered and does not be called anymore.
2267  * @par Example
2268  * @code
2269 void audio_route_policy_changed_callback(void* data, system_audio_route_t policy)
2270 {
2271         int value = (int) data;
2272         system_audio_route_t lv_policy;
2273         char *str_route[SYSTEM_AUDIO_ROUTE_POLICY_MAX] = {
2274                         "DEFAULT","IGN_A2DP","HANDSET"
2275                 };
2276         printf("Audio Route Policy has changed to [%s]\n", str_route[policy]);
2277         printf("user data : %d\n", value);
2278         if(0 > mm_sound_route_get_system_policy(&lv_policy)) {
2279                 printf("Can not get policy...in callback function\n");
2280         }
2281         else {
2282                 printf("readed policy [%s]\n", str_route[lv_policy]);
2283         }
2284 }
2285 int make_callback()
2286 {
2287         int ret = 0;
2288         ret = mm_sound_route_add_change_callback(audio_route_policy_changed_callback, (void*)111);
2289         if(ret < 0)
2290         {
2291                 printf("Can not add callback\n");
2292         }
2293         else
2294         {
2295                 ret = mm_sound_route_remove_change_callback();
2296                 if(ret < 0)
2297                 {
2298                         printf("Can not remove callback\n");
2299                 }
2300         }
2301         return 0;
2302 }
2303  * @endcode
2304  */
2305 int mm_sound_route_remove_change_callback(void);
2306
2307 /*
2308  * Enumerations of device & route
2309  */
2310
2311 typedef enum{
2312         MM_SOUND_DIRECTION_NONE,
2313         MM_SOUND_DIRECTION_IN,                                                  /**< Capture */
2314         MM_SOUND_DIRECTION_OUT,                                                 /**< Playback */
2315 } mm_sound_direction;
2316
2317 typedef enum{
2318         MM_SOUND_DEVICE_IN_NONE                         = 0x00,
2319         MM_SOUND_DEVICE_IN_MIC                          = 0x01,         /**< Device builtin mic. */
2320         MM_SOUND_DEVICE_IN_WIRED_ACCESSORY      = 0x02,         /**< Wired input devices */
2321         MM_SOUND_DEVICE_IN_BT_SCO       = 0x08,         /**< Bluetooth SCO device */
2322 } mm_sound_device_in;
2323
2324 typedef enum{
2325         MM_SOUND_DEVICE_OUT_NONE                        = 0x000,
2326         MM_SOUND_DEVICE_OUT_SPEAKER             = 0x001<<8,     /**< Device builtin speaker */
2327         MM_SOUND_DEVICE_OUT_RECEIVER            = 0x002<<8,     /**< Device builtin receiver */
2328         MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY     = 0x004<<8,     /**< Wired output devices such as headphone, headset, and so on. */
2329         MM_SOUND_DEVICE_OUT_BT_SCO                      = 0x008<<8,     /**< Bluetooth SCO device */
2330         MM_SOUND_DEVICE_OUT_BT_A2DP             = 0x010<<8,     /**< Bluetooth A2DP device */
2331         MM_SOUND_DEVICE_OUT_DOCK                        = 0x020<<8,     /**< DOCK device */
2332         MM_SOUND_DEVICE_OUT_HDMI                        = 0x040<<8,     /**< HDMI device */
2333         MM_SOUND_DEVICE_OUT_MIRRORING           = 0x080<<8, /**< MIRRORING device */
2334         MM_SOUND_DEVICE_OUT_USB_AUDIO           = 0x100<<8,     /**< USB Audio device */
2335         MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK     = 0x200<<8,     /**< Multimedia DOCK device */
2336 } mm_sound_device_out;
2337
2338 typedef enum {
2339         MM_SOUND_VOLUME_DEVICE_OUT_SPEAKER,                             /**< Device builtin speaker */
2340         MM_SOUND_VOLUME_DEVICE_OUT_RECEIVER,                    /**< Device builtin receiver */
2341         MM_SOUND_VOLUME_DEVICE_OUT_WIRED_ACCESSORY,             /**< Wired output devices such as headphone, headset, and so on. */
2342         MM_SOUND_VOLUME_DEVICE_OUT_BT_SCO,                              /**< Bluetooth SCO device */
2343         MM_SOUND_VOLUME_DEVICE_OUT_BT_A2DP,                             /**< Bluetooth A2DP device */
2344         MM_SOUND_VOLUME_DEVICE_OUT_DOCK,                                /**< DOCK device */
2345         MM_SOUND_VOLUME_DEVICE_OUT_HDMI,                                /**< HDMI device */
2346         MM_SOUND_VOLUME_DEVICE_OUT_MIRRORING,                   /**< MIRRORING device */
2347         MM_SOUND_VOLUME_DEVICE_OUT_USB_AUDIO,                   /**< USB Audio device */
2348         MM_SOUND_VOLUME_DEVICE_OUT_MULTIMEDIA_DOCK,             /**< Multimedia DOCK device */
2349 } mm_sound_volume_device_out_t;
2350
2351 #define MM_SOUND_ROUTE_NUM 16
2352 #define MM_SOUND_NAME_NUM 32
2353
2354 typedef enum{
2355         MM_SOUND_ROUTE_OUT_SPEAKER = MM_SOUND_DEVICE_OUT_SPEAKER, /**< Routing audio output to builtin device such as internal speaker. */
2356         MM_SOUND_ROUTE_OUT_RECEIVER = MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio output to builtin device such as internal receiver. */
2357         MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY = MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio output to wired accessory such as headphone, headset, and so on. */
2358         MM_SOUND_ROUTE_OUT_BLUETOOTH_SCO = MM_SOUND_DEVICE_OUT_BT_SCO, /**< Routing audio output to bluetooth SCO. */
2359         MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP = MM_SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */
2360         MM_SOUND_ROUTE_OUT_DOCK = MM_SOUND_DEVICE_OUT_DOCK, /**< Routing audio output to DOCK */
2361         MM_SOUND_ROUTE_OUT_HDMI = MM_SOUND_DEVICE_OUT_HDMI, /**< Routing audio output to HDMI */
2362         MM_SOUND_ROUTE_OUT_MIRRORING = MM_SOUND_DEVICE_OUT_MIRRORING, /**< Routing audio output to MIRRORING */
2363         MM_SOUND_ROUTE_OUT_USB_AUDIO = MM_SOUND_DEVICE_OUT_USB_AUDIO, /**< Routing audio output to USB Audio */
2364         MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK = MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Routing audio output to Multimedia DOCK */
2365         MM_SOUND_ROUTE_IN_MIC = MM_SOUND_DEVICE_IN_MIC, /**< Routing audio input to device builtin mic. */
2366         MM_SOUND_ROUTE_IN_WIRED_ACCESSORY = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY, /**< Routing audio input to wired accessory. */
2367         MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio input to device builtin mic and routing audio output to builtin receiver*/
2368         MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_SPEAKER , /**< Routing audio input to device builtin mic and routing audio output to builtin speaker */
2369         MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio input to device builtin mic and routing audio output to headphone */
2370         MM_SOUND_ROUTE_INOUT_HEADSET = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,        /**< Routing audio input and output to headset*/
2371         MM_SOUND_ROUTE_INOUT_BLUETOOTH = MM_SOUND_DEVICE_IN_BT_SCO | MM_SOUND_DEVICE_OUT_BT_SCO /**< Routing audio input and output to bluetooth SCO */
2372 } mm_sound_route;
2373
2374 /*
2375  * MMSound Device APIs
2376  */
2377
2378 typedef enum {
2379         MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG      = 0x0001,  /**< Flag for input devices */
2380         MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG     = 0x0002,  /**< Flag for output devices */
2381         MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG    = 0x0004,  /**< Flag for input/output devices (both directions are available) */
2382         MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG        = 0x0010,  /**< Flag for built-in devices */
2383         MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG        = 0x0020,  /**< Flag for external devices */
2384         MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG    = 0x1000,  /**< Flag for deactivated devices */
2385         MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG      = 0x2000,  /**< Flag for activated devices */
2386         MM_SOUND_DEVICE_ALL_FLAG                  = 0xFFFF,  /**< Flag for all devices */
2387 } mm_sound_device_flags_e;
2388
2389 typedef enum {
2390         MM_SOUND_DEVICE_IO_DIRECTION_IN,
2391         MM_SOUND_DEVICE_IO_DIRECTION_OUT,
2392         MM_SOUND_DEVICE_IO_DIRECTION_BOTH,
2393 } mm_sound_device_io_direction_e;
2394
2395 typedef enum {
2396         MM_SOUND_DEVICE_STATE_DEACTIVATED,
2397         MM_SOUND_DEVICE_STATE_ACTIVATED,
2398 } mm_sound_device_state_e;
2399
2400 typedef enum
2401 {
2402         MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER,   /**< Built-in speaker. */
2403         MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER,  /**< Built-in receiver. */
2404         MM_SOUND_DEVICE_TYPE_BUILTIN_MIC,       /**< Built-in mic. */
2405         MM_SOUND_DEVICE_TYPE_AUDIOJACK,         /**< Audio jack such as headphone, headset, and so on. */
2406         MM_SOUND_DEVICE_TYPE_BLUETOOTH,         /**< Bluetooth */
2407         MM_SOUND_DEVICE_TYPE_HDMI,              /**< HDMI. */
2408         MM_SOUND_DEVICE_TYPE_MIRRORING,         /**< MIRRORING. */
2409         MM_SOUND_DEVICE_TYPE_USB_AUDIO,         /**< USB Audio. */
2410 } mm_sound_device_type_e;
2411
2412 typedef void *MMSoundDevice_t;          /**< MMsound Device handle */
2413 typedef void *MMSoundDeviceList_t;      /**< MMsound Device list handle */
2414 typedef void (*mm_sound_device_connected_cb) (MMSoundDevice_t device_h, bool is_connected, void *user_data);
2415 typedef void (*mm_sound_device_info_changed_cb) (MMSoundDevice_t device_h, int changed_info_type, void *user_data);
2416
2417 int mm_sound_add_device_connected_callback(mm_sound_device_flags_e flags, mm_sound_device_connected_cb func, void *user_data);
2418 int mm_sound_remove_device_connected_callback(void);
2419 int mm_sound_add_device_information_changed_callback(mm_sound_device_flags_e flags, mm_sound_device_info_changed_cb func, void *user_data);
2420 int mm_sound_remove_device_information_changed_callback(void);
2421
2422 int mm_sound_get_current_device_list(mm_sound_device_flags_e device_mask, MMSoundDeviceList_t *device_list);
2423 int mm_sound_get_next_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
2424 int mm_sound_get_prev_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
2425 int mm_sound_get_device_type(MMSoundDevice_t device_h, mm_sound_device_type_e *type);
2426 int mm_sound_get_device_io_direction(MMSoundDevice_t device_h, mm_sound_device_io_direction_e *io_direction);
2427 int mm_sound_get_device_id(MMSoundDevice_t device_h, int *id);
2428 int mm_sound_get_device_state(MMSoundDevice_t device_h, mm_sound_device_state_e *state);
2429 int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name);
2430
2431 /* below APIs are for product */
2432 typedef int (*mm_sound_available_route_cb)(mm_sound_route route, void *user_data);
2433 int mm_sound_is_route_available(mm_sound_route route, bool *is_available);
2434 int mm_sound_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data);
2435 int mm_sound_set_active_route(mm_sound_route route);
2436 int mm_sound_set_active_route_auto(void);
2437
2438
2439 /**
2440  * This function is to set active route without callback to client.
2441  *
2442  * @param       route                   [IN]    route
2443  * @return      This function returns MM_ERROR_NONE on success, or negative value
2444  *                      with error code.
2445  * @remark      None.
2446  * @pre         None.
2447  * @post        None.
2448  * @see         mm_sound_set_active_route_without_broadcast mm_sound_route
2449  */
2450 int mm_sound_set_active_route_without_broadcast(mm_sound_route route);
2451
2452 /**
2453  * This function is to get active playback device and capture device.
2454  *
2455  * @param       playback_device                 [out]   playback device.
2456  * @param       capture_device                  [out]   capture device.
2457  *
2458  * @return      This function returns MM_ERROR_NONE on success, or negative value
2459  *                      with error code.
2460  * @remark      None.
2461  * @pre         None.
2462  * @post        None.
2463  * @see         mm_sound_set_active_route mm_sound_device_in mm_sound_device_out
2464  */
2465 int mm_sound_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
2466
2467 /**
2468  * Active device changed callback function type.
2469  *
2470  * @param       user_data               [in]    Argument passed when callback has called
2471  *
2472  * @return      No return value
2473  * @remark      None.
2474  * @see         mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
2475  */
2476 typedef void (*mm_sound_active_device_changed_cb) (mm_sound_device_in device_in, mm_sound_device_out device_out, void *user_data);
2477
2478 /**
2479  * This function is to add active device callback.
2480  *
2481  * @param       name                    [in]    plugin name (name max size : MM_SOUND_NAME_NUM 32)
2482  * @param       func                    [in]    callback function pointer
2483  * @param       user_data               [in]    user data passing to callback function
2484  *
2485  * @return      This function returns MM_ERROR_NONE on success, or negative value
2486  *                      with error code.
2487  * @remark      None.
2488  * @see         mm_sound_remove_active_device_changed_callback mm_sound_active_device_changed_cb
2489  * @pre         None.
2490  * @post        None.
2491  * @par Example
2492  * @code
2493
2494 void __active_device_callback(void *user_data)
2495 {
2496         printf("Callback function\n");
2497 }
2498
2499 int active_device_control()
2500 {
2501         int ret = 0;
2502
2503         ret = mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
2504         if ( MM_ERROR_NONE != ret)
2505         {
2506                 printf("Can not add callback\n");
2507         }
2508         else
2509         {
2510                 printf("Add callback success\n");
2511         }
2512
2513         return ret;
2514 }
2515
2516  * @endcode
2517  */
2518 int mm_sound_add_active_device_changed_callback(const char *name,mm_sound_active_device_changed_cb func, void *user_data);
2519 /**
2520  * This function is to remove active device callback.
2521  *
2522  * @param       name                    [in]    plugin name (name max size : MM_SOUND_NAME_NUM 32)
2523  * @return      This function returns MM_ERROR_NONE on success, or negative value
2524  *                      with error code.
2525  * @remark      None.
2526  * @pre         Active device callback should be registered.
2527  * @post        Active device callback deregistered and does not be called anymore.
2528  * @see         mm_sound_add_active_device_changed_callback mm_sound_active_device_changed_cb
2529  * @par Example
2530  * @code
2531 void __active_device_callback(void *data)
2532 {
2533         printf("Callback function\n");
2534 }
2535
2536 int active_device_control()
2537 {
2538         int ret = 0;
2539
2540         mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
2541
2542         ret = mm_sound_remove_active_device_changed_callback();
2543         if ( MM_ERROR_NONE == ret)
2544         {
2545                 printf("Remove callback success\n");
2546         }
2547         else
2548         {
2549                 printf("Remove callback failed\n");
2550         }
2551
2552         return ret;
2553 }
2554
2555  * @endcode
2556  */
2557 int mm_sound_remove_active_device_changed_callback(const char *name);
2558 /**
2559  * Available route changed callback function type.
2560  *
2561  * @param       user_data               [in]    Argument passed when callback has called
2562  *
2563  * @return      No return value
2564  * @remark      None.
2565  * @see         mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
2566  */
2567 typedef void (*mm_sound_available_route_changed_cb) (mm_sound_route route, bool available, void *user_data);
2568
2569 /**
2570  * This function is to add available device callback.
2571  *
2572  * @param       func                    [in]    callback function pointer
2573  * @param       user_data               [in]    user data passing to callback function
2574  *
2575  * @return      This function returns MM_ERROR_NONE on success, or negative value
2576  *                      with error code.
2577  * @remark      None.
2578  * @see         mm_sound_remove_available_route_changed_callback mm_sound_active_device_changed_cb
2579  * @pre         None.
2580  * @post        None.
2581  * @par Example
2582  * @code
2583
2584 void __available_device_callback(void *user_data)
2585 {
2586         printf("Callback function\n");
2587 }
2588
2589 int available_device_control()
2590 {
2591         int ret = 0;
2592
2593         ret = mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2594         if ( MM_ERROR_NONE != ret)
2595         {
2596                 printf("Can not add callback\n");
2597         }
2598         else
2599         {
2600                 printf("Add callback success\n");
2601         }
2602
2603         return ret;
2604 }
2605
2606  * @endcode
2607  */
2608 int mm_sound_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void *user_data);
2609
2610 /**
2611  * This function is to remove available device callback.
2612  *
2613  * @return      This function returns MM_ERROR_NONE on success, or negative value
2614  *                      with error code.
2615  * @remark      None.
2616  * @pre         available device callback should be registered.
2617  * @post        available device callback deregistered and does not be called anymore.
2618  * @see         mm_sound_add_available_route_changed_callback mm_sound_active_device_changed_cb
2619  * @par Example
2620  * @code
2621 void __available_device_callback(void *data)
2622 {
2623         printf("Callback function\n");
2624 }
2625
2626 int available_device_control()
2627 {
2628         int ret = 0;
2629
2630         mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2631
2632         ret = mm_sound_remove_available_route_changed_callback();
2633         if ( MM_ERROR_NONE == ret)
2634         {
2635                 printf("Remove callback success\n");
2636         }
2637         else
2638         {
2639                 printf("Remove callback failed\n");
2640         }
2641
2642         return ret;
2643 }
2644
2645  * @endcode
2646  */
2647 int mm_sound_remove_available_route_changed_callback(void);
2648
2649  /**
2650  * This function is to set path for active device.
2651  *
2652  * @param       device_out              [in]    active playback device
2653  * @param       device_in               [in]    active capture device
2654  *
2655  * @return      This function returns MM_ERROR_NONE on success, or negative value
2656  *                      with error code.
2657  * @remark      None.
2658  * @see         None
2659  * @pre         None.
2660  * @post        None.
2661  * @par Example
2662  * @*/
2663 int mm_sound_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in);
2664
2665 /**
2666 * This function is to get current audio path.
2667 *
2668 * @param   device_out      [in]    active playback device
2669 * @param   device_in       [in]    active capture device
2670 *
2671 * @return  This function returns MM_ERROR_NONE on success, or negative value
2672 *                  with error code.
2673 * @remark  None.
2674 * @see     None
2675 * @pre     None.
2676 * @post    None.
2677 * @par Example
2678 * @*/
2679
2680 int mm_sound_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
2681
2682 /**
2683         @}
2684  */
2685
2686 #ifdef __cplusplus
2687 }
2688 #endif
2689
2690 #endif  /* __MM_SOUND_H__ */
2691