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

Kenneth C. Arnold kcarnold at xiph.org
Fri Aug 10 19:55:39 PDT 2001



kcarnold    01/08/10 19:55:39

  Modified:    ogg123   Tag: kcarnold_work ao_interface.c ao_interface.h
                        buffer.c buffer.h curl_interface.c curl_interface.h
                        ogg123.c
  Log:
  EOF works. Buffer now has generic EOS capabilities.

Revision  Changes    Path
No                   revision

No                   revision

1.5.2.4   +2 -2      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.3
retrieving revision 1.5.2.4
diff -u -r1.5.2.3 -r1.5.2.4
--- ao_interface.c	2001/08/11 02:10:09	1.5.2.3
+++ ao_interface.c	2001/08/11 02:55:37	1.5.2.4
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ao_interface.c,v 1.5.2.3 2001/08/11 02:10:09 kcarnold Exp $
+ last mod: $Id: ao_interface.c,v 1.5.2.4 2001/08/11 02:55:37 kcarnold Exp $
 
  ********************************************************************/
 
@@ -43,7 +43,7 @@
     return devices_list;
 }
 
-size_t devices_write(void *ptr, size_t size, size_t nmemb, devices_t * d)
+size_t devices_write(void *ptr, size_t size, size_t nmemb, devices_t * d, char iseos)
 {
   size_t i, total = 0;
   devices_t * start = d;

1.1.2.2   +2 -2      vorbis-tools/ogg123/Attic/ao_interface.h

Index: ao_interface.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/ao_interface.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- ao_interface.h	2001/08/10 20:50:26	1.1.2.1
+++ ao_interface.h	2001/08/11 02:55:37	1.1.2.2
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
  
- last mod: $Id: ao_interface.h,v 1.1.2.1 2001/08/10 20:50:26 kcarnold Exp $
+ last mod: $Id: ao_interface.h,v 1.1.2.2 2001/08/11 02:55:37 kcarnold Exp $
  
 ********************************************************************/
 
@@ -33,7 +33,7 @@
 
 devices_t *append_device(devices_t * devices_list, int driver_id,
                          ao_option * options, char *filename);
-size_t devices_write(void *ptr, size_t size, size_t nmemb, devices_t * d);
+size_t devices_write(void *ptr, size_t size, size_t nmemb, devices_t * d, char iseos);
 int add_option(ao_option ** op_h, const char *optstring);
 int get_default_device(void);
 void ao_onexit (int exitcode, void *devices);

1.7.2.9   +13 -4     vorbis-tools/ogg123/buffer.c

Index: buffer.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/buffer.c,v
retrieving revision 1.7.2.8
retrieving revision 1.7.2.9
diff -u -r1.7.2.8 -r1.7.2.9
--- buffer.c	2001/08/11 02:10:09	1.7.2.8
+++ buffer.c	2001/08/11 02:55:37	1.7.2.9
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: buffer.c,v 1.7.2.8 2001/08/11 02:10:09 kcarnold Exp $
+ last mod: $Id: buffer.c,v 1.7.2.9 2001/08/11 02:55:37 kcarnold Exp $
 
  ********************************************************************/
 
@@ -83,6 +83,7 @@
   volatile buf_t *vbuf = (volatile buf_t*) buf; /* optimizers... grr */
   size_t WriteThisTime = 0;
   chunk *NewWriterPtr;
+  char iseos = 0;
 
   DEBUG0("BufferFunc");
   sigfillset (&set);
@@ -156,8 +157,10 @@
           DEBUG1("up to buf->reader, buf->reader - buf->writer = %d", buf->reader - buf->writer);
           if (buf->reader - buf->writer > TARGET_WRITE_SIZE)
             WriteThisTime = TARGET_WRITE_SIZE;
-	  else
+	  else {
             WriteThisTime = buf->reader - buf->writer;
+	    iseos = buf->eos;
+	  }
           NewWriterPtr = buf->writer + WriteThisTime;
         }
 
