Rebase code with tizen 2.3 with following additional changes
[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 is to play PCM memory buffer.
1022  *
1023  * @param       handle  [in] handle to play pcm data
1024  * @param       ptr             [in] pcm buffer address
1025  * @param       length_byte     [in] size of pcm buffer (in bytes)
1026  *
1027  * @return      This function returns written data size on success, or negative value
1028  *                      with error code.
1029  * @remark      Make pcm buffer size with returned value of mm_sound_pcm_play_open()
1030  * @see         mm_sound_pcm_play_open, mm_sound_pcm_play_close
1031  * @pre         PCM play handle should be created.
1032  * @post        Sound will be generated with given PCM buffer data.
1033  * @par Example
1034  * @code
1035 #include <mm_sound.h>
1036 #include <stdio.h>
1037 #include <alloca.h>
1038
1039 int main(int argc, char* argv[])
1040 {
1041         FILE *fp = NULL;
1042         char *buffer = NULL;
1043         int ret = 0;
1044         int size = 0;
1045         int readed = 0;
1046         MMSoundPcmHandle_t handle;
1047         char *filename = NULL;
1048
1049         if(argc !=2 )
1050         {
1051                 printf("Usage) %s filename\n", argv[0]);
1052                 return -1;
1053         }
1054         filename = argv[1];
1055
1056         fp = fopen(filename,"r");
1057         if(fp ==NULL)
1058         {
1059                 printf("Can not open file %s\n", filename);
1060                 return -1;
1061         }
1062
1063         size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
1064         if(size < 0)
1065         {
1066                 printf("Can not open playback handle\n");
1067                 return -2;
1068         }
1069
1070         buffer = alloca(size);
1071         while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
1072         {
1073                 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
1074                 if(ret < 0)
1075                 {
1076                         printf("write fail\n");
1077                         break;
1078                 }
1079                 memset(buffer, '\0', sizeof(buffer));
1080         }
1081
1082         fclose(fp);
1083         mm_sound_pcm_play_close(handle);
1084         return 0;
1085 }
1086  * @endcode
1087  */
1088 int mm_sound_pcm_play_write(MMSoundPcmHandle_t handle, void* ptr, unsigned int length_byte);
1089
1090
1091
1092 /**
1093  * This function is to close PCM memory playback handle
1094  *
1095  * @param       handle  [in] handle to play pcm data
1096  *
1097  * @return      This function returns MM_ERROR_NONE on success, or negative value
1098  *                      with error code.
1099  * @remark      None
1100  * @see         mm_sound_pcm_play_open, mm_sound_pcm_play_write
1101  * @pre         PCM play handle should be created
1102  * @post        PCM play handle will be terminated.
1103  * @par Example
1104  * @code
1105 #include <mm_sound.h>
1106 #include <stdio.h>
1107 #include <alloca.h>
1108
1109 int main(int argc, char* argv[])
1110 {
1111         FILE *fp = NULL;
1112         char *buffer = NULL;
1113         int ret = 0;
1114         int size = 0;
1115         int readed = 0;
1116         MMSoundPcmHandle_t handle;
1117         char *filename = NULL;
1118
1119         if(argc !=2 )
1120         {
1121                 printf("Usage) %s filename\n", argv[0]);
1122                 return -1;
1123         }
1124         filename = argv[1];
1125
1126         fp = fopen(filename,"r");
1127         if(fp ==NULL)
1128         {
1129                 printf("Can not open file %s\n", filename);
1130                 return -1;
1131         }
1132
1133         size = mm_sound_pcm_play_open(&handle, 44100, MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, VOLUME_TYPE_SYSTEM);
1134         if(size < 0)
1135         {
1136                 printf("Can not open playback handle\n");
1137                 return -2;
1138         }
1139
1140         buffer = alloca(size);
1141         while((readed = fread(buffer, size, sizeof(char), fp)) > 0 )
1142         {
1143                 ret = mm_sound_pcm_play_write(handle, (void*)buffer, readed);
1144                 if(ret < 0)
1145                 {
1146                         printf("write fail\n");
1147                         break;
1148                 }
1149                 memset(buffer, '\0', sizeof(buffer));
1150         }
1151
1152         fclose(fp);
1153         mm_sound_pcm_play_close(handle);
1154         return 0;
1155 }
1156  * @endcode
1157  */
1158 int mm_sound_pcm_play_close(MMSoundPcmHandle_t handle);
1159
1160 /**
1161  * This function is to ignore session for playback
1162  *
1163  * @param       handle  [in] handle to play pcm data
1164  *
1165  * @return      This function returns MM_ERROR_NONE on success, or negative value
1166  *                      with error code.
1167  * @remark      This function only works for not started pcm handle and can't be reversed.
1168  * @see
1169  * @pre         PCM play handle should be created and not started.
1170  * @post        PCM play session will be set to mix.
1171  */
1172 int mm_sound_pcm_play_ignore_session(MMSoundPcmHandle_t *handle);
1173
1174 /**
1175  * This function is to create handle for PCM capture.
1176  *
1177  * @param       handle  [out] handle to capture pcm data
1178  * @param       rate    [in] sample rate (8000Hz ~ 44100Hz)
1179  * @param       channel [in] number of channels (mono or stereo)
1180  * @param       format  [in] S8 or S16LE
1181  *
1182  * @return      This function returns suggested buffer size (in bytes) on success, or negative value
1183  *                      with error code.
1184  * @remark      only mono channel is valid for now.
1185  * @see         mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
1186  * @pre         None.
1187  * @post        PCM capture handle will be allocated.
1188  * @par Example
1189  * @code
1190 #include <mm_sound.h>
1191 #include <stdio.h>
1192 #include <alloca.h>
1193
1194 int main(int argc, char* argv[])
1195 {
1196         FILE *fp = NULL;
1197         char *buffer = NULL;
1198         int ret = 0;
1199         int size = 0;
1200         int count = 0;
1201         MMSoundPcmHandle_t handle;
1202         char *filename = NULL;
1203
1204         if(argc !=2 )
1205         {
1206                 printf("Usage) %s filename\n", argv[0]);
1207                 return -1;
1208         }
1209         filename = argv[1];
1210
1211         fp = fopen(filename,"w");
1212         if(fp ==NULL)
1213         {
1214                 printf("Can not open file %s\n", filename);
1215                 return -1;
1216         }
1217
1218         size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1219         if(size < 0)
1220         {
1221                 printf("Can not open capture handle\n");
1222                 return -2;
1223         }
1224
1225         buffer = alloca(size);
1226         while(1)
1227         {
1228                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1229                 if(ret < 0)
1230                 {
1231                         printf("read fail\n");
1232                         break;
1233                 }
1234                 fwrite(buffer, ret, sizeof(char), fp);
1235                 if(count++ > 20) {
1236                         break;
1237                 }
1238         }
1239
1240         fclose(fp);
1241         mm_sound_pcm_capture_close(handle);
1242         return 0;
1243 }
1244
1245  * @endcode
1246  */
1247 int mm_sound_pcm_capture_open(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format);
1248
1249 /**
1250  * This function is to create handle for PCM capture of source_type.
1251  *
1252  * @param       handle  [out] handle to capture pcm data
1253  * @param       rate    [in] sample rate (8000Hz ~ 44100Hz)
1254  * @param       channel [in] number of channels (mono or stereo)
1255  * @param       format  [in] S8 or S16LE
1256  * @param       source_type             [in]  The source_type,mm_sound_source_type_e
1257  *
1258  * @return      This function returns suggested buffer size (in bytes) on success, or negative value
1259  *                      with error code.
1260  * @remark      only mono channel is valid for now.
1261  * @see         mm_sound_pcm_capture_read, mm_sound_pcm_capture_close, MMSoundPcmFormat_t, MMSoundPcmChannel_t
1262  * @pre         None.
1263  * @post        PCM capture handle will be allocated.
1264  * @par Example
1265  * @code
1266 #include <mm_sound.h>
1267 #include <stdio.h>
1268 #include <alloca.h>
1269
1270 int main(int argc, char* argv[])
1271 {
1272         FILE *fp = NULL;
1273         char *buffer = NULL;
1274         int ret = 0;
1275         int size = 0;
1276         int count = 0;
1277         MMSoundPcmHandle_t handle;
1278         char *filename = NULL;
1279
1280         if(argc !=2 )
1281         {
1282                 printf("Usage) %s filename\n", argv[0]);
1283                 return -1;
1284         }
1285         filename = argv[1];
1286
1287         fp = fopen(filename,"w");
1288         if(fp ==NULL)
1289         {
1290                 printf("Can not open file %s\n", filename);
1291                 return -1;
1292         }
1293
1294         size = mm_sound_pcm_capture_open_ex(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE,1);
1295         if(size < 0)
1296         {
1297                 printf("Can not open capture handle\n");
1298                 return -2;
1299         }
1300
1301         buffer = alloca(size);
1302         while(1)
1303         {
1304                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1305                 if(ret < 0)
1306                 {
1307                         printf("read fail\n");
1308                         break;
1309                 }
1310                 fwrite(buffer, ret, sizeof(char), fp);
1311                 if(count++ > 20) {
1312                         break;
1313                 }
1314         }
1315
1316         fclose(fp);
1317         mm_sound_pcm_capture_close(handle);
1318         return 0;
1319 }
1320
1321  * @endcode
1322  */
1323 int mm_sound_pcm_capture_open_ex(MMSoundPcmHandle_t *handle, const unsigned int rate, MMSoundPcmChannel_t channel, MMSoundPcmFormat_t format, mm_sound_source_type_e source_type);
1324
1325 /**
1326  * This function start pcm capture
1327  *
1328  * @param       handle  [in] handle to start capture
1329  *
1330  * @return      This function returns read data size on success, or negative value
1331  *                      with error code.
1332  * @remark
1333  * @see
1334  * @pre         PCM capture handle should be allocated.
1335  * @post        PCM capture data will be buffered.
1336  */
1337 int mm_sound_pcm_capture_start(MMSoundPcmHandle_t handle);
1338
1339 /**
1340  * This function stop pcm capture
1341  *
1342  * @param       handle  [in] handle to stop capture
1343  *
1344  * @return      This function returns read data size on success, or negative value
1345  *                      with error code.
1346  * @remark
1347  * @see
1348  * @pre         PCM capture handle should be allocated.
1349  * @post        PCM capture data will not be buffered.
1350  */
1351 int mm_sound_pcm_capture_stop(MMSoundPcmHandle_t handle);
1352
1353 /**
1354  * This function captures PCM to memory buffer. (Samsung extension)
1355  *
1356  * @param       handle  [in] handle to play pcm data
1357  * @param       buffer  [in] pcm buffer address
1358  * @param       length  [in] size of pcm buffer (in bytes)
1359  *
1360  * @return      This function returns read data size on success, or negative value
1361  *                      with error code.
1362  * @remark      Make pcm buffer size with returned value of mm_sound_pcm_capture_open()
1363  * @see         mm_sound_pcm_capture_open, mm_sound_pcm_capture_close
1364  * @pre         PCM capture handle should be allcated.
1365  * @post        PCM data will be filled to given memory pointer.
1366  * @par Example
1367  * @code
1368 #include <mm_sound.h>
1369 #include <stdio.h>
1370 #include <alloca.h>
1371
1372 int main(int argc, char* argv[])
1373 {
1374         FILE *fp = NULL;
1375         char *buffer = NULL;
1376         int ret = 0;
1377         int size = 0;
1378         int count = 0;
1379         MMSoundPcmHandle_t handle;
1380         char *filename = NULL;
1381
1382         if(argc !=2 )
1383         {
1384                 printf("Usage) %s filename\n", argv[0]);
1385                 return -1;
1386         }
1387         filename = argv[1];
1388
1389         fp = fopen(filename,"w");
1390         if(fp ==NULL)
1391         {
1392                 printf("Can not open file %s\n", filename);
1393                 return -1;
1394         }
1395
1396         size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1397         if(size < 0)
1398         {
1399                 printf("Can not open capture handle\n");
1400                 return -2;
1401         }
1402
1403         buffer = alloca(size);
1404         while(1)
1405         {
1406                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1407                 if(ret < 0)
1408                 {
1409                         printf("read fail\n");
1410                         break;
1411                 }
1412                 fwrite(buffer, ret, sizeof(char), fp);
1413                 if(count++ > 20) {
1414                         break;
1415                 }
1416         }
1417
1418         fclose(fp);
1419         mm_sound_pcm_capture_close(handle);
1420         return 0;
1421 }
1422
1423  * @endcode
1424  */
1425 int mm_sound_pcm_capture_read(MMSoundPcmHandle_t handle, void *buffer, const unsigned int length );
1426
1427 /**
1428  * This function captures PCM memory to memory buffer (Samsung extension)
1429  *
1430  * @param       handle  [in] handle to capture pcm data
1431  *
1432  * @return      This function returns MM_ERROR_NONE on success, or negative value
1433  *                      with error code.
1434  * @remark      None.
1435  * @see         mm_sound_pcm_capture_open, mm_sound_pcm_capture_read
1436  * @pre         PCM capture handle should be opend.
1437  * @post        PCM capture handle will be freed.
1438  * @par Example
1439  * @code
1440 #include <mm_sound.h>
1441 #include <stdio.h>
1442 #include <alloca.h>
1443
1444 int main(int argc, char* argv[])
1445 {
1446         FILE *fp = NULL;
1447         char *buffer = NULL;
1448         int ret = 0;
1449         int size = 0;
1450         int count = 0;
1451         MMSoundPcmHandle_t handle;
1452         char *filename = NULL;
1453
1454         if(argc !=2 )
1455         {
1456                 printf("Usage) %s filename\n", argv[0]);
1457                 return -1;
1458         }
1459         filename = argv[1];
1460
1461         fp = fopen(filename,"w");
1462         if(fp ==NULL)
1463         {
1464                 printf("Can not open file %s\n", filename);
1465                 return -1;
1466         }
1467
1468         size = mm_sound_pcm_capture_open(&handle, 44100, MMSOUND_PCM_MONO, MMSOUND_PCM_S16_LE);
1469         if(size < 0)
1470         {
1471                 printf("Can not open capture handle\n");
1472                 return -2;
1473         }
1474
1475         buffer = alloca(size);
1476         while(1)
1477         {
1478                 ret = mm_sound_pcm_capture_read(handle, (void*)buffer, size);
1479                 if(ret < 0)
1480                 {
1481                         printf("read fail\n");
1482                         break;
1483                 }
1484                 fwrite(buffer, ret, sizeof(char), fp);
1485                 if(count++ > 20) {
1486                         break;
1487                 }
1488         }
1489
1490         fclose(fp);
1491         mm_sound_pcm_capture_close(handle);
1492         return 0;
1493 }
1494
1495  * @endcode
1496  */
1497 int mm_sound_pcm_capture_close(MMSoundPcmHandle_t handle);
1498
1499 /**
1500  * This function is to ignore session for capture
1501  *
1502  * @param       handle  [in] handle to capture pcm data
1503  *
1504  * @return      This function returns MM_ERROR_NONE on success, or negative value
1505  *                      with error code.
1506  * @remark      This function only works for not started pcm handle and can't be reversed.
1507  * @see
1508  * @pre         PCM capture handle should be created and not started.
1509  * @post        PCM capture session will be set to mix.
1510  */
1511 int mm_sound_pcm_capture_ignore_session(MMSoundPcmHandle_t *handle);
1512
1513 /**
1514  * This function sets callback function for receiving messages from pcm API.
1515  *
1516  * @param       handle          [in]    Handle of pcm.
1517  * @param       callback        [in]    Message callback function.
1518  * @param       user_param      [in]    User parameter which is passed to callback function.
1519  *
1520  * @return      This function returns MM_ERROR_NONE on success, or negative value with error code.
1521  * @see         MMMessageCallback
1522  * @remark      None
1523  * @par Example
1524  * @code
1525 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1526 {
1527         switch (message)
1528         {
1529                 case MM_MESSAGE_SOUND_PCM_CAPTURE_RESTRICTED:
1530                         //do something
1531                         break;
1532
1533                 case MM_MESSAGE_SOUND_PCM_INTERRUPTED:
1534                         //do something
1535                         break;
1536
1537                 default:
1538                         break;
1539         }
1540         return TRUE;
1541 }
1542
1543 mm_sound_pcm_set_message_callback(pcmHandle, msg_callback, (void *)pcmHandle);
1544  * @endcode
1545  */
1546 int mm_sound_pcm_set_message_callback (MMSoundPcmHandle_t handle, MMMessageCallback callback, void *user_param);
1547
1548 /**
1549  * Terminate callback function type.
1550  *
1551  * @param       data            [in]    Argument passed when callback was set
1552  * @param       id              [in]    handle which has completed playing
1553  *
1554  * @return      No return value
1555  * @remark      It is not allowed to call MMSound API recursively or do time-consuming
1556  *                      task in this callback because this callback is called synchronously.
1557  * @see         mm_sound_play_sound
1558  */
1559 typedef void (*mm_sound_stop_callback_func) (void *data, int id);
1560
1561 /*
1562  * MMSound Play APIs
1563  */
1564
1565 /**
1566  * This function is to play system sound.
1567  *
1568  * @param       filename                [in] Sound filename to play
1569  * @param       volume config   [in] Volume type & volume gain
1570  * @param       callback                [in] Callback function pointer when playing is terminated.
1571  * @param       data                    [in] Pointer to user data when callback is called.
1572  * @param       handle                  [out] Handle of sound play.
1573  *
1574  * @return      This function returns MM_ERROR_NONE on success, or negative value
1575  *                      with error code.
1576  * @remark      When the stop callback is set, it will be called when system sound is
1577  *                      terminated. If mm_sound_stop_sound() is called apparently before
1578  *                      system sound is terminated, stop_callback will not be called.
1579  * @see         mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1580  * @pre         None.
1581  * @post        Sound will be generated with given filename.
1582  * @par Example
1583  * @code
1584 int g_stop=0;
1585 void _stop_callback(void* data)
1586 {
1587         printf("Stop callback\n");
1588         g_stop = 1;
1589 }
1590
1591 int play_file()
1592 {
1593         char filename[] ="/opt/media/Sound/testfile.wav";
1594         volume_type_t volume = VOLUME_TYPE_SYSTEM;
1595         int ret = 0;
1596         int handle = -1;
1597
1598         ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1599         if(ret < 0)
1600         {
1601                 printf("play file failed\n");
1602         }
1603         else
1604         {
1605                 printf("play file success\n");
1606         }
1607         while(g_stop == 0)
1608         {
1609                 sleep(1);
1610         }
1611         printf("play stopped\n");
1612         return 0;
1613 }
1614  * @endcode
1615  */
1616 int mm_sound_play_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1617
1618 int mm_sound_play_sound_without_session(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1619
1620 int mm_sound_play_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1621
1622 /**
1623  * This function is to play system sound. And other audio stream will be mute during playing time
1624  *
1625  * @param       filename                [in] Sound filename to play
1626  * @param       volume config   [in] Volume type & volume gain
1627  * @param       callback                [in] Callback function pointer when playing is terminated.
1628  * @param       data                    [in] Pointer to user data when callback is called.
1629  * @param       handle                  [out] Handle of sound play.
1630  *
1631  * @return      This function returns MM_ERROR_NONE on success, or negative value
1632  *                      with error code.
1633  * @remark      This function is almost same with mm_sound_play_sound,
1634  *                      but this make other audio playback stream to mute during playing time.
1635  * @see         mm_sound_stop_sound mm_sound_stop_callback_func volume_type_t volume_gain_t
1636  * @pre         None.
1637  * @post        Sound will be generated with given filename.
1638  * @par Example
1639  * @code
1640 int g_stop=0;
1641 void _stop_callback(void* data)
1642 {
1643         printf("Stop callback\n");
1644         g_stop = 1;
1645 }
1646
1647 int play_file()
1648 {
1649         char filename[] ="/opt/media/Sound/testfile.wav";
1650         volume_type_t volume = VOLUME_TYPE_SYSTEM;
1651         int ret = 0;
1652         int handle = -1;
1653
1654         ret = mm_sound_play_loud_solo_sound(filename, volume, _stop_callback, NULL, &handle);
1655         if(ret < 0)
1656         {
1657                 printf("play file failed\n");
1658         }
1659         else
1660         {
1661                 printf("play file success\n");
1662         }
1663         while(g_stop == 0)
1664         {
1665                 sleep(1);
1666         }
1667         printf("play stopped\n");
1668         return 0;
1669 }
1670  * @endcode
1671  */
1672 int mm_sound_play_loud_solo_sound(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1673
1674 int mm_sound_play_loud_solo_sound_no_restore(const char *filename, int volume_config, mm_sound_stop_callback_func callback, void *data, int *handle);
1675
1676 /**
1677  * This function is to stop playing system sound.
1678  *
1679  * @param       handle  [in] Handle of mm_sound_play_sound
1680  *
1681  * @return      This function returns MM_ERROR_NONE on success, or negative value
1682  *                      with error code.
1683  *
1684  * @remark      When system sound is terminated with this function call, it does not
1685  *                      call stop callback which was set when start playing system sound.
1686  * @see         mm_sound_play_sound
1687  * @pre         An sound play handle should be valid.
1688  * @post        Playing sound file will be stopped.
1689  * @par Example
1690  * @code
1691 int g_stop=0;
1692 void _stop_callback(void* data)
1693 {
1694         printf("Stop callback\n");
1695         g_stop = 1;
1696 }
1697
1698 int play_file_one_second()
1699 {
1700         char filename[] ="/opt/media/Sound/testfile.wav";
1701         volume_type_t volume = VOLUME_TYPE_SYSTEM;
1702         int ret = 0;
1703         int handle = -1;
1704
1705         ret = mm_sound_play_sound(filename, volume, _stop_callback, NULL, &handle);
1706         if(ret < 0)
1707         {
1708                 printf("play file failed\n");
1709         }
1710         else
1711         {
1712                 printf("play file success\n");
1713         }
1714
1715         sleep(1); //wait 1 second
1716
1717         ret = mm_sound_stop_sound(handle);
1718         if(ret < 0)
1719         {
1720                 printf("stop failed\n");
1721         }
1722         else
1723         {
1724                 printf("play stopped\n");
1725         }
1726         return 0;
1727 }
1728  * @endcode
1729  */
1730 int mm_sound_stop_sound(int handle);
1731
1732
1733 /**
1734  * Enumerations for TONE
1735  */
1736
1737 typedef enum  {
1738         MM_SOUND_TONE_DTMF_0 = 0,                       /**< Predefined DTMF 0 */
1739         MM_SOUND_TONE_DTMF_1,                           /**< Predefined DTMF 1 */
1740         MM_SOUND_TONE_DTMF_2,                           /**< Predefined DTMF 2 */
1741         MM_SOUND_TONE_DTMF_3,                           /**< Predefined DTMF 3 */
1742         MM_SOUND_TONE_DTMF_4,                           /**< Predefined DTMF 4 */
1743         MM_SOUND_TONE_DTMF_5,                           /**< Predefined DTMF 5 */
1744         MM_SOUND_TONE_DTMF_6,                           /**< Predefined DTMF 6 */
1745         MM_SOUND_TONE_DTMF_7,                           /**< Predefined DTMF 7 */
1746         MM_SOUND_TONE_DTMF_8,                           /**< Predefined DTMF 8 */
1747         MM_SOUND_TONE_DTMF_9,                           /**< Predefined DTMF 9 */
1748         MM_SOUND_TONE_DTMF_S,                           /**< Predefined DTMF Star - Asterisk (*) */
1749         MM_SOUND_TONE_DTMF_P,                           /**< Predefined DTMF sharP (#) */
1750         MM_SOUND_TONE_DTMF_A,                           /**< Predefined DTMF A (A) */
1751         MM_SOUND_TONE_DTMF_B,                           /**< Predefined DTMF B (B) */
1752         MM_SOUND_TONE_DTMF_C,                           /**< Predefined DTMF C (C) */
1753         MM_SOUND_TONE_DTMF_D,                           /**< Predefined DTMF D (D) */
1754
1755         /**< Pre-defined TONE */
1756         MM_SOUND_TONE_SUP_DIAL,                                 /**Call supervisory tone, Dial tone: CEPT: 425Hz, continuous */
1757         MM_SOUND_TONE_ANSI_DIAL,                                /**Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous */
1758         MM_SOUND_TONE_JAPAN_DIAL,                               /**Call supervisory tone, Dial tone: JAPAN: 400Hz, continuous*/
1759         MM_SOUND_TONE_SUP_BUSY,                         /**Call supervisory tone, Busy: CEPT: 425Hz, 500ms ON, 500ms OFF... */
1760         MM_SOUND_TONE_ANSI_BUSY,                                /**Call supervisory tone, Busy: ANSI (IS-95): 480Hz+620Hz, 500ms ON, 500ms OFF... */
1761         MM_SOUND_TONE_JAPAN_BUSY,                               /**Call supervisory tone, Busy: JAPAN: 400Hz, 500ms ON, 500ms OFF...*/
1762         MM_SOUND_TONE_SUP_CONGESTION,           /**Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF */
1763         MM_SOUND_TONE_ANSI_CONGESTION,          /**Call supervisory tone, Congestion: ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF... */
1764         MM_SOUND_TONE_SUP_RADIO_ACK,                    /**Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON  */
1765         MM_SOUND_TONE_JAPAN_RADIO_ACK,          /**Call supervisory tone, Radio path acknowlegment : JAPAN: 400Hz, 1s ON, 2s OFF...*/
1766         MM_SOUND_TONE_SUP_RADIO_NOTAVAIL,               /**Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts */
1767         MM_SOUND_TONE_SUP_ERROR,                                /**Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF... */
1768         MM_SOUND_TONE_SUP_CALL_WAITING,         /**Call supervisory tone, Call Waiting: CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF...  */
1769         MM_SOUND_TONE_ANSI_CALL_WAITING,                /**Call supervisory tone, Call Waiting: ANSI (IS-95): 440 Hz, 300 ms ON, 9.7 s OFF, (100 ms ON, 100 ms OFF, 100 ms ON, 9.7s OFF ...) */
1770         MM_SOUND_TONE_SUP_RINGTONE,                     /**Call supervisory tone, Ring Tone: CEPT, JAPAN: 425Hz, 1s ON, 4s OFF... */
1771         MM_SOUND_TONE_ANSI_RINGTONE,                    /**Call supervisory tone, Ring Tone: ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF... */
1772         MM_SOUND_TONE_PROP_BEEP,                                /**General beep: 400Hz+1200Hz, 35ms ON */
1773         MM_SOUND_TONE_PROP_ACK,                                 /**Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts */
1774         MM_SOUND_TONE_PROP_NACK,                                /**Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON */
1775         MM_SOUND_TONE_PROP_PROMPT,                      /**Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON         */
1776         MM_SOUND_TONE_PROP_BEEP2,                               /**Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON */
1777         MM_SOUND_TONE_SUP_INTERCEPT,                                            /**Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms */
1778         MM_SOUND_TONE_SUP_INTERCEPT_ABBREV,                             /**Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds */
1779         MM_SOUND_TONE_SUP_CONGESTION_ABBREV,                            /**Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds */
1780         MM_SOUND_TONE_SUP_CONFIRM,                                              /**Call supervisory tone (IS-95), confirm tone: a 350 Hz tone added to a 440 Hz tone repeated 3 times in a 100 ms on, 100 ms off cycle */
1781         MM_SOUND_TONE_SUP_PIP,                                                  /**Call supervisory tone (IS-95), pip tone: four bursts of 480 Hz tone (0.1 s on, 0.1 s off). */
1782         MM_SOUND_TONE_CDMA_DIAL_TONE_LITE,                              /**425Hz continuous */
1783         MM_SOUND_TONE_CDMA_NETWORK_USA_RINGBACK,                /**CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...*/
1784         MM_SOUND_TONE_CDMA_INTERCEPT,                                   /**CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...*/
1785         MM_SOUND_TONE_CDMA_ABBR_INTERCEPT,                              /**CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON */
1786         MM_SOUND_TONE_CDMA_REORDER,                                             /**CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF... */
1787         MM_SOUND_TONE_CDMA_ABBR_REORDER,                                /**CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times */
1788         MM_SOUND_TONE_CDMA_NETWORK_BUSY,                                /**CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous */
1789         MM_SOUND_TONE_CDMA_CONFIRM,                                             /**CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times */
1790         MM_SOUND_TONE_CDMA_ANSWER,                                              /**CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF */
1791         MM_SOUND_TONE_CDMA_NETWORK_CALLWAITING,                         /**CDMA Network Callwaiting tone: 440Hz 300ms ON */
1792         MM_SOUND_TONE_CDMA_PIP,                                                         /**CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times */
1793         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL,             /**ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times, 2091 32ms ON, 2556 48ms ON, 4s OFF */
1794         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP,         /**ISDN Call Signal Intergroup tone: {2091Hz 32ms ON, 2556 64ms ON} 8 times, 2091Hz 32ms ON, 400ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 8times, 2091Hz 32ms ON, 4s OFF.*/
1795         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI,             /**ISDN Call Signal SP PRI tone:{2091Hz 32ms ON, 2556 64ms ON} 4 times 2091Hz 16ms ON, 200ms OFF, {2091Hz 32ms ON, 2556Hz 64ms ON} 4 times, 2091Hz 16ms ON, 200ms OFF */
1796         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT3,               /**SDN Call sign PAT3 tone: silent tone */
1797         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING,  /**ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON */
1798         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT5,               /**ISDN Pat5 tone: silent tone */
1799         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT6,               /**ISDN Pat6 tone: silent tone */
1800         MM_SOUND_TONE_CDMA_CALL_SIGNAL_ISDN_PAT7,               /**ISDN Pat7 tone: silent tone */
1801         MM_SOUND_TONE_CDMA_HIGH_L,                                              /**TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1802         MM_SOUND_TONE_CDMA_MED_L,                                               /**TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times 4000ms OFF, Repeat .... */
1803         MM_SOUND_TONE_CDMA_LOW_L,                                               /**TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, 4000ms OFF, Repeat .... */
1804         MM_SOUND_TONE_CDMA_HIGH_SS,                                             /**CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1805         MM_SOUND_TONE_CDMA_MED_SS,                                              /**CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1806         MM_SOUND_TONE_CDMA_LOW_SS,                                              /**CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, 400ms OFF, repeat .... */
1807         MM_SOUND_TONE_CDMA_HIGH_SSL,                                            /**CDMA HIGH SSL tone: {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
1808         MM_SOUND_TONE_CDMA_MED_SSL,                                             /**CDMA MED SSL tone: {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
1809         MM_SOUND_TONE_CDMA_LOW_SSL,                                             /**CDMA LOW SSL tone: {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} repeat 16 times, 4000ms OFF, repeat ... */
1810         MM_SOUND_TONE_CDMA_HIGH_SS_2,                                   /**CDMA HIGH SS2 tone: {3700Hz 25ms, 4000Hz 25ms} 20 times, 1000ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 3000ms OFF, repeat .... */
1811         MM_SOUND_TONE_CDMA_MED_SS_2,                                            /**CDMA MED SS2 tone: {2600Hz 25ms, 2900Hz 25ms} 20 times, 1000ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 3000ms OFF, repeat .... */
1812         MM_SOUND_TONE_CDMA_LOW_SS_2,                                            /**CDMA LOW SS2 tone: {1300Hz 25ms, 1450Hz 25ms} 20 times, 1000ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 3000ms OFF, repeat .... */
1813         MM_SOUND_TONE_CDMA_HIGH_SLS,                                            /**CDMA HIGH SLS tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 3000ms OFF, REPEAT */
1814         MM_SOUND_TONE_CDMA_MED_SLS,                                             /**CDMA MED SLS tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 3000ms OFF, REPEAT */
1815         MM_SOUND_TONE_CDMA_LOW_SLS,                                             /**CDMA LOW SLS tone: {1300Hz 25ms, 1450Hz 25ms} 10 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 500ms OFF, {1300Hz 25ms, 1450Hz 25ms} 10 times, 3000ms OFF, REPEAT */
1816         MM_SOUND_TONE_CDMA_HIGH_S_X4,                                   /**CDMA HIGH S X4 tone: {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 500ms OFF, {3700Hz 25ms, 4000Hz 25ms} 10 times, 2500ms OFF, REPEAT.... */
1817         MM_SOUND_TONE_CDMA_MED_S_X4,                                            /**CDMA MED S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT.... */
1818         MM_SOUND_TONE_CDMA_LOW_S_X4,                                            /**CDMA LOW S X4 tone: {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 500ms OFF, {2600Hz 25ms, 2900Hz 25ms} 10 times, 2500ms OFF, REPEAT....*/
1819         MM_SOUND_TONE_CDMA_HIGH_PBX_L,                                  /**CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1820         MM_SOUND_TONE_CDMA_MED_PBX_L,                                   /**CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1821         MM_SOUND_TONE_CDMA_LOW_PBX_L,                                   /**CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, 2000ms OFF, REPEAT.... */
1822         MM_SOUND_TONE_CDMA_HIGH_PBX_SS,                                         /**CDMA HIGH PBX SS tone: {3700Hz 25ms, 4000Hz 25ms} 8 times 200 ms OFF, {3700Hz 25ms 4000Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
1823         MM_SOUND_TONE_CDMA_MED_PBX_SS,                                  /**CDMA MED PBX SS tone: {2600Hz 25ms, 2900Hz 25ms} 8 times 200 ms OFF, {2600Hz 25ms 2900Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
1824         MM_SOUND_TONE_CDMA_LOW_PBX_SS,                                  /**CDMA LOW PBX SS tone: {1300Hz 25ms, 1450Hz 25ms} 8 times 200 ms OFF, {1300Hz 25ms 1450Hz 25ms}8 times, 2000ms OFF, REPEAT.... */
1825         MM_SOUND_TONE_CDMA_HIGH_PBX_SSL,                                        /**CDMA HIGH PBX SSL tone:{3700Hz 25ms, 4000Hz 25ms} 8 times 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
1826         MM_SOUND_TONE_CDMA_MED_PBX_SSL,                                         /**CDMA MED PBX SSL tone:{2600Hz 25ms, 2900Hz 25ms} 8 times 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
1827         MM_SOUND_TONE_CDMA_LOW_PBX_SSL,                                         /**CDMA LOW PBX SSL tone:{1300Hz 25ms, 1450Hz 25ms} 8 times 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 1000ms OFF, REPEAT.... */
1828         MM_SOUND_TONE_CDMA_HIGH_PBX_SLS,                                        /**CDMA HIGH PBX SLS tone:{3700Hz 25ms, 4000Hz 25ms} 8 times 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 16 times, 200ms OFF, {3700Hz 25ms, 4000Hz 25ms} 8 times, 1000ms OFF, REPEAT....  */
1829         MM_SOUND_TONE_CDMA_MED_PBX_SLS,                                         /**CDMA MED PBX SLS tone:{2600Hz 25ms, 2900Hz 25ms} 8 times 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 16 times, 200ms OFF, {2600Hz 25ms, 2900Hz 25ms} 8 times, 1000ms OFF, REPEAT.... */
1830         MM_SOUND_TONE_CDMA_LOW_PBX_SLS,                                         /**CDMA LOW PBX SLS tone:{1300Hz 25ms, 1450Hz 25ms} 8 times 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 16 times, 200ms OFF, {1300Hz 25ms, 1450Hz 25ms} 8 times, 1000ms OFF, REPEAT.... */
1831         MM_SOUND_TONE_CDMA_HIGH_PBX_S_X4,                               /**CDMA HIGH PBX X S4 tone: {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 200ms OFF, {3700Hz 25ms 4000Hz 25ms} 8 times, 800ms OFF, REPEAT... */
1832         MM_SOUND_TONE_CDMA_MED_PBX_S_X4,                                        /**CDMA MED PBX X S4 tone: {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 200ms OFF, {2600Hz 25ms 2900Hz 25ms} 8 times, 800ms OFF, REPEAT... */
1833         MM_SOUND_TONE_CDMA_LOW_PBX_S_X4,                                        /**CDMA LOW PBX X S4 tone: {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 200ms OFF, {1300Hz 25ms 1450Hz 25ms} 8 times, 800ms OFF, REPEAT... */
1834         MM_SOUND_TONE_CDMA_ALERT_NETWORK_LITE,                  /**CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON 622Hz 62ms ON, 1109Hz 62ms ON */
1835         MM_SOUND_TONE_CDMA_ALERT_AUTOREDIAL_LITE,               /**CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON */
1836         MM_SOUND_TONE_CDMA_ONE_MIN_BEEP,                                        /**CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON */
1837         MM_SOUND_TONE_CDMA_KEYPAD_VOLUME_KEY_LITE,              /**CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON */
1838         MM_SOUND_TONE_CDMA_PRESSHOLDKEY_LITE,                   /**CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON */
1839         MM_SOUND_TONE_CDMA_ALERT_INCALL_LITE,                           /**CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms, 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms*/
1840         MM_SOUND_TONE_CDMA_EMERGENCY_RINGBACK,                  /**CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times 4990ms OFF, REPEAT... */
1841         MM_SOUND_TONE_CDMA_ALERT_CALL_GUARD,                    /**CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times */
1842         MM_SOUND_TONE_CDMA_SOFT_ERROR_LITE,                             /**CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms */
1843         MM_SOUND_TONE_CDMA_CALLDROP_LITE,                               /**CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms */
1844         MM_SOUND_TONE_CDMA_NETWORK_BUSY_ONE_SHOT,               /**CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF. */
1845         MM_SOUND_TONE_CDMA_ABBR_ALERT,                                  /**CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON */
1846         MM_SOUND_TONE_CDMA_SIGNAL_OFF,                                  /**CDMA_SIGNAL_OFF - silent tone */
1847         MM_SOUND_TONE_LOW_FRE,                                  /**100Hz continuous */
1848         MM_SOUND_TONE_MED_FRE,                                  /**200Hz continuous */
1849         MM_SOUND_TONE_HIGH_FRE,                                 /**300Hz continuous */
1850         MM_SOUND_TONE_NUM,
1851 }MMSoundTone_t;
1852
1853 typedef unsigned long sound_time_msec_t;                /**< millisecond unit */
1854
1855 /**
1856  * This function is to play tone sound.
1857  *
1858  * @param       num                             [in] predefined tone type (MMSoundTone_t)
1859  *                      volume config   [in] volume type & volume gain
1860  *                      volume                  [in] volume ratio (0.0 ~1.0)
1861  *                      duration                [in] millisecond (-1 for infinite)
1862  *                      handle                  [in] Handle of mm_sound_play_tone
1863  *                      enable_session  [in] set enable/unable session
1864  *
1865  * @return      This function returns MM_ERROR_NONE on success, or negative value
1866  *                      with error code.
1867  *
1868  * @remark      It doesn't provide stop
1869  * @see volume_type_t volume_gain_t MMSoundTone_t
1870  * @pre         None.
1871  * @post        TONE sound will be played.
1872  * @par Example
1873  * @code
1874 int ret = 0;
1875
1876 ret = mm_sound_play_tone_ex(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle, TRUE); //play 1 second with volume ratio 1.0
1877 if(ret < 0)
1878 {
1879         printf("play tone failed\n");
1880 }
1881 else
1882 {
1883         printf("play tone success\n");
1884 }
1885  * @endcode
1886  */
1887 int mm_sound_play_tone_ex (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle, bool enable_session);
1888
1889 /**
1890  * This function is to play tone sound.
1891  *
1892  * @param       num                             [in] predefined tone type (MMSoundTone_t)
1893  *                      volume config   [in] volume type & volume gain
1894  *                      volume                  [in] volume ratio (0.0 ~1.0)
1895  *                      duration                [in] millisecond (-1 for infinite)
1896  *                      handle                  [in] Handle of mm_sound_play_tone
1897  *
1898  * @return      This function returns MM_ERROR_NONE on success, or negative value
1899  *                      with error code.
1900  *
1901  * @remark      It doesn't provide stop
1902  * @see volume_type_t volume_gain_t MMSoundTone_t
1903  * @pre         None.
1904  * @post        TONE sound will be played.
1905  * @par Example
1906  * @code
1907 int ret = 0;
1908
1909 ret = mm_sound_play_tone(MM_SOUND_TONE_DTMF_9, VOLUME_TYPE_SYSTEM, 1.0, 1000, &handle); //play 1 second with volume ratio 1.0
1910 if(ret < 0)
1911 {
1912         printf("play tone failed\n");
1913 }
1914 else
1915 {
1916         printf("play tone success\n");
1917 }
1918  * @endcode
1919  */
1920 int mm_sound_play_tone (MMSoundTone_t num, int volume_config, const double volume, const int duration, int *handle);
1921
1922 /*
1923  * Enumerations of System audio route policy
1924  */
1925 typedef enum {
1926         SYSTEM_AUDIO_ROUTE_POLICY_DEFAULT,                      /**< Play via a2dp headset if connected. or play via headset if connected. or play via speaker.
1927                                                                                                         And capture via 4pole headset-mic if connected. or capture via mic */
1928         SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP,          /**< Play via headset if connected. or play via speaker
1929                                                                                                          And capture via 4pole headset-mic if connected. or capture via mic */
1930         SYSTEM_AUDIO_ROUTE_POLICY_HANDSET_ONLY,         /**< Play via speaker. and capture via mic  */
1931         SYSTEM_AUDIO_ROUTE_POLICY_MAX
1932 }system_audio_route_t;
1933
1934 typedef enum {
1935         SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_NONE,                        /**< Abnormal case */
1936         SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_HANDSET,             /**< Speaker or Headset or Earpiece */
1937         SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_BLUETOOTH,   /**< Bluetooth */
1938         SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_EARPHONE,    /**< Earphone */
1939         SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_MAX,
1940 }system_audio_route_device_t;
1941
1942 typedef enum {
1943         SYSTEM_AUDIO_CAPTURE_NONE,      /**< Capture device is not in use */
1944         SYSTEM_AUDIO_CAPTURE_ACTIVE,    /**< Capture device is in use */
1945         SYSTEM_AUDIO_CAPTURE_MAX,
1946 }system_audio_capture_status_t;
1947
1948
1949 /**
1950  * This function set system route policy.
1951  *
1952  * @param       route           [in] audio route type
1953  *
1954  * @return      This function returns MM_ERROR_NONE on success, or negative value
1955  *                      with error code.
1956  * @remark      If bluetooth has disconnected during SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP policy,
1957  *                      The audio route policy will be changed to SYSTEM_AUDIO_ROUTE_POLICY_DEFAULT.
1958  * @see         mm_sound_route_get_system_policy system_audio_route_t mm_sound_route_is_a2dp_on
1959  * @pre         None.
1960  * @post        Audio routing policy will be changed with given type. And route change callback function will be called if registered.
1961  * @par Example
1962  * @code
1963 int g_stop = 0;
1964 void _stop_callback()
1965 {
1966         g_stop = 1;
1967 }
1968
1969 int play_file_via_speaker()
1970 {
1971         int ret = 0;
1972         system_audio_route_t route, original_route;
1973
1974         //get backup current policy
1975         ret = mm_sound_route_get_system_policy(&original_route);
1976         if(ret < 0)
1977         {
1978                 printf("Can not get system audio route policy\n");
1979         }
1980         else
1981         {
1982                 //set route policy to ignore a2dp
1983                 route = SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP;
1984                 ret = mm_sound_route_set_system_policy(route);
1985                 if(ret < 0)
1986                 {
1987                         printf("Ca not set route policy\n");
1988                 }
1989                 else
1990                 {
1991                         int handle;
1992                         //play wav file
1993                         ret = mm_sound_play_sound("/opt/media/Sound/alert.wav", VOLUME_TYPE_SYSTEM, NULL, NULL, &handle);
1994                         if(ret < 0)
1995                         {
1996                                 printf("Can not play wav file\n");
1997                         }
1998                         else
1999                         {
2000                                 while(g_stop == 0)
2001                                 {
2002                                         sleep(1);
2003                                 }
2004                                 //restore original policy
2005                                 mm_sound_route_set_system_policy(original_route);
2006                         }
2007                 }
2008         }
2009         return 0;
2010 }
2011  * @endcode
2012  */
2013 int mm_sound_route_set_system_policy (system_audio_route_t route);
2014
2015 /**
2016  * This function get sysytem route policy.
2017  *
2018  * @param       route           [out] audio route type
2019  *
2020  * @return      This function returns MM_ERROR_NONE on success, or negative value
2021  *                      with error code.
2022  * @remark      None.
2023  * @see         mm_sound_route_set_system_policy system_audio_route_t mm_sound_route_is_a2dp_on
2024  * @pre         None.
2025  * @post        None.
2026  * @par Example
2027  * @code
2028 int g_stop = 0;
2029 void _stop_callback()
2030 {
2031         g_stop = 1;
2032 }
2033
2034 int play_file_via_speaker()
2035 {
2036         int ret = 0;
2037         system_audio_route_t route, original_route;
2038
2039         //get backup current policy
2040         ret = mm_sound_route_get_system_policy(&original_route);
2041         if(ret < 0)
2042         {
2043                 printf("Can not get system audio route policy\n");
2044         }
2045         else
2046         {
2047                 //set route policy to ignore a2dp
2048                 route = SYSTEM_AUDIO_ROUTE_POLICY_IGNORE_A2DP;
2049                 ret = mm_sound_route_set_system_policy(route);
2050                 if(ret < 0)
2051                 {
2052                         printf("Can not set route policy\n");
2053                 }
2054                 else
2055                 {
2056                         int handle;
2057                         //play wav file
2058                         ret = mm_sound_play_sound("/opt/media/Sound/alert.wav", VOLUME_TYPE_SYSTEM, NULL, NULL, &handle);
2059                         if(ret < 0)
2060                         {
2061                                 printf("Can not play wav file\n");
2062                         }
2063                         else
2064                         {
2065                                 while(g_stop == 0)
2066                                 {
2067                                         sleep(1);
2068                                 }
2069                                 //restore original policy
2070                                 mm_sound_route_set_system_policy(original_route);
2071                         }
2072                 }
2073         }
2074         return 0;
2075 }
2076  * @endcode
2077  */
2078 int mm_sound_route_get_system_policy (system_audio_route_t *route);
2079
2080
2081
2082 /**
2083  * This function get a2dp activation information.
2084  *
2085  * @param        connected                  [out] is Bluetooth A2DP connected (1:connected, 0:not connected)
2086  *              bt_name         [out] Bluetooth A2DP connected device name (allocated by internal when connected=1 otherwise set to null)
2087  *
2088  *
2089  * @return      This function returns MM_ERROR_NONE on success, or negative value
2090  *                      with error code.
2091  * @remark      This function allocation memory to given bt_name pointer internally.
2092  *          So application should free given memory pointer later after use.
2093  *          bt_name will be null if there's no a2dp device is connected (connected is 0)
2094  * @see         mm_sound_route_set_system_policy mm_sound_route_get_system_policy
2095  * @pre         None.
2096  * @post        memory buffer will be allocated and fill with bluetooth device name.
2097  * @par Example
2098  * @code
2099 int ret;
2100 int connected = 0;
2101 char* bt_name = NULL;
2102 ret = mm_sound_route_get_a2dp_status (&connected, &bt_name);
2103
2104 if (ret == MM_ERROR_NONE) {
2105         g_print ("### Is Bluetooth A2DP On Success : connected=[%d] name=[%s]\n", connected, bt_name);
2106         if (bt_name)
2107                 free (bt_name);
2108 } else {
2109         g_print ("### Is Bluetooth A2DP On Error : errno [%d]\n", ret);
2110
2111  * @endcode
2112  */
2113 int mm_sound_route_get_a2dp_status (bool* connected, char** bt_name);
2114
2115
2116 /**
2117  * This function get current playing device.
2118  *
2119  * @param       dev             [out] current playing device information
2120  *
2121  * @return      This function returns MM_ERROR_NONE on success, or negative value
2122  *                      with error code.
2123  * @remark      if there is no running instance in system,
2124  *                      output parameter dev can be SYSTEM_AUDIO_ROUTE_PLAYING_DEVICE_NONE.
2125  *
2126  * @see         system_audio_route_device_t
2127  * @pre         None.
2128  * @post        None.
2129  * @par Example
2130  * @code
2131 int ret = 0;
2132 system_audio_route_device_t dev;
2133
2134 ret = mm_sound_route_get_playing_device (&dev);
2135 if(ret == MM_ERROR_NONE)
2136 {
2137         switch(dev)
2138         {
2139         case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_HANDSET:
2140                 printf("Handset is playing\n");
2141                 break;
2142         case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_BLUETOOTH:
2143                 printf("Bluetooth is playing\n");
2144                 break;
2145         case SYSTEM_AUDIO_ROUTE_PLAYBACK_DEVICE_NONE:
2146         default:
2147                 printf("Unexptected\n");
2148                 break;
2149         }
2150 }
2151 else
2152 {
2153         printf ("Can not get current running device\n");
2154 }
2155
2156  * @endcode
2157  */
2158 int mm_sound_route_get_playing_device(system_audio_route_device_t *dev);
2159
2160 /**
2161  * Audio route policy change callback function type.
2162  *
2163  * @param       user_data               [in]    Argument passed when callback has called
2164  * @param       policy                  [in]    changed policy type
2165  *
2166  * @return      No return value
2167  * @remark
2168  * @see         mm_sound_volume_add_callback mm_sound_volume_remove_callback
2169  */
2170 typedef void (*audio_route_policy_changed_callback_fn)(void* user_data, system_audio_route_t policy);
2171
2172 /**
2173  * This function set system audio policy changed callback function.
2174  *
2175  * @param       func            [in] callback function pointer
2176  * @param       user_data       [in] user data will be called with func
2177  *
2178  * @return      This function returns MM_ERROR_NONE on success, or negative value
2179  *                      with error code.
2180  * @remark      None.
2181  * @see         mm_sound_route_remove_change_callback mm_sound_route_set_system_policy mm_sound_route_get_system_policy system_audio_route_t
2182  * @pre         None.
2183  * @post        None.
2184  * @par Example
2185  * @code
2186 void audio_route_policy_changed_callback(void* data, system_audio_route_t policy)
2187 {
2188         int value = (int) data;
2189         system_audio_route_t lv_policy;
2190         char *str_route[SYSTEM_AUDIO_ROUTE_POLICY_MAX] = {
2191                         "DEFAULT","IGN_A2DP","HANDSET"
2192                 };
2193         printf("Audio Route Policy has changed to [%s]\n", str_route[policy]);
2194         printf("user data : %d\n", value);
2195         if(0 > mm_sound_route_get_system_policy(&lv_policy)) {
2196                 printf("Can not get policy...in callback function\n");
2197         }
2198         else {
2199                 printf("readed policy [%s]\n", str_route[lv_policy]);
2200         }
2201 }
2202 int make_callback()
2203 {
2204         int ret = 0;
2205         ret = mm_sound_route_add_change_callback(audio_route_policy_changed_callback, (void*)111);
2206         if(ret < 0)
2207         {
2208                 printf("Can not add callback\n");
2209         }
2210         return 0;
2211 }
2212  * @endcode
2213  */
2214 int mm_sound_route_add_change_callback(audio_route_policy_changed_callback_fn func, void* user_data);
2215
2216 /**
2217  * This function remove system audio policy changed callback function.
2218  *
2219  * @return      This function returns MM_ERROR_NONE on success, or negative value
2220  *                      with error code.
2221  * @remark      None.
2222  * @see         mm_sound_route_add_change_callback mm_sound_route_set_system_policy mm_sound_route_get_system_policy system_audio_route_t
2223  * @pre         Sound route change callback should be registered.
2224  * @post        Sound route change callback deregistered and does not be called anymore.
2225  * @par Example
2226  * @code
2227 void audio_route_policy_changed_callback(void* data, system_audio_route_t policy)
2228 {
2229         int value = (int) data;
2230         system_audio_route_t lv_policy;
2231         char *str_route[SYSTEM_AUDIO_ROUTE_POLICY_MAX] = {
2232                         "DEFAULT","IGN_A2DP","HANDSET"
2233                 };
2234         printf("Audio Route Policy has changed to [%s]\n", str_route[policy]);
2235         printf("user data : %d\n", value);
2236         if(0 > mm_sound_route_get_system_policy(&lv_policy)) {
2237                 printf("Can not get policy...in callback function\n");
2238         }
2239         else {
2240                 printf("readed policy [%s]\n", str_route[lv_policy]);
2241         }
2242 }
2243 int make_callback()
2244 {
2245         int ret = 0;
2246         ret = mm_sound_route_add_change_callback(audio_route_policy_changed_callback, (void*)111);
2247         if(ret < 0)
2248         {
2249                 printf("Can not add callback\n");
2250         }
2251         else
2252         {
2253                 ret = mm_sound_route_remove_change_callback();
2254                 if(ret < 0)
2255                 {
2256                         printf("Can not remove callback\n");
2257                 }
2258         }
2259         return 0;
2260 }
2261  * @endcode
2262  */
2263 int mm_sound_route_remove_change_callback(void);
2264
2265 /*
2266  * Enumerations of device & route
2267  */
2268
2269 typedef enum{
2270         MM_SOUND_DIRECTION_NONE,
2271         MM_SOUND_DIRECTION_IN,                                                  /**< Capture */
2272         MM_SOUND_DIRECTION_OUT,                                                 /**< Playback */
2273 } mm_sound_direction;
2274
2275 typedef enum{
2276         MM_SOUND_DEVICE_IN_NONE                         = 0x00,
2277         MM_SOUND_DEVICE_IN_MIC                          = 0x01,         /**< Device builtin mic. */
2278         MM_SOUND_DEVICE_IN_WIRED_ACCESSORY      = 0x02,         /**< Wired input devices */
2279         MM_SOUND_DEVICE_IN_BT_SCO       = 0x08,         /**< Bluetooth SCO device */
2280 } mm_sound_device_in;
2281
2282 typedef enum{
2283         MM_SOUND_DEVICE_OUT_NONE                        = 0x000,
2284         MM_SOUND_DEVICE_OUT_SPEAKER             = 0x001<<8,     /**< Device builtin speaker */
2285         MM_SOUND_DEVICE_OUT_RECEIVER            = 0x002<<8,     /**< Device builtin receiver */
2286         MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY     = 0x004<<8,     /**< Wired output devices such as headphone, headset, and so on. */
2287         MM_SOUND_DEVICE_OUT_BT_SCO                      = 0x008<<8,     /**< Bluetooth SCO device */
2288         MM_SOUND_DEVICE_OUT_BT_A2DP             = 0x010<<8,     /**< Bluetooth A2DP device */
2289         MM_SOUND_DEVICE_OUT_DOCK                        = 0x020<<8,     /**< DOCK device */
2290         MM_SOUND_DEVICE_OUT_HDMI                        = 0x040<<8,     /**< HDMI device */
2291         MM_SOUND_DEVICE_OUT_MIRRORING           = 0x080<<8, /**< MIRRORING device */
2292         MM_SOUND_DEVICE_OUT_USB_AUDIO           = 0x100<<8,     /**< USB Audio device */
2293         MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK     = 0x200<<8,     /**< Multimedia DOCK device */
2294 } mm_sound_device_out;
2295
2296 typedef enum {
2297         MM_SOUND_VOLUME_DEVICE_OUT_SPEAKER,                             /**< Device builtin speaker */
2298         MM_SOUND_VOLUME_DEVICE_OUT_RECEIVER,                    /**< Device builtin receiver */
2299         MM_SOUND_VOLUME_DEVICE_OUT_WIRED_ACCESSORY,             /**< Wired output devices such as headphone, headset, and so on. */
2300         MM_SOUND_VOLUME_DEVICE_OUT_BT_SCO,                              /**< Bluetooth SCO device */
2301         MM_SOUND_VOLUME_DEVICE_OUT_BT_A2DP,                             /**< Bluetooth A2DP device */
2302         MM_SOUND_VOLUME_DEVICE_OUT_DOCK,                                /**< DOCK device */
2303         MM_SOUND_VOLUME_DEVICE_OUT_HDMI,                                /**< HDMI device */
2304         MM_SOUND_VOLUME_DEVICE_OUT_MIRRORING,                   /**< MIRRORING device */
2305         MM_SOUND_VOLUME_DEVICE_OUT_USB_AUDIO,                   /**< USB Audio device */
2306         MM_SOUND_VOLUME_DEVICE_OUT_MULTIMEDIA_DOCK,             /**< Multimedia DOCK device */
2307 } mm_sound_volume_device_out_t;
2308
2309 #define MM_SOUND_ROUTE_NUM 16
2310 #define MM_SOUND_NAME_NUM 32
2311
2312 typedef enum{
2313         MM_SOUND_ROUTE_OUT_SPEAKER = MM_SOUND_DEVICE_OUT_SPEAKER, /**< Routing audio output to builtin device such as internal speaker. */
2314         MM_SOUND_ROUTE_OUT_RECEIVER = MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio output to builtin device such as internal receiver. */
2315         MM_SOUND_ROUTE_OUT_WIRED_ACCESSORY = MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio output to wired accessory such as headphone, headset, and so on. */
2316         MM_SOUND_ROUTE_OUT_BLUETOOTH_SCO = MM_SOUND_DEVICE_OUT_BT_SCO, /**< Routing audio output to bluetooth SCO. */
2317         MM_SOUND_ROUTE_OUT_BLUETOOTH_A2DP = MM_SOUND_DEVICE_OUT_BT_A2DP, /**< Routing audio output to bluetooth A2DP. */
2318         MM_SOUND_ROUTE_OUT_DOCK = MM_SOUND_DEVICE_OUT_DOCK, /**< Routing audio output to DOCK */
2319         MM_SOUND_ROUTE_OUT_HDMI = MM_SOUND_DEVICE_OUT_HDMI, /**< Routing audio output to HDMI */
2320         MM_SOUND_ROUTE_OUT_MIRRORING = MM_SOUND_DEVICE_OUT_MIRRORING, /**< Routing audio output to MIRRORING */
2321         MM_SOUND_ROUTE_OUT_USB_AUDIO = MM_SOUND_DEVICE_OUT_USB_AUDIO, /**< Routing audio output to USB Audio */
2322         MM_SOUND_ROUTE_OUT_MULTIMEDIA_DOCK = MM_SOUND_DEVICE_OUT_MULTIMEDIA_DOCK, /**< Routing audio output to Multimedia DOCK */
2323         MM_SOUND_ROUTE_IN_MIC = MM_SOUND_DEVICE_IN_MIC, /**< Routing audio input to device builtin mic. */
2324         MM_SOUND_ROUTE_IN_WIRED_ACCESSORY = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY, /**< Routing audio input to wired accessory. */
2325         MM_SOUND_ROUTE_IN_MIC_OUT_RECEIVER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_RECEIVER, /**< Routing audio input to device builtin mic and routing audio output to builtin receiver*/
2326         MM_SOUND_ROUTE_IN_MIC_OUT_SPEAKER = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_SPEAKER , /**< Routing audio input to device builtin mic and routing audio output to builtin speaker */
2327         MM_SOUND_ROUTE_IN_MIC_OUT_HEADPHONE = MM_SOUND_DEVICE_IN_MIC | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,/**< Routing audio input to device builtin mic and routing audio output to headphone */
2328         MM_SOUND_ROUTE_INOUT_HEADSET = MM_SOUND_DEVICE_IN_WIRED_ACCESSORY | MM_SOUND_DEVICE_OUT_WIRED_ACCESSORY,        /**< Routing audio input and output to headset*/
2329         MM_SOUND_ROUTE_INOUT_BLUETOOTH = MM_SOUND_DEVICE_IN_BT_SCO | MM_SOUND_DEVICE_OUT_BT_SCO /**< Routing audio input and output to bluetooth SCO */
2330 } mm_sound_route;
2331
2332 /*
2333  * MMSound Device APIs
2334  */
2335
2336 typedef enum {
2337         MM_SOUND_DEVICE_IO_DIRECTION_IN_FLAG      = 0x0001,  /**< Flag for input devices */
2338         MM_SOUND_DEVICE_IO_DIRECTION_OUT_FLAG     = 0x0002,  /**< Flag for output devices */
2339         MM_SOUND_DEVICE_IO_DIRECTION_BOTH_FLAG    = 0x0004,  /**< Flag for input/output devices (both directions are available) */
2340         MM_SOUND_DEVICE_TYPE_INTERNAL_FLAG        = 0x0010,  /**< Flag for built-in devices */
2341         MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG        = 0x0020,  /**< Flag for external devices */
2342         MM_SOUND_DEVICE_STATE_DEACTIVATED_FLAG    = 0x1000,  /**< Flag for deactivated devices */
2343         MM_SOUND_DEVICE_STATE_ACTIVATED_FLAG      = 0x2000,  /**< Flag for activated devices */
2344         MM_SOUND_DEVICE_ALL_FLAG                  = 0xFFFF,  /**< Flag for all devices */
2345 } mm_sound_device_flags_e;
2346
2347 typedef enum {
2348         MM_SOUND_DEVICE_IO_DIRECTION_IN,
2349         MM_SOUND_DEVICE_IO_DIRECTION_OUT,
2350         MM_SOUND_DEVICE_IO_DIRECTION_BOTH,
2351 } mm_sound_device_io_direction_e;
2352
2353 typedef enum {
2354         MM_SOUND_DEVICE_STATE_DEACTIVATED,
2355         MM_SOUND_DEVICE_STATE_ACTIVATED,
2356 } mm_sound_device_state_e;
2357
2358 typedef enum
2359 {
2360         MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER,   /**< Built-in speaker. */
2361         MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER,  /**< Built-in receiver. */
2362         MM_SOUND_DEVICE_TYPE_BUILTIN_MIC,       /**< Built-in mic. */
2363         MM_SOUND_DEVICE_TYPE_AUDIOJACK,         /**< Audio jack such as headphone, headset, and so on. */
2364         MM_SOUND_DEVICE_TYPE_BLUETOOTH,         /**< Bluetooth */
2365         MM_SOUND_DEVICE_TYPE_HDMI,              /**< HDMI. */
2366         MM_SOUND_DEVICE_TYPE_MIRRORING,         /**< MIRRORING. */
2367         MM_SOUND_DEVICE_TYPE_USB_AUDIO,         /**< USB Audio. */
2368 } mm_sound_device_type_e;
2369
2370 typedef void *MMSoundDevice_t;          /**< MMsound Device handle */
2371 typedef void *MMSoundDeviceList_t;      /**< MMsound Device list handle */
2372 typedef void (*mm_sound_device_connected_cb) (MMSoundDevice_t device_h, bool is_connected, void *user_data);
2373 typedef void (*mm_sound_device_info_changed_cb) (MMSoundDevice_t device_h, int changed_info_type, void *user_data);
2374
2375 int mm_sound_add_device_connected_callback(mm_sound_device_flags_e flags, mm_sound_device_connected_cb func, void *user_data);
2376 int mm_sound_remove_device_connected_callback(void);
2377 int mm_sound_add_device_information_changed_callback(mm_sound_device_flags_e flags, mm_sound_device_info_changed_cb func, void *user_data);
2378 int mm_sound_remove_device_information_changed_callback(void);
2379
2380 int mm_sound_get_current_device_list(mm_sound_device_flags_e device_mask, MMSoundDeviceList_t *device_list);
2381 int mm_sound_get_next_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
2382 int mm_sound_get_prev_device (MMSoundDeviceList_t device_list, MMSoundDevice_t *device);
2383 int mm_sound_get_device_type(MMSoundDevice_t device_h, mm_sound_device_type_e *type);
2384 int mm_sound_get_device_io_direction(MMSoundDevice_t device_h, mm_sound_device_io_direction_e *io_direction);
2385 int mm_sound_get_device_id(MMSoundDevice_t device_h, int *id);
2386 int mm_sound_get_device_state(MMSoundDevice_t device_h, mm_sound_device_state_e *state);
2387 int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name);
2388
2389 /* below APIs are for product */
2390 typedef int (*mm_sound_available_route_cb)(mm_sound_route route, void *user_data);
2391 int mm_sound_is_route_available(mm_sound_route route, bool *is_available);
2392 int mm_sound_foreach_available_route_cb(mm_sound_available_route_cb, void *user_data);
2393 int mm_sound_set_active_route(mm_sound_route route);
2394 int mm_sound_set_active_route_auto(void);
2395
2396
2397 /**
2398  * This function is to set active route without callback to client.
2399  *
2400  * @param       route                   [IN]    route
2401  * @return      This function returns MM_ERROR_NONE on success, or negative value
2402  *                      with error code.
2403  * @remark      None.
2404  * @pre         None.
2405  * @post        None.
2406  * @see         mm_sound_set_active_route_without_broadcast mm_sound_route
2407  */
2408 int mm_sound_set_active_route_without_broadcast(mm_sound_route route);
2409
2410 /**
2411  * This function is to get active playback device and capture device.
2412  *
2413  * @param       playback_device                 [out]   playback device.
2414  * @param       capture_device                  [out]   capture device.
2415  *
2416  * @return      This function returns MM_ERROR_NONE on success, or negative value
2417  *                      with error code.
2418  * @remark      None.
2419  * @pre         None.
2420  * @post        None.
2421  * @see         mm_sound_set_active_route mm_sound_device_in mm_sound_device_out
2422  */
2423 int mm_sound_get_active_device(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
2424
2425 /**
2426  * Active device changed callback function type.
2427  *
2428  * @param       user_data               [in]    Argument passed when callback has called
2429  *
2430  * @return      No return value
2431  * @remark      None.
2432  * @see         mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
2433  */
2434 typedef void (*mm_sound_active_device_changed_cb) (mm_sound_device_in device_in, mm_sound_device_out device_out, void *user_data);
2435
2436 /**
2437  * This function is to add active device callback.
2438  *
2439  * @param       name                    [in]    plugin name (name max size : MM_SOUND_NAME_NUM 32)
2440  * @param       func                    [in]    callback function pointer
2441  * @param       user_data               [in]    user data passing to callback function
2442  *
2443  * @return      This function returns MM_ERROR_NONE on success, or negative value
2444  *                      with error code.
2445  * @remark      None.
2446  * @see         mm_sound_remove_active_device_changed_callback mm_sound_active_device_changed_cb
2447  * @pre         None.
2448  * @post        None.
2449  * @par Example
2450  * @code
2451
2452 void __active_device_callback(void *user_data)
2453 {
2454         printf("Callback function\n");
2455 }
2456
2457 int active_device_control()
2458 {
2459         int ret = 0;
2460
2461         ret = mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
2462         if ( MM_ERROR_NONE != ret)
2463         {
2464                 printf("Can not add callback\n");
2465         }
2466         else
2467         {
2468                 printf("Add callback success\n");
2469         }
2470
2471         return ret;
2472 }
2473
2474  * @endcode
2475  */
2476 int mm_sound_add_active_device_changed_callback(const char *name,mm_sound_active_device_changed_cb func, void *user_data);
2477 /**
2478  * This function is to remove active device callback.
2479  *
2480  * @param       name                    [in]    plugin name (name max size : MM_SOUND_NAME_NUM 32)
2481  * @return      This function returns MM_ERROR_NONE on success, or negative value
2482  *                      with error code.
2483  * @remark      None.
2484  * @pre         Active device callback should be registered.
2485  * @post        Active device callback deregistered and does not be called anymore.
2486  * @see         mm_sound_add_active_device_changed_callback mm_sound_active_device_changed_cb
2487  * @par Example
2488  * @code
2489 void __active_device_callback(void *data)
2490 {
2491         printf("Callback function\n");
2492 }
2493
2494 int active_device_control()
2495 {
2496         int ret = 0;
2497
2498         mm_sound_add_active_device_changed_callback(__active_device_callback, NULL);
2499
2500         ret = mm_sound_remove_active_device_changed_callback();
2501         if ( MM_ERROR_NONE == ret)
2502         {
2503                 printf("Remove callback success\n");
2504         }
2505         else
2506         {
2507                 printf("Remove callback failed\n");
2508         }
2509
2510         return ret;
2511 }
2512
2513  * @endcode
2514  */
2515 int mm_sound_remove_active_device_changed_callback(const char *name);
2516 /**
2517  * Available route changed callback function type.
2518  *
2519  * @param       user_data               [in]    Argument passed when callback has called
2520  *
2521  * @return      No return value
2522  * @remark      None.
2523  * @see         mm_sound_add_active_device_changed_callback mm_sound_remove_active_device_changed_callback
2524  */
2525 typedef void (*mm_sound_available_route_changed_cb) (mm_sound_route route, bool available, void *user_data);
2526
2527 /**
2528  * This function is to add available device callback.
2529  *
2530  * @param       func                    [in]    callback function pointer
2531  * @param       user_data               [in]    user data passing to callback function
2532  *
2533  * @return      This function returns MM_ERROR_NONE on success, or negative value
2534  *                      with error code.
2535  * @remark      None.
2536  * @see         mm_sound_remove_available_route_changed_callback mm_sound_active_device_changed_cb
2537  * @pre         None.
2538  * @post        None.
2539  * @par Example
2540  * @code
2541
2542 void __available_device_callback(void *user_data)
2543 {
2544         printf("Callback function\n");
2545 }
2546
2547 int available_device_control()
2548 {
2549         int ret = 0;
2550
2551         ret = mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2552         if ( MM_ERROR_NONE != ret)
2553         {
2554                 printf("Can not add callback\n");
2555         }
2556         else
2557         {
2558                 printf("Add callback success\n");
2559         }
2560
2561         return ret;
2562 }
2563
2564  * @endcode
2565  */
2566 int mm_sound_add_available_route_changed_callback(mm_sound_available_route_changed_cb func, void *user_data);
2567
2568 /**
2569  * This function is to remove available device callback.
2570  *
2571  * @return      This function returns MM_ERROR_NONE on success, or negative value
2572  *                      with error code.
2573  * @remark      None.
2574  * @pre         available device callback should be registered.
2575  * @post        available device callback deregistered and does not be called anymore.
2576  * @see         mm_sound_add_available_route_changed_callback mm_sound_active_device_changed_cb
2577  * @par Example
2578  * @code
2579 void __available_device_callback(void *data)
2580 {
2581         printf("Callback function\n");
2582 }
2583
2584 int available_device_control()
2585 {
2586         int ret = 0;
2587
2588         mm_sound_add_available_route_changed_callback(__available_device_callback, NULL);
2589
2590         ret = mm_sound_remove_available_route_changed_callback();
2591         if ( MM_ERROR_NONE == ret)
2592         {
2593                 printf("Remove callback success\n");
2594         }
2595         else
2596         {
2597                 printf("Remove callback failed\n");
2598         }
2599
2600         return ret;
2601 }
2602
2603  * @endcode
2604  */
2605 int mm_sound_remove_available_route_changed_callback(void);
2606
2607  /**
2608  * This function is to set path for active device.
2609  *
2610  * @param       device_out              [in]    active playback device
2611  * @param       device_in               [in]    active capture device
2612  *
2613  * @return      This function returns MM_ERROR_NONE on success, or negative value
2614  *                      with error code.
2615  * @remark      None.
2616  * @see         None
2617  * @pre         None.
2618  * @post        None.
2619  * @par Example
2620  * @*/
2621 int mm_sound_set_sound_path_for_active_device(mm_sound_device_out device_out, mm_sound_device_in device_in);
2622
2623 /**
2624 * This function is to get current audio path.
2625 *
2626 * @param   device_out      [in]    active playback device
2627 * @param   device_in       [in]    active capture device
2628 *
2629 * @return  This function returns MM_ERROR_NONE on success, or negative value
2630 *                  with error code.
2631 * @remark  None.
2632 * @see     None
2633 * @pre     None.
2634 * @post    None.
2635 * @par Example
2636 * @*/
2637
2638 int mm_sound_get_audio_path(mm_sound_device_in *device_in, mm_sound_device_out *device_out);
2639
2640 /**
2641         @}
2642  */
2643
2644 #ifdef __cplusplus
2645 }
2646 #endif
2647
2648 #endif  /* __MM_SOUND_H__ */
2649