]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6627
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 24 Jun 2014 20:42:07 +0000 (15:42 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 24 Jun 2014 20:42:07 +0000 (15:42 -0500)
src/mod/formats/mod_shout/mod_shout.c

index a99a299479c7f382a203139f21dca3a6e8ba697b..ae1ee83d38f98ff19a3ca14f417718f2e2e38a39 100644 (file)
@@ -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;