@@ -165,7 +168,7 @@
       /* unlock while playing sample */
       UNLOCK_MUTEX (buf->SizeMutex);
       DEBUG1("WriteThisTime=%d", WriteThisTime);
-      buf->write_func (buf->writer, WriteThisTime, 1, buf->data);
+      buf->write_func (buf->writer, WriteThisTime, 1, buf->data, iseos);
 
       DEBUG0("incrementing pointer");
       LOCK_MUTEX (buf->SizeMutex);
@@ -184,7 +187,7 @@
 }
 
 buf_t *StartBuffer (long size, long prebuffer, void *data, 
-		    size_t (*write_func) (void *, size_t, size_t, void *),
+		    size_t (*write_func) (void *, size_t, size_t, void *, char),
                     void *initData, int (*init_func) (void*))
 {
   buf_t *buf = malloc (sizeof(buf_t) + sizeof (chunk) * (size - 1));
@@ -349,6 +352,12 @@
 {
   return (char) !(buf->StatMask & STAT_PLAYING);
 }
+
+void buffer_MarkEOS (buf_t *buf)
+{
+  buf->eos = 1;
+}
+
 
 void buffer_cleanup (buf_t *buf) {
   if (buf) {

1.2.2.9   +5 -3      vorbis-tools/ogg123/buffer.h

Index: buffer.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/buffer.h,v
retrieving revision 1.2.2.8
retrieving revision 1.2.2.9
diff -u -r1.2.2.8 -r1.2.2.9
--- buffer.h	2001/08/11 02:10:09	1.2.2.8
+++ buffer.h	2001/08/11 02:55:37	1.2.2.9
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
  
- last mod: $Id: buffer.h,v 1.2.2.8 2001/08/11 02:10:09 kcarnold Exp $
+ last mod: $Id: buffer.h,v 1.2.2.9 2001/08/11 02:55:37 kcarnold Exp $
  
 ********************************************************************/
 
@@ -28,7 +28,7 @@
 {
   /* generic buffer interface */
   void * data;
-  size_t (*write_func) (chunk *ptr, size_t size, size_t nmemb, void * d);
+  size_t (*write_func) (chunk *ptr, size_t size, size_t nmemb, void * d, char iseos);
 
   void * initData;
   int (*init_func) (void *);
@@ -46,6 +46,7 @@
   long size;         /* buffer size, for reference */
   long curfill;      /* how much the buffer is currently filled */
   long prebuffer;    /* number of chunks to prebuffer */
+  char eos;        /* set if reader is at end of stream */
   chunk *reader;   /* Chunk the reader is busy with */
   chunk *writer;   /* Chunk the writer is busy with */
   chunk *end;      /* Last chunk in the buffer (for convenience) */
@@ -59,9 +60,10 @@
 #define TARGET_WRITE_SIZE 4096 /* to agree with other mechanisms used in ogg123 */
 
 buf_t *StartBuffer (long size, long prebuffer, void *data, 
-		    size_t (*write_func) (void *, size_t, size_t, void *),
+		    size_t (*write_func) (void *, size_t, size_t, void *, char),
                     void *initData, int (*init_func) (void*));
 void SubmitData (buf_t *buf, chunk *data, size_t size, size_t nmemb);
+void buffer_MarkEOS (buf_t *buf);
 void buffer_shutdown (buf_t *buf);
 void buffer_cleanup (buf_t *buf);
 void buffer_flush (buf_t *buf);

1.1.2.2   +21 -6     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.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- curl_interface.c	2001/08/11 02:10:09	1.1.2.1
+++ curl_interface.c	2001/08/11 02:55:37	1.1.2.2
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
  
- last mod: $Id: curl_interface.c,v 1.1.2.1 2001/08/11 02:10:09 kcarnold Exp $
+ last mod: $Id: curl_interface.c,v 1.1.2.2 2001/08/11 02:55:37 kcarnold Exp $
  
 ********************************************************************/
 
@@ -31,7 +31,7 @@
   return size*nmemb;
 }
 
-size_t BufferWriteChunk (void *ptr, size_t size, void *arg)
+size_t BufferWriteChunk (void *ptr, size_t size, void *arg, char iseos)
 {
   StreamInputBufferData_t *data = arg;
 
@@ -65,6 +65,9 @@
       data->ExcessDataSize = size;
       
       debug ("signalling successful read\n");
+      data->EOS = iseos;
+      if (iseos)
+	debug ("End of stream.\n");
       pthread_mutex_unlock (&data->ReadDataMutex);
       pthread_cond_signal (&data->ReadDoneCondition);
     }
@@ -73,12 +76,15 @@
   return size;
 }
 
-size_t BufferWriteFunction (void *ptr, size_t size, size_t nmemb, void *arg)
+size_t BufferWriteFunction (void *ptr, size_t size, size_t nmemb, void *arg, char iseos)
 {
   size_t written = 0;
   while (nmemb > 0)
     {
-      written += BufferWriteChunk (ptr, size, arg);
+      if (nmemb == 1)
+	written += BufferWriteChunk (ptr, size, arg, iseos);
+      else
+	written += BufferWriteChunk (ptr, size, arg, 0);
       nmemb--;
     }
   return written;
@@ -126,7 +132,7 @@
   fprintf (stderr, "CurlGo\n");
   ret = curl_easy_perform ((CURL*) data->CurlHandle);
   debug ("curl done.\n");
-  data->EOFAt = buf->curfill;
+  buffer_MarkEOS (buf);
   return (void*) ret;
 }
 
@@ -201,7 +207,16 @@
       memmove (ptr, data->ExcessData, data->ExcessDataSize);
       ptr += data->ExcessDataSize;
       size -= data->ExcessDataSize;
-      data->ExcessDataSize = 0;
+      if (data->EOS)
+	{
+	  ret = data->ExcessDataSize;
+	  debug ("Data marked EOS, so returning just excess data\n");
+	  pthread_mutex_unlock (&data->ReadDataMutex);
+	  data->ExcessDataSize = 0;
+	  return ret;
+	}
+      else
+	data->ExcessDataSize = 0;
       
       data->BytesRequested = size;
       data->WriteTarget = data->CurWritePtr = ptr;

1.1.2.2   +3 -3      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.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- curl_interface.h	2001/08/11 02:10:09	1.1.2.1
+++ curl_interface.h	2001/08/11 02:55:37	1.1.2.2
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
  
- last mod: $Id: curl_interface.h,v 1.1.2.1 2001/08/11 02:10:09 kcarnold Exp $
+ last mod: $Id: curl_interface.h,v 1.1.2.2 2001/08/11 02:55:37 kcarnold Exp $
  
 ********************************************************************/
 
@@ -50,8 +50,8 @@
   pthread_cond_t ReadDoneCondition;
 
   CURL * CurlHandle;
-  char EOFAt;
-  char EOFWhileReading;
+
+  char EOS;
 
   size_t BytesRequested;
   unsigned char *WriteTarget;

1.39.2.11 +2 -2      vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.39.2.10
retrieving revision 1.39.2.11
diff -u -r1.39.2.10 -r1.39.2.11
--- ogg123.c	2001/08/11 02:10:09	1.39.2.10
+++ ogg123.c	2001/08/11 02:55:37	1.39.2.11
@@ -14,7 +14,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.39.2.10 2001/08/11 02:10:09 kcarnold Exp $
+ last mod: $Id: ogg123.c,v 1.39.2.11 2001/08/11 02:55:37 kcarnold Exp $
 
  ********************************************************************/
 
@@ -550,7 +550,7 @@
                     if (OutBuffer)
                         SubmitData (OutBuffer, convbuffer, ret, 1);
                     else
-		      devices_write(convbuffer, ret, 1, opt.outdevices);
+		      devices_write(convbuffer, ret, 1, opt.outdevices, 0);
                     nthc = opt.nth - 1;
                   }
                 } while (++ntimesc < opt.ntimes);

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