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

Kenneth C. Arnold kcarnold at xiph.org
Mon Aug 13 14:00:43 PDT 2001



kcarnold    01/08/13 14:00:43

  Modified:    ogg123   Tag: kcarnold_work buffer.c buffer.h ogg123.c
  Log:
  Better fix for the stop/cont condition. But leaving the timed waits in
  there, ifdef'ed out -- they're a good idea for when release time
  comes (maybe).

Revision  Changes    Path
No                   revision

No                   revision

1.7.2.16  +18 -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.15
retrieving revision 1.7.2.16
diff -u -r1.7.2.15 -r1.7.2.16
--- buffer.c	2001/08/13 20:41:51	1.7.2.15
+++ buffer.c	2001/08/13 21:00:41	1.7.2.16
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: buffer.c,v 1.7.2.15 2001/08/13 20:41:51 kcarnold Exp $
+ last mod: $Id: buffer.c,v 1.7.2.16 2001/08/13 21:00:41 kcarnold Exp $
 
  ********************************************************************/
 
@@ -35,6 +35,7 @@
 #include "buffer.h"
 
 #undef DEBUG_BUFFER
+#undef DEADLOCK_PROTECTION
 
 #ifdef DEBUG_BUFFER
 FILE *debugfile;
@@ -49,7 +50,12 @@
 
 #define LOCK_MUTEX(mutex) do { DEBUG1("Locking mutex %s.", #mutex); pthread_mutex_lock (&(mutex)); } while (0)
 #define UNLOCK_MUTEX(mutex) do { DEBUG1("Unlocking mutex %s", #mutex); pthread_mutex_unlock(&(mutex)); } while (0) 
+
+#ifdef DEADLOCK_PROTECTION
 #define TIMEDWAIT(cond, mutex, sec, nsec) do { struct timeval now; struct timespec timeout; gettimeofday(&now, NULL); timeout.tv_sec = now.tv_sec + sec; timeout.tv_nsec = now.tv_usec * 1000 + nsec; pthread_cond_timedwait (&(cond), &(mutex), &timeout); } while (0)
+#else
+#define TIMEDWAIT(cond, mutex, sec, nsec) do { pthread_cond_wait (&(cond), &(mutex)); } while (0)
+#endif
 
 void Prebuffer (buf_t * buf)
 {
@@ -422,13 +428,24 @@
 void buffer_Unpause (buf_t *buf)
 {
   buf->Playing = 1;
+#if 0
   /* can't signal here; this can be called from sighandler :( */
   /* pthread_cond_signal (&buf->DataReadyCondition); */
+#else
+  /* this function cannot be called from a signal handler. */
+  pthread_cond_signal (&buf->DataReadyCondition);
+#endif
 }
 
 char buffer_Paused (buf_t *buf)
 {
   return (char) !(buf->Playing);
+}
+
+/* don't TERM or KILL the buffer with this if possible. */
+void buffer_KillBuffer (buf_t *buf, int signo)
+{
+  pthread_kill (buf->BufferThread, signo);
 }
 
 void buffer_MarkEOS (buf_t *buf)

1.2.2.14  +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.13
retrieving revision 1.2.2.14
diff -u -r1.2.2.13 -r1.2.2.14
--- buffer.h	2001/08/13 20:41:51	1.2.2.13
+++ buffer.h	2001/08/13 21:00:41	1.2.2.14
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
  
- last mod: $Id: buffer.h,v 1.2.2.13 2001/08/13 20:41:51 kcarnold Exp $
+ last mod: $Id: buffer.h,v 1.2.2.14 2001/08/13 21:00:41 kcarnold Exp $
  
 ********************************************************************/
 
@@ -79,5 +79,6 @@
 void buffer_Pause (buf_t *buf);
 void buffer_Unpause (buf_t *buf);
 char buffer_Paused (buf_t *buf);
+void buffer_KillBuffer (buf_t *buf, int signo);
 
 #endif /* !defined (__BUFFER_H) */

1.39.2.21 +5 -3      vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.39.2.20
retrieving revision 1.39.2.21
diff -u -r1.39.2.20 -r1.39.2.21
--- ogg123.c	2001/08/13 20:41:51	1.39.2.20
+++ ogg123.c	2001/08/13 21:00:41	1.39.2.21
@@ -14,7 +14,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.39.2.20 2001/08/13 20:41:51 kcarnold Exp $
+ last mod: $Id: ogg123.c,v 1.39.2.21 2001/08/13 21:00:41 kcarnold Exp $
 
  ********************************************************************/
 
@@ -562,12 +562,14 @@
     break;
   case SIGTSTP:
     if (Options.outputOpts.buffer)
-      buffer_Pause (Options.outputOpts.buffer);
+      buffer_KillBuffer (Options.outputOpts.buffer, SIGSTOP);
+      /*      buffer_Pause (Options.outputOpts.buffer); */
     kill (getpid(), SIGSTOP);
     break;
   case SIGCONT:
     if (Options.outputOpts.buffer)
-      buffer_Unpause (Options.outputOpts.buffer);
+      buffer_KillBuffer (Options.outputOpts.buffer, SIGCONT);
+      /* buffer_Unpause (Options.outputOpts.buffer); */
     break;
   default:
     psignal (signo, "Unknown signal caught");

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