Fix ogg123 buffering. Prefer shared memory by mmap() over SYSVSHM
even after fixing the latter.
This commit is contained in:
parent
a2189846be
commit
a277f5d2d9
69
audio/vorbis-tools/patches/patch-acinclude_m4
Normal file
69
audio/vorbis-tools/patches/patch-acinclude_m4
Normal file
@ -0,0 +1,69 @@
|
||||
$OpenBSD: patch-acinclude_m4,v 1.1 2001/03/17 17:07:10 naddy Exp $
|
||||
--- acinclude.m4.orig Sat Mar 17 16:28:41 2001
|
||||
+++ acinclude.m4 Sat Mar 17 16:36:54 2001
|
||||
@@ -280,3 +280,65 @@ int main ()
|
||||
AC_SUBST(AO_LIBS)
|
||||
rm -f conf.aotest
|
||||
])
|
||||
+
|
||||
+dnl Shamelessly stolen from Joerg Schilling's star.
|
||||
+dnl Copyright 1998 J. Schilling
|
||||
+
|
||||
+dnl Checks if mmap() works to get shared memory
|
||||
+dnl Defines HAVE_SMMAP on success.
|
||||
+AC_DEFUN(AC_FUNC_SMMAP,
|
||||
+[AC_CACHE_CHECK([if mmap works to get shared memory], ac_cv_func_smmap,
|
||||
+ [AC_TRY_RUN([
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/mman.h>
|
||||
+
|
||||
+char *
|
||||
+mkshare()
|
||||
+{
|
||||
+ int size = 8192;
|
||||
+ int f;
|
||||
+ char *addr;
|
||||
+
|
||||
+ if ((f = open("/dev/zero", 2)) < 0)
|
||||
+ exit(1);
|
||||
+ addr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, f, 0);
|
||||
+ if (addr == (char *)-1)
|
||||
+ exit(1);
|
||||
+ close(f);
|
||||
+
|
||||
+ return (addr);
|
||||
+}
|
||||
+
|
||||
+main()
|
||||
+{
|
||||
+ char *addr;
|
||||
+
|
||||
+ addr = mkshare(8192);
|
||||
+ *addr = 'I';
|
||||
+
|
||||
+ switch (fork()) {
|
||||
+
|
||||
+ case -1:
|
||||
+ printf("help\n"); exit(1);
|
||||
+
|
||||
+ case 0: /* child */
|
||||
+ *addr = 'N';
|
||||
+ _exit(0);
|
||||
+ break;
|
||||
+ default: /* parent */
|
||||
+ wait(0);
|
||||
+ sleep(1);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (*addr != 'N')
|
||||
+ exit(1);
|
||||
+ exit(0);
|
||||
+}
|
||||
+],
|
||||
+ [ac_cv_func_smmap=yes],
|
||||
+ [ac_cv_func_smmap=no],
|
||||
+ [ac_cv_func_smmap=no])])
|
||||
+if test $ac_cv_func_smmap = yes; then
|
||||
+ AC_DEFINE(HAVE_SMMAP)
|
||||
+fi])
|
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-aclocal_m4,v 1.1.1.1 2001/03/14 01:58:25 todd Exp $
|
||||
--- aclocal.m4.orig Wed Feb 28 19:33:40 2001
|
||||
+++ aclocal.m4 Wed Feb 28 19:33:47 2001
|
||||
$OpenBSD: patch-aclocal_m4,v 1.2 2001/03/17 17:07:11 naddy Exp $
|
||||
--- aclocal.m4.orig Mon Feb 26 06:51:03 2001
|
||||
+++ aclocal.m4 Sat Mar 17 17:06:03 2001
|
||||
@@ -222,7 +222,7 @@ AC_ARG_ENABLE(aotest, [ --disable-aotes
|
||||
AO_LIBS="-L$ao_prefix/lib"
|
||||
fi
|
||||
@ -10,3 +10,72 @@ $OpenBSD: patch-aclocal_m4,v 1.1.1.1 2001/03/14 01:58:25 todd Exp $
|
||||
|
||||
AC_MSG_CHECKING(for ao)
|
||||
no_ao=""
|
||||
@@ -292,6 +292,68 @@ int main ()
|
||||
AC_SUBST(AO_LIBS)
|
||||
rm -f conf.aotest
|
||||
])
|
||||
+
|
||||
+dnl Shamelessly stolen from Joerg Schilling's star.
|
||||
+dnl Copyright 1998 J. Schilling
|
||||
+
|
||||
+dnl Checks if mmap() works to get shared memory
|
||||
+dnl Defines HAVE_SMMAP on success.
|
||||
+AC_DEFUN(AC_FUNC_SMMAP,
|
||||
+[AC_CACHE_CHECK([if mmap works to get shared memory], ac_cv_func_smmap,
|
||||
+ [AC_TRY_RUN([
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/mman.h>
|
||||
+
|
||||
+char *
|
||||
+mkshare()
|
||||
+{
|
||||
+ int size = 8192;
|
||||
+ int f;
|
||||
+ char *addr;
|
||||
+
|
||||
+ if ((f = open("/dev/zero", 2)) < 0)
|
||||
+ exit(1);
|
||||
+ addr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, f, 0);
|
||||
+ if (addr == (char *)-1)
|
||||
+ exit(1);
|
||||
+ close(f);
|
||||
+
|
||||
+ return (addr);
|
||||
+}
|
||||
+
|
||||
+main()
|
||||
+{
|
||||
+ char *addr;
|
||||
+
|
||||
+ addr = mkshare(8192);
|
||||
+ *addr = 'I';
|
||||
+
|
||||
+ switch (fork()) {
|
||||
+
|
||||
+ case -1:
|
||||
+ printf("help\n"); exit(1);
|
||||
+
|
||||
+ case 0: /* child */
|
||||
+ *addr = 'N';
|
||||
+ _exit(0);
|
||||
+ break;
|
||||
+ default: /* parent */
|
||||
+ wait(0);
|
||||
+ sleep(1);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (*addr != 'N')
|
||||
+ exit(1);
|
||||
+ exit(0);
|
||||
+}
|
||||
+],
|
||||
+ [ac_cv_func_smmap=yes],
|
||||
+ [ac_cv_func_smmap=no],
|
||||
+ [ac_cv_func_smmap=no])])
|
||||
+if test $ac_cv_func_smmap = yes; then
|
||||
+ AC_DEFINE(HAVE_SMMAP)
|
||||
+fi])
|
||||
|
||||
# Do all the work for Automake. This macro actually does too much --
|
||||
# some checks are only needed if your package does certain things.
|
||||
|
12
audio/vorbis-tools/patches/patch-configure_in
Normal file
12
audio/vorbis-tools/patches/patch-configure_in
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-configure_in,v 1.1 2001/03/17 17:07:11 naddy Exp $
|
||||
--- configure.in.orig Sat Mar 17 16:50:29 2001
|
||||
+++ configure.in Sat Mar 17 16:52:47 2001
|
||||
@@ -67,7 +67,7 @@ dnl ------------------------------------
|
||||
dnl Check for library functions
|
||||
dnl --------------------------------------------------
|
||||
|
||||
-dnl none
|
||||
+AC_FUNC_SMMAP
|
||||
|
||||
dnl --------------------------------------------------
|
||||
dnl Work around FHS stupidity
|
11
audio/vorbis-tools/patches/patch-ogg123_Makefile_am
Normal file
11
audio/vorbis-tools/patches/patch-ogg123_Makefile_am
Normal file
@ -0,0 +1,11 @@
|
||||
$OpenBSD: patch-ogg123_Makefile_am,v 1.1 2001/03/17 17:07:11 naddy Exp $
|
||||
--- ogg123/Makefile.am.orig Sat Mar 17 15:55:09 2001
|
||||
+++ ogg123/Makefile.am Sat Mar 17 15:55:13 2001
|
||||
@@ -5,7 +5,6 @@ AUTOMAKE_OPTIONS = foreign
|
||||
bin_PROGRAMS = ogg123
|
||||
docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION)
|
||||
doc_DATA = ogg123rc-example
|
||||
-mandir = $(datadir)/man
|
||||
man_MANS = ogg123.1
|
||||
|
||||
INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@ @AO_CFLAGS@
|
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-ogg123_Makefile_in,v 1.1.1.1 2001/03/14 01:58:25 todd Exp $
|
||||
--- ogg123/Makefile.in.orig Tue Mar 13 17:48:16 2001
|
||||
+++ ogg123/Makefile.in Tue Mar 13 17:49:35 2001
|
||||
$OpenBSD: patch-ogg123_Makefile_in,v 1.2 2001/03/17 17:07:11 naddy Exp $
|
||||
--- ogg123/Makefile.in.orig Sat Mar 17 17:55:34 2001
|
||||
+++ ogg123/Makefile.in Sat Mar 17 17:55:54 2001
|
||||
@@ -85,7 +85,7 @@ AUTOMAKE_OPTIONS = foreign
|
||||
bin_PROGRAMS = ogg123
|
||||
docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION)
|
||||
|
@ -1,7 +1,18 @@
|
||||
$OpenBSD: patch-ogg123_buffer_c,v 1.1.1.1 2001/03/14 01:58:25 todd Exp $
|
||||
--- ogg123/buffer.c.orig Tue Mar 13 17:35:55 2001
|
||||
+++ ogg123/buffer.c Tue Mar 13 17:36:36 2001
|
||||
@@ -13,10 +13,6 @@
|
||||
$OpenBSD: patch-ogg123_buffer_c,v 1.2 2001/03/17 17:07:11 naddy Exp $
|
||||
--- ogg123/buffer.c.orig Tue Jan 30 11:42:48 2001
|
||||
+++ ogg123/buffer.c Sat Mar 17 17:12:02 2001
|
||||
@@ -6,17 +6,16 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
+#if HAVE_SMMAP
|
||||
+#include <sys/mman.h>
|
||||
+#else
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
-#include <sys/stat.h>
|
||||
+#endif
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h> /* for fork and pipe*/
|
||||
#include <fcntl.h>
|
||||
|
||||
@ -12,3 +23,44 @@ $OpenBSD: patch-ogg123_buffer_c,v 1.1.1.1 2001/03/14 01:58:25 todd Exp $
|
||||
#include "ogg123.h"
|
||||
#include "buffer.h"
|
||||
|
||||
@@ -73,10 +72,26 @@ buf_t *fork_writer (long size, devices_t
|
||||
int childpid;
|
||||
buf_t *buf;
|
||||
|
||||
+#if HAVE_SMMAP
|
||||
+ int fd;
|
||||
+
|
||||
+ if ((fd = open("/dev/zero", O_RDWR)) < 0)
|
||||
+ {
|
||||
+ perror ("cannot open /dev/zero");
|
||||
+ exit (1);
|
||||
+ }
|
||||
+ if ((buf = (buf_t *) mmap (0, sizeof(buf_t) + sizeof (chunk_t) * (size - 1),
|
||||
+ PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) < 0)
|
||||
+ {
|
||||
+ perror("mmap");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ close(fd);
|
||||
+#else
|
||||
/* Get the shared memory segment. */
|
||||
int shmid = shmget (IPC_PRIVATE,
|
||||
sizeof(buf_t) + sizeof (chunk_t) * (size - 1),
|
||||
- IPC_CREAT|S_IREAD|S_IWRITE);
|
||||
+ IPC_CREAT|SHM_R|SHM_W);
|
||||
|
||||
if (shmid == -1)
|
||||
{
|
||||
@@ -92,7 +107,11 @@ buf_t *fork_writer (long size, devices_t
|
||||
perror ("shmat");
|
||||
exit (1);
|
||||
}
|
||||
-
|
||||
+
|
||||
+ /* Remove segment after last process detaches it or terminates. */
|
||||
+ shmctl(shmid, IPC_RMID, 0);
|
||||
+#endif /* HAVE_SMMAP */
|
||||
+
|
||||
buffer_init (buf, size);
|
||||
|
||||
/* Create a pipe for communication between the two processes. Unlike
|
||||
|
Loading…
Reference in New Issue
Block a user