mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-24 07:59:19 +00:00
--resolve FS-5243 improve mod_unimrcp audio buffering
This commit is contained in:
parent
49138460a3
commit
f8d263683a
@ -273,7 +273,8 @@ static switch_status_t audio_queue_destroy(audio_queue_t *queue);
|
||||
* SPEECH_CHANNEL : speech functions common to recognizer and synthesizer
|
||||
*/
|
||||
|
||||
#define SPEECH_CHANNEL_TIMEOUT_USEC (5 * 1000000)
|
||||
#define SPEECH_CHANNEL_TIMEOUT_USEC (5000 * 1000)
|
||||
#define AUDIO_TIMEOUT_USEC (SWITCH_MAX_INTERVAL * 1000)
|
||||
|
||||
/**
|
||||
* Type of MRCP channel
|
||||
@ -725,11 +726,18 @@ static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch
|
||||
#endif
|
||||
switch_mutex_lock(queue->mutex);
|
||||
|
||||
/* allow the initial frame to buffer */
|
||||
if (!queue->read_bytes && switch_buffer_inuse(queue->buffer) < requested) {
|
||||
*data_len = 0;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* wait for data, if allowed */
|
||||
if (block) {
|
||||
while (switch_buffer_inuse(queue->buffer) < requested) {
|
||||
queue->waiting = requested;
|
||||
if (switch_thread_cond_timedwait(queue->cond, queue->mutex, SPEECH_CHANNEL_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT) {
|
||||
if (switch_thread_cond_timedwait(queue->cond, queue->mutex, AUDIO_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -774,6 +782,9 @@ static switch_status_t audio_queue_clear(audio_queue_t *queue)
|
||||
switch_buffer_zero(queue->buffer);
|
||||
switch_thread_cond_signal(queue->cond);
|
||||
switch_mutex_unlock(queue->mutex);
|
||||
queue->read_bytes = 0;
|
||||
queue->write_bytes = 0;
|
||||
queue->waiting = 0;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user