From a4b1f2b7f6764aaea2a20178ab57c7985108a764 Mon Sep 17 00:00:00 2001 From: moritz Date: Tue, 14 Aug 2007 03:32:13 +0000 Subject: [PATCH] Ticket #1225, reported by matpoc at lenta dot ru: Bring back special case for streaming MP3 files without reencoding, which was lost during the many changes in 0.3.0 and subsequently forgotten. Sorry for the inconvenience, and thanks for the report. git-svn-id: https://svn.xiph.org/trunk/ezstream@13542 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- src/ezstream.c | 15 ++++++--------- src/util.c | 25 +++++++++++++++++++++++++ src/util.h | 1 + 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/ezstream.c b/src/ezstream.c index 6a00941..f471156 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -624,7 +624,9 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag, close(stderr_fd); return (filep); - } + } else if (strrcasecmp(fileName, ".mp3") == 0) + /* MP3 streams are special: */ + setMetadata(shout, mdata, NULL); metadata_free(&mdata); @@ -816,7 +818,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName, clearerr(filepstream); ret = STREAM_CONT; } else - printf("%s: streamFile(): Error while reading '%s': %s\n", + printf("%s: sendStream(): Error while reading '%s': %s\n", __progname, fileName, strerror(errno)); } @@ -1306,21 +1308,16 @@ main(int argc, char *argv[]) if (shout_open(shout) == SHOUTERR_SUCCESS) { int ret; - char *tmpFileName, *p; printf("%s: Connected to http://%s:%d%s\n", __progname, host, port, mount); - tmpFileName = xstrdup(pezConfig->fileName); - for (p = tmpFileName; *p != '\0'; p++) - *p = tolower((int)*p); if (pezConfig->fileNameIsProgram || - strrcmp(tmpFileName, ".m3u") == 0 || - strrcmp(tmpFileName, ".txt") == 0) + strrcasecmp(pezConfig->fileName, ".m3u") == 0 || + strrcasecmp(pezConfig->fileName, ".txt") == 0) playlistMode = 1; else playlistMode = 0; - xfree(tmpFileName); if (vFlag && pezConfig->fileNameIsProgram) printf("%s: Using program '%s' to get filenames for streaming\n", diff --git a/src/util.c b/src/util.c index 32254c3..4f8f99e 100644 --- a/src/util.c +++ b/src/util.c @@ -21,9 +21,12 @@ # include "config.h" #endif +#include +#include #include #include "util.h" +#include "xalloc.h" int strrcmp(const char *s, const char *sub) @@ -36,3 +39,25 @@ strrcmp(const char *s, const char *sub) return (memcmp(s + slen - sublen, sub, sublen)); } + +int +strrcasecmp(const char *s, const char *sub) +{ + char *s_cpy = xstrdup(s); + char *sub_cpy = xstrdup(sub); + char *p; + int ret; + + for (p = s_cpy; *p != '\0'; p++) + *p = tolower((int)*p); + + for (p = sub_cpy; *p != '\0'; p++) + *p = tolower((int)*p); + + ret = strrcmp(s_cpy, sub_cpy); + + xfree(s_cpy); + xfree(sub_cpy); + + return (ret); +} diff --git a/src/util.h b/src/util.h index 7da0108..105cc67 100644 --- a/src/util.h +++ b/src/util.h @@ -21,5 +21,6 @@ #define __UTIL_H__ int strrcmp(const char *, const char *); +int strrcasecmp(const char *, const char *); #endif /* __UTIL_H__ */