[xiph-cvs] cvs commit: vorbis-tools/ogg123 ao_interface.c buffer.c curl_interface.c curl_interface.h ogg123.c ogg123rc-example options.c options.h status.c status.h

Kenneth C. Arnold kcarnold at xiph.org
Fri Aug 31 11:01:15 PDT 2001



kcarnold    01/08/31 11:01:14

  Modified:    ogg123   Tag: kcarnold_work ao_interface.c buffer.c
                        curl_interface.c curl_interface.h ogg123.c
                        ogg123rc-example options.c options.h status.c
                        status.h
  Log:
  Silence one metric bajillion compiler warnings. Anyone who wants my
  INSANECFLAGS used to do that, just ask.

Revision  Changes    Path
No                   revision

No                   revision

1.5.2.7   +3 -1      vorbis-tools/ogg123/ao_interface.c

Index: ao_interface.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ao_interface.c,v
retrieving revision 1.5.2.6
retrieving revision 1.5.2.7
diff -u -r1.5.2.6 -r1.5.2.7
--- ao_interface.c	2001/08/12 18:34:46	1.5.2.6
+++ ao_interface.c	2001/08/31 18:01:12	1.5.2.7
@@ -11,9 +11,11 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ao_interface.c,v 1.5.2.6 2001/08/12 18:34:46 kcarnold Exp $
+ last mod: $Id: ao_interface.c,v 1.5.2.7 2001/08/31 18:01:12 kcarnold Exp $
 
  ********************************************************************/
+
+#define _GNU_SOURCE
 
 #include <stdio.h>
 #include <string.h>

1.7.2.22  +5 -2      vorbis-tools/ogg123/buffer.c

Index: buffer.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/buffer.c,v
retrieving revision 1.7.2.21
retrieving revision 1.7.2.22
diff -u -r1.7.2.21 -r1.7.2.22
--- buffer.c	2001/08/31 15:18:53	1.7.2.21
+++ buffer.c	2001/08/31 18:01:12	1.7.2.22
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: buffer.c,v 1.7.2.21 2001/08/31 15:18:53 kcarnold Exp $
+ last mod: $Id: buffer.c,v 1.7.2.22 2001/08/31 18:01:12 kcarnold Exp $
 
  ********************************************************************/
 
@@ -22,6 +22,8 @@
  * that program is used in this buffer.
  */
 
