From c304dfe48a7f20e5a5c5dc0f1eb5c7f8b04c7d57 Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Fri, 22 May 2015 00:20:54 +0200 Subject: [PATCH] Support passthrough "encoders" again --- src/cfg_encoder.c | 21 ++++++++------------- src/ezstream.c | 3 +++ tests/check_cfg.c | 13 +++++++------ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/cfg_encoder.c b/src/cfg_encoder.c index 8f7b246..a90ca04 100644 --- a/src/cfg_encoder.c +++ b/src/cfg_encoder.c @@ -131,14 +131,12 @@ int cfg_encoder_set_program(struct cfg_encoder *e, const char *program, const char **errstrp) { - if (!program || !program[0]) { - if (errstrp) - *errstrp = "empty"; - return (-1); - } - xfree(e->program); - e->program = xstrdup(program); + + if (!program || !program[0]) + e->program = NULL; + else + e->program = xstrdup(program); return (0); } @@ -146,18 +144,15 @@ cfg_encoder_set_program(struct cfg_encoder *e, const char *program, int 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 (errstrp) *errstrp = "format not set"; return (-1); } + if (!e->program) + return (0); + CHECKPH_PROHIBITED(e->program, PLACEHOLDER_TRACK); CHECKPH_PROHIBITED(e->program, PLACEHOLDER_STRING); CHECKPH_DUPLICATE(e->program, PLACEHOLDER_METADATA); diff --git a/src/ezstream.c b/src/ezstream.c index ed3a435..5532925 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -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), PLACEHOLDER_ARTIST, localArtist); if (strstr(enc_str, PLACEHOLDER_TITLE) != NULL) { diff --git a/tests/check_cfg.c b/tests/check_cfg.c index 790bae0..39cc7e5 100644 --- a/tests/check_cfg.c +++ b/tests/check_cfg.c @@ -645,7 +645,13 @@ END_TEST 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 @@ -678,11 +684,6 @@ START_TEST(test_encoder_validate) cfg_encoder_t enc = cfg_encoder_get("test_encoder_validate"); 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_str_eq(errstr, "format not set");