[xiph-cvs] cvs commit: ices/src metadata.c input.c im_alsa.c im_oss.c im_stdinpcm.c im_sun.c

Karl Heyes karl at xiph.org
Fri Jan 16 20:24:11 PST 2004



karl        04/01/16 23:24:11

  Modified:    src      metadata.c input.c im_alsa.c im_oss.c im_stdinpcm.c
                        im_sun.c
  Log:
  handle clean shutdown of metadata threads and avoid reading stdin
  metadata when background enabled.

Revision  Changes    Path
1.12      +47 -3     ices/src/metadata.c

Index: metadata.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/metadata.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- metadata.c	22 Mar 2003 02:27:55 -0000	1.11
+++ metadata.c	17 Jan 2004 04:24:10 -0000	1.12
@@ -1,7 +1,7 @@
 /* metadata.c
  * - Metadata manipulation
  *
- * $Id: metadata.c,v 1.11 2003/03/22 02:27:55 karl Exp $
+ * $Id: metadata.c,v 1.12 2004/01/17 04:24:10 karl Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -36,11 +36,49 @@
     char buf[1024];
     input_module_t *mod = arg;
 
+    if (ices_config->background)
+    {
+        LOG_INFO0("Metadata thread shutting down, tried to use "
+                "stdin from background");
+        return NULL;
+    }
     while(1)
     {
         char **md = NULL;
         int comments = 0;
+        int wait_for_data = 1;
+
+        /* wait for data */
+        while (wait_for_data)
+        {
+            struct timeval t;
+            fd_set fds;
+            FD_ZERO (&fds);
+            FD_SET (0, &fds);
+            t.tv_sec = 0;
+            t.tv_usec = 150;
+            
+            switch (select (1, &fds, NULL, NULL, &t))
+            {
+            case 1:
+                wait_for_data = 0;
+            case 0:
+                break;
+            default:
+                if (errno != EAGAIN)
+                {
+                    LOG_INFO1 ("shutting down thread (%d)", errno);
+                    return NULL; /* problem get out quick */
+                }
+                break;
+            }
 
+            if (ices_config->shutdown)
+            {
+                LOG_INFO0 ("metadata thread shutting down");
+                return NULL;
+            }
+        }
         while(fgets(buf, 1024, stdin))
         {
             if(buf[0] == '\n')
@@ -80,15 +118,21 @@
         int comments = 0;
         FILE *file;
 
-        while(metadata_update_signalled == 0){
+        while(metadata_update_signalled == 0)
+        {
             thread_cond_wait(&ices_config->event_pending_cond);
+            if (ices_config->shutdown)
+            {
+                LOG_INFO0 ("metadata thread shutting down");
+                return NULL;
+            }
         }
 
         metadata_update_signalled = 0;
 
         file = fopen(ices_config->metadata_filename, "r");
         if(!file) {
-            LOG_WARN2("Failed to open file %s for metadata update: %s", 
+            LOG_WARN2("Failed to open file \"%s\" for metadata update: %s", 
                     ices_config->metadata_filename, strerror(errno));
             continue;
         }

<p><p>1.30      +6 -2      ices/src/input.c

Index: input.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/input.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- input.c	9 Jul 2003 23:44:11 -0000	1.29
+++ input.c	17 Jan 2004 04:24:10 -0000	1.30
@@ -2,7 +2,7 @@
  *  - Main producer control loop. Fetches data from input modules, and controls
  *    submission of these to the instance threads. Timing control happens here.
  *
- * $Id: input.c,v 1.29 2003/07/09 23:44:11 karl Exp $
+ * $Id: input.c,v 1.30 2004/01/17 04:24:10 karl Exp $
  * 
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -509,7 +509,11 @@
         }
     }
 
-    LOG_DEBUG0("All instances removed, shutting down control thread.");
+    LOG_INFO0 ("All instances removed, shutting down...");
+
+    ices_config->shutdown = 1;
+    thread_cond_broadcast(&ices_config->event_pending_cond);
+    timing_sleep(250); /* sleep for quarter of a second */
 
     thread_cond_destroy(&ices_config->queue_cond);
     thread_cond_destroy(&ices_config->event_pending_cond);

<p><p>1.7       +2 -2      ices/src/im_alsa.c

Index: im_alsa.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/im_alsa.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- im_alsa.c	11 Jan 2004 03:11:05 -0000	1.6
+++ im_alsa.c	17 Jan 2004 04:24:10 -0000	1.7
@@ -1,7 +1,7 @@
 /* im_alsa.c
  * - Raw PCM input from ALSA devices
  *
- * $Id: im_alsa.c,v 1.6 2004/01/11 03:11:05 karl Exp $
+ * $Id: im_alsa.c,v 1.7 2004/01/17 04:24:10 karl Exp $
  *
  * by Jason Chu <jchu at uvic.ca>, based
  * on im_oss.c which is...
@@ -257,11 +257,11 @@
 
     if(use_metadata)
     {
+        LOG_INFO0("Starting metadata update thread");
         if(ices_config->metadata_filename)
             thread_create("im_alsa-metadata", metadata_thread_signal, mod, 1);
         else
             thread_create("im_alsa-metadata", metadata_thread_stdin, mod, 1);
-        LOG_INFO0("Started metadata update thread");
     }
 
     return mod;

<p><p>1.14      +2 -2      ices/src/im_oss.c

Index: im_oss.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/im_oss.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- im_oss.c	28 Mar 2003 01:07:37 -0000	1.13
+++ im_oss.c	17 Jan 2004 04:24:10 -0000	1.14
@@ -1,7 +1,7 @@
 /* im_oss.c
  * - Raw PCM input from OSS devices
  *
- * $Id: im_oss.c,v 1.13 2003/03/28 01:07:37 karl Exp $
+ * $Id: im_oss.c,v 1.14 2004/01/17 04:24:10 karl Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -256,11 +256,11 @@
 
     if(use_metadata)
     {
+        LOG_INFO0("Starting metadata update thread");
         if(ices_config->metadata_filename)
             thread_create("im_oss-metadata", metadata_thread_signal, mod, 1);
         else
             thread_create("im_oss-metadata", metadata_thread_stdin, mod, 1);
-        LOG_INFO0("Started metadata update thread");
     }
 
     return mod;

<p><p>1.10      +5 -4      ices/src/im_stdinpcm.c

Index: im_stdinpcm.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/im_stdinpcm.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- im_stdinpcm.c	6 Jul 2003 06:20:34 -0000	1.9
+++ im_stdinpcm.c	17 Jan 2004 04:24:10 -0000	1.10
@@ -1,7 +1,7 @@
 /* im_stdinpcm.c
  * - Raw PCM input from stdin
  *
- * $Id: im_stdinpcm.c,v 1.9 2003/07/06 06:20:34 brendan Exp $
+ * $Id: im_stdinpcm.c,v 1.10 2004/01/17 04:24:10 karl Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -180,10 +180,11 @@
     }
     if(use_metadata)
     {
-        if(ices_config->metadata_filename) {
+        if (ices_config->metadata_filename)
+        {
+            LOG_INFO0("Starting metadata update thread");
             thread_create("im_stdinpcm-metadata", metadata_thread_signal, mod, 1);
-	    LOG_INFO0("Started metadata update thread");
-	}
+        }
     }
 
     return mod;

<p><p>1.13      +2 -2      ices/src/im_sun.c

Index: im_sun.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/im_sun.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- im_sun.c	24 Dec 2003 15:52:09 -0000	1.12
+++ im_sun.c	17 Jan 2004 04:24:10 -0000	1.13
@@ -1,7 +1,7 @@
 /* im_sun.c
  * - Raw PCM input from Solaris audio devices
  *
- * $Id: im_sun.c,v 1.12 2003/12/24 15:52:09 karl Exp $
+ * $Id: im_sun.c,v 1.13 2004/01/17 04:24:10 karl Exp $
  *
  * by Ciaran Anscomb <ciarana at rd.bbc.co.uk>, based
  * on im_oss.c which is...
@@ -250,11 +250,11 @@
 
     if(use_metadata)
     {
+        LOG_INFO0("Starting metadata update thread");
         if(ices_config->metadata_filename)
             thread_create("im_sun-metadata", metadata_thread_signal, mod, 1);
         else
             thread_create("im_sun-metadata", metadata_thread_stdin, mod, 1);
-        LOG_INFO0("Started metadata update thread");
     }
 
     return mod;

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list