提交 b093ec1e authored 作者: Anthony Minessale's avatar Anthony Minessale

add interval to file handles for streams

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6473 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 701feee9
...@@ -279,6 +279,7 @@ struct switch_file_handle { ...@@ -279,6 +279,7 @@ struct switch_file_handle {
/*! pre-buffer x bytes for streams */ /*! pre-buffer x bytes for streams */
uint32_t prebuf; uint32_t prebuf;
/*! private data for the format module to store handle specific info */ /*! private data for the format module to store handle specific info */
uint32_t interval;
void *private_info; void *private_info;
char *handler; char *handler;
int64_t pos; int64_t pos;
......
...@@ -174,6 +174,7 @@ static switch_status_t local_stream_file_open(switch_file_handle_t *handle, cons ...@@ -174,6 +174,7 @@ static switch_status_t local_stream_file_open(switch_file_handle_t *handle, cons
handle->seekable = 0; handle->seekable = 0;
handle->speed = 0; handle->speed = 0;
handle->private_info = context; handle->private_info = context;
handle->interval = source->interval;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening Stream [%s] %dhz\n", path, handle->samplerate); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening Stream [%s] %dhz\n", path, handle->samplerate);
switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, handle->memory_pool); switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, handle->memory_pool);
......
...@@ -1123,6 +1123,7 @@ void do_broadcast(switch_stream_handle_t *stream) ...@@ -1123,6 +1123,7 @@ void do_broadcast(switch_stream_handle_t *stream)
uint8_t buf[1024]; uint8_t buf[1024];
int rlen; int rlen;
int is_local = 0; int is_local = 0;
uint32_t interval = 20000;
if (strstr(path_info + 7, "://")) { if (strstr(path_info + 7, "://")) {
file = strdup(path_info + 7); file = strdup(path_info + 7);
...@@ -1171,6 +1172,9 @@ void do_broadcast(switch_stream_handle_t *stream) ...@@ -1171,6 +1172,9 @@ void do_broadcast(switch_stream_handle_t *stream)
path_info + 7); path_info + 7);
if (fh.interval) {
interval = fh.interval;
}
for(;;) { for(;;) {
switch_size_t samples = sizeof(buf) / 2; switch_size_t samples = sizeof(buf) / 2;
...@@ -1178,7 +1182,7 @@ void do_broadcast(switch_stream_handle_t *stream) ...@@ -1178,7 +1182,7 @@ void do_broadcast(switch_stream_handle_t *stream)
switch_core_file_read(&fh, buf, &samples); switch_core_file_read(&fh, buf, &samples);
if (is_local) { if (is_local) {
switch_yield(20000); switch_yield(interval);
} }
if (!samples) { if (!samples) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论