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

Stan Seibert volsung at xiph.org
Tue Dec 18 17:34:27 PST 2001



volsung     01/12/18 17:34:27

  Modified:    ogg123   Tag: volsung_kc_20011011 buffer.c buffer.h
                        http_transport.c
  Log:
  Explict pthread cancel testing in the buffer code.
  Actually check the curl return code.

Revision  Changes    Path
No                   revision

No                   revision

1.7.2.23.2.11 +12 -1     vorbis-tools/ogg123/buffer.c

Index: buffer.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/buffer.c,v
retrieving revision 1.7.2.23.2.10
retrieving revision 1.7.2.23.2.11
diff -u -r1.7.2.23.2.10 -r1.7.2.23.2.11
--- buffer.c	2001/12/18 04:15:44	1.7.2.23.2.10
+++ buffer.c	2001/12/19 01:34:26	1.7.2.23.2.11
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: buffer.c,v 1.7.2.23.2.10 2001/12/18 04:15:44 volsung Exp $
+ last mod: $Id: buffer.c,v 1.7.2.23.2.11 2001/12/19 01:34:26 volsung Exp $
 
  ********************************************************************/
 
@@ -56,6 +56,7 @@
   buf->prebuffering = buf->prebuffer_size > 0;
   buf->paused = 0;
   buf->eos = 0;
+  buf->abort_write = 0;
   
   buf->curfill = 0;
   buf->start = 0;
@@ -208,6 +209,8 @@
     
     UNLOCK_MUTEX(buf->mutex);
 
+    pthread_testcancel();
+
     /* Don't need to lock buffer while running actions since position
        won't change.  We clear out any actions before we compute the
        dequeue size so we don't consider actions that need to
@@ -219,6 +222,8 @@
     /* Need to be locked while we check things. */
     write_amount = compute_dequeue_size(buf, buf->audio_chunk_size);
 
+    pthread_testcancel();
+
     UNLOCK_MUTEX(buf->mutex);
  
     /* No need to lock mutex here because the other thread will
@@ -497,6 +502,9 @@
       COND_WAIT(buf->playback_cond, buf->mutex);
     }
 
+    if (buf->abort_write)
+      break;
+
     /* Note: Even if curfill is still 0, nothing bad will happen here */
     
     /* For simplicity, the number of bytes played must satisfy
@@ -528,6 +536,8 @@
 
   UNLOCK_MUTEX(buf->mutex);
   
+  pthread_testcancel();
+
   DEBUG("Exit buffer_get_data");
    
   return orig_size - nbytes;
@@ -549,6 +559,7 @@
   DEBUG("buffer_mark_eos");
 
   LOCK_MUTEX(buf->mutex);
+  buf->abort_write = 1;
   COND_SIGNAL(buf->write_cond);
   UNLOCK_MUTEX(buf->mutex);  
 }

1.2.2.16.2.7 +2 -1      vorbis-tools/ogg123/buffer.h

Index: buffer.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/buffer.h,v
retrieving revision 1.2.2.16.2.6
retrieving revision 1.2.2.16.2.7
diff -u -r1.2.2.16.2.6 -r1.2.2.16.2.7
--- buffer.h	2001/12/18 04:15:44	1.2.2.16.2.6
+++ buffer.h	2001/12/19 01:34:26	1.2.2.16.2.7
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
  
- last mod: $Id: buffer.h,v 1.2.2.16.2.6 2001/12/18 04:15:44 volsung Exp $
+ last mod: $Id: buffer.h,v 1.2.2.16.2.7 2001/12/19 01:34:26 volsung Exp $
  
 ********************************************************************/
 
@@ -58,6 +58,7 @@
   int prebuffering;
   int paused;
   int eos;
+  int abort_write;
 
   /* buffer data */
   long curfill;     /* how much the buffer is currently filled */

1.1.2.3   +11 -4     vorbis-tools/ogg123/Attic/http_transport.c

Index: http_transport.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/http_transport.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- http_transport.c	2001/12/18 04:15:45	1.1.2.2
+++ http_transport.c	2001/12/19 01:34:26	1.1.2.3
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
  
- last mod: $Id: http_transport.c,v 1.1.2.2 2001/12/18 04:15:45 volsung Exp $
+ last mod: $Id: http_transport.c,v 1.1.2.3 2001/12/19 01:34:26 volsung Exp $
  
 ********************************************************************/
 
@@ -36,7 +36,7 @@
   pthread_t curl_thread;
 
   CURL *curl_handle;
-
+  char error[CURL_ERROR_SIZE];
   data_source_stats_t stats;
 } http_private_t;
 
@@ -44,6 +44,7 @@
 typedef struct curl_thread_arg_t {
   buf_t *buf;
   data_source_t *data_source;
+  http_private_t *http_private;
   CURL *curl_handle;
 } curl_thread_arg_t;
 
@@ -64,7 +65,7 @@
 
 /* -------------------------- Private functions --------------------- */
 
-void set_curl_opts (CURL *handle, buf_t *buf, char *url)
+void set_curl_opts (CURL *handle, buf_t *buf, char *url, http_private_t *priv)
 {
   curl_easy_setopt(handle, CURLOPT_FILE, buf);
   curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_callback);
@@ -77,6 +78,8 @@
   if (inputOpts.ProxyTunnel)
     curl_easy_setopt (handle, CURLOPT_HTTPPROXYTUNNEL, inputOpts.ProxyTunnel);
   */
+  curl_easy_setopt(handle, CURLOPT_MUTE, 1);
+  curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, priv->error);
   curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 1);
   curl_easy_setopt(handle, CURLOPT_USERAGENT, "ogg123 "VERSION);
 }
@@ -94,6 +97,7 @@
   
   arg->buf = buf;
   arg->data_source = data_source;
+  arg->http_private = data_source->private;
   arg->curl_handle = curl_handle;
 
   return arg;
@@ -116,6 +120,9 @@
 
   ret = curl_easy_perform((CURL *) myarg->curl_handle);
 
+  if (ret != 0)
+    status_error(myarg->http_private->error);
+    
   buffer_mark_eos(myarg->buf);
 
   curl_easy_cleanup(myarg->curl_handle);
@@ -179,7 +186,7 @@
   if (private->curl_handle == NULL)
     goto fail;
 
-  set_curl_opts(private->curl_handle, private->buf, source_string);
+  set_curl_opts(private->curl_handle, private->buf, source_string, private);
 
   /* Start thread */
   if (pthread_create(&private->curl_thread, NULL, 

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