[xiph-commits] r18742 - icecast/trunk/ices/src
ph3-der-loewe at svn.xiph.org
ph3-der-loewe at svn.xiph.org
Thu Dec 13 16:34:27 PST 2012
Author: ph3-der-loewe
Date: 2012-12-13 16:34:27 -0800 (Thu, 13 Dec 2012)
New Revision: 18742
Modified:
icecast/trunk/ices/src/im_playlist.c
icecast/trunk/ices/src/im_playlist.h
icecast/trunk/ices/src/playlist_basic.c
icecast/trunk/ices/src/playlist_script.c
Log:
added experimental patch to allow to run a command at end of song
Modified: icecast/trunk/ices/src/im_playlist.c
===================================================================
--- icecast/trunk/ices/src/im_playlist.c 2012-12-13 20:13:52 UTC (rev 18741)
+++ icecast/trunk/ices/src/im_playlist.c 2012-12-14 00:34:27 UTC (rev 18742)
@@ -116,6 +116,10 @@
fclose(pl->current_file);
pl->current_file = NULL;
}
+ if (pl->file_ended)
+ {
+ pl->file_ended(pl->data, pl->filename);
+ }
newfn = pl->get_filename(pl->data);
if (!newfn)
Modified: icecast/trunk/ices/src/im_playlist.h
===================================================================
--- icecast/trunk/ices/src/im_playlist.h 2012-12-13 20:13:52 UTC (rev 18741)
+++ icecast/trunk/ices/src/im_playlist.h 2012-12-14 00:34:27 UTC (rev 18742)
@@ -30,6 +30,7 @@
char *(*get_filename)(void *data); /* returns the next desired filename */
void (*free_filename)(void *data, char *fn); /* Called when im_playlist is
done with this filename */
+ void (*file_ended)(void *data, char *fn); /* Called when the current file is done */
void (*clear)(void *data); /* module clears self here */
void *data; /* Internal data for this particular playlist module */
Modified: icecast/trunk/ices/src/playlist_basic.c
===================================================================
--- icecast/trunk/ices/src/playlist_basic.c 2012-12-13 20:13:52 UTC (rev 18741)
+++ icecast/trunk/ices/src/playlist_basic.c 2012-12-14 00:34:27 UTC (rev 18742)
@@ -240,6 +240,7 @@
pl->get_filename = playlist_basic_get_next_filename;
pl->clear = playlist_basic_clear;
pl->free_filename = playlist_basic_free_filename;
+ pl->file_ended = NULL;
pl->data = calloc(1, sizeof(basic_playlist));
data = (basic_playlist *)pl->data;
Modified: icecast/trunk/ices/src/playlist_script.c
===================================================================
--- icecast/trunk/ices/src/playlist_script.c 2012-12-13 20:13:52 UTC (rev 18741)
+++ icecast/trunk/ices/src/playlist_script.c 2012-12-14 00:34:27 UTC (rev 18742)
@@ -30,6 +30,7 @@
typedef struct {
char *program;
+ char *on_ended;
} script_playlist;
void playlist_script_clear(void *data) {
@@ -87,6 +88,25 @@
free(fn);
}
+void playlist_script_file_ended(void *data, char *fn)
+{
+ script_playlist *pl = data;
+ FILE *pipe;
+
+ if (!pl->on_ended)
+ return;
+
+ pipe = popen(pl->on_ended, "w");
+
+ if(!pipe) {
+ LOG_ERROR1("Couldn't open pipe to program \"%s\"", pl->on_ended);
+ return;
+ }
+
+ fprintf(pipe, "%s\n", fn);
+ pclose(pipe);
+}
+
int playlist_script_initialise(module_param_t *params, playlist_state_t *pl)
{
script_playlist *data;
@@ -94,6 +114,7 @@
pl->get_filename = playlist_script_get_filename;
pl->clear = playlist_script_clear;
pl->free_filename = playlist_script_free_filename;
+ pl->file_ended = playlist_script_file_ended;
pl->data = calloc(1, sizeof(script_playlist));
if(!pl->data)
@@ -106,6 +127,10 @@
if(data->program) free(data->program);
data->program = params->value;
}
+ else if(!strcmp(params->name, "on-ended")) {
+ if(data->on_ended) free(data->on_ended);
+ data->on_ended = params->value;
+ }
else if(!strcmp(params->name, "allow-repeats"))
pl->allow_repeat = atoi(params->value);
else if(!strcmp(params->name, "type")) {
More information about the commits
mailing list