+#define _GNU_SOURCE
+
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/time.h>
@@ -385,7 +387,8 @@
 
 void SubmitData (buf_t *buf, chunk *data, size_t size, size_t nmemb)
 {
-  int i, s;
+  size_t i, s;
+
   size *= nmemb;
   for (i = 0; i < size; i += buf->OptimalWriteSize) {
     s = i + buf->OptimalWriteSize <= size ? buf->OptimalWriteSize : size - i;

1.1.2.6   +13 -3     vorbis-tools/ogg123/Attic/curl_interface.c

Index: curl_interface.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/curl_interface.c,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- curl_interface.c	2001/08/13 00:43:20	1.1.2.5
+++ curl_interface.c	2001/08/31 18:01:12	1.1.2.6
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
  
- last mod: $Id: curl_interface.c,v 1.1.2.5 2001/08/13 00:43:20 kcarnold Exp $
+ last mod: $Id: curl_interface.c,v 1.1.2.6 2001/08/31 18:01:12 kcarnold Exp $
  
 ********************************************************************/
 
@@ -30,19 +30,28 @@
 #define debug(x, y...) do { } while (0)
 #endif
 
+/* we only need one function from ogg123 itself. */
+extern void Ogg123UpdateStats(void);
+/* and one flag. */
+extern char exit_requested;
+
 size_t
 CurlWriteFunction (void *ptr, size_t size, size_t nmemb, void *arg)
 {
   buf_t *buf = arg;
   debug ("CurlWriteFunction, submitting %d bytes.\n", size * nmemb);
+  if (exit_requested)
+    exit(0);
   SubmitData (buf, ptr, size, nmemb);
+  Ogg123UpdateStats();
   return size * nmemb;
 }
 
 size_t
-BufferWriteChunk (void *ptr, size_t size, void *arg, char iseos)
+BufferWriteChunk (void *voidptr, size_t size, void *arg, char iseos)
 {
   StreamInputBufferData_t *data = arg;
+  unsigned char *ptr = voidptr;
 
   debug ("buffer writing chunk of %d, %d bytes to go\n", size,
          data->BytesRequested);
@@ -210,9 +219,10 @@
 }
 
 size_t
-_StreamBufferRead (void *ptr, size_t size, size_t nmemb, void *arg)
+_StreamBufferRead (void *voidptr, size_t size, size_t nmemb, void *arg)
 {
   StreamInputBufferData_t *data = arg;
+  unsigned char *ptr = voidptr;
   size_t ret;
 
   ret = size *= nmemb;		/* makes things simpler and run smoother */

1.1.2.7   +2 -2      vorbis-tools/ogg123/Attic/curl_interface.h

Index: curl_interface.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/curl_interface.h,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- curl_interface.h	2001/08/13 17:31:46	1.1.2.6
+++ curl_interface.h	2001/08/31 18:01:12	1.1.2.7
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
  
- last mod: $Id: curl_interface.h,v 1.1.2.6 2001/08/13 17:31:46 kcarnold Exp $
+ last mod: $Id: curl_interface.h,v 1.1.2.7 2001/08/31 18:01:12 kcarnold Exp $
  
 ********************************************************************/
 
@@ -66,7 +66,7 @@
   unsigned char *WriteTarget;
   unsigned char *CurWritePtr;
   unsigned char ExcessData[VORBIS_CHUNKIN_SIZE];
-  int ExcessDataSize;
+  size_t ExcessDataSize;
   FILE *SavedStream;
 } StreamInputBufferData_t;
 

1.39.2.27 +41 -34    vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.39.2.26
retrieving revision 1.39.2.27
diff -u -r1.39.2.26 -r1.39.2.27
--- ogg123.c	2001/08/31 15:18:53	1.39.2.26
+++ ogg123.c	2001/08/31 18:01:12	1.39.2.27
@@ -14,10 +14,12 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.39.2.26 2001/08/31 15:18:53 kcarnold Exp $
+ last mod: $Id: ogg123.c,v 1.39.2.27 2001/08/31 18:01:12 kcarnold Exp $
 
  ********************************************************************/
 
+#define _GNU_SOURCE
+
 #include <sys/types.h>
 #include <string.h>
 #include <stdlib.h>
@@ -37,18 +39,18 @@
 
 /* take buffer out of the data segment, not the stack */
 #define BUFFER_CHUNK_SIZE 4096
-char convbuffer[BUFFER_CHUNK_SIZE];
+unsigned char convbuffer[BUFFER_CHUNK_SIZE];
 int convsize = BUFFER_CHUNK_SIZE;
 
 /* take big options structure from the data segment */
 ogg123_options_t Options;
 
-static char skipfile_requested;
-static char exit_requested;
+char skipfile_requested;
+char exit_requested;
 
 struct {
-    char *key;			/* includes the '=' for programming convenience */
-    char *formatstr;		/* formatted output */
+    const char *key;			/* includes the '=' for programming convenience */
+    const char *formatstr;		/* formatted output */
 } ogg_comment_keys[] = {
   {"ARTIST=", "Artist: %s"},
   {"ALBUM=", "Album: %s"},
@@ -87,7 +89,7 @@
 };
 
 /* configuration interface */
-int ConfigErrorFunc (void *arg, ParseCode pcode, int lineno, char *filename, char *line)
+int ConfigErrorFunc (void *arg, ParseCode pcode, int lineno, const char *filename, char *line)
 {
   if (pcode == parse_syserr)
     {
@@ -102,7 +104,7 @@
     }
 }
 
-ParseCode ReadConfig (Option_t opts[], char *filename)
+ParseCode ReadConfig (Option_t opts[], const char *filename)
 {
   return ParseFile (opts, filename, ConfigErrorFunc, NULL);
 }
@@ -157,9 +159,9 @@
 
 void SetTime (Stat_t stats[], ogg_int64_t sample)
 {
-  double time = (double) sample / (double) Options.outputOpts.rate;
-  long c_min = (long) time / (long) 60;
-  double c_sec = time - 60.0f * c_min;
+  double CurTime = (double) sample / (double) Options.outputOpts.rate;
+  long c_min = (long) CurTime / (long) 60;
+  double c_sec = CurTime - 60.0f * c_min;
   long r_min, t_min;
   double r_sec, t_sec;
 
@@ -167,13 +169,13 @@
     if (sample > Options.inputOpts.totalSamples) {
       /* file probably grew while playing; update total time */
       Options.inputOpts.totalSamples = sample;
-      Options.inputOpts.totalTime = time;
+      Options.inputOpts.totalTime = CurTime;
       stats[3].arg.stringarg[0] = '\0';
       r_min = 0;
       r_sec = 0.0f;
     } else {
-      r_min = (long) (Options.inputOpts.totalTime - time) / (long) 60;
-      r_sec = ((double) Options.inputOpts.totalTime - time) - 60.0f * (double) r_min;
+      r_min = (long) (Options.inputOpts.totalTime - CurTime) / (long) 60;
+      r_sec = ((double) Options.inputOpts.totalTime - CurTime) - 60.0f * (double) r_min;
     }
     sprintf (stats[2].arg.stringarg, "[%02li:%05.2f]", r_min, r_sec);
     if (stats[3].arg.stringarg[0] == '\0') {
@@ -239,6 +241,12 @@
   stats[9].arg.stringarg = strdup (strbuf);
 }
 
+void Ogg123UpdateStats (void)
+{
+  SetBuffersStats ();
+  UpdateStats (Options.statOpts.stats);
+}
+
 /* /status interface */
 
 /* buffer interface */
@@ -246,7 +254,7 @@
 {
   static ogg_int64_t cursample = 0;
   static unsigned char RechunkBuffer[BUFFER_CHUNK_SIZE];
-  static int curBuffered = 0;
+  static size_t curBuffered = 0;
   size_t origSize;
   unsigned char *data = ptr;
 
@@ -254,8 +262,7 @@
   origSize = size;
   
   SetTime (Options.statOpts.stats, cursample);
-  SetBuffersStats ();
-  UpdateStats (Options.statOpts.stats);
+  Ogg123UpdateStats();
   cursample += Options.playOpts.nth * size * nmemb / Options.outputOpts.channels / 2 / Options.playOpts.ntimes; /* locked to 16-bit */
 
   /* optimized fast path */
@@ -264,7 +271,7 @@
   else
     /* don't actually write until we have a full chunk, or of course EOS */
     while (size) {
-      int toChunkNow = BUFFER_CHUNK_SIZE - curBuffered <= size ? BUFFER_CHUNK_SIZE - curBuffered : size;
+      size_t toChunkNow = BUFFER_CHUNK_SIZE - curBuffered <= size ? BUFFER_CHUNK_SIZE - curBuffered : size;
       memmove (RechunkBuffer + curBuffered, data, toChunkNow);
       size -= toChunkNow;
       data += toChunkNow;
@@ -327,6 +334,14 @@
          "  -l, --delay=s  set s (default 1). If s=-1, disable song skip.\n");
 }
 
+#define INIT(type, value) type type##_##value = value
+char char_n = 'n';
+float float_50f = 50.0f;
+float float_0f = 0.0f;
+INIT(int, 10000);
+INIT(int, 1);
+INIT(int, 0);
+
 int main(int argc, char **argv)
 {
   int ret;
@@ -337,14 +352,6 @@
   int temp_driver_id = -1;
   devices_t *current;
 
-  /* data used just to initialize the pointers */
-  char char_n = 'n';
-  long int_10000 = 10000;
-  float float_50f = 50.0f;
-  float float_0f = 0.0f;
-  long int_1 = 1;
-  long int_0 = 0;
-
   /* *INDENT-OFF* */
   Option_t opts[] = {
     /* found, name, description, type, ptr, default */
@@ -717,17 +724,17 @@
       
       for (i = 0; i < vc->comments; i++) {
         char *cc = vc->user_comments[i];	/* current comment */
-	int i;
+	int j;
         
-	for (i = 0; ogg_comment_keys[i].key != NULL; i++)
+	for (j = 0; ogg_comment_keys[j].key != NULL; j++)
           if (!strncasecmp
-	      (ogg_comment_keys[i].key, cc,
-	       strlen(ogg_comment_keys[i].key))) {
-	    ShowMessage (1, 0, 1, ogg_comment_keys[i].formatstr,
-			 cc + strlen(ogg_comment_keys[i].key));
+	      (ogg_comment_keys[j].key, cc,
+	       strlen(ogg_comment_keys[j].key))) {
+	    ShowMessage (1, 0, 1, ogg_comment_keys[j].formatstr,
+			 cc + strlen(ogg_comment_keys[j].key));
             break;
           }
-	if (ogg_comment_keys[i].key == NULL)
+	if (ogg_comment_keys[j].key == NULL)
           ShowMessage (1, 0, 1, "Unrecognized comment: '%s'", cc);
       }
       
@@ -774,7 +781,7 @@
 
         old_section = current_section;
         ret =
-	  ov_read(&vf, convbuffer, sizeof(convbuffer), is_big_endian,
+	  ov_read(&vf, (char *) convbuffer, sizeof(convbuffer), is_big_endian,
                   2, 1, &current_section);
         if (ret == 0) {
           /* End of file */

1.3.2.2   +2 -2      vorbis-tools/ogg123/ogg123rc-example

Index: ogg123rc-example
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123rc-example,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- ogg123rc-example	2001/08/23 01:26:43	1.3.2.1
+++ ogg123rc-example	2001/08/31 18:01:12	1.3.2.2
@@ -10,7 +10,7 @@
 verbose=1
 outbuffer=0
 outprebuffer=0
-inbuffer=100000
-inprebuffer=50
+inbuffer=10000
+inprebuffer=10
 #save_stream=
 delay=1

1.1.2.8   +3 -6      vorbis-tools/ogg123/Attic/options.c

Index: options.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/options.c,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- options.c	2001/08/30 23:38:41	1.1.2.7
+++ options.c	2001/08/31 18:01:12	1.1.2.8
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: options.c,v 1.1.2.7 2001/08/30 23:38:41 kcarnold Exp $
+ last mod: $Id: options.c,v 1.1.2.8 2001/08/31 18:01:12 kcarnold Exp $
 
  ********************************************************************/
 
@@ -61,8 +61,6 @@
         case opt_type_double:
         *(double *) opts->ptr = *(double *) opts->dfl;
         break;
-	
-	default:
         }
       }
       opts++;
@@ -196,9 +194,9 @@
  *  Output: opts[] is updated with the options in the file.
  *  Return: a ParseCode
  */
-ParseCode ParseFile (Option_t opts[], char *filename, int (*errfunc) (void *, ParseCode, int, char*, char*), void *arg)
+ParseCode ParseFile (Option_t opts[], const char *filename, int (*errfunc) (void *, ParseCode, int, const char*, char*), void *arg)
 {
-  int len=80;
+  unsigned int len=80;
   char *line = malloc (len);
   int readoffset, thischar, lineno;
   FILE *file;
@@ -396,7 +394,6 @@
         case opt_type_double:
           fprintf (f, "%f", *(double *) opt->dfl);
           break;
-	default:
         }
       }
       fputc ('\n', f);

1.1.2.2   +4 -4      vorbis-tools/ogg123/Attic/options.h

Index: options.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/options.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- options.h	2001/08/12 03:59:31	1.1.2.1
+++ options.h	2001/08/31 18:01:12	1.1.2.2
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: options.h,v 1.1.2.1 2001/08/12 03:59:31 kcarnold Exp $
+ last mod: $Id: options.h,v 1.1.2.2 2001/08/31 18:01:12 kcarnold Exp $
 
  ********************************************************************/
 
@@ -44,8 +44,8 @@
 
 typedef struct Option_s {
   char found;
-  char *name;
-  char *desc;
+  const char *name;
+  const char *desc;
   OptionType type;
   void *ptr;
   void *dfl;
@@ -53,7 +53,7 @@
 
 void InitOpts (Option_t opts[]);
 ParseCode ParseLine (Option_t opts[], char *line);
-ParseCode ParseFile (Option_t opts[], char *filename, int (*errfunc) (void *, ParseCode, int, char*, char*), void *arg);
+ParseCode ParseFile (Option_t opts[], const char *filename, int (*errfunc) (void *, ParseCode, int, const char*, char*), void *arg);
 const char *ParseErr (ParseCode pcode);
 void DescribeOptions (Option_t opts[], FILE *outfile);
 

1.1.2.7   +9 -6      vorbis-tools/ogg123/Attic/status.c

Index: status.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/status.c,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- status.c	2001/08/22 16:42:31	1.1.2.6
+++ status.c	2001/08/31 18:01:12	1.1.2.7
@@ -11,12 +11,14 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: status.c,v 1.1.2.6 2001/08/22 16:42:31 kcarnold Exp $
+ last mod: $Id: status.c,v 1.1.2.7 2001/08/31 18:01:12 kcarnold Exp $
 
  ********************************************************************/
 
 /* status interface */
 
+#define _GNU_SOURCE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include "status.h"
@@ -24,7 +26,7 @@
 /* a few globals */
 /* stderr is thread-global, so status vars should be also; caller must
  * ensure that status functions are not called concurrently */
-int buflen = 100; /* guess max length to be 100 */
+size_t buflen = 100; /* guess max length to be 100 */
 char *tmpbuf = NULL; /* global so updating quick after size determined */
 int LastLineLen = 0;
 int MaxPrio = 0;
@@ -38,9 +40,10 @@
   fputc ('\r', stderr);
 }
 
-int AppendString (int len, char *fmt, ...) {
+int AppendString (int len, const char *fmt, ...) {
   va_list ap;
-  int n = -1, size;
+  int n = -1;
+  size_t size;
 
   while (n == -1) {
     size = buflen - len - 1;
@@ -113,7 +116,7 @@
   LastLineLen = len;
 }
 
-void ShowMessage (int prio, char keepLastLine, char addNewline, char *fmt, ...)
+void ShowMessage (int prio, char keepLastLine, char addNewline, const char *fmt, ...)
 {
   va_list ap;
 
@@ -133,7 +136,7 @@
 }
 
 /* a degenerate ShowMessage specifically for spitting out an error. fmt has a newline. */
-void Error (char *fmt, ...)
+void Error (const char *fmt, ...)
 {
   va_list ap;
   va_start (ap, fmt);

1.1.2.4   +4 -4      vorbis-tools/ogg123/Attic/status.h

Index: status.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/status.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- status.h	2001/08/22 16:42:31	1.1.2.3
+++ status.h	2001/08/31 18:01:12	1.1.2.4
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: status.h,v 1.1.2.3 2001/08/22 16:42:31 kcarnold Exp $
+ last mod: $Id: status.h,v 1.1.2.4 2001/08/31 18:01:12 kcarnold Exp $
 
  ********************************************************************/
 
@@ -25,7 +25,7 @@
 typedef struct {
   int prio;
   char enabled;
-  char *formatstr;
+  const char *formatstr;
   enum {
     stat_noarg = 0,
     stat_intarg,
@@ -42,8 +42,8 @@
 } Stat_t;
 
 void UpdateStats (Stat_t stats[]);
-void ShowMessage (int prio, char keepStatusLine, char addNewline, char *fmt, ...);
-void Error (char *fmt, ...);
+void ShowMessage (int prio, char keepStatusLine, char addNewline, const char *fmt, ...);
+void Error (const char *fmt, ...);
 void SetPriority (int prio);
 
 #endif /* __STATUS_H */

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