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:
commit
78aa7ea37f
|
@ -148,7 +148,7 @@ static switch_status_t switch_opusfile_decode(opus_file_context *context, void *
|
||||||
if (globals.debug) {
|
if (globals.debug) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[OGG/OPUS Decoder]: EOF reached [%d]\n", ret);
|
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;
|
break;
|
||||||
} else /* (ret > 0)*/ {
|
} else /* (ret > 0)*/ {
|
||||||
/*The number of samples read per channel on success*/
|
/*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);
|
switch_mutex_unlock(context->audio_mutex);
|
||||||
context->eof = FALSE; // for next page
|
context->eof = SWITCH_FALSE; // for next page
|
||||||
return SWITCH_STATUS_SUCCESS;
|
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);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "[OGG/OPUS File] Channels: %i\n", head->channel_count);
|
||||||
if (head->input_sample_rate) {
|
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);
|
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)) {
|
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 (!handle->handler) {
|
||||||
if (switch_opusfile_decode(context, data, bytes, handle->real_channels) == SWITCH_STATUS_FALSE) {
|
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);
|
switch_mutex_lock(context->audio_mutex);
|
||||||
rb = switch_buffer_read(context->audio_buffer, data, bytes);
|
rb = switch_buffer_read(context->audio_buffer, data, bytes);
|
||||||
switch_mutex_unlock(context->audio_mutex);
|
switch_mutex_unlock(context->audio_mutex);
|
||||||
|
|
||||||
if (!rb && (context->eof)) {
|
if (!rb || (context->eof)) {
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
if (rb) {
|
if (rb) {
|
||||||
|
|
Loading…
Reference in New Issue