[xiph-cvs] cvs commit: vorbis-tools/ogg123 ogg123.c

Stan Seibert volsung at xiph.org
Mon Sep 24 11:44:47 PDT 2001



volsung     01/09/24 11:44:47

  Modified:    ogg123   Tag: kcarnold_work ogg123.c
  Log:
  - Added mutex to prevent race conditions when printing the statistics.
  This is not necessarily a long term fix.
  - Removed ASCII decorations around file and stream names.
  - Replaced UpdateStats() call with Ogg123Stats() call so that the mutex
  code is run.

Revision  Changes    Path
No                   revision

No                   revision

1.39.2.29 +18 -13    vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.39.2.28
retrieving revision 1.39.2.29
diff -u -r1.39.2.28 -r1.39.2.29
--- ogg123.c	2001/08/31 18:19:57	1.39.2.28
+++ ogg123.c	2001/09/24 18:44:46	1.39.2.29
@@ -14,7 +14,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.39.2.28 2001/08/31 18:19:57 kcarnold Exp $
+ last mod: $Id: ogg123.c,v 1.39.2.29 2001/09/24 18:44:46 volsung Exp $
 
  ********************************************************************/
 
@@ -48,6 +48,8 @@
 char skipfile_requested;
 char exit_requested;
 
+pthread_mutex_t stats_lock = PTHREAD_MUTEX_INITIALIZER;
+
 struct {
     const char *key;			/* includes the '=' for programming convenience */
     const char *formatstr;		/* formatted output */
@@ -243,8 +245,10 @@
 
 void Ogg123UpdateStats (void)
 {
+  pthread_mutex_lock(&stats_lock);
   SetBuffersStats ();
   UpdateStats (Options.statOpts.stats);
+  pthread_mutex_unlock(&stats_lock);
 }
 
 /* /status interface */
@@ -296,8 +300,9 @@
 {
   int i, driver_count;
   ao_info **devices = ao_driver_info_list(&driver_count);
-  
-  Error ("Ogg123 from " PACKAGE " " VERSION "\n"
+
+  printf ( 
+         "Ogg123 from " PACKAGE " " VERSION "\n"
          " by Kenneth Arnold <kcarnold at arnoldnet.net> and others\n\n"
          "Usage: ogg123 [<options>] <input file> ...\n\n"
          "  -h, --help     this help\n"
@@ -307,17 +312,18 @@
          "        ");
   
   for(i = 0; i < driver_count; i++) {
-    Error ("%s", devices[i]->short_name);
+    printf ("%s", devices[i]->short_name);
     if (devices[i]->type == AO_TYPE_LIVE)
-      Error ("*");
+      printf ("*");
     else if (devices[i]->type == AO_TYPE_FILE)
-      Error ("@");
-    Error (" ");
+      printf ("@");
+    printf (" ");
   }
 
-  Error ("\n");
+  printf ("\n");
   
-  Error ("  -f, --file=filename  Set the output filename for a previously\n"
+  printf (
+	 "  -f, --file=filename  Set the output filename for a previously\n"
          "      specified file device (with -d).\n"
          "  -k n, --skip n  Skip the first 'n' seconds\n"
          "  -o, --device-option=k:v passes special option k with value\n"
@@ -653,7 +659,7 @@
   if (tmp < 10 && tmp + 2 < strlen(Options.playOpts.read_file) && !strncmp(Options.playOpts.read_file + tmp, "://", 3))
     {
       /* let's call this a URL. */
-      ShowMessage (1, 0, 1, "-=( Stream: %s )=-", Options.playOpts.read_file);
+      ShowMessage (1, 0, 1, "Stream: %s", Options.playOpts.read_file);
       VorbisfileCallbacks.read_func = StreamBufferRead;
       VorbisfileCallbacks.seek_func = StreamBufferSeek;
       VorbisfileCallbacks.close_func = StreamBufferClose;
@@ -679,7 +685,7 @@
 #endif
       if (strcmp(Options.playOpts.read_file, "-"))
         {
-	  ShowMessage (1, 0, 1, "-=( File: %s )=-", Options.playOpts.read_file);
+	  ShowMessage (1, 0, 1, "File: %s", Options.playOpts.read_file);
           /* Open the file. */
           if ((InStream = fopen(Options.playOpts.read_file, "rb")) == NULL) {
             perror ("=== Error opening input file");
@@ -807,8 +813,7 @@
             if (nthc-- == 0) {
               if (Options.outputOpts.buffer) {
                 SubmitData (Options.outputOpts.buffer, convbuffer, ret, 1);
-		SetBuffersStats ();
-		UpdateStats (Options.statOpts.stats);
+		Ogg123UpdateStats();
               }
               else
                 OutBufferWrite (convbuffer, ret, 1, &Options, 0);

--- >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