Revision
16705
Author
rupa
Date
2010-02-19 12:53:02 -0600 (Fri, 19 Feb 2010)

Log Message

even more mod_shout logging

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c (16704 => 16705)


--- freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c	2010-02-19 18:51:57 UTC (rev 16704)
+++ freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c	2010-02-19 18:53:02 UTC (rev 16705)
@@ -584,12 +584,14 @@
 }
 
 #define TC_BUFFER_SIZE 1024 * 32
+#define MPGERROR() {err = "MPG123 Error at __FILE__:__LINE__."; mpg123err = mpg123_strerror(context->mh); goto error; }
 static switch_status_t shout_file_open(switch_file_handle_t *handle, const char *path)
 {
 	shout_context_t *context;
 	char *host, *file;
 	char *username, *password, *port;
 	char *err = NULL;
+	const char *mpg123err = NULL;
 	int portno = 0;
 
 	if ((context = switch_core_alloc(handle->memory_pool, sizeof(*context))) == 0) {
@@ -617,14 +619,20 @@
 		}
 
 		context->mh = our_mpg123_new(NULL, NULL);
-		mpg123_format_all(context->mh);
-		mpg123_param(context->mh, MPG123_FORCE_RATE, context->samplerate, 0);
+		if (mpg123_format_all(context->mh) != MPG123_OK) {
+			MPGERROR();
+		}
+		if (mpg123_param(context->mh, MPG123_FORCE_RATE, context->samplerate, 0) != MPG123_OK) {
+			MPGERROR();
+		}
 
 		if (handle->handler) {
-			mpg123_param(context->mh, MPG123_FLAGS, MPG123_SEEKBUFFER | MPG123_MONO_MIX, 0);
+			if (mpg123_param(context->mh, MPG123_FLAGS, MPG123_SEEKBUFFER | MPG123_MONO_MIX, 0) != MPG123_OK) {
+				MPGERROR();
+			}
 			if (mpg123_open_feed(context->mh) != MPG123_OK) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening mpg feed\n");
-				err = (char*) mpg123_strerror(context->mh);
+				mpg123err = mpg123_strerror(context->mh);
 				goto error;
 			}
 			context->stream_url = switch_core_sprintf(context->memory_pool, "http://%s", path);
@@ -632,10 +640,12 @@
 			launch_read_stream_thread(context);
 		} else {
 			handle->seekable = 1;
-			mpg123_param(context->mh, MPG123_FLAGS, MPG123_MONO_MIX, 0);
+			if (mpg123_param(context->mh, MPG123_FLAGS, MPG123_MONO_MIX, 0) != MPG123_OK) {
+				MPGERROR();
+			}
 			if (mpg123_open(context->mh, path) != MPG123_OK) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
-				err = (char*) mpg123_strerror(context->mh);
+				mpg123err = mpg123_strerror(context->mh);
 				goto error;
 			}
 
@@ -789,6 +799,9 @@
 	if (err) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: %s\n", err);
 	}
+	if (mpg123err) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error from mpg123: %s\n", mpg123err);
+	}
 	free_context(context);
 	return SWITCH_STATUS_GENERR;