git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1837 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.70
@@ -20,6 +20,7 @@ Tim Blechmann | |||||
2008-02-03 Stephane Letz <letz@grame.fr> | 2008-02-03 Stephane Letz <letz@grame.fr> | ||||
* Reduce WaitGraphChange wait value. | * Reduce WaitGraphChange wait value. | ||||
* Remove use of assert in JackFifo, JackMachSemaphore, and JackPosixSemaphore: print an error instead. | |||||
2008-02-03 Stephane Letz <letz@grame.fr> | 2008-02-03 Stephane Letz <letz@grame.fr> | ||||
@@ -24,7 +24,6 @@ This program is free software; you can redistribute it and/or modify | |||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <assert.h> | |||||
namespace Jack | namespace Jack | ||||
{ | { | ||||
@@ -38,8 +37,12 @@ bool JackFifo::Signal() | |||||
{ | { | ||||
bool res; | bool res; | ||||
char c = 0; | char c = 0; | ||||
assert(fFifo >= 0); | |||||
if (fFifo < 0) { | |||||
jack_error("JackFifo::Signal name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFlush) | if (fFlush) | ||||
return true; | return true; | ||||
@@ -53,7 +56,11 @@ bool JackFifo::SignalAll() | |||||
{ | { | ||||
bool res; | bool res; | ||||
char c = 0; | char c = 0; | ||||
assert(fFifo >= 0); | |||||
if (fFifo < 0) { | |||||
jack_error("JackFifo::SignalAll name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFlush) | if (fFlush) | ||||
return true; | return true; | ||||
@@ -68,7 +75,11 @@ bool JackFifo::Wait() | |||||
{ | { | ||||
bool res; | bool res; | ||||
char c; | char c; | ||||
assert(fFifo >= 0); | |||||
if (fFifo < 0) { | |||||
jack_error("JackFifo::Wait name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if ((res = (read(fFifo, &c, sizeof(c)) != sizeof(c)))) { | if ((res = (read(fFifo, &c, sizeof(c)) != sizeof(c)))) { | ||||
jack_error("JackFifo::Wait name = %s err = %s", fName, strerror(errno)); | jack_error("JackFifo::Wait name = %s err = %s", fName, strerror(errno)); | ||||
@@ -34,7 +34,11 @@ void JackPosixSemaphore::BuildName(const char* name, const char* server_name, ch | |||||
bool JackPosixSemaphore::Signal() | bool JackPosixSemaphore::Signal() | ||||
{ | { | ||||
int res; | int res; | ||||
assert(fSemaphore); | |||||
if (!fSemaphore) { | |||||
jack_error("JackPosixSemaphore::Signal name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFlush) | if (fFlush) | ||||
return true; | return true; | ||||
@@ -48,7 +52,11 @@ bool JackPosixSemaphore::Signal() | |||||
bool JackPosixSemaphore::SignalAll() | bool JackPosixSemaphore::SignalAll() | ||||
{ | { | ||||
int res; | int res; | ||||
assert(fSemaphore); | |||||
if (!fSemaphore) { | |||||
jack_error("JackPosixSemaphore::SignalAll name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFlush) | if (fFlush) | ||||
return true; | return true; | ||||
@@ -63,7 +71,12 @@ bool JackPosixSemaphore::SignalAll() | |||||
bool JackPosixSemaphore::Wait() | bool JackPosixSemaphore::Wait() | ||||
{ | { | ||||
int res; | int res; | ||||
assert(fSemaphore); | |||||
if (!fSemaphore) { | |||||
jack_error("JackPosixSemaphore::Wait name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if ((res = sem_wait(fSemaphore)) != 0) { | if ((res = sem_wait(fSemaphore)) != 0) { | ||||
jack_error("JackPosixSemaphore::Wait name = %s err = %s", fName, strerror(errno)); | jack_error("JackPosixSemaphore::Wait name = %s err = %s", fName, strerror(errno)); | ||||
} | } | ||||
@@ -92,7 +105,11 @@ bool JackPosixSemaphore::TimedWait(long usec) // unusable semantic !! | |||||
int res; | int res; | ||||
struct timeval now; | struct timeval now; | ||||
timespec time; | timespec time; | ||||
assert(fSemaphore); | |||||
if (!fSemaphore) { | |||||
jack_error("JackPosixSemaphore::TimedWait name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
gettimeofday(&now, 0); | gettimeofday(&now, 0); | ||||
time.tv_sec = now.tv_sec + usec / 1000000; | time.tv_sec = now.tv_sec + usec / 1000000; | ||||
time.tv_nsec = (now.tv_usec + (usec % 1000000)) * 1000; | time.tv_nsec = (now.tv_usec + (usec % 1000000)) * 1000; | ||||
@@ -20,7 +20,6 @@ This program is free software; you can redistribute it and/or modify | |||||
#include "JackMachSemaphore.h" | #include "JackMachSemaphore.h" | ||||
#include "JackError.h" | #include "JackError.h" | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <assert.h> | |||||
namespace Jack | namespace Jack | ||||
{ | { | ||||
@@ -35,7 +34,11 @@ void JackMachSemaphore::BuildName(const char* name, const char* server_name, cha | |||||
bool JackMachSemaphore::Signal() | bool JackMachSemaphore::Signal() | ||||
{ | { | ||||
kern_return_t res; | kern_return_t res; | ||||
assert(fSemaphore > 0); | |||||
if (!fSemaphore) { | |||||
jack_error("JackMachSemaphore::Signal name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFlush) | if (fFlush) | ||||
return true; | return true; | ||||
@@ -49,7 +52,11 @@ bool JackMachSemaphore::Signal() | |||||
bool JackMachSemaphore::SignalAll() | bool JackMachSemaphore::SignalAll() | ||||
{ | { | ||||
kern_return_t res; | kern_return_t res; | ||||
assert(fSemaphore > 0); | |||||
if (!fSemaphore) { | |||||
jack_error("JackMachSemaphore::SignalAll name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if (fFlush) | if (fFlush) | ||||
return true; | return true; | ||||
@@ -63,7 +70,12 @@ bool JackMachSemaphore::SignalAll() | |||||
bool JackMachSemaphore::Wait() | bool JackMachSemaphore::Wait() | ||||
{ | { | ||||
kern_return_t res; | kern_return_t res; | ||||
assert(fSemaphore > 0); | |||||
if (!fSemaphore) { | |||||
jack_error("JackMachSemaphore::Wait name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if ((res = semaphore_wait(fSemaphore)) != KERN_SUCCESS) { | if ((res = semaphore_wait(fSemaphore)) != KERN_SUCCESS) { | ||||
jack_error("JackMachSemaphore::Wait name = %s err = %s", fName, mach_error_string(res)); | jack_error("JackMachSemaphore::Wait name = %s err = %s", fName, mach_error_string(res)); | ||||
} | } | ||||
@@ -76,7 +88,12 @@ bool JackMachSemaphore::TimedWait(long usec) | |||||
mach_timespec time; | mach_timespec time; | ||||
time.tv_sec = usec / 1000000; | time.tv_sec = usec / 1000000; | ||||
time.tv_nsec = (usec % 1000000) * 1000; | time.tv_nsec = (usec % 1000000) * 1000; | ||||
assert(fSemaphore > 0); | |||||
if (!fSemaphore) { | |||||
jack_error("JackMachSemaphore::TimedWait name = %s already desallocated!!", fName); | |||||
return false; | |||||
} | |||||
if ((res = semaphore_timedwait(fSemaphore, time)) != KERN_SUCCESS) { | if ((res = semaphore_timedwait(fSemaphore, time)) != KERN_SUCCESS) { | ||||
jack_error("JackMachSemaphore::TimedWait name = %s usec = %ld err = %s", fName, usec, mach_error_string(res)); | jack_error("JackMachSemaphore::TimedWait name = %s usec = %ld err = %s", fName, usec, mach_error_string(res)); | ||||
} | } | ||||