]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_shout: Rework our_mpg123_new() to handle error cases correctly and to clean up...
authorStefan Knoblich <stkn@openisdn.net>
Thu, 11 Jul 2013 01:12:25 +0000 (03:12 +0200)
committerStefan Knoblich <stkn@openisdn.net>
Thu, 11 Jul 2013 01:17:04 +0000 (03:17 +0200)
Keeping parameter handling quirks for backwards compatibility reasons.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
src/mod/formats/mod_shout/mod_shout.c

index eb081a226f09e3435d3fc2ec28b4e7f38531513d..0b64ba7e5bdb735166178d48bcd5ef5a26aaaa41 100644 (file)
@@ -60,52 +60,43 @@ static struct {
 
 mpg123_handle *our_mpg123_new(const char *decoder, int *error)
 {
-       mpg123_handle *mh;
        const char *arch = "auto";
+       const char *err = NULL;
+       mpg123_handle *mh;
        int x64 = 0;
        int rc = 0;
-       const char *err = NULL;
 
-       if (*globals.decoder || globals.outscale || globals.vol) {
-               if (*globals.decoder) {
-                       arch = globals.decoder;
-               }
-               if ((mh = mpg123_new(arch, &rc))) {
-                       if (rc) {
-                               err = mpg123_plain_strerror(rc);
-                       }
-                       if (globals.outscale) {
-                               mpg123_param(mh, MPG123_OUTSCALE, globals.outscale, 0);
-                       }
-                       if (globals.vol) {
-                               mpg123_volume(mh, globals.vol);
-                       }
-               }
+       if (*globals.decoder) {
+               arch = globals.decoder;
+       }
+#ifndef WIN32
+       else if (sizeof(void *) == 4) {
+               arch = "i586";
        } else {
-
-#ifdef WIN32
-               x64++;
+               x64 = 1;
+       }
 #else
-               if (sizeof(void *) == 4) {
-                       arch = "i586";
-               } else {
-                       x64++;
-               }
+       x64 = 1;
 #endif
+       mh = mpg123_new(arch, &rc);
+       if (!mh) {
+               err = mpg123_plain_strerror(rc);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error allocating mpg123 handle! %s\n", switch_str_nil(err));
+               return NULL;
+       }
 
-               if ((mh = mpg123_new(arch, &rc))) {
-                       if (rc) {
-                               err = mpg123_plain_strerror(rc);
-                       }
-                       if (x64) {
-                               mpg123_param(mh, MPG123_OUTSCALE, 8192, 0);
-                       }
+       /* NOTE: keeping the globals.decoder check here for behaviour backwards compat - stkn */
+       if (*globals.decoder || globals.outscale || globals.vol) {
+               if (globals.outscale) {
+                       mpg123_param(mh, MPG123_OUTSCALE, globals.outscale, 0);
+               }
+               if (globals.vol) {
+                       mpg123_volume(mh, globals.vol);
                }
+       } else if (x64) {
+               mpg123_param(mh, MPG123_OUTSCALE, 8192, 0);
        }
 
-       if (err) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error allocating mpg123 handle! %s\n", err);
-       }
        return mh;
 }