[mod_opusfile] fix play sample rate (don't use original rate, always use 48k), fix eof.
This commit is contained in:
parent
053be38506
commit
937c4a03eb
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue