1
0
Fork 0

Make relative path lookups configurable

Retain current behavior by default, where files are found based on
the current working directory.
This commit is contained in:
Moritz Grimm 2022-10-09 02:13:52 +02:00
parent d59108b825
commit 06e49d2313
10 changed files with 57 additions and 5 deletions

5
NEWS
View File

@ -1,10 +1,13 @@
Changes in 1.NNN, released on YYYY-MM-DD:
Changes in 1.1.0, released on YYYY-MM-DD:
* Fix regression when streaming formats other than Ogg (e.g. MP3). From
zygmund2000 on Github (#30) and Roland Hermans on GitLab (#2271).
* Fix build issue on OSX. From Mitchell Blank on GitLab (#2270).
* Support reproducible builds. Via Unit 193 on GitLab (#2276).
* Update autoconf requirement to 2.69
* Add <rel_to_list /> setting to look for files relative to the playlist
file location instead of the current working directory. From Dan Sanford
on GitLab (#2283).

View File

@ -2,7 +2,7 @@ dnl ###########
dnl ## SETUP ###########################################################
dnl ###########
AC_INIT([ezstream], [1.0.2], [https://gitlab.xiph.org/xiph/ezstream/issues])
AC_INIT([ezstream], [1.1.0], [https://gitlab.xiph.org/xiph/ezstream/issues])
AC_PREREQ([2.69])
AC_CONFIG_SRCDIR([src/ezstream.c])
AC_CONFIG_AUX_DIR([build-aux])

View File

@ -498,6 +498,19 @@ default).
.It Ar 1|Yes|True
After streaming all media input, exit.
.El
.It Sy \&<rel_to_list\ /\&>
Boolean setting, whether to locate playlist entries
.Qq relative to the list .
Entries with absolute path names are not affected.
.Pp
.Bl -tag -width 0|NO|FALSE -compact
.It Ar 0|No|False
Find files relative to the current working directory of
.Nm
(the default).
.It Ar 1|Yes|True
Find files relative to the location of the playlist file or program.
.El
.El
.Ss Metadata block
.Bl -tag -width -Ds

View File

@ -143,11 +143,14 @@
<!-- Input file, program name, or "stdin" keyword (deprecated) -->
<filename>playlist.m3u</filename>
<!-- Setting to shuffle playlists -->
<!-- Shuffle playlists (default: no) -->
<shuffle>Yes</shuffle>
<!-- Setting whether to stream intake indefinitely or only once -->
<!-- Stream intake indefinitely or only once (default: no) -->
<stream_once>Yes</stream_once>
<!-- Search for files relative to the playlist location (default: no) -->
<rel_to_list>Yes</rel_to_list>
</intake>
</intakes>

View File

@ -35,6 +35,7 @@ struct cfg_intake {
char filename[PATH_MAX];
int shuffle;
int stream_once;
int rel_to_list;
};
TAILQ_HEAD(cfg_intake_list, cfg_intake);
@ -227,6 +228,15 @@ cfg_intake_set_stream_once(struct cfg_intake *i, struct cfg_intake_list *not_use
return (0);
}
int
cfg_intake_set_rel_to_list(struct cfg_intake *i, struct cfg_intake_list *not_used,
const char *rel_to_list, const char **errstrp)
{
(void)not_used;
SET_BOOLEAN(i->rel_to_list, rel_to_list, errstrp);
return (0);
}
int
cfg_intake_validate(struct cfg_intake *i, const char **errstrp)
{
@ -287,3 +297,9 @@ cfg_intake_get_stream_once(struct cfg_intake *i)
{
return (i->stream_once);
}
int
cfg_intake_get_rel_to_list(struct cfg_intake *i)
{
return (i->rel_to_list);
}

View File

@ -57,6 +57,8 @@ int cfg_intake_set_shuffle(cfg_intake_t, cfg_intake_list_t, const char *,
const char **);
int cfg_intake_set_stream_once(cfg_intake_t, cfg_intake_list_t,
const char *, const char **);
int cfg_intake_set_rel_to_list(cfg_intake_t, cfg_intake_list_t,
const char *, const char **);
int cfg_intake_validate(cfg_intake_t, const char **);
@ -70,5 +72,6 @@ const char *
cfg_intake_get_filename(cfg_intake_t);
int cfg_intake_get_shuffle(cfg_intake_t);
int cfg_intake_get_stream_once(cfg_intake_t);
int cfg_intake_get_rel_to_list(cfg_intake_t);
#endif /* __CFG_INTAKE_H__ */

View File

@ -222,6 +222,7 @@ _cfgfile_xml_parse_intake(xmlDocPtr doc, xmlNodePtr cur)
XML_INPUT_SET(i, il, cfg_intake_set_filename, "filename");
XML_INPUT_SET(i, il, cfg_intake_set_shuffle, "shuffle");
XML_INPUT_SET(i, il, cfg_intake_set_stream_once, "stream_once");
XML_INPUT_SET(i, il, cfg_intake_set_rel_to_list, "rel_to_list");
}
if (0 > cfg_intake_validate(i, &errstr)) {
@ -438,6 +439,7 @@ _cfgfile_xml_parse_encoders(xmlDocPtr doc, xmlNodePtr cur)
* filename
* shuffle
* stream_once
* rel_to_list
* ...
* metadata
* program
@ -650,6 +652,8 @@ _cfgfile_xml_print_intake(cfg_intake_t i, void *arg)
fprintf(fp, " <shuffle>yes</shuffle>\n");
if (cfg_intake_get_stream_once(i))
fprintf(fp, " <stream_once>yes</stream_once>\n");
if (cfg_intake_get_rel_to_list(i))
fprintf(fp, " <rel_to_list>yes</rel_to_list>\n");
fprintf(fp, " </intake>\n");
}

View File

@ -684,7 +684,8 @@ streamPlaylist(stream_t stream)
while ((song_next = playlist_get_next(playlist)) != NULL) {
strlcpy(song_prev, song_next, sizeof(song_prev));
if ('/' == song_next[0])
if ('/' == song_next[0] ||
!cfg_intake_get_rel_to_list(cfg_intake))
(void)snprintf(tmp_path, sizeof(tmp_path), "%s",
song_next);
else

View File

@ -105,6 +105,13 @@ START_TEST(test_intake_set_stream_once)
}
END_TEST
START_TEST(test_intake_set_rel_to_list)
{
TEST_BOOLEAN_T(cfg_intake_t, cfg_intake_list_get, intakes,
cfg_intake_set_rel_to_list, cfg_intake_get_rel_to_list);
}
END_TEST
START_TEST(test_intake_validate)
{
cfg_intake_t in = cfg_intake_list_get(intakes, "test_intake_validate");
@ -147,6 +154,7 @@ cfg_suite(void)
tcase_add_test(tc_intake, test_intake_set_filename);
tcase_add_test(tc_intake, test_intake_set_shuffle);
tcase_add_test(tc_intake, test_intake_set_stream_once);
tcase_add_test(tc_intake, test_intake_set_rel_to_list);
tcase_add_test(tc_intake, test_intake_validate);
suite_add_tcase(s, tc_intake);

View File

@ -48,6 +48,7 @@
<filename></filename>
<shuffle></shuffle>
<stream_once></stream_once>
<rel_to_list></rel_to_list>
</intake>
</intakes>