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