diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c index a99a299479..ae1ee83d38 100644 --- a/src/mod/formats/mod_shout/mod_shout.c +++ b/src/mod/formats/mod_shout/mod_shout.c @@ -670,6 +670,7 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char context->stream_url = switch_core_sprintf(context->memory_pool, "http://%s", path); context->prebuf = handle->prebuf; launch_read_stream_thread(context); + switch_cond_next(); } else { handle->seekable = 1; @@ -681,8 +682,26 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char } + if (handle->handler) { + int sanity = 1000; + + while(--sanity > 0 && !switch_buffer_inuse(context->audio_buffer)) { + switch_yield(20000); + } + + if (!sanity) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s (data stream timeout)\n", path); + goto error; + } + } mpg123_getformat(context->mh, &rate, &channels, &encoding); + + if (!channels || !rate) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s (invalid rate or channel count)\n", path); + goto error; + } + handle->channels = channels; handle->samplerate = rate;