Commit f3b05930 authored by sletz's avatar sletz
Browse files

Remove use of assert in JackFifo, JackMachSemaphore, and JackPosixSemaphore:...

Remove use of assert in JackFifo, JackMachSemaphore, and JackPosixSemaphore: print an error instead.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1837 0c269be4-1314-0410-8aa9-9f06e86f4224
parent c1cec90f
......@@ -20,6 +20,7 @@ Tim Blechmann
2008-02-03 Stephane Letz <letz@grame.fr>
* 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>
......
......@@ -24,7 +24,6 @@ This program is free software; you can redistribute it and/or modify
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
namespace Jack
{
......@@ -38,8 +37,12 @@ bool JackFifo::Signal()
{
bool res;
char c = 0;
assert(fFifo >= 0);
if (fFifo < 0) {
jack_error("JackFifo::Signal name = %s already desallocated!!", fName);
return false;
}
if (fFlush)
return true;
......@@ -53,7 +56,11 @@ bool JackFifo::SignalAll()
{
bool res;
char c = 0;
assert(fFifo >= 0);
if (fFifo < 0) {
jack_error("JackFifo::SignalAll name = %s already desallocated!!", fName);
return false;
}
if (fFlush)
return true;
......@@ -68,7 +75,11 @@ bool JackFifo::Wait()
{
bool res;
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)))) {
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()
{
int res;
assert(fSemaphore);
if (!fSemaphore) {
jack_error("JackPosixSemaphore::Signal name = %s already desallocated!!", fName);
return false;
}
if (fFlush)
return true;
......@@ -48,7 +52,11 @@ bool JackPosixSemaphore::Signal()
bool JackPosixSemaphore::SignalAll()
{
int res;
assert(fSemaphore);
if (!fSemaphore) {
jack_error("JackPosixSemaphore::SignalAll name = %s already desallocated!!", fName);
return false;
}
if (fFlush)
return true;
......@@ -63,7 +71,12 @@ bool JackPosixSemaphore::SignalAll()
bool JackPosixSemaphore::Wait()
{
int res;
assert(fSemaphore);
if (!fSemaphore) {
jack_error("JackPosixSemaphore::Wait name = %s already desallocated!!", fName);
return false;
}
if ((res = sem_wait(fSemaphore)) != 0) {
jack_error("JackPosixSemaphore::Wait name = %s err = %s", fName, strerror(errno));
}
......@@ -92,7 +105,11 @@ bool JackPosixSemaphore::TimedWait(long usec) // unusable semantic !!
int res;
struct timeval now;
timespec time;
assert(fSemaphore);
if (!fSemaphore) {
jack_error("JackPosixSemaphore::TimedWait name = %s already desallocated!!", fName);
return false;
}
gettimeofday(&now, 0);
time.tv_sec = now.tv_sec + usec / 1000000;
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 "JackError.h"
#include <stdio.h>
#include <assert.h>
namespace Jack
{
......@@ -35,7 +34,11 @@ void JackMachSemaphore::BuildName(const char* name, const char* server_name, cha
bool JackMachSemaphore::Signal()
{
kern_return_t res;
assert(fSemaphore > 0);
if (!fSemaphore) {
jack_error("JackMachSemaphore::Signal name = %s already desallocated!!", fName);
return false;
}
if (fFlush)
return true;
......@@ -49,7 +52,11 @@ bool JackMachSemaphore::Signal()
bool JackMachSemaphore::SignalAll()
{
kern_return_t res;
assert(fSemaphore > 0);
if (!fSemaphore) {
jack_error("JackMachSemaphore::SignalAll name = %s already desallocated!!", fName);
return false;
}
if (fFlush)
return true;
......@@ -63,7 +70,12 @@ bool JackMachSemaphore::SignalAll()
bool JackMachSemaphore::Wait()
{
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) {
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;
time.tv_sec = usec / 1000000;
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) {
jack_error("JackMachSemaphore::TimedWait name = %s usec = %ld err = %s", fName, usec, mach_error_string(res));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment