Merge branch 'master' of git.distorted.org.uk:~mdw/publish/public-git/disorder
[disorder] / disobedience / disobedience.c
index 1a54e3e..75e5b97 100644 (file)
  */
 
 #include "disobedience.h"
+#include "regexp.h"
 #include "version.h"
 
 #include <getopt.h>
 #include <locale.h>
-#include <pcre.h>
 #include <gcrypt.h>
 
 /* Apologies for the numerous de-consting casts, but GLib et al do not seem to
@@ -71,9 +71,6 @@ int volume_l;
 /** @brief Right channel volume */
 int volume_r;
 
-/** @brief Audio backend */
-const struct uaudio *backend;
-
 double goesupto = 10;                   /* volume upper bound */
 
 /** @brief True if a NOP is in flight */
@@ -379,10 +376,9 @@ static gboolean periodic_fast(gpointer attribute((unused)) data) {
   }
   last = now;
 #endif
-  if(rtp_supported && backend && backend->get_volume) {
+  if(rtp_supported) {
     int nl, nr;
-    backend->get_volume(&nl, &nr);
-    if(nl != volume_l || nr != volume_r) {
+    if (!rtp_getvol(&nl, &nr) && (nl != volume_l || nr != volume_r)) {
       volume_l = nl;
       volume_r = nr;
       event_raise("volume-changed", 0);
@@ -470,13 +466,14 @@ static const struct option options[] = {
   { "help", no_argument, 0, 'h' },
   { "version", no_argument, 0, 'V' },
   { "config", required_argument, 0, 'c' },
+  { "user-config", required_argument, 0, 'u' },
   { "tufnel", no_argument, 0, 't' },
   { "debug", no_argument, 0, 'd' },
   { 0, 0, 0, 0 }
 };
 
 /* display usage message and terminate */
-static void help(void) {
+static void attribute((noreturn)) help(void) {
   xprintf("Disobedience - GUI client for DisOrder\n"
           "\n"
           "Usage:\n"
@@ -484,7 +481,8 @@ static void help(void) {
          "Options:\n"
          "  --help, -h              Display usage message\n"
          "  --version, -V           Display version number\n"
-         "  --config PATH, -c PATH  Set configuration file\n"
+         "  --config PATH, -c PATH  Set system configuration file\n"
+         "  --user-config PATH, -u PATH  Set user configuration file\n"
          "  --debug, -d             Turn on debugging\n"
           "\n"
           "Also GTK+ options will work.\n");
@@ -547,15 +545,15 @@ int main(int argc, char **argv) {
 
   mem_init();
   /* garbage-collect PCRE's memory */
-  pcre_malloc = xmalloc;
-  pcre_free = xfree;
+  regexp_setup();
   if(!setlocale(LC_CTYPE, "")) disorder_fatal(errno, "error calling setlocale");
   gtkok = gtk_init_check(&argc, &argv);
-  while((n = getopt_long(argc, argv, "hVc:dtHC", options, 0)) >= 0) {
+  while((n = getopt_long(argc, argv, "hVc:dtu:", options, 0)) >= 0) {
     switch(n) {
     case 'h': help();
     case 'V': version("disobedience");
     case 'c': configfile = optarg; break;
+    case 'u': userconfigfile = optarg; break;
     case 'd': debugging = 1; break;
     case 't': goesupto = 11; break;
     default: disorder_fatal(0, "invalid option");
@@ -575,12 +573,6 @@ int main(int argc, char **argv) {
   D(("create main loop"));
   mainloop = g_main_loop_new(0, 0);
   if(config_read(0, NULL)) disorder_fatal(0, "cannot read configuration");
-  /* we'll need mixer support */
-  backend = uaudio_default(uaudio_apis, UAUDIO_API_CLIENT);
-  if(backend->configure)
-    backend->configure();
-  if(backend->open_mixer)
-    backend->open_mixer();
   /* create the clients */
   if(!(client = gtkclient())
      || !(logclient = gtkclient()))