4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungbae Shin <seungbae.shin@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
26 #include <semaphore.h>
28 #include "../../include/mm_sound_plugin_codec.h"
38 #include <pulse/sample.h>
39 #include "../../../include/mm_sound_pa_client.h"
42 #define M_PI 3.14159265358979323846
46 #define M_PI_2 1.57079632679489661923
49 #define SAMPLERATE 44100
51 #define SAMPLE_SIZE 16
53 #define MAX_DURATION 100
55 #define WAIT_THREAD_WAIT_CNT 100
56 #define WAIT_THREAD_WAIT_TIME 10 /* ms */
67 THREAD_STATE_NONE = 0,
82 pthread_mutex_t syncker;
90 int size; /* sizeof hole amr data */
91 pthread_mutex_t mutex;
93 /* Audio Infomations */
96 /* control Informations */
119 typedef struct st_tone
122 float middle_frequency;
123 float high_frequency;
129 static const int TONE_SEGMENT[][MM_SOUND_TONE_NUM] =
131 {941, 1336, 0, -1, 0, 0,
132 -1, -1, -1, -1, 0, 0},// 0 key: 1336Hz, 941Hz
134 {697, 1209, 0, -1, 0, 0,
135 -1, -1, -1, -1, 0, 0},// 1 key: 1209Hz, 697Hz
137 {697, 1336, 0, -1, 0, 0,
138 -1, -1, -1, -1, 0, 0},// 2 key: 1336Hz, 697Hz
140 {697, 1477, 0, -1, 0, 0,
141 -1, -1, -1, -1, 0, 0}, // 3 key: 1477Hz, 697Hz
143 {770, 1209, 0, -1, 0, 0,
144 -1, -1, -1, -1, 0, 0},// 4 key: 1209Hz, 770Hz
146 {770, 1336, 0, -1, 0, 0,
147 -1, -1, -1, -1, 0, 0},// 5 key: 1336Hz, 770Hz
149 {770, 1477, 0, -1, 0, 0,
150 -1, -1, -1, -1, 0, 0},// 6 key: 1477Hz, 770Hz
152 {852, 1209, 0, -1, 0, 0,
153 -1, -1, -1, -1, 0, 0},// 7 key: 1209Hz, 852Hz
155 {852, 1336, 0, -1, 0, 0,
156 -1, -1, -1, -1, 0, 0},// 8 key: 1336Hz, 852Hz
158 {852, 1477, 0, -1, 0, 0,
159 -1, -1, -1, -1, 0, 0},// 9 key: 1477Hz, 852Hz
161 {941, 1209, 0, -1, 0, 0,
162 -1, -1, -1, -1, 0, 0},// * key: 1209Hz, 941Hz
164 {941, 1477, 0, -1, 0, 0,
165 -1, -1, -1, -1, 0, 0},// # key: 1477Hz, 941Hz
167 {697, 1633, 0, -1, 0, 0,
168 -1, -1, -1, -1, 0, 0},// A key: 1633Hz, 697Hz
170 {770, 1633, 0, -1, 0, 0,
171 -1, -1, -1, -1, 0, 0},// B key: 1633Hz, 770Hz
173 {852, 1633, 0, -1, 0, 0,
174 -1, -1, -1, -1, 0, 0},// C key: 1633Hz, 852Hz
176 {941, 1633, 0, -1, 0, 0,
177 -1, -1, -1, -1, 0, 0}, // D key: 1633Hz, 941Hz
179 {425, 0, 0, -1, 0, 0,
180 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Dial tone: CEPT: 425Hz, continuous
182 {350, 440, 0, -1, 0, 0,
183 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Dial tone: ANSI (IS-95): 350Hz+440Hz, continuous
185 {400, 0, 0, -1, 0, 0,
186 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Dial tone: JAPAN: 400Hz, continuous
188 {425, 0, 0, 500, 0, 0,
190 -1, -1, -1, -1, 0, 0},//Call supervisory tone, Busy: CEPT: 425Hz, 500ms ON, 500ms OFF...
192 {480, 620, 0, 500, 0, 0,
194 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Busy: ANSI (IS-95): 480Hz+620Hz, 500ms ON, 500ms OFF...
196 {400, 0, 0, 500, 0, 0,
198 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Busy: JAPAN: 400Hz, 500ms ON, 500ms OFF...
200 {425, 0, 0, 200, 0, 0,
202 -1, -1, -1, -1, 1, 0}, //Call supervisory tone, Congestion: CEPT, JAPAN: 425Hz, 200ms ON, 200ms OFF
204 {480, 620, 0, 250, 0, 0,
206 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Congestion: ANSI (IS-95): 480Hz+620Hz, 250ms ON, 250ms OFF...
208 {425, 0, 0, 200, 0, 0,
209 -1, -1, -1, -1, 1, 0}, //Call supervisory tone, Radio path acknowlegment : CEPT, ANSI: 425Hz, 200ms ON
211 {400, 0, 0, 1000, 0, 0,
213 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Radio path acknowlegment : JAPAN: 400Hz, 1s ON, 2s OFF...
215 {425, 0, 0, 200, 0, 0,
217 -1, -1, -1, -1, 3, 0}, //Call supervisory tone, Radio path not available: 425Hz, 200ms ON, 200 OFF 3 bursts
219 {950, 1400, 1800, 330, 0, 0,
221 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Error/Special info: 950Hz+1400Hz+1800Hz, 330ms ON, 1s OFF...
223 {425, 0, 0, 200, 0, 0,
225 425, 0, 0, 200, 0, 0,
227 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Call Waiting: CEPT, JAPAN: 425Hz, 200ms ON, 600ms OFF, 200ms ON, 3s OFF...
229 {440, 0, 0, 300, 0, 0,
231 440, 0, 0, 100, 0, 0,
233 440, 0, 0, 100, 0, 0,
235 -1, -1, -1, -1, 0, 0}, //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 ...)
237 {425, 0, 0, 1000, 0, 0,
239 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Ring Tone: CEPT, JAPAN: 425Hz, 1s ON, 4s OFF...
241 {440, 480, 0, 2000, 0, 0,
243 -1, -1, -1, -1, 0, 0}, //Call supervisory tone, Ring Tone: ANSI (IS-95): 440Hz + 480Hz, 2s ON, 4s OFF...
245 {400, 1200, 0, 35, 0, 0,
246 -1, -1, -1, -1, 1, 0}, // General beep: 400Hz+1200Hz, 35ms ON
248 {1200, 0, 0, 100, 0, 0,
250 -1, -1, -1, -1, 2, 0}, //Proprietary tone, positive acknowlegement: 1200Hz, 100ms ON, 100ms OFF 2 bursts
252 {300, 400, 500, 400, 0, 0,
253 -1, -1, -1, -1, 1, 0}, //Proprietary tone, negative acknowlegement: 300Hz+400Hz+500Hz, 400ms ON
255 {400, 1200, 0, 200, 0, 0,
256 -1, -1, -1, -1, 1, 0}, //Proprietary tone, prompt tone: 400Hz+1200Hz, 200ms ON
258 {400, 1200, 0, 35, 0, 0,
260 400, 1200, 0, 35, 0, 0,
261 -1, -1, -1, -1, 1, 0}, //Proprietary tone, general double beep: twice 400Hz+1200Hz, 35ms ON, 200ms OFF, 35ms ON
263 {440, 0, 0, 250, 0, 0,
264 620, 0, 0, 250, 0, 0,
265 -1, -1, -1, -1, 1, 0}, //Call supervisory tone (IS-95), intercept tone: alternating 440 Hz and 620 Hz tones, each on for 250 ms
267 {440, 0, 0, 250, 0, 0,
268 620, 0, 0, 250, 0, 0,
269 -1, -1, -1, -1, 8, 0}, //Call supervisory tone (IS-95), abbreviated intercept: intercept tone limited to 4 seconds
271 {480, 620, 0, 250, 0, 0,
273 -1, -1, -1, -1, 8, 0 }, //Call supervisory tone (IS-95), abbreviated congestion: congestion tone limited to 4 seconds
275 {350, 440, 0, 100, 0, 0,
277 -1, -1, -1, -1, 3, 0}, //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
279 {480, 0, 0, 100, 0, 0,
281 -1, -1, -1, -1, 4, 0}, //Call supervisory tone (IS-95), pip tone: four bursts of 480 Hz tone (0.1 s on, 0.1 s off).
283 { 425, 0, 0, -1, 0, 0,
284 -1, -1, -1, -1, 0, 0}, //425Hz continuous
286 {440, 480, 0, 2000, 0, 0,
288 -1, -1, -1, -1, 0, 0}, //CDMA USA Ringback: 440Hz+480Hz 2s ON, 4000 OFF ...
290 {440, 0, 0, 250, 0, 0,
291 620, 0, 0, 250, 0, 0,
292 -1, -1, -1, -1, 0, 0}, //CDMA Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON ...
294 {440, 0, 0, 250, 0, 0,
295 620, 0, 0, 250, 0, 0,
296 -1, -1, -1, -1, 1, 0 }, //CDMA Abbr Intercept tone: 440Hz 250ms ON, 620Hz 250ms ON
298 {480, 620, 0, 250, 0, 0,
300 -1, -1, -1, -1, 0, 0 }, //CDMA Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF...
302 {480, 620, 0, 250, 0, 0,
304 -1, -1, -1, -1, 8, 0}, //CDMA Abbr Reorder tone: 480Hz+620Hz 250ms ON, 250ms OFF repeated for 8 times
306 {480, 620, 0, 500, 0, 0,
308 -1, -1, -1, -1, 0, 0}, //CDMA Network Busy tone: 480Hz+620Hz 500ms ON, 500ms OFF continuous
310 {350, 440, 0, 100, 0, 0,
312 -1, -1, -1, -1, 3, 0}, //CDMA Confirm tone: 350Hz+440Hz 100ms ON, 100ms OFF repeated for 3 times
314 {660, 1000, 0, 500, 0, 0,
316 -1, -1, -1, -1, 1, 0}, //CDMA answer tone: silent tone - defintion Frequency 0, 0ms ON, 0ms OFF
318 {440, 0, 0, 300, 0, 0,
319 -1, -1, -1, -1, 1, 0}, //CDMA Network Callwaiting tone: 440Hz 300ms ON
321 {480, 0, 0, 100, 0, 0,
323 -1, -1, -1, -1, 4, 0}, //CDMA PIP tone: 480Hz 100ms ON, 100ms OFF repeated for 4 times
325 {2090, 0, 0, 32, 0, 0,
326 2556, 0, 0, 64, 19, 0,
327 2090, 0, 0, 32, 0, 0,
328 2556, 0, 0, 48, 0, 0,
330 -1, -1, -1, -1, 1, 0}, //ISDN Call Signal Normal tone: {2091Hz 32ms ON, 2556 64ms ON} 20 times, 2091 32ms ON, 2556 48ms ON, 4s OFF
332 {2091, 0, 0, 32, 0, 0,
333 2556, 0, 0, 64, 7, 0,
334 2091, 0, 0, 32, 0, 0,
336 2091, 0, 0, 32, 0, 0,
337 2556, 0, 0, 64, 7, 4,
338 2091, 0, 0, 32, 0, 0,
340 -1, -1, -1, -1, 1, 0}, //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
342 {2091, 0, 0, 32, 0, 0,
343 2556, 0, 0, 64, 3, 0,
344 2091, 0, 0, 32, 0, 0,
346 2091, 0, 0, 32, 0, 0,
347 2556, 0, 0, 64, 3, 4,
348 2091, 0, 0, 32, 0, 0,
350 -1, -1, -1, -1, 1, 0},//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
353 -1, -1, -1, -1, 1, 0}, //ISDN Call sign PAT3 tone: silent tone
355 {2091, 0, 0, 32, 0, 0,
356 2556, 0, 0, 64, 4, 0,
357 2091, 0, 0, 20, 0, 0,
358 -1, -1, -1, -1, 1, 0}, //ISDN Ping Ring tone: {2091Hz 32ms ON, 2556Hz 64ms ON} 5 times 2091Hz 20ms ON
361 -1, -1, -1, -1, 1, 0}, //ISDN Pat5 tone: silent tone
364 -1, -1, -1, -1, 1, 0}, //ISDN Pat6 tone: silent tone
367 -1, -1, -1, -1, 1, 0}, //ISDN Pat7 tone: silent tone
369 {3700, 0, 0, 25, 0, 0,
370 4000, 0, 0, 25, 39, 0,
372 -1, -1, -1, -1, 0, 0}, //TONE_CDMA_HIGH_L tone: {3700Hz 25ms, 4000Hz 25ms} 40 times 4000ms OFF, Repeat ....
374 {2600, 0, 0, 25, 0, 0,
375 2900, 0, 0, 25, 39, 0,
377 -1, -1, -1, -1, 0, 0},//TONE_CDMA_MED_L tone: {2600Hz 25ms, 2900Hz 25ms} 40 times 4000ms OFF, Repeat ....
379 {1300, 0, 0, 25, 0, 0,
380 1450, 0, 0, 25, 39, 0,
382 -1, -1, -1, -1, 0, 0}, //TONE_CDMA_LOW_L tone: {1300Hz 25ms, 1450Hz 25ms} 40 times, 4000ms OFF, Repeat ....
384 {3700, 0, 0, 25, 0, 0,
385 4000, 0, 0, 25, 15, 0,
387 -1, -1, -1, -1, 0, 0},//CDMA HIGH SS tone: {3700Hz 25ms, 4000Hz 25ms} repeat 16 times, 400ms OFF, repeat ....
389 {2600, 0, 0, 25, 0, 0,
390 2900, 0, 0, 25, 15, 0,
392 -1, -1, -1, -1, 0, 0}, //CDMA MED SS tone: {2600Hz 25ms, 2900Hz 25ms} repeat 16 times, 400ms OFF, repeat ....
394 {1300, 0, 0, 25, 0, 0,
395 1450, 0, 0, 25, 15, 0,
397 -1, -1, -1, -1, 0, 0}, //CDMA LOW SS tone: {1300z 25ms, 1450Hz 25ms} repeat 16 times, 400ms OFF, repeat ....
399 {3700, 0, 0, 25, 0, 0,
400 4000, 0, 0, 25, 7, 0,
402 3700, 0, 0, 25, 0, 0,
403 4000, 0, 0, 25, 7, 3,
405 3700, 0, 0, 25, 0, 0,
406 4000, 0, 0, 25, 15, 6,
408 -1, -1, -1, -1, 0, 0}, //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 ...
410 {2600, 0, 0, 25, 0, 0,
411 2900, 0, 0, 25, 7, 0,
413 2600, 0, 0, 25, 0, 0,
414 2900, 0, 0, 25, 7, 3,
416 2600, 0, 0, 25, 0, 0,
417 2900, 0, 0, 25, 15, 6,
419 -1, -1, -1, -1, 0, 0}, //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 ...
421 {1300, 0, 0, 25, 0, 0,
422 1450, 0, 0, 25, 7, 0,
424 1300, 0, 0, 25, 0, 0,
425 1450, 0, 0, 25, 7, 3,
427 1300, 0, 0, 25, 0, 0,
428 1450, 0, 0, 25, 15, 6,
430 -1, -1, -1, -1, 0, 0}, //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 ...
432 {3700, 0, 0, 25, 0, 0,
433 4000, 0, 0, 25, 19, 0,
435 3700, 0, 0, 25, 0, 0,
436 4000, 0, 0, 25, 19, 3,
438 -1, -1, -1, -1, 0, 0 },//CDMA HIGH SS2 tone: {3700Hz 25ms, 4000Hz 25ms} 20 times, 1000ms OFF, {3700Hz 25ms, 4000Hz 25ms} 20 times, 3000ms OFF, repeat ....
440 {2600, 0, 0, 25, 0, 0,
441 2900, 0, 0, 25, 19, 0,
443 2600, 0, 0, 25, 0, 0,
444 2900, 0, 0, 25, 19, 3,
446 -1, -1, -1, -1, 0, 0}, //CDMA MED SS2 tone: {2600Hz 25ms, 2900Hz 25ms} 20 times, 1000ms OFF, {2600Hz 25ms, 2900Hz 25ms} 20 times, 3000ms OFF, repeat ....
448 {1300, 0, 0, 25, 0, 0,
449 1450, 0, 0, 25, 19, 0,
451 1300, 0, 0, 25, 0, 0,
452 1450, 0, 0, 25, 19, 3,
454 -1, -1, -1, -1, 0, 0 }, //CDMA LOW SS2 tone: {1300Hz 25ms, 1450Hz 25ms} 20 times, 1000ms OFF, {1300Hz 25ms, 1450Hz 25ms} 20 times, 3000ms OFF, repeat ....
456 {3700, 0, 0, 25, 0, 0,
457 4000, 0, 0, 25, 9, 0,
459 3700, 0, 0, 25, 0, 0,
460 4000, 0, 0, 25, 19, 3,
462 3700, 0, 0, 25, 0, 0,
463 4000, 0, 0, 25, 9, 6,
465 -1, -1, -1, -1, 0, 0}, //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....
467 {2600, 0, 0, 25, 0, 0,
468 2900, 0, 0, 25, 9, 0,
470 2600, 0, 0, 25, 0, 0,
471 2900, 0, 0, 25, 19, 3,
473 2600, 0, 0, 25, 0, 0,
474 2900, 0, 0, 25, 9, 6,
476 -1, -1, -1, -1, 0, 0}, //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....
478 {1300, 0, 0, 25, 0, 0,
479 1450, 0, 0, 25, 9, 0,
481 1300, 0, 0, 25, 0, 0,
482 1450, 0, 0, 25, 19, 3,
484 1300, 0, 0, 25, 0, 0,
485 1450, 0, 0, 25, 9, 6,
487 -1, -1, -1, -1, 0, 0}, //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....
489 {3700, 0, 0, 25, 0, 0,
490 4000, 0, 0, 25, 9, 0,
492 3700, 0, 0, 25, 0, 0,
493 4000, 0, 0, 25, 9, 3,
495 3700, 0, 0, 25, 0, 0,
496 4000, 0, 0, 25, 9, 6,
498 -1, -1, -1, -1, 0, 0}, ////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....
500 {2600, 0, 0, 25, 0, 0,
501 2900, 0, 0, 25, 9, 0,
503 2600, 0, 0, 25, 0, 0,
504 2900, 0, 0, 25, 9, 4,
506 2600, 0, 0, 25, 0, 0,
507 2900, 0, 0, 25, 9, 6,
509 -1, -1, -1, -1, 0, 0 },//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....
511 {1300, 0, 0, 25, 0, 0,
512 1450, 0, 0, 25, 9, 0,
514 1300, 0, 0, 25, 0, 0,
515 1450, 0, 0, 25, 9, 3,
517 1300, 0, 0, 25, 0, 0,
518 1450, 0, 0, 25, 9, 6,
520 -1, -1, -1, -1, 0, 0}, //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....
522 {3700, 0, 0, 25, 0, 0,
523 4000, 0, 0, 25, 19, 0,
525 -1, -1, -1, -1, 0, 0 },//CDMA HIGH PBX L: {3700Hz 25ms, 4000Hz 25ms}20 times, 2000ms OFF, REPEAT....
527 {2600, 0, 0, 25, 0, 0,
528 2900, 0, 0, 25, 19, 0,
530 -1, -1, -1, -1, 0, 0}, //CDMA MED PBX L: {2600Hz 25ms, 2900Hz 25ms}20 times, 2000ms OFF, REPEAT....
532 {1300, 0, 0, 25, 0, 0,
533 1450, 0, 0, 25, 19, 0,
535 -1, -1, -1, -1, 0, 0 },//CDMA LOW PBX L: {1300Hz 25ms,1450Hz 25ms}20 times, 2000ms OFF, REPEAT....
537 {3700, 0, 0, 25, 0, 0,
538 4000, 0, 0, 25, 7, 0,
540 3700, 0, 0, 25, 0, 0,
541 4000, 0, 0, 25, 7, 3,
543 -1, -1, -1, -1, 0, 0}, //CDMA HIGH PBX SS tone: {3700Hz 25ms, 4000Hz 25ms} 8 times 200 ms OFF, {3700Hz 25ms 4000Hz 25ms}8 times, 2000ms OFF, REPEAT....
545 {2600, 0, 0, 25, 0, 0,
546 2900, 0, 0, 25, 7, 0,
548 2600, 0, 0, 25, 0, 0,
549 2900, 0, 0, 25, 7, 3,
551 -1, -1, -1, -1, 0, 0 }, //CDMA MED PBX SS tone: {2600Hz 25ms, 2900Hz 25ms} 8 times 200 ms OFF, {2600Hz 25ms 2900Hz 25ms}8 times, 2000ms OFF, REPEAT....
553 {1300, 0, 0, 25, 0, 0,
554 1450, 0, 0, 25, 7, 0,
556 1300, 0, 0, 25, 0, 0,
557 1450, 0, 0, 25, 7, 3,
559 -1, -1, -1, -1, 0, 0 },//CDMA LOW PBX SS tone: {1300Hz 25ms, 1450Hz 25ms} 8 times 200 ms OFF, {1300Hz 25ms 1450Hz 25ms}8 times, 2000ms OFF, REPEAT....
561 {3700, 0, 0, 25, 0, 0,
562 4000, 0, 0, 25, 7, 0,
564 3700, 0, 0, 25, 0, 0,
565 4000, 0, 0, 25, 7, 3,
567 3700, 0, 0, 25, 0, 0,
568 4000, 0, 0, 25, 15, 6,
570 -1, -1, -1, -1, 0, 0}, //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....//
572 {2600, 0, 0, 25, 0, 0,
573 2900, 0, 0, 25, 7, 0,
575 2600, 0, 0, 25, 0, 0,
576 2900, 0, 0, 25, 7, 3,
578 2600, 0, 0, 25, 0, 0,
579 2900, 0, 0, 25, 15, 6,
581 -1, -1, -1, -1, 0, 0}, //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....//
583 {1300, 0, 0, 25, 0, 0,
584 1450, 0, 0, 25, 7, 0,
586 1300, 0, 0, 25, 0, 0,
587 1450, 0, 0, 25, 7, 3,
589 1300, 0, 0, 25, 0, 0,
590 1450, 0, 0, 25, 15, 6,
592 -1, -1, -1, -1, 0, 0}, //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....//
594 {3700, 0, 0, 25, 0, 0,
595 4000, 0, 0, 25, 15, 0,
597 3700, 0, 0, 25, 0, 0,
598 4000, 0, 0, 25, 7, 3,
600 -1, -1, -1, -1, 0, 0 },//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.... //
602 {2600, 0, 0, 25, 0, 0,
603 2900, 0, 0, 25, 15, 0,
605 2600, 0, 0, 25, 0, 0,
606 2900, 0, 0, 25, 7, 3,
608 -1, -1, -1, -1, 0, 0 }, //CDMA HIGH 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....//
610 {1300, 0, 0, 25, 0, 0,
611 1450, 0, 0, 25, 15, 0,
613 1300, 0, 0, 25, 0, 0,
614 1450, 0, 0, 25, 7, 3,
616 -1, -1, -1, -1, 0, 0 }, //CDMA HIGH 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....//
618 {3700, 0, 0, 25, 0, 0,
619 4000, 0, 0, 25, 7, 0,
621 3700, 0, 0, 25, 0, 0,
622 4000, 0, 0, 25, 7, 3,
624 3700, 0, 0, 25, 0, 0,
625 4000, 0, 0, 25, 7, 6,
627 3700, 0, 0, 25, 0, 0,
628 4000, 0, 0, 25, 7, 9,
630 -1, -1, -1, -1, 0, 0}, //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...
632 {2600, 0, 0, 25, 0, 0,
633 2900, 0, 0, 25, 7, 0,
635 2600, 0, 0, 25, 0, 0,
636 2900, 0, 0, 25, 7, 3,
638 2600, 0, 0, 25, 0, 0,
639 2900, 0, 0, 25, 7, 6,
641 2600, 0, 0, 25, 0, 0,
642 2900, 0, 0, 25, 7, 9,
644 -1, -1, -1, -1, 0, 0}, //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...
646 {1300, 0, 0, 25, 0, 0,
647 1450, 0, 0, 25, 7, 0,
649 1300, 0, 0, 25, 0, 0,
650 1450, 0, 0, 25, 7, 3,
652 1300, 0, 0, 25, 0, 0,
653 1450, 0, 0, 25, 7, 6,
655 1300, 0, 0, 25, 0, 0,
656 1450, 0, 0, 25, 7, 9,
658 -1, -1, -1, -1, 0, 0}, //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...
660 {1109, 0, 0, 62, 0, 0,
664 1109, 0, 0, 62, 0, 0,
665 -1, -1, -1, -1, 1, 0}, //CDMA Alert Network Lite tone: 1109Hz 62ms ON, 784Hz 62ms ON, 740Hz 62ms ON 622Hz 62ms ON, 1109Hz 62ms ON
667 {1245, 0, 0, 62, 0, 0,
669 1245, 0, 0, 62, 0, 0,
671 1245, 0, 0, 62, 0, 0,
673 1245, 0, 0, 62, 0, 0,
674 -1, -1, -1, -1, 1, 0},//CDMA Alert Auto Redial tone: {1245Hz 62ms ON, 659Hz 62ms ON} 3 times, 1245 62ms ON//
676 {1150, 770, 0, 400, 0, 0,
677 -1, -1, -1, -1, 1, 0}, //CDMA One Min Beep tone: 1150Hz+770Hz 400ms ON//
679 {941, 1477, 0, 120, 0, 0,
680 -1, -1, -1, -1, 1, 0}, //CDMA KEYPAD Volume key lite tone: 941Hz+1477Hz 120ms ON
682 {587, 0, 0, 375, 0, 0,
683 1175, 0, 0, 125, 0, 0,
684 -1, -1, -1, -1, 1, 0}, //CDMA PRESSHOLDKEY LITE tone: 587Hz 375ms ON, 1175Hz 125ms ON
686 {587, 0, 0, 62, 0, 0,
690 1109, 0, 0, 62, 0, 0,
694 -1, -1, -1, -1, 1, 0}, //CDMA ALERT INCALL LITE tone: 587Hz 62ms, 784 62ms, 831Hz 62ms, 784Hz 62ms, 1109 62ms, 784Hz 62ms, 831Hz 62ms, 784Hz 62ms
696 {941, 0, 0, 125, 0, 0,
698 941, 0, 0, 125, 0, 0,
700 1245, 0, 0, 62, 0, 0,
703 -1, -1, -1, -1, 0, 0}, //CDMA EMERGENCY RINGBACK tone: {941Hz 125ms ON, 10ms OFF} 3times 4990ms OFF, REPEAT...
705 {1319, 0, 0, 125, 0, 0,
707 -1, -1, -1, -1, 3, 0 }, //CDMA ALERT CALL GUARD tone: {1319Hz 125ms ON, 125ms OFF} 3 times
709 {1047, 0, 0, 125, 0, 0,
710 370, 0, 0, 125, 0, 0,
711 -1, -1, -1, -1, 1, 0}, //CDMA SOFT ERROR LITE tone: 1047Hz 125ms ON, 370Hz 125ms
713 {1480, 0, 0, 125, 0, 0,
714 1397, 0, 0, 125, 0, 0,
715 784, 0, 0, 125, 0, 0,
716 -1, -1, -1, -1, 1, 0}, //CDMA CALLDROP LITE tone: 1480Hz 125ms, 1397Hz 125ms, 784Hz 125ms//
718 {425, 0, 0, 125, 0, 0,
720 -1, -1, -1, -1, 1, 0},//CDMA_NETWORK_BUSY_ONE_SHOT tone: 425Hz 500ms ON, 500ms OFF
722 {1150, 770, 0, 400, 0, 0,
723 -1, -1, -1, -1, 1, 0}, //CDMA_ABBR_ALERT tone: 1150Hz+770Hz 400ms ON
726 -1, -1, -1, -1, 1, 0}, //CDMA_SIGNAL_OFF - silent tone
728 {100, 0, 0, -1, 0, 0,
729 -1, -1, -1, -1, 0, 0}, //100Hz continuous
731 {200, 0, 0, -1, 0, 0,
732 -1, -1, -1, -1, 0, 0}, //200Hz continuous
734 {300, 0, 0, -1, 0, 0,
735 -1, -1, -1, -1, 0, 0}, //300Hz continuous
739 static tone_control_t g_control;
742 static int (*g_thread_pool_func)(void*, void (*)(void*)) = NULL;
744 static int _MMSoundToneInit(void);
745 static int _MMSoundToneFini(void);
747 static void _running_tone(void *param);
751 int* MMSoundPlugCodecToneGetSupportTypes(void)
754 static int suported[2] = {MM_SOUND_SUPPORTED_CODEC_DTMF, 0};
759 int MMSoundPlugCodecToneParse(MMSourceType *source, mmsound_codec_info_t *info)
764 return MM_ERROR_NONE;
767 int MMSoundPlugCodecToneCreate(mmsound_codec_param_t *param, mmsound_codec_info_t *info, MMHandleType *handle)
769 tone_info_t *toneInfo;
774 int result = MM_ERROR_NONE;
779 toneInfo = (tone_info_t *)malloc(sizeof(tone_info_t));
780 if (toneInfo == NULL) {
781 debug_error("memory allocation error\n");
782 return MM_ERROR_OUT_OF_MEMORY;
785 memset(toneInfo, 0, sizeof(tone_info_t));
787 pthread_mutex_init(&toneInfo->mutex, NULL);
788 pthread_mutex_lock(&toneInfo->mutex);
789 toneInfo->state = STATE_READY;
790 toneInfo->thread_state = THREAD_STATE_NONE;
791 pthread_mutex_unlock(&toneInfo->mutex);
793 ss.rate = SAMPLERATE;
794 ss.channels = CHANNELS;
795 ss.format = PA_SAMPLE_S16LE;
797 toneInfo->handle = mm_sound_pa_open(HANDLE_MODE_OUTPUT, param->volume_config, &ss, NULL, &size, param->stream_type, param->stream_index);
798 if (!toneInfo->handle) {
799 debug_error("Device Open Error 0x%x\n", result);
802 debug_log("Create audio_handle is %lu\n", toneInfo->handle);
804 debug_msg("tone : %d\n", param->tone);
805 debug_msg("repeat : %d\n", param->repeat_count);
806 debug_msg("volume config : %x\n", param->volume_config);
807 debug_msg("callback : %p\n", param->stop_cb);
808 debug_msg("pid : %d\n", param->pid);
810 toneInfo->number = param->tone;
811 toneInfo->time = param->repeat_count;
812 toneInfo->stop_cb = param->stop_cb;
813 toneInfo->cb_param = param->param;
814 toneInfo->pid = param->pid;
815 toneInfo->volume = param->volume;
817 result = g_thread_pool_func(toneInfo, _running_tone);
819 debug_error("pthread_create() fail in pcm thread\n");
820 result = MM_ERROR_SOUND_INTERNAL;
824 *handle = (MMHandleType)toneInfo;
826 debug_msg("wait until thread_stare THREAD_STATE_START");
827 while((toneInfo->thread_state == THREAD_STATE_NONE) && (wait_count < WAIT_THREAD_WAIT_CNT)) {
828 usleep(WAIT_THREAD_WAIT_TIME * 1000);
832 if (wait_count >= WAIT_THREAD_WAIT_CNT) {
833 debug_error("timeout for thread pool. wait_count: %d ms ", WAIT_THREAD_WAIT_CNT * WAIT_THREAD_WAIT_TIME);
835 debug_msg("_running_tone thread is started");
839 return MM_ERROR_NONE;
843 if(toneInfo->handle) {
844 if(MM_ERROR_NONE != mm_sound_pa_close(toneInfo->handle))
845 debug_error("mm_sound_pa_close() fail. handle(%lu)\n", toneInfo->handle);
854 int MMSoundPlugCodecToneDestroy(MMHandleType handle)
856 tone_info_t *toneInfo = (tone_info_t*) handle;
857 int err = MM_ERROR_NONE;
859 debug_critical("Confirm the hadle (is NULL)\n");
860 return MM_ERROR_SOUND_INTERNAL;
863 debug_enter("(handle %x)\n", handle);
865 pthread_mutex_destroy(&toneInfo->mutex);
874 int MMSoundPlugCodecTonePlay(MMHandleType handle)
876 tone_info_t *toneInfo = (tone_info_t *) handle;
878 debug_enter("(handle %x)\n", handle);
879 pthread_mutex_lock(&toneInfo->mutex);
880 toneInfo->state = STATE_BEGIN;
881 pthread_mutex_unlock(&toneInfo->mutex);
882 debug_msg("sent start signal\n");
886 return MM_ERROR_NONE;
890 _create_tone(double *sample, TONE _TONE, double volume, int *toneSize, gboolean is_cycle_ended)
894 double amplitude, f1, f2, f3;
897 float middle_frequency;
898 float high_frequency;
904 middle_frequency = 0;
907 low_frequency = _TONE.low_frequency;
908 middle_frequency = _TONE.middle_frequency;
909 high_frequency = _TONE.high_frequency;
913 debug_error("Sample buffer is not allocated\n");
917 /* Create a buffer for the tone */
918 if((_TONE.playingTime > MAX_DURATION) || (_TONE.playingTime == -1) ) {
919 *toneSize = ((MAX_DURATION / 1000.) * SAMPLERATE * SAMPLE_SIZE * CHANNELS) / 8;
921 *toneSize = ((_TONE.playingTime / 1000.) * SAMPLERATE * SAMPLE_SIZE * CHANNELS) / 8;
923 *toneSize = ((*toneSize+1)>>1)<<1;
924 sample_size = (*toneSize) / (SAMPLE_SIZE / 8);
926 debug_log("%0.f, %0.f, %0.f _TONE.playing_time: %d toneSize: %d\n",
927 low_frequency, middle_frequency, high_frequency, _TONE.playingTime, *toneSize);
929 buffer = g_malloc (*toneSize);
931 debug_error("Buffer is not allocated\n");
934 pbuf = (short*)buffer;
936 if(_TONE.low_frequency > 0) {
939 if(_TONE.middle_frequency > 0) {
942 if(_TONE.high_frequency > 0) {
946 for (i = 0; i < sample_size; i++) {
948 * We add the fundamental frequencies together.
951 f1 = sin (2 * M_PI * low_frequency * ((*sample) / SAMPLERATE));
952 f2 = sin (2 * M_PI * middle_frequency * ((*sample) / SAMPLERATE));
953 f3 = sin (2 * M_PI * high_frequency * ((*sample) / SAMPLERATE));
955 if(f1 + f2 + f3 != 0) {
956 amplitude = (f1 + f2 + f3) / quota;
957 /* Adjust the volume */
960 /* Make the [-1:1] interval into a [-32767:32767] interval */
966 /* Store it in the data buffer */
967 *(pbuf++) = (short) amplitude;
976 _mm_get_tone(int key, int CurIndex)
980 _TONE.low_frequency = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + LOW_FREQUENCY];
981 _TONE.middle_frequency = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + MIDDLE_FREQUENCY];
982 _TONE.high_frequency = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + HIGH_FREQUENCY];
983 _TONE.playingTime = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + PLAYING_TIME];
984 _TONE.loopCnt = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + LOOP_COUNT];
985 _TONE.loopIndx = TONE_SEGMENT[key][CurIndex * TONE_COLUMN + LOOP_INDEX];
991 _mm_get_waveCnt_PlayingTime(int toneTime, TONE _TONE, int *waveCnt, int *waveRestPlayTime)
993 int ret = MM_ERROR_NONE;
994 if(waveCnt == NULL || waveRestPlayTime == NULL) {
995 debug_error("waveCnt || waveRestPlayTime buffer is NULL\n");
996 return MM_ERROR_SOUND_INTERNAL;
998 /*Set wave count and wave playing time*/
999 if( _TONE.playingTime == -1) {
1000 *waveCnt = abs(toneTime) /MAX_DURATION;
1001 *waveRestPlayTime = abs(toneTime) % MAX_DURATION;
1003 *waveCnt = _TONE.playingTime /MAX_DURATION;
1004 *waveRestPlayTime = _TONE.playingTime % MAX_DURATION;
1010 _mm_get_CurIndex(TONE _TONE, int *CurArrayPlayCnt, int *CurIndex)
1012 int ret = MM_ERROR_NONE;
1013 if(CurArrayPlayCnt == NULL || CurIndex == NULL) {
1014 debug_error("CurArrayPlayCnt || CurIndex buffer is NULL\n");
1015 return MM_ERROR_SOUND_INTERNAL;
1018 if(_TONE.loopCnt != 0 && *CurArrayPlayCnt <= _TONE.loopCnt) {
1019 (*CurArrayPlayCnt)++;
1020 if(*CurArrayPlayCnt >_TONE.loopCnt) {
1022 *CurArrayPlayCnt = 0;
1024 *CurIndex = _TONE.loopIndx;
1029 debug_log("[%d] CurIndex: %d", *CurArrayPlayCnt, *CurIndex);
1033 static void _running_tone(void *param)
1035 char *ptoneBuf = NULL;
1039 debug_error("param Buffer is not allocated\n");
1042 tone_info_t *toneInfo = (tone_info_t*) param;
1045 int prePlayingTime = 0;
1047 int playingTime = 0;
1049 int CurWaveIndex = 0;
1051 int waveRestPlayTime = 0;
1053 int CurArrayPlayCnt = 0;
1054 gboolean is_cycle_ended = FALSE;
1057 pthread_mutex_lock(&toneInfo->mutex);
1058 toneInfo->thread_state = THREAD_STATE_START;
1059 debug_msg("set thread_state as THREAD_STATE_START");
1060 pthread_mutex_unlock(&toneInfo->mutex);
1062 toneTime = toneInfo->time;
1064 toneKey = toneInfo->number;
1065 debug_msg ("toneKey number = %d\n", toneKey);
1067 /* Set pid check file */
1068 snprintf(filename, sizeof(filename), "/proc/%d/cmdline", toneInfo->pid);
1070 debug_msg("Wait start signal\n");
1071 while(toneInfo->state == STATE_READY)
1073 debug_msg("Recv start signal\n");
1074 pthread_mutex_lock(&toneInfo->mutex);
1076 if ((toneInfo->state == STATE_STOP)||(toneInfo->thread_state == THREAD_STATE_STOP)) {
1077 debug_msg("state is stop. state(%d) thread_state(%d) goto exit.\n", toneInfo->state, toneInfo->thread_state );
1078 pthread_mutex_unlock(&toneInfo->mutex);
1081 debug_msg("set state STATE_PLAY\n");
1082 toneInfo->state = STATE_PLAY;
1084 pthread_mutex_unlock(&toneInfo->mutex);
1090 while (toneInfo->thread_state == THREAD_STATE_START) {
1091 TONE _TONE = _mm_get_tone(toneKey, CurIndex); /*Pop one of Tone Set */
1092 if(_mm_get_waveCnt_PlayingTime(toneTime, _TONE, &numWave, &waveRestPlayTime) != MM_ERROR_NONE) {
1093 debug_error("_mm_get_waveCnt_PlayingTime return value error\n");
1097 if(_mm_get_CurIndex(_TONE, &CurArrayPlayCnt, &CurIndex) != MM_ERROR_NONE) {
1098 debug_error("_mm_get_CurIndex return value error\n");
1102 debug_log ("Predefined Tone[%d] Total Play time (ms) : %d, _TONE.playing_time: %d _numWave = %d low_frequency: %0.f, middle_frequency: %0.f, high_frequency: %0.f\n",
1103 CurIndex, toneTime, _TONE.playingTime, numWave, _TONE.low_frequency, _TONE.middle_frequency, _TONE.high_frequency);
1106 if (_TONE.low_frequency == -1) { /* skip frequency which's value is -1*/
1107 if((_TONE.loopCnt > 0) && (CurArrayPlayCnt == _TONE.loopCnt)) {
1108 is_cycle_ended = TRUE;
1109 debug_log("[is_cycle_ended]");
1111 CurIndex = _TONE.loopIndx;
1115 /* Write pcm data */
1116 for(CurWaveIndex = 0; CurWaveIndex < numWave+1; CurWaveIndex++) {
1117 if(CurWaveIndex == numWave ) { /* play the last tone set*/
1118 playingTime = waveRestPlayTime;
1120 playingTime = MAX_DURATION;
1122 duration = playingTime;
1124 if(playingTime == 0) {
1128 if(prePlayingTime + playingTime > toneTime && toneTime != -1) {
1129 playingTime = toneTime - prePlayingTime;
1132 ptoneBuf = _create_tone(&sample, _TONE, toneInfo->volume, &toneSize, is_cycle_ended);
1133 if(ptoneBuf == NULL) {
1134 debug_error("Tone Buffer is not allocated\n");
1137 debug_log ("[TONE] Play.....%dth %dms\n", CurWaveIndex, playingTime);
1138 mm_sound_pa_write(toneInfo->handle, ptoneBuf, ((toneSize * playingTime /duration + 1)>>1)<<1);
1139 prePlayingTime += playingTime;
1140 debug_log ("previous_sum: %d\n", prePlayingTime);
1144 if(prePlayingTime == toneTime || toneInfo->state != STATE_PLAY) {
1145 debug_log ("Finished.....on Total Playing Time : %d _TONE.playing_time: %d\n", prePlayingTime, _TONE.playingTime);
1146 mm_sound_pa_drain(toneInfo->handle);
1147 debug_log ("Finished.....quit loop\n");
1150 debug_log ("[%d] CurIndex: %d previous_sum: %d\n", CurArrayPlayCnt, CurIndex, prePlayingTime);
1155 if(MM_ERROR_NONE != mm_sound_pa_close(toneInfo->handle))
1156 debug_error("mm_sound_pa_close() fail. handle(%lu)\n", toneInfo->handle);
1159 pthread_mutex_destroy(&g_control.syncker);
1162 debug_msg("Play end\n");
1163 pthread_mutex_lock(&toneInfo->mutex);
1164 toneInfo->state = STATE_NONE;
1165 pthread_mutex_unlock(&toneInfo->mutex);
1167 if (toneInfo->stop_cb)
1168 toneInfo->stop_cb(toneInfo->cb_param);
1174 int MMSoundPlugCodecToneStop(MMHandleType handle)
1176 tone_info_t *toneInfo = (tone_info_t*) handle;
1178 debug_enter("(handle %x)\n", handle);
1179 pthread_mutex_lock(&toneInfo->mutex);
1180 /*If stopped why stop again*/
1181 if (toneInfo->state == STATE_NONE || toneInfo->state == STATE_STOP) {
1182 pthread_mutex_unlock(&toneInfo->mutex);
1183 debug_msg("state(%d) is already STOP or NONE. return\n", toneInfo->state);
1184 return MM_ERROR_NONE;
1186 toneInfo->state = STATE_STOP;
1187 toneInfo->thread_state = THREAD_STATE_STOP;
1188 pthread_mutex_unlock(&toneInfo->mutex);
1189 debug_msg("sent stop signal\n");
1191 while(toneInfo->state != STATE_NONE) {
1197 return MM_ERROR_NONE;
1201 int MMSoundPlugCodecToneSetThreadPool(int (*func)(void*, void (*)(void*)))
1203 debug_enter("(func : 0x%x)\n", func);
1204 g_thread_pool_func = func;
1206 return MM_ERROR_NONE;
1210 static int _MMSoundToneInit(void)
1212 memset(&g_control, 0, sizeof(tone_control_t));
1213 pthread_mutex_init(&g_control.syncker, NULL);
1214 return MM_ERROR_NONE;
1217 static int _MMSoundToneFini(void)
1219 pthread_mutex_destroy(&g_control.syncker);
1220 return MM_ERROR_NONE;
1225 int MMSoundGetPluginType(void)
1229 return MM_SOUND_PLUGIN_TYPE_CODEC;
1233 int MMSoundPlugCodecGetInterface(mmsound_codec_interface_t *intf)
1237 intf->GetSupportTypes = MMSoundPlugCodecToneGetSupportTypes;
1238 intf->Parse = MMSoundPlugCodecToneParse;
1239 intf->Create = MMSoundPlugCodecToneCreate;
1240 intf->Destroy = MMSoundPlugCodecToneDestroy;
1241 intf->Play = MMSoundPlugCodecTonePlay;
1242 intf->Stop = MMSoundPlugCodecToneStop;
1243 intf->SetThreadPool = MMSoundPlugCodecToneSetThreadPool;
1247 return MM_ERROR_NONE;