[xiph-cvs] cvs commit: vorbis-tools/ogg123 buffer.c buffer.h ogg123.c ogg123.h
Kenneth C. Arnold
kcarnold at xiph.org
Sat Jun 23 18:03:13 PDT 2001
kcarnold 01/06/23 18:03:13
Modified: ogg123 Tag: kcarnold_work buffer.c buffer.h ogg123.c
ogg123.h
Log:
Random hacking, munging, and stupidity fixing.
(never trust Ken with signals. don't ask.)
Revision Changes Path
No revision
No revision
1.7.2.3 +23 -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.2
retrieving revision 1.7.2.3
diff -u -r1.7.2.2 -r1.7.2.3
--- buffer.c 2001/06/22 03:57:16 1.7.2.2
+++ buffer.c 2001/06/24 01:03:12 1.7.2.3
@@ -5,7 +5,7 @@
* that program is used in this buffer.
*/
-#define DEBUG_BUFFER
+/* #define DEBUG_BUFFER */
#include <sys/types.h>
#if HAVE_SMMAP
@@ -14,6 +14,7 @@
#include <sys/ipc.h>
#include <sys/shm.h>
#endif
+#include <sys/wait.h>
#include <sys/time.h>
#include <unistd.h> /* for fork and pipe*/
#include <fcntl.h>
@@ -266,4 +267,25 @@
shmdt(buf);
#endif /* HAVE_SMMAP */
DEBUG0("buffer done.");
+}
+
+long buffer_full (buf_t* buf) {
+ chunk_t *reader = buf->reader; /* thread safety... */
+
+ if (reader > buf->writer)
+ return (reader - buf->writer + 1);
+ else
+ return (buf->end - reader) + (buf->writer - buf->buffer) + 2;
+}
+
+void buffer_cleanup (buf_t *buf) {
+ if (buf) {
+ if (buf->readerpid)
+ kill (buf->readerpid, SIGTERM);
+ wait (0);
+ buf->readerpid = 0;
+#ifndef HAVE_SMMAP
+ shmdt(buf);
+#endif
+ }
}
1.2.2.2 +2 -0 vorbis-tools/ogg123/buffer.h
Index: buffer.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/buffer.h,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- buffer.h 2001/06/22 03:55:36 1.2.2.1
+++ buffer.h 2001/06/24 01:03:12 1.2.2.2
@@ -29,7 +29,9 @@
buf_t *fork_writer (long size, devices_t *d);
void submit_chunk (buf_t *buf, chunk_t chunk);
void buffer_shutdown (buf_t *buf);
+void buffer_cleanup (buf_t *buf);
void buffer_flush (buf_t *buf);
+long buffer_full (buf_t *buf);
#define STAT_FLUSH 1
#define STAT_SHUTDOWN 2
1.39.2.4 +10 -18 vorbis-tools/ogg123/ogg123.c
Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.39.2.3
retrieving revision 1.39.2.4
diff -u -r1.39.2.3 -r1.39.2.4
--- ogg123.c 2001/06/23 00:28:17 1.39.2.3
+++ ogg123.c 2001/06/24 01:03:12 1.39.2.4
@@ -14,7 +14,7 @@
* *
********************************************************************
- last mod: $Id: ogg123.c,v 1.39.2.3 2001/06/23 00:28:17 kcarnold Exp $
+ last mod: $Id: ogg123.c,v 1.39.2.4 2001/06/24 01:03:12 kcarnold Exp $
********************************************************************/
@@ -119,7 +119,7 @@
opt.nth = 1;
opt.ntimes = 1;
- atexit (buffer_cleanup);
+ atexit (ogg123_atexit);
signal (SIGINT, signal_quit);
ao_initialize();
@@ -262,7 +262,9 @@
signal(which_signal,old_sig);
raise(which_signal);
}
-
+ else
+ signal (SIGINT, signal_quit);
+ /* should that be unconditional? man pages are not clear on this */
}
void signal_activate_skipfile(int ignored)
@@ -623,19 +625,9 @@
return 0;
}
-long buffer_full (buf_t* buf) {
- chunk_t *reader = buf->reader; /* thread safety... */
-
- if (reader > buf->writer)
- return (reader - buf->writer + 1);
- else
- return (buf->end - reader) + (buf->writer - buf->buffer) + 2;
-}
-
-void buffer_cleanup (void) {
- if (buffer) {
- buffer_flush (buffer);
- buffer_shutdown (buffer);
- buffer = NULL;
- }
+void ogg123_atexit (void)
+{
+ if (buffer)
+ buffer_cleanup (buffer);
+ buffer = NULL;
}
1.7.2.4 +1 -2 vorbis-tools/ogg123/ogg123.h
Index: ogg123.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.h,v
retrieving revision 1.7.2.3
retrieving revision 1.7.2.4
diff -u -r1.7.2.3 -r1.7.2.4
--- ogg123.h 2001/06/23 00:28:17 1.7.2.3
+++ ogg123.h 2001/06/24 01:03:12 1.7.2.4
@@ -50,8 +50,7 @@
int get_tcp_socket(void); /* Will be going soon. */
FILE *http_open(char *server, int port, char *path); /* ditto */
int open_audio_devices(ogg123_options_t *opt, int rate, int channels, buf_t ** buffer);
-long buffer_full (buf_t* buffer);
-void buffer_cleanup (void);
void signal_quit (int ignored);
+void ogg123_atexit (void);
#endif /* !defined(__OGG123_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