1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00

Make configuration handling around streaming from stdin more robust

This commit is contained in:
Moritz Grimm 2017-09-15 19:23:16 +02:00
parent 58f615486a
commit 7729fa9773
3 changed files with 17 additions and 6 deletions

View File

@ -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);

View File

@ -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: */

View File

@ -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