blob: 4f521e5af33c372b6afd0742242a5f054116143c [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001/*-----------------------------------------------------------------------------------------------*/
2/**
3 @file ql_audio_cfg.h
4 @brief audio config API, including audio initlization, audio configuration
5
6 @detailes
7 Quectel AG55x series module AUDIO service.
8
9 @htmlonly
10 <span style="font-weight: bold">History</span>
11 @endhtmlonly
12
13 when | who | what, where, why
14 -------- | --- | ----------------------------------------------------------
15 2021-11-03 | dameng.lin | Created .
16
17 Copyright (c) 2019 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
18 Quectel Wireless Solution Proprietary and Confidential.
19-------------------------------------------------------------------------------------------------*/
20#ifndef __QL_AUDIO_CFG_H__
21#define __QL_AUDIO_CFG_H__
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include <math.h>
28#include <stdint.h>
29#include "mbtk_log.h"
30#include "mbtk_audio2.h"
31#include "mbtk_audio_gain.h"
32#include "mbtk_audio_ubus.h"
33#include "ql_v2/ql_type.h"
34
35#define QL_AUDIO_STATE_0 0
36#define QL_AUDIO_STATE_1 1
37
38#define AUDIO_MODE_NORMAL 0
39#define AUDIO_MODE_RINGTONE 1
40#define AUDIO_MODE_IN_CALL 2
41#define DEVICE_EARPIECE 0
42#define DEVICE_SPEAKER 1
43#define DEVICE_HEADSET 2
44
45#define MIC_GAIN_MIN 0
46#define MIC_GAIN_MAX 65535
47#define VOLUME_MIN 0
48#define VOLUME_MAX 100
49
50static int32_t stored_mic_gain = -1;
51static int32_t stored_down_volume = -1;
52
53
54/**
55 @brief The audio service error callback function
56 @param error error code.See ql_type.h for details.
57*/
58typedef void (*ql_audio_service_error_cb_f)(int error);
59
60ql_audio_service_error_cb_f audio_error_callback = NULL;
61
62/*-----------------------------------------------------------------------------------------------*/
63/**
64 @brief This function initializes an audio service.
65
66 @retval QL_ERR_OK Successful execution
67 @retval QL_ERR_SERVICE_NOT_READY Audio service not ready. Try again later.
68 @retval Others Failed execution.See ql_type.h for error codes
69 */
70/*-----------------------------------------------------------------------------------------------*/
71int ql_audio_init(void)
72{
73 int result = mbtk_audio_pcm_init();
74 if (result != 0) {
75 LOGE("Error: mbtk_audio_wav_init failed with error code %d\n", result);
76 if (audio_error_callback) {
77 audio_error_callback(result);
78 }
79 return QL_ERR_SERVICE_NOT_READY;
80 }
81
82 return QL_ERR_OK;
83}
84/*-----------------------------------------------------------------------------------------------*/
85/**
86 @brief This function deinitializes audio services.
87
88 @retval QL_ERR_OK Successful
89 @retval QL_ERR_SERVICE_NOT_READY Service is not ready, need to retry
90 @retval Others Failed execution.See ql_type.h for error codes.
91 */
92/*-----------------------------------------------------------------------------------------------*/
93int ql_audio_deinit(void)
94{
95 int result = mbtk_audio_wav_deinit();
96 if (result != 0) {
97 LOGE("Error: mbtk_audio_wav_deinit failed with error code %d\n", result);
98 if (audio_error_callback) {
99 audio_error_callback(result);
100 }
101 return QL_ERR_SERVICE_NOT_READY;
102 }
103
104 return QL_ERR_OK;
105}
106
107/*-----------------------------------------------------------------------------------------------*/
108/**
109 @brief This function sets the value of a mixer.
110
111 @param[in] control the name of the mixer
112 @param[in] val_list the value of the mixer to be set. String type value.Multiple values are separated by spaces.
113
114 @retval QL_ERR_OK Successful execution
115 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
116 @retval Others Failed execution.See ql_type.h for error codes.
117 */
118/*-----------------------------------------------------------------------------------------------*/
119int ql_audio_set_mixer_control(const char *control, const char *val_list);
120
121/*-----------------------------------------------------------------------------------------------*/
122/**
123 @brief This function gets the value of the mixer.
124
125 @param[in] control the name of the mixer
126 @param[out] val_list_buf buffer for storing mixer values
127 @param[in] buf_size the buffer size. Unit:Byte
128
129 @retval QL_ERR_OK Successful execution.
130 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
131 @retval Others Failed execution.See ql_type.h for error codes.
132
133 @note Generally, 64 bytes is enough
134 */
135/*-----------------------------------------------------------------------------------------------*/
136int ql_audio_get_mixer_control(const char *control, char *val_list_buf, uint32_t buf_size);
137
138
139
140/*-----------------------------------------------------------------------------------------------*/
141/**
142 @brief This function sets the microphone gain for voice call uplink.
143
144 @param[in] mic_gain the microphone gain to be set. range:0-65535
145
146 @retval QL_ERR_OK Successful execution
147 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
148 @retval Others errorcode defined by ql_type.h.
149
150 @note The API should be called before a voice call
151 */
152/*-----------------------------------------------------------------------------------------------*/
153int ql_audio_set_tx_voice_mic_gain(int32_t mic_gain)
154{
155 if (mic_gain < MIC_GAIN_MIN || mic_gain > MIC_GAIN_MAX) {
156 return QL_ERR_INVALID_ARG;
157 }
158
159 stored_mic_gain = mic_gain;
160
161 float mapped_gain = MBTK_AUDIO_GAIN_MIN + ((float)mic_gain * (MBTK_AUDIO_GAIN_MAX - MBTK_AUDIO_GAIN_MIN) / MIC_GAIN_MAX);
162 int result = mbtk_dsp_gain_set(CONFIG_DSPGAIN_TX, (int)round(mapped_gain));
163 if (result != 0) {
164 LOGE("Error: mbtk_dsp_gain_set failed with error code %d\n", result);
165 if (audio_error_callback) {
166 audio_error_callback(result);
167 }
168 return QL_ERR_SERVICE_NOT_READY;
169 }
170
171 return QL_ERR_OK;
172}
173
174/*-----------------------------------------------------------------------------------------------*/
175/**
176 @brief This function gets the microphone gain for voice call uplink.
177
178 @param[out] p_mic_gain the current microphone gain for voice call uplink.
179
180 @retval QL_ERR_OK Successful execution
181 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
182 @retval Others errorcode defined by ql_type.h.
183 */
184/*-----------------------------------------------------------------------------------------------*/
185int ql_audio_get_tx_voice_mic_gain(int32_t *p_mic_gain)
186{
187 if (p_mic_gain == NULL) {
188 return QL_ERR_INVALID_ARG;
189 }
190
191 if (stored_mic_gain != -1) {
192 *p_mic_gain = stored_mic_gain;
193 } else {
194 int rx_gain, tx_gain;
195 int result = mbtk_dsp_gain_get(&rx_gain, &tx_gain);
196 if (result != 0) {
197 LOGE("Error: mbtk_dsp_gain_get failed with error code %d\n", result);
198 if (audio_error_callback) {
199 audio_error_callback(result);
200 }
201 return QL_ERR_SERVICE_NOT_READY;
202 }
203 *p_mic_gain = (tx_gain - MBTK_AUDIO_GAIN_MIN) * MIC_GAIN_MAX / (MBTK_AUDIO_GAIN_MAX - MBTK_AUDIO_GAIN_MIN);
204 }
205 LOGD("Retrieved mic gain: %d\n", *p_mic_gain);
206 return QL_ERR_OK;
207}
208
209/*-----------------------------------------------------------------------------------------------*/
210/**
211 @brief This function sets the speaker gain for voice call downlink.
212
213 @param[in] spkr_gain the speaker gain to be set. range:0-65535
214
215 @retval QL_ERR_OK Successful execution
216 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
217 @retval Others errorcode defined by ql_type.h.
218
219 @note The API should be called before a voice call
220 */
221/*-----------------------------------------------------------------------------------------------*/
222int ql_audio_set_rx_voice_spkr_gain(int32_t spkr_gain);
223
224/*-----------------------------------------------------------------------------------------------*/
225/**
226 @brief This function gets the speaker gain for voice call downlink.
227
228 @param[out] p_spkr_gain the current speaker gain for voice call downlink.
229
230 @retval QL_ERR_OK Successful execution
231 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
232 @retval Others errorcode defined by ql_type.h.
233 */
234/*-----------------------------------------------------------------------------------------------*/
235int ql_audio_get_rx_voice_spkr_gain(int32_t *p_spkr_gain);
236
237
238/*-----------------------------------------------------------------------------------------------*/
239/**
240 @brief This function sets the mute state of voice call uplink.
241
242 @param[in] mute_state the mute state to be set.
243 QL_AUDIO_STATE_0: unmute, QL_AUDIO_STATE_1: mute
244
245 @retval QL_ERR_OK Successful execution
246 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
247 @retval Others errorcode defined by ql_type.h.
248
249 @note The API should be called during the call
250 */
251/*-----------------------------------------------------------------------------------------------*/
252int ql_audio_set_tx_voice_mute_state(int32_t mute_state);
253
254/*-----------------------------------------------------------------------------------------------*/
255/**
256 @brief This function gets the mute state of voice call uplink.
257
258 @param[out] p_mute_state the current mute state of voice call uplink. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
259
260 @retval QL_ERR_OK Successful execution
261 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
262 @retval Others errorcode defined by ql_type.h.
263 */
264/*-----------------------------------------------------------------------------------------------*/
265int ql_audio_get_tx_voice_mute_state(int32_t *p_mute_state);
266
267/*-----------------------------------------------------------------------------------------------*/
268/**
269 @brief This function sets the mute state of voice call downlink.
270
271 @param[in] mute_state the mute state to be set.
272 QL_AUDIO_STATE_0: unmute, QL_AUDIO_STATE_1: mute
273
274 @retval QL_ERR_OK Successful execution
275 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
276 @retval Others errorcode defined by ql_type.h.
277
278 @note The API should be called during the call
279 */
280/*-----------------------------------------------------------------------------------------------*/
281int ql_audio_set_rx_voice_mute_state(int32_t mute_state);
282
283/*-----------------------------------------------------------------------------------------------*/
284/**
285 @brief This function gets the mute state of voice call downlink.
286
287 @param[out] p_mute_state the current mute state of voice call downlink. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
288
289 @retval QL_ERR_OK Successful execution
290 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
291 @retval Others errorcode defined by ql_type.h.
292 */
293/*-----------------------------------------------------------------------------------------------*/
294int ql_audio_get_rx_voice_mute_state(int32_t *p_mute_state);
295
296/*-----------------------------------------------------------------------------------------------*/
297/**
298 @brief This function sets the uplink volume of a codec.
299
300 @param[in] up_volume the uplink volume to be set. range:0-100
301
302 @retval QL_ERR_OK Successful execution
303 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
304 @retval Others errorcode defined by ql_type.h.
305 */
306/*-----------------------------------------------------------------------------------------------*/
307int ql_audio_set_codec_up_vol(int32_t up_volume);
308
309/*-----------------------------------------------------------------------------------------------*/
310/**
311 @brief This function gets the uplink volume of a codec.
312
313 @param[out] p_up_volume the current uplink volume of codec. range:0-100
314
315 @retval QL_ERR_OK Successful execution
316 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
317 @retval Others errorcode defined by ql_type.h.
318 */
319/*-----------------------------------------------------------------------------------------------*/
320int ql_audio_get_codec_up_vol(int32_t *p_up_volume);
321
322/*-----------------------------------------------------------------------------------------------*/
323/**
324 @brief This function sets the downlink volume of a codec.
325
326 @param[in] down_volume the volume to be set. range:0-100
327
328 @retval QL_ERR_OK Successful execution
329 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
330 @retval Others errorcode defined by ql_type.h.
331 */
332/*-----------------------------------------------------------------------------------------------*/
333int ql_audio_set_codec_down_vol(int32_t down_volume)
334{
335 if (down_volume < VOLUME_MIN || down_volume > VOLUME_MAX) {
336 return QL_ERR_INVALID_ARG;
337 }
338
339 stored_down_volume = down_volume;
340
341 float mapped_volume = MBTK_AUDIO_GAIN_MIN + ((float)down_volume * (MBTK_AUDIO_GAIN_MAX - MBTK_AUDIO_GAIN_MIN) / VOLUME_MAX);
342 int result = mbtk_dsp_gain_set(CONFIG_DSPGAIN_RX, (int)round(mapped_volume));
343 if (result != 0) {
344 LOGE("Error: mbtk_dsp_gain_set failed with error code %d\n", result);
345 if (audio_error_callback) {
346 audio_error_callback(result);
347 }
348 return QL_ERR_SERVICE_NOT_READY;
349 }
350
351 return QL_ERR_OK;
352}
353
354/*-----------------------------------------------------------------------------------------------*/
355/**
356 @brief This function gets the downlink volume of a codec.
357
358 @param[out] p_down_volume the current downlink volume of codec. range:0-100
359
360 @retval QL_ERR_OK Successful execution
361 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
362 @retval Others errorcode defined by ql_type.h.
363 */
364/*-----------------------------------------------------------------------------------------------*/
365int ql_audio_get_codec_down_vol(int32_t *p_down_volume)
366{
367 if (p_down_volume == NULL) {
368 return QL_ERR_INVALID_ARG;
369 }
370
371 if (stored_down_volume != -1) {
372 *p_down_volume = stored_down_volume;
373 } else {
374 int rx_gain, tx_gain;
375 int result = mbtk_dsp_gain_get(&rx_gain, &tx_gain);
376 if (result != 0) {
377 LOGE("Error: mbtk_dsp_gain_get failed with error code %d\n", result);
378 if (audio_error_callback) {
379 audio_error_callback(result);
380 }
381 return QL_ERR_SERVICE_NOT_READY;
382 }
383 *p_down_volume = (rx_gain - MBTK_AUDIO_GAIN_MIN) * VOLUME_MAX / (MBTK_AUDIO_GAIN_MAX - MBTK_AUDIO_GAIN_MIN);
384 }
385 LOGD("Retrieved codec downlink volume: %d\n", *p_down_volume);
386 return QL_ERR_OK;
387}
388
389/*-----------------------------------------------------------------------------------------------*/
390/**
391 @brief This function sets the microphone mute state of a codec.
392
393 @param[in] mute_state the muute state to be set.
394 QL_AUDIO_STATE_0: unmute, QL_AUDIO_STATE_1: mute
395
396 @retval QL_ERR_OK Successful execution
397 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
398 @retval Others errorcode defined by ql_type.h.
399
400 @note The API should be called during the call or audio playback
401 */
402/*-----------------------------------------------------------------------------------------------*/
403int ql_audio_set_codec_mic_mute_state(int32_t mute_state);
404
405/*-----------------------------------------------------------------------------------------------*/
406/**
407 @brief This function gets the microphone mute state of a codec.
408
409 @param[out] p_mute_state the current microphone mute state of codec. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
410
411 @retval QL_ERR_OK Successful execution
412 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
413 @retval Others errorcode defined by ql_type.h.
414 */
415/*-----------------------------------------------------------------------------------------------*/
416int ql_audio_get_codec_mic_mute_state(int32_t *p_mute_state);
417
418/*-----------------------------------------------------------------------------------------------*/
419/**
420 @brief This function sets the speaker mute state of a codec.
421
422 @param[in] mute_state the mute state to be set.
423 QL_AUDIO_STATE_0: unmute, QL_AUDIO_STATE_1: mute
424
425 @retval QL_ERR_OK Successful execution
426 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
427 @retval Others errorcode defined by ql_type.h.
428
429 @note The API should be called during the call or audio playback
430 */
431/*-----------------------------------------------------------------------------------------------*/
432int ql_audio_set_codec_spk_mute_state(int32_t mute_state);
433
434/*-----------------------------------------------------------------------------------------------*/
435/**
436 @brief This function gets the speaker mute state of a codec.
437
438 @param[out] p_mute_state the current speaker mute state of codec. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
439
440 @retval QL_ERR_OK Successful execution
441 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
442 @retval Others errorcode defined by ql_type.h.
443 */
444/*-----------------------------------------------------------------------------------------------*/
445int ql_audio_get_codec_spk_mute_state(int32_t *p_mute_state);
446
447
448/*-----------------------------------------------------------------------------------------------*/
449/**
450 @brief This function enables/disables loopback.
451
452 @param[in] enable_state enable/disable the loopback to be set.
453 QL_AUDIO_STATE_0: disable, QL_AUDIO_STATE_1: enable
454
455 @retval QL_ERR_OK Successful execution
456 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
457 @retval Others errorcode defined by ql_type.h.
458 */
459/*-----------------------------------------------------------------------------------------------*/
460int ql_audio_set_loopback_enable_state(int32_t enable_state)
461{
462 int result;
463 int device = DEVICE_SPEAKER;
464
465 if (enable_state == QL_AUDIO_STATE_1) {
466 result = mbtk_audio_set_loopback_enable_state(device, enable_state);
467 if (result != 0) {
468 LOGE("Error: mbtk_audio_set_loopback_enable_state failed\n");
469 if (audio_error_callback) {
470 audio_error_callback(result);
471 }
472 return QL_ERR_SERVICE_NOT_READY;
473 }
474 LOGD("Loopback started successfully\n");
475 } else if (enable_state == QL_AUDIO_STATE_0) {
476 result = mbtk_audio_set_loopback_enable_state(device, enable_state);
477 if (result != 0) {
478 LOGE("Error: mbtk_audio_set_loopback_enable_state failed\n");
479 if (audio_error_callback) {
480 audio_error_callback(result);
481 }
482 return QL_ERR_SERVICE_NOT_READY;
483 }
484 } else {
485 LOGD("Error: Invalid enable_state %d\n", enable_state);
486 return QL_ERR_INVALID_ARG;
487 }
488
489 return QL_ERR_OK;
490}
491
492/*-----------------------------------------------------------------------------------------------*/
493/**
494 @brief The function gets the loopback state.
495
496 @param[out] p_enable_state the current loopback state. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
497
498 @retval QL_ERR_OK Successful execution
499 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
500 @retval Others errorcode defined by ql_type.h.
501 */
502/*-----------------------------------------------------------------------------------------------*/
503int ql_audio_get_loopback_enable_state(int32_t *p_enable_state)
504{
505 if (p_enable_state == NULL) {
506 LOGE("Error: p_enable_state is NULL\n");
507 return QL_ERR_INVALID_ARG;
508 }
509
510 int device;
511 int result = mbtk_audio_get_loopback_enable_state(&device, p_enable_state);
512 if (result != 0) {
513 LOGE("Error: mbtk_audio_get_loopback_enable_state failed\n");
514 if (audio_error_callback) {
515 audio_error_callback(result);
516 }
517 return QL_ERR_SERVICE_NOT_READY;
518 }
519
520 LOGD("Current loopback state: %d\n", *p_enable_state);
521 return QL_ERR_OK;
522}
523/*-----------------------------------------------------------------------------------------------*/
524/**
525 @brief This function sets the sidetone gain.
526
527 @param[in] sidetone_gain sidetone gain to be set. range: 0-65535
528
529 @retval QL_ERR_OK Successful execution
530 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
531 @retval Others errorcode defined by ql_type.h.
532 */
533/*-----------------------------------------------------------------------------------------------*/
534int ql_audio_set_sidetone_gain(int32_t sidetone_gain);
535
536/*-----------------------------------------------------------------------------------------------*/
537/**
538 @brief This function gets the sidetone gain.
539
540 @param[out] p_sidetone_gain the current sidetone gain. range: 0-65535, default value: 1298
541
542 @retval QL_ERR_OK Successful execution
543 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
544 @retval Others errorcode defined by ql_type.h.
545 */
546/*-----------------------------------------------------------------------------------------------*/
547int ql_audio_get_sidetone_gain(int32_t *p_sidetone_gain);
548
549
550/*-----------------------------------------------------------------------------------------------*/
551/**
552 @brief This function sets the voice call manager state. By default, voice call services such as ringtones, ringback
553tones, third-party ringtones and voice stream status control are all implemented by ql_audiod program
554automatically.
555
556 @param[in] manager_state The manager state to be set. Voice call services include ringtones, ringback tones, the third-party
557ringtones and voice stream status control. range: QL_AUDIO_STATE_0 and QL_AUDIO_STATE_1
558
559 @retval QL_ERR_OK Successful execution
560 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
561 @retval Others errorcode defined by ql_type.h.
562
563 @note The voice service, such as call ring, beep tone, will not work during a voice call
564 If the manager_state is set to QL_AUDIO_STATE_1
565 */
566/*-----------------------------------------------------------------------------------------------*/
567int ql_audio_set_voice_call_manager_state(int32_t manager_state);
568
569/*-----------------------------------------------------------------------------------------------*/
570/**
571 @brief This function gets the voice call manager state.
572
573 @param[out] p_manager_state the current voice call manager state.
574 QL_AUDIO_STATE_0: close, QL_AUDIO_STATE_1:open
575
576 @retval QL_ERR_OK Successful execution
577 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
578 @retval Others errorcode defined by ql_type.h.
579 */
580/*-----------------------------------------------------------------------------------------------*/
581int ql_audio_get_voice_call_manager_state(int32_t *p_manager_state);
582
583/*-----------------------------------------------------------------------------------------------*/
584/**
585 @brief This function sets the voice stream state.
586
587 @param[in] stream_state voice stream state to be set.
588 QL_AUDIO_STATE_0: close, QL_AUDIO_STATE_1:open
589
590 @retval QL_ERR_OK Successful execution
591 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
592 @retval Others errorcode defined by ql_type.h.
593
594 @note After the voice call manager state is set to QL_AUDIO_STATE_1 by calling
595ql_audio_set_voice_call_manager_state(), the service program ql_audiod will not enable voice stream
596while establishing a voice call. In such a case, call ql_audio_set_voice_stream_state() to enable voice
597stream state by setting stream_state to QL_AUDIO_STATE_1, and then the voice stream can be disabled
598by setting stream_state to QL_AUDIO_STATE_0.*/
599/*-----------------------------------------------------------------------------------------------*/
600//int ql_audio_set_voice_stream_state(int32_t stream_state);
601int ql_audio_set_voice_stream_state(int32_t stream_state);
602
603/*-----------------------------------------------------------------------------------------------*/
604/**
605 @brief The function gets the voice stream state.
606
607 @param[out] p_stream_state the current voice stream state. QL_AUDIO_STATE_0 or QL_AUDIO_STATE_1
608
609 @retval QL_ERR_OK Successful execution
610 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
611 @retval Others errorcode defined by ql_type.h.
612 */
613/*-----------------------------------------------------------------------------------------------*/
614//int ql_audio_get_voice_stream_state(int32_t *p_stream_state);
615int ql_audio_get_voice_stream_state(int32_t *p_stream_state);
616
617
618/*-----------------------------------------------------------------------------------------------*/
619/**
620 @brief This function sets the callback function for audio service errors.
621 @param[in] cb The callback function for audio service errors.Only when the audioservice exit abnormally,the callback function is executed.
622 @retval QL_ERR_OK Successful execution
623 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
624 @retval Others errorcode defined by ql_type.h.
625 */
626/*-----------------------------------------------------------------------------------------------*/
627int ql_audio_set_service_error_cb(ql_audio_service_error_cb_f cb)
628{
629 if (cb == NULL) {
630 LOGE("Error: Callback function is NULL\n");
631 return QL_ERR_INVALID_ARG;
632 }
633
634 audio_error_callback = cb;
635
636 return QL_ERR_OK;
637}
638
639/*-----------------------------------------------------------------------------------------------*/
640/**
641 @brief This function switch codec.
642
643 @param[in] codec_switch the which codec to be switch.
644 0:GSSP 1:internal codec
645
646 @retval QL_ERR_OK Successful execution
647 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
648 @retval Others errorcode defined by ql_type.h.
649 */
650/*-----------------------------------------------------------------------------------------------*/
651int ql_audio_set_codec_switch(int32_t codec_switch);
652
653
654/*-----------------------------------------------------------------------------------------------*/
655/**
656 @brief This function gets the tone state.
657
658 @param[out] p_codec_switch which codec has switch.
659
660 @retval QL_ERR_OK Successful execution
661 @retval QL_ERR_INVALID_ARG Failed execution.Invalid arguments
662 @retval Others errorcode defined by ql_type.h.
663 */
664/*-----------------------------------------------------------------------------------------------*/
665int ql_audio_get_codec_switch(int32_t *p_codec_switch);
666
667
668typedef struct ql_audio_tone_config_struct
669{
670 int32_t low_fre;
671 int32_t high_fre;
672 int32_t on_duration;
673 int32_t off_duration;
674 int32_t volume;
675 int32_t count;
676}ql_audio_tone_config_t;
677
678/*-----------------------------------------------------------------------------------------------*/
679/**
680 @brief Set tone enable state
681
682 @param[in] low_fre low frequency, range: 100~4000
683 @param[in] high_fre high frequency, range: 100~4000
684 @param[in] on_duration tone play time, unit is millisecond
685 @param[in] off_duration tone pause time, unit is millisecond
686 @param[in] volume tone play volume, range: 0~5000
687 @param[in] count tone play count
688
689 @return QL_ERR_OK - Successful
690 QL_ERR_INVALID_ARG - Invalid arguments
691 Other errorcode defined by ql_type.h
692 */
693/*-----------------------------------------------------------------------------------------------*/
694int ql_audio_set_tone_enable_state(int32_t enable_state,ql_audio_tone_config_t *p_tone_config);
695
696/*-----------------------------------------------------------------------------------------------*/
697/**
698 @brief Get tone enable state
699
700 @param[out] p_enable_state tone enable state,
701 QL_AUDIO_STATE_0: close, QL_AUDIO_STATE_1:open
702
703 @return QL_ERR_OK - Successful
704 QL_ERR_INVALID_ARG - Invalid arguments
705 Other errorcode defined by ql_type.h.
706 */
707/*-----------------------------------------------------------------------------------------------*/
708int ql_audio_get_tone_enable_state(int32_t *p_enable_state);
709
710#ifdef __cplusplus
711}
712#endif
713#endif
714