diff --git a/src/cfg.c b/src/cfg.c index 7aa2f7f..dfa4396 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -184,7 +184,8 @@ cfg_check(const char **errstrp) return (-1); } - if (!cfg_get_media_filename()) { + if (!cfg_get_media_filename() && + CFG_MEDIA_STDIN != cfg_get_media_type()) { if (NULL != errstrp) *errstrp = "media filename missing"; return (-1); diff --git a/src/ezstream.c b/src/ezstream.c index 0995178..0bff301 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -275,7 +275,8 @@ openResource(stream_t stream, const char *fileName, int *popenFlag, if (songLen != NULL) *songLen = 0; - if (strcmp(fileName, "stdin") == 0) { + if ((isStdin && *isStdin) || + strcasecmp(fileName, "stdin") == 0) { if (cfg_get_metadata_program()) { if ((mdata = getMetadata(cfg_get_metadata_program())) == NULL) return (NULL); @@ -566,7 +567,7 @@ streamFile(stream_t stream, const char *fileName) FILE *filepstream = NULL; int popenFlag = 0; char *songLenStr = NULL; - int isStdin = 0; + int isStdin = cfg_get_media_type() == CFG_MEDIA_STDIN; int ret, retval = 0; long songLen; metadata_t mdata; @@ -590,7 +591,8 @@ streamFile(stream_t stream, const char *fileName) if ((metaData = util_utf82char(tmp, ICONV_REPLACE)) == NULL) metaData = xstrdup("(unknown title)"); xfree(tmp); - log_notice("streaming: %s (%s)", metaData, fileName); + log_notice("streaming: %s (%s)", metaData, + isStdin ? "stdin" : fileName); xfree(metaData); /* MP3 streams are special, so set the metadata explicitly: */ diff --git a/tests/check_cfg.c b/tests/check_cfg.c index 4ba5820..75b6f4f 100644 --- a/tests/check_cfg.c +++ b/tests/check_cfg.c @@ -136,8 +136,7 @@ START_TEST(test_check) ck_assert_int_eq(cfg_check(NULL), -1); ck_assert_int_eq(cfg_check(&errstr), -1); ck_assert_str_eq(errstr, "media filename missing"); - ck_assert_int_eq(cfg_set_media_filename(SRCDIR "/playlist.txt", NULL), - 0); + ck_assert_int_eq(cfg_set_media_type("stdin", NULL), 0); ck_assert_int_eq(cfg_check(NULL), -1); ck_assert_int_eq(cfg_check(&errstr), -1); @@ -145,6 +144,15 @@ START_TEST(test_check) ck_assert_int_eq(cfg_set_stream_format(CFG_SFMT_VORBIS, NULL), 0); ck_assert_int_eq(cfg_check(NULL), 0); + + ck_assert_int_eq(cfg_set_media_type("autodetect", NULL), 0); + ck_assert_int_eq(cfg_check(NULL), -1); + ck_assert_int_eq(cfg_check(&errstr), -1); + ck_assert_str_eq(errstr, "media filename missing"); + ck_assert_int_eq(cfg_set_media_filename(SRCDIR "/playlist.txt", NULL), + 0); + + ck_assert_int_eq(cfg_check(NULL), 0); } END_TEST