[xiph-commits] r18248 - icecast/trunk/ices/src

ph3-der-loewe at svn.xiph.org ph3-der-loewe at svn.xiph.org
Mon Apr 23 14:42:14 PDT 2012


Author: ph3-der-loewe
Date: 2012-04-23 14:42:14 -0700 (Mon, 23 Apr 2012)
New Revision: 18248

Modified:
   icecast/trunk/ices/src/im_roar.c
   icecast/trunk/ices/src/im_roar.h
Log:
Support loading of libroar plugins into im-roar module.


Modified: icecast/trunk/ices/src/im_roar.c
===================================================================
--- icecast/trunk/ices/src/im_roar.c	2012-04-23 21:12:08 UTC (rev 18247)
+++ icecast/trunk/ices/src/im_roar.c	2012-04-23 21:42:14 UTC (rev 18248)
@@ -53,7 +53,13 @@
             if(s->vss)
                 roar_vs_close(s->vss, ROAR_VS_TRUE, NULL);
 
+            if (s->plugins)
+            {
+                roar_plugincontainer_appsched_trigger(s->plugins, ROAR_DL_APPSCHED_FREE);
+                roar_plugincontainer_unref(s->plugins);
+            }
 
+
             thread_mutex_destroy(&s->metadatalock);
             free(s);
         }
@@ -125,6 +131,8 @@
     int err;
     im_roar_state *s = self;
 
+    roar_plugincontainer_appsched_trigger(s->plugins, ROAR_DL_APPSCHED_UPDATE);
+
     rb->buf = malloc(BUFSIZE * roar_info2framesize(&s->info)/8);
     if(!rb->buf)
         return -1;
@@ -158,6 +166,39 @@
     return rb->len;
 }
 
+static void roar_plugin_load(input_module_t *mod, const char *nameargs)
+{
+    im_roar_state *s;
+    struct roar_dl_librarypara *para;
+    char *name, *args;
+
+    s = mod->internal;
+
+    name = strdup(nameargs);
+    args = strstr(name, " ");
+    if (args)
+    {
+        *args = 0;
+        args++;
+    }
+
+    para = roar_dl_para_new(args, mod, IM_ROAR_APPNAME, IM_ROAR_ABIVERSION);
+    if (!para)
+    {
+        LOG_WARN2("Can not create parameters for plugin %s: %s", name, roar_error2str(roar_error));
+        free(name);
+        return;
+    }
+
+    if (roar_plugincontainer_load(s->plugins, name, para) == -1)
+    {
+        LOG_WARN2("Can not load plugin %s: %s", name, roar_error2str(roar_error));
+    }
+
+    roar_dl_para_unref(para);
+    free(name);
+}
+
 input_module_t *roar_open_module(module_param_t *params)
 {
     input_module_t *mod = calloc(1, sizeof(input_module_t));
@@ -183,8 +224,16 @@
     }
     s->info.bits = 16;
 
-    s->vss   = NULL;
+    s->vss       = NULL;
 
+    s->plugins   = roar_plugincontainer_new_simple(IM_ROAR_APPNAME, IM_ROAR_ABIVERSION);
+    if (!s->plugins)
+    {
+        LOG_ERROR1("Failed to create plugin container: %s",
+                roar_error2str(roar_error));
+        return NULL;
+    }
+
     thread_mutex_create(&s->metadatalock);
 
     current = params;
@@ -220,6 +269,8 @@
         } else if(!strcmp(current->name, "metadatafilename")) {
             ices_config->metadata_filename = current->value;
             use_metadata = MD_FILE;
+        } else if(!strcmp(current->name, "plugin")) {
+            roar_plugin_load(mod, current->value);
         } else
             LOG_WARN1("Unknown parameter %s for roar module", current->name);
 
@@ -249,6 +300,7 @@
          return NULL;
     }
 
+    roar_plugincontainer_appsched_trigger(s->plugins, ROAR_DL_APPSCHED_INIT);
 
     /* Open the VS connection */
     if ( (s->vss = roar_vs_new(server, IM_ROAR_PROGNAME, &err)) == NULL ) {

Modified: icecast/trunk/ices/src/im_roar.h
===================================================================
--- icecast/trunk/ices/src/im_roar.h	2012-04-23 21:12:08 UTC (rev 18247)
+++ icecast/trunk/ices/src/im_roar.h	2012-04-23 21:42:14 UTC (rev 18248)
@@ -17,7 +17,17 @@
 #include <roaraudio.h>
 #include "inputmodule.h"
 
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
 #define IM_ROAR_PROGNAME   "ices2"
+#define IM_ROAR_APPNAME    IM_ROAR_PROGNAME " <Xiph.Org Foundation>"
+#ifdef PACKAGE_VERSION
+ #define IM_ROAR_ABIVERSION "input-roar/" PACKAGE_VERSION
+#else
+ #define IM_ROAR_ABIVERSION "input-roar/unknown-version"
+#endif
 
 typedef struct
 {
@@ -28,6 +38,9 @@
     char **metadata;
     int newtrack;
     mutex_t metadatalock;
+
+    // plugins:
+    struct roar_plugincontainer * plugins;
 } im_roar_state; 
 
 input_module_t *roar_open_module(module_param_t *params);



More information about the commits mailing list