提交 564dc7e4 authored 作者: Anthony Minessale's avatar Anthony Minessale

return break in mod_sndfile when seek returns failure

上级 4cf58428
...@@ -242,16 +242,23 @@ static switch_status_t sndfile_file_close(switch_file_handle_t *handle) ...@@ -242,16 +242,23 @@ static switch_status_t sndfile_file_close(switch_file_handle_t *handle)
static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence) static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
{ {
sndfile_context *context = handle->private_info; sndfile_context *context = handle->private_info;
sf_count_t count;
switch_status_t r = SWITCH_STATUS_SUCCESS;
if (!handle->seekable) { if (!handle->seekable) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File is not seekable\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File is not seekable\n");
return SWITCH_STATUS_NOTIMPL; return SWITCH_STATUS_NOTIMPL;
} }
*cur_sample = (unsigned int) sf_seek(context->handle, samples, whence); if ((count = sf_seek(context->handle, samples, whence)) == ((sf_count_t) -1)) {
handle->pos = *cur_sample; r = SWITCH_STATUS_BREAK;
count = sf_seek(context->handle, -1, SEEK_END);
return SWITCH_STATUS_SUCCESS; }
*cur_sample = (unsigned int) count;
handle->pos = *cur_sample;
return r;
} }
static switch_status_t sndfile_file_read(switch_file_handle_t *handle, void *data, size_t *len) static switch_status_t sndfile_file_read(switch_file_handle_t *handle, void *data, size_t *len)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论