Browse Source

get sysv shm api code working again

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@372 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.109.0
pbd 22 years ago
parent
commit
f43e68de2d
4 changed files with 58 additions and 19 deletions
  1. +12
    -5
      configure.in
  2. +4
    -4
      example-clients/capture_client.c
  3. +6
    -0
      jackd/engine.c
  4. +36
    -10
      libjack/shm.c

+ 12
- 5
configure.in View File

@@ -13,7 +13,7 @@ dnl micro version = incremented when implementation-only
dnl changes are made
dnl ---
JACK_MAJOR_VERSION=0
JACK_MINOR_VERSION=68
JACK_MINOR_VERSION=69
JACK_MICRO_VERSION=0

dnl ---
@@ -41,7 +41,7 @@ dnl slacker than this, and closer to those for the JACK version
dnl number.
dnl ---
JACK_API_CURRENT=0
JACK_API_REVISION=18
JACK_API_REVISION=19
JACK_API_AGE=0

AC_SUBST(JACK_MAJOR_VERSION)
@@ -87,12 +87,19 @@ dnl look for system support for POSIX shm API
dnl XXX this could probably be improved
dnl

AC_ARG_ENABLE(sysv-shm, [ --enable-sysv-shm use System V shm API even if POSIX API is supported ])

AC_MSG_CHECKING([POSIX shm support (compile time)])
df | grep -s /dev/shm >/dev/null 2>&1
if test $? = 0 ; then
SHM_FLAGS=-DUSE_POSIX_SHM
AC_MSG_RESULT([found.
JACK will use shm_open() and friends])
if test "x$enable-sysv-shm" = "xno" ; then
SHM_FLAGS=-DUSE_POSIX_SHM
AC_MSG_RESULT([found.
JACK will use shm_open() and friends.])
else
AC_MSG_RESULT([found.
But JACK will use shmget() and friends because you asked for it.])
fi
else
AC_MSG_RESULT([not found.
JACK will use System V shm API (shmget() and friends])


+ 4
- 4
example-clients/capture_client.c View File

@@ -127,7 +127,7 @@ disk_thread (void *arg)
unsigned int chn;
jack_nframes_t total_captured = 0;
int done = 0;
double *fbuf;
float *fbuf;

pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
pthread_mutex_lock (&buffer_lock);
@@ -147,11 +147,11 @@ disk_thread (void *arg)
while ((buf = get_write_buffer ()) != 0) {
pthread_mutex_unlock (&buffer_lock);

/* grrr ... libsndfile doesn't do float data yet, only double */
/* libsndfile requires interleaved data */
if (info->can_capture) {

fbuf = (double *) malloc (sizeof (double) * buf->nframes * info->channels);
fbuf = (float *) malloc (sizeof (float) * buf->nframes * info->channels);

for (chn = 0; chn < info->channels; chn++) {
for (i = 0; i < buf->nframes; i++) {
@@ -159,7 +159,7 @@ disk_thread (void *arg)
}
}
if (sf_writef_double (info->sf, fbuf, buf->nframes) != (sf_count_t)buf->nframes) {
if (sf_writef_float (info->sf, fbuf, buf->nframes) != (sf_count_t)buf->nframes) {
char errstr[256];
sf_error_str (0, errstr, sizeof (errstr) - 1);
fprintf (stderr, "cannot write data to sndfile (%s)\n", errstr);


+ 6
- 0
jackd/engine.c View File

@@ -55,7 +55,13 @@
* Time to wait for clients in msecs. Used when jackd is
* run in non-ASIO mode and without realtime priority enabled.
*/
#define DEBUGGING_SLOW_CLIENTS

#ifdef DEBUGGING_SLOW_CLIENTS
#define JACKD_SOFT_MODE_TIMEOUT 5000
#else
#define JACKD_SOFT_MODE_TIMEOUT 500
#endif

#define JACK_ERROR_WITH_SOCKETS 10000000



+ 36
- 10
libjack/shm.c View File

@@ -64,6 +64,12 @@ jack_initialize_shm ()
void *addr;
int id;

#ifdef USE_POSIX_SHM
fprintf (stderr, "JACK compiled with POSIX SHM support\n");
#else
fprintf (stderr, "JACK compiled with System V SHM support\n");
#endif

if (jack_shm_registry != NULL) {
return 0;
}
@@ -82,7 +88,7 @@ jack_initialize_shm ()
jack_shm_registry = (jack_shm_registry_entry_t *) addr;
jack_shm_id_cnt = 0;
jack_register_shm("/jack-shm-registry", addr, id);
jack_register_shm ("/jack-shm-registry", addr, id);

return 0;
}
@@ -264,23 +270,43 @@ jack_get_shm (const char *shm_name, size_t size, int perm, int mode, int prot, i
unlink (path);
return MAP_FAILED;
}
/* XXX need to figure out how to do this without causing the inode reallocation
the next time this function is called resulting in ftok() returning non-unique
keys.
*/

unlink (path);
/* unlink (path); */

fprintf (stderr, "key for %s is 0x%x\n", path, key);
shmflags = mode;

shmflags = 0;
if (perm & O_CREAT) {
shmflags |= IPC_CREAT;
}

// if (mode & O_TRUNC) {
// shmflags |= IPC_CREAT;
// }
if (perm & O_TRUNC) {
shmflags |= IPC_EXCL;
}

if ((*shmid = shmget (key, size, shmflags)) < 0) {
jack_error ("cannot create shm segment %s (%s)", shm_name, strerror (errno));
return MAP_FAILED;

if (errno == EEXIST && (shmflags & IPC_EXCL)) {

shmflags &= ~IPC_EXCL;

if ((*shmid = shmget (key, size, shmflags)) < 0) {
jack_error ("cannot get existing shm segment for %s (%s)",
shm_name, strerror (errno));
return MAP_FAILED;
}

} else {
jack_error ("cannot create shm segment %s (%s)", shm_name, strerror (errno));
return MAP_FAILED;
}
}

if ((addr = shmat (*shmid, 0, 0)) != 0) {
if ((addr = shmat (*shmid, 0, 0)) < 0) {
jack_error ("cannot attach shm segment %s (%s)", shm_name, strerror (errno));
return MAP_FAILED;
}


Loading…
Cancel
Save