Merge pull request #202 from dragos-oancea/opusfile_fixes

[mod_opusfile] fix play sample rate (don't use original rate, always use 48k), fix eof.
This commit is contained in:
Andrey Volk 2020-01-06 22:38:38 +04:00 committed by GitHub
commit 78aa7ea37f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -148,7 +148,7 @@ static switch_status_t switch_opusfile_decode(opus_file_context *context, void *
if (globals.debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[OGG/OPUS Decoder]: EOF reached [%d]\n", ret);
}
context->eof = TRUE;
context->eof = SWITCH_TRUE;
break;
} else /* (ret > 0)*/ {
/*The number of samples read per channel on success*/
@ -161,7 +161,7 @@ static switch_status_t switch_opusfile_decode(opus_file_context *context, void *
}
}
switch_mutex_unlock(context->audio_mutex);
context->eof = FALSE; // for next page
context->eof = SWITCH_FALSE; // for next page
return SWITCH_STATUS_SUCCESS;
}
@ -282,7 +282,6 @@ static switch_status_t switch_opusfile_open(switch_file_handle_t *handle, const
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "[OGG/OPUS File] Channels: %i\n", head->channel_count);
if (head->input_sample_rate) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "[OGG/OPUS File] Original sampling rate: %lu Hz\n", (unsigned long)head->input_sample_rate);
handle->samplerate = context->samplerate = head->input_sample_rate;
}
}
if (op_seekable(context->of)) {
@ -365,14 +364,14 @@ static switch_status_t switch_opusfile_read(switch_file_handle_t *handle, void *
if (!handle->handler) {
if (switch_opusfile_decode(context, data, bytes, handle->real_channels) == SWITCH_STATUS_FALSE) {
context->eof = 1;
context->eof = SWITCH_TRUE;
}
}
switch_mutex_lock(context->audio_mutex);
rb = switch_buffer_read(context->audio_buffer, data, bytes);
switch_mutex_unlock(context->audio_mutex);
if (!rb && (context->eof)) {
if (!rb || (context->eof)) {
return SWITCH_STATUS_FALSE;
}
if (rb) {