1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-12-04 14:46:31 -05:00

Support passthrough "encoders" again

This commit is contained in:
Moritz Grimm 2015-05-22 00:20:54 +02:00
parent b8ea620f7a
commit c304dfe48a
3 changed files with 18 additions and 19 deletions

View File

@ -131,14 +131,12 @@ int
cfg_encoder_set_program(struct cfg_encoder *e, const char *program, cfg_encoder_set_program(struct cfg_encoder *e, const char *program,
const char **errstrp) const char **errstrp)
{ {
if (!program || !program[0]) {
if (errstrp)
*errstrp = "empty";
return (-1);
}
xfree(e->program); xfree(e->program);
e->program = xstrdup(program);
if (!program || !program[0])
e->program = NULL;
else
e->program = xstrdup(program);
return (0); return (0);
} }
@ -146,18 +144,15 @@ cfg_encoder_set_program(struct cfg_encoder *e, const char *program,
int int
cfg_encoder_validate(struct cfg_encoder *e, const char **errstrp) cfg_encoder_validate(struct cfg_encoder *e, const char **errstrp)
{ {
if (!e->program) {
if (errstrp)
*errstrp = "program not set";
return (-1);
}
if (CFG_STREAM_INVALID == e->format) { if (CFG_STREAM_INVALID == e->format) {
if (errstrp) if (errstrp)
*errstrp = "format not set"; *errstrp = "format not set";
return (-1); return (-1);
} }
if (!e->program)
return (0);
CHECKPH_PROHIBITED(e->program, PLACEHOLDER_TRACK); CHECKPH_PROHIBITED(e->program, PLACEHOLDER_TRACK);
CHECKPH_PROHIBITED(e->program, PLACEHOLDER_STRING); CHECKPH_PROHIBITED(e->program, PLACEHOLDER_STRING);
CHECKPH_DUPLICATE(e->program, PLACEHOLDER_METADATA); CHECKPH_DUPLICATE(e->program, PLACEHOLDER_METADATA);

View File

@ -314,6 +314,9 @@ buildReencodeCommand(const char *extension, const char *fileName,
} }
} }
if (!cfg_encoder_get_program(encoder))
return (dec_str);
enc_str = replaceString(cfg_encoder_get_program(encoder), enc_str = replaceString(cfg_encoder_get_program(encoder),
PLACEHOLDER_ARTIST, localArtist); PLACEHOLDER_ARTIST, localArtist);
if (strstr(enc_str, PLACEHOLDER_TITLE) != NULL) { if (strstr(enc_str, PLACEHOLDER_TITLE) != NULL) {

View File

@ -645,7 +645,13 @@ END_TEST
START_TEST(test_encoder_set_program) START_TEST(test_encoder_set_program)
{ {
TEST_ENC_XSTRDUP(cfg_encoder_set_program, cfg_encoder_get_program); cfg_encoder_t enc = cfg_encoder_get("test_encoder_set_program");
ck_assert_int_eq(cfg_encoder_set_program(enc, NULL, NULL), 0);
ck_assert_ptr_eq(cfg_encoder_get_program(enc), NULL);
ck_assert_int_eq(cfg_encoder_set_program(enc, "test", NULL), 0);
ck_assert_str_eq(cfg_encoder_get_program(enc), "test");
} }
END_TEST END_TEST
@ -678,11 +684,6 @@ START_TEST(test_encoder_validate)
cfg_encoder_t enc = cfg_encoder_get("test_encoder_validate"); cfg_encoder_t enc = cfg_encoder_get("test_encoder_validate");
const char *errstr; const char *errstr;
errstr = NULL;
ck_assert_int_ne(cfg_encoder_validate(enc, &errstr), 0);
ck_assert_str_eq(errstr, "program not set");
ck_assert_int_eq(cfg_encoder_set_program(enc, "test", NULL), 0);
ck_assert_int_ne(cfg_encoder_validate(enc, &errstr), 0); ck_assert_int_ne(cfg_encoder_validate(enc, &errstr), 0);
ck_assert_str_eq(errstr, "format not set"); ck_assert_str_eq(errstr, "format not set");