git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4663 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.9.9.5
@@ -26,6 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
#include "JackLibSampleRateResampler.h" | |||
#endif | |||
#include "JackTime.h" | |||
#include "JackError.h" | |||
#include <stdio.h> | |||
namespace Jack | |||
@@ -317,4 +318,75 @@ namespace Jack | |||
return res; | |||
} | |||
int JackAudioAdapterInterface::SetHostBufferSize(jack_nframes_t buffer_size) | |||
{ | |||
fHostBufferSize = buffer_size; | |||
if (fAdaptative) { | |||
AdaptRingBufferSize(); | |||
} | |||
return 0; | |||
} | |||
int JackAudioAdapterInterface::SetAdaptedBufferSize(jack_nframes_t buffer_size) | |||
{ | |||
fAdaptedBufferSize = buffer_size; | |||
if (fAdaptative) { | |||
AdaptRingBufferSize(); | |||
} | |||
return 0; | |||
} | |||
int JackAudioAdapterInterface::SetBufferSize(jack_nframes_t buffer_size) | |||
{ | |||
SetHostBufferSize(buffer_size); | |||
SetAdaptedBufferSize(buffer_size); | |||
return 0; | |||
} | |||
int JackAudioAdapterInterface::SetHostSampleRate(jack_nframes_t sample_rate) | |||
{ | |||
fHostSampleRate = sample_rate; | |||
fPIControler.Init(double(fHostSampleRate) / double(fAdaptedSampleRate)); | |||
return 0; | |||
} | |||
int JackAudioAdapterInterface::SetAdaptedSampleRate(jack_nframes_t sample_rate) | |||
{ | |||
fAdaptedSampleRate = sample_rate; | |||
fPIControler.Init(double(fHostSampleRate) / double(fAdaptedSampleRate)); | |||
return 0; | |||
} | |||
int JackAudioAdapterInterface::SetSampleRate(jack_nframes_t sample_rate) | |||
{ | |||
SetHostSampleRate(sample_rate); | |||
SetAdaptedSampleRate(sample_rate); | |||
return 0; | |||
} | |||
void JackAudioAdapterInterface::SetInputs(int inputs) | |||
{ | |||
jack_log("JackAudioAdapterInterface::SetInputs %d", inputs); | |||
fCaptureChannels = inputs; | |||
} | |||
void JackAudioAdapterInterface::SetOutputs(int outputs) | |||
{ | |||
jack_log("JackAudioAdapterInterface::SetOutputs %d", outputs); | |||
fPlaybackChannels = outputs; | |||
} | |||
int JackAudioAdapterInterface::GetInputs() | |||
{ | |||
//jack_log("JackAudioAdapterInterface::GetInputs %d", fCaptureChannels); | |||
return fCaptureChannels; | |||
} | |||
int JackAudioAdapterInterface::GetOutputs() | |||
{ | |||
//jack_log ("JackAudioAdapterInterface::GetOutputs %d", fPlaybackChannels); | |||
return fPlaybackChannels; | |||
} | |||
} // namespace |
@@ -154,75 +154,16 @@ namespace Jack | |||
return 0; | |||
} | |||
virtual int SetHostBufferSize(jack_nframes_t buffer_size) | |||
{ | |||
fHostBufferSize = buffer_size; | |||
if (fAdaptative) { | |||
AdaptRingBufferSize(); | |||
} | |||
return 0; | |||
} | |||
virtual int SetAdaptedBufferSize(jack_nframes_t buffer_size) | |||
{ | |||
fAdaptedBufferSize = buffer_size; | |||
if (fAdaptative) { | |||
AdaptRingBufferSize(); | |||
} | |||
return 0; | |||
} | |||
virtual int SetBufferSize(jack_nframes_t buffer_size) | |||
{ | |||
SetHostBufferSize(buffer_size); | |||
SetAdaptedBufferSize(buffer_size); | |||
return 0; | |||
} | |||
virtual int SetHostSampleRate(jack_nframes_t sample_rate) | |||
{ | |||
fHostSampleRate = sample_rate; | |||
fPIControler.Init(double(fHostSampleRate) / double(fAdaptedSampleRate)); | |||
return 0; | |||
} | |||
virtual int SetAdaptedSampleRate(jack_nframes_t sample_rate) | |||
{ | |||
fAdaptedSampleRate = sample_rate; | |||
fPIControler.Init(double(fHostSampleRate) / double(fAdaptedSampleRate)); | |||
return 0; | |||
} | |||
virtual int SetSampleRate(jack_nframes_t sample_rate) | |||
{ | |||
SetHostSampleRate(sample_rate); | |||
SetAdaptedSampleRate(sample_rate); | |||
return 0; | |||
} | |||
void SetInputs(int inputs) | |||
{ | |||
jack_log("JackAudioAdapterInterface::SetInputs %d", inputs); | |||
fCaptureChannels = inputs; | |||
} | |||
void SetOutputs(int outputs) | |||
{ | |||
jack_log("JackAudioAdapterInterface::SetOutputs %d", outputs); | |||
fPlaybackChannels = outputs; | |||
} | |||
int GetInputs() | |||
{ | |||
//jack_log("JackAudioAdapterInterface::GetInputs %d", fCaptureChannels); | |||
return fCaptureChannels; | |||
} | |||
int GetOutputs() | |||
{ | |||
//jack_log ("JackAudioAdapterInterface::GetOutputs %d", fPlaybackChannels); | |||
return fPlaybackChannels; | |||
} | |||
virtual int SetHostBufferSize(jack_nframes_t buffer_size); | |||
virtual int SetAdaptedBufferSize(jack_nframes_t buffer_size); | |||
virtual int SetBufferSize(jack_nframes_t buffer_size); | |||
virtual int SetHostSampleRate(jack_nframes_t sample_rate); | |||
virtual int SetAdaptedSampleRate(jack_nframes_t sample_rate); | |||
virtual int SetSampleRate(jack_nframes_t sample_rate); | |||
void SetInputs(int inputs); | |||
void SetOutputs(int outputs); | |||
int GetInputs(); | |||
int GetOutputs(); | |||
virtual int GetInputLatency(int port_index) { return 0; } | |||
virtual int GetOutputLatency(int port_index) { return 0; } | |||
@@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU Lesser General Public License for more details. | |||
You should have received a copy of the GNU Lesser General Public License | |||
along with this program; if not, write to the Free Software | |||
along with this program; if not, write to the Free Software | |||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
*/ | |||
@@ -36,12 +36,12 @@ class SERVER_EXPORT JackClientInterface | |||
{ | |||
public: | |||
JackClientInterface() | |||
{} | |||
virtual ~JackClientInterface() | |||
{} | |||
virtual int Close() = 0; | |||
virtual int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2) = 0; | |||
@@ -2,21 +2,21 @@ | |||
Copyright (C) 2001 Paul Davis | |||
Copyright (C) 2004-2008 Grame | |||
Copyright (C) 2008 Nedko Arnaudov | |||
This program is free software; you can redistribute it and/or modify | |||
it under the terms of the GNU Lesser General Public License as published by | |||
the Free Software Foundation; either version 2.1 of the License, or | |||
(at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU Lesser General Public License for more details. | |||
You should have received a copy of the GNU Lesser General Public License | |||
along with this program; if not, write to the Free Software | |||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
*/ | |||
#include <stdarg.h> | |||
@@ -29,7 +29,7 @@ using namespace Jack; | |||
static bool change_thread_log_function(jack_log_function_t log_function) | |||
{ | |||
return (jack_tls_get(JackGlobals::fKeyLogFunction) == NULL | |||
return (jack_tls_get(JackGlobals::fKeyLogFunction) == NULL | |||
&& jack_tls_set(JackGlobals::fKeyLogFunction, (void*)log_function)); | |||
} | |||
@@ -31,14 +31,8 @@ extern "C" | |||
{ | |||
#endif | |||
#define LOG_LEVEL_INFO 1 | |||
#define LOG_LEVEL_ERROR 2 | |||
SERVER_EXPORT void jack_error(const char *fmt, ...); | |||
SERVER_EXPORT void jack_info(const char *fmt, ...); | |||
// like jack_info() but only if verbose mode is enabled | |||
SERVER_EXPORT void jack_log(const char *fmt, ...); | |||
SERVER_EXPORT extern void (*jack_error_callback)(const char *desc); | |||
@@ -47,14 +41,16 @@ extern "C" | |||
SERVER_EXPORT extern void default_jack_error_callback(const char *desc); | |||
SERVER_EXPORT extern void default_jack_info_callback(const char *desc); | |||
SERVER_EXPORT extern void silent_jack_error_callback(const char *desc); | |||
SERVER_EXPORT extern void silent_jack_info_callback(const char *desc); | |||
SERVER_EXPORT void silent_jack_error_callback(const char *desc); | |||
SERVER_EXPORT void silent_jack_info_callback(const char *desc); | |||
typedef void (* jack_log_function_t)(int level, const char *message); | |||
SERVER_EXPORT int set_threaded_log_function(); | |||
void jack_log_function(int level, const char *message); | |||
#define LOG_LEVEL_INFO 1 | |||
#define LOG_LEVEL_ERROR 2 | |||
SERVER_EXPORT int set_threaded_log_function(); | |||
void jack_log_function(int level, const char *message); | |||
typedef void (* jack_log_function_t)(int level, const char *message); | |||
#ifdef __cplusplus | |||
} | |||
@@ -0,0 +1,34 @@ | |||
/* | |||
Copyright (C) 2008 Grame | |||
This program is free software; you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program; if not, write to the Free Software | |||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
*/ | |||
#include "JackException.h" | |||
#include "JackError.h" | |||
namespace Jack | |||
{ | |||
void JackException::PrintMessage() | |||
{ | |||
std::string str = what(); | |||
if (str != "") { | |||
jack_info(str.c_str()); | |||
} | |||
} | |||
} |
@@ -20,10 +20,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
#ifndef __JackException__ | |||
#define __JackException__ | |||
#include "JackCompilerDeps.h" | |||
#include <stdexcept> | |||
#include <iostream> | |||
#include <string> | |||
#include "JackError.h" | |||
namespace Jack | |||
{ | |||
@@ -55,14 +56,9 @@ class SERVER_EXPORT JackException : public std::runtime_error { | |||
return what(); | |||
} | |||
void PrintMessage() | |||
{ | |||
std::string str = what(); | |||
if (str != "") { | |||
jack_info(str.c_str()); | |||
} | |||
} | |||
}; | |||
void PrintMessage(); | |||
}; | |||
/*! | |||
\brief Exception thrown by JackEngine in temporary mode. | |||
@@ -18,6 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
*/ | |||
#include "JackLibSampleRateResampler.h" | |||
#include "JackError.h" | |||
namespace Jack | |||
{ | |||
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
#include "JackMidiBufferReadQueue.h" | |||
#include "JackMidiUtil.h" | |||
#include "JackError.h" | |||
using Jack::JackMidiBufferReadQueue; | |||
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
#include "JackMidiBufferWriteQueue.h" | |||
#include "JackMidiUtil.h" | |||
#include "JackError.h" | |||
using Jack::JackMidiBufferWriteQueue; | |||
@@ -19,9 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
#include <assert.h> | |||
#include <stdarg.h> | |||
#include "JackNetInterface.h" | |||
#include "JackError.h" | |||
#include "JackException.h" | |||
#include "JackAudioAdapterInterface.h" | |||
#ifdef __cplusplus | |||
@@ -122,6 +121,13 @@ extern "C" | |||
LIB_EXPORT int jack_adapter_push_and_pull(jack_adapter_t* adapter, float** input, float** output, unsigned int frames); | |||
LIB_EXPORT int jack_adapter_pull_and_push(jack_adapter_t* adapter, float** input, float** output, unsigned int frames); | |||
#define LOG_LEVEL_INFO 1 | |||
#define LOG_LEVEL_ERROR 2 | |||
LIB_EXPORT void jack_error(const char *fmt, ...); | |||
LIB_EXPORT void jack_info(const char *fmt, ...); | |||
LIB_EXPORT void jack_log(const char *fmt, ...); | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
@@ -16,6 +16,8 @@ along with this program; if not, write to the Free Software | |||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
*/ | |||
#include "JackCompilerDeps.h" | |||
#include "driver_interface.h" | |||
#include "JackNetDriver.h" | |||
#include "JackEngineControl.h" | |||
#include "JackLockedEngine.h" | |||
@@ -588,6 +590,7 @@ namespace Jack | |||
extern "C" | |||
{ | |||
#endif | |||
SERVER_EXPORT jack_driver_desc_t* driver_get_descriptor() | |||
{ | |||
jack_driver_desc_t * desc; | |||
@@ -18,6 +18,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
#include "JackNetInterface.h" | |||
#include "JackException.h" | |||
#include "JackError.h" | |||
#include <assert.h> | |||
using namespace std; | |||
@@ -608,6 +610,17 @@ namespace Jack | |||
uint JackNetSlaveInterface::fSlaveCounter = 0; | |||
void JackNetSlaveInterface::InitAPI() | |||
{ | |||
// open Socket API with the first slave | |||
if (fSlaveCounter++ == 0) { | |||
if (SocketAPIInit() < 0) { | |||
jack_error("Can't init Socket API, exiting..."); | |||
throw std::bad_alloc(); | |||
} | |||
} | |||
} | |||
bool JackNetSlaveInterface::Init() | |||
{ | |||
jack_log("JackNetSlaveInterface::Init()"); | |||
@@ -206,16 +206,7 @@ namespace Jack | |||
void FatalRecvError(); | |||
void FatalSendError(); | |||
void InitAPI() | |||
{ | |||
// open Socket API with the first slave | |||
if (fSlaveCounter++ == 0) { | |||
if (SocketAPIInit() < 0) { | |||
jack_error("Can't init Socket API, exiting..."); | |||
throw std::bad_alloc(); | |||
} | |||
} | |||
} | |||
void InitAPI(); | |||
public: | |||
@@ -753,6 +753,7 @@ JackNetOneDriver::render_jack_ports_to_payload (int bitdepth, JSList *playback_p | |||
extern "C" | |||
{ | |||
#endif | |||
SERVER_EXPORT jack_driver_desc_t* driver_get_descriptor () | |||
{ | |||
jack_driver_desc_t * desc; | |||
@@ -20,7 +20,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
#ifndef __JackNetSocket__ | |||
#define __JackNetSocket__ | |||
#include "JackError.h" | |||
#include "JackCompilerDeps.h" | |||
#include <cstdlib> | |||
#include <cstdio> | |||
#include <iostream> | |||
@@ -29,7 +30,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
namespace Jack | |||
{ | |||
//get host name********************************* | |||
SERVER_EXPORT int GetHostName ( char * name, int size ); | |||
SERVER_EXPORT int GetHostName(char * name, int size); | |||
//net errors *********************************** | |||
enum _net_error | |||
@@ -18,6 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
*/ | |||
#include "JackNetTool.h" | |||
#include "JackError.h" | |||
#ifdef __APPLE__ | |||
@@ -18,6 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
*/ | |||
#include "JackResampler.h" | |||
#include "JackError.h" | |||
#include <stdio.h> | |||
namespace Jack | |||
@@ -22,7 +22,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
#include "ringbuffer.h" | |||
#include "types.h" | |||
#include "JackError.h" | |||
namespace Jack | |||
{ | |||
@@ -294,5 +294,123 @@ void BuildClientPath(char* path_to_so, int path_len, const char* so_name) | |||
#endif | |||
template <class T> | |||
JackGnuPlotMonitor<T>::JackGnuPlotMonitor(uint32_t measure_cnt, uint32_t measure_points, std::string name) | |||
{ | |||
jack_log ( "JackGnuPlotMonitor::JackGnuPlotMonitor %u measure points - %u measures", measure_points, measure_cnt ); | |||
fMeasureCnt = measure_cnt; | |||
fMeasurePoints = measure_points; | |||
fTablePos = 0; | |||
fName = name; | |||
fCurrentMeasure = new T[fMeasurePoints]; | |||
fMeasureTable = new T*[fMeasureCnt]; | |||
for ( uint32_t cnt = 0; cnt < fMeasureCnt; cnt++ ) | |||
{ | |||
fMeasureTable[cnt] = new T[fMeasurePoints]; | |||
fill_n ( fMeasureTable[cnt], fMeasurePoints, 0 ); | |||
} | |||
} | |||
template <class T> | |||
JackGnuPlotMonitor<T>::~JackGnuPlotMonitor() | |||
{ | |||
jack_log ( "JackGnuPlotMonitor::~JackGnuPlotMonitor" ); | |||
for ( uint32_t cnt = 0; cnt < fMeasureCnt; cnt++ ) | |||
delete[] fMeasureTable[cnt]; | |||
delete[] fMeasureTable; | |||
delete[] fCurrentMeasure; | |||
} | |||
template <class T> | |||
T JackGnuPlotMonitor<T>::AddNew(T measure_point) | |||
{ | |||
fMeasureId = 0; | |||
return fCurrentMeasure[fMeasureId++] = measure_point; | |||
} | |||
template <class T> | |||
uint32_t JackGnuPlotMonitor<T>::New() | |||
{ | |||
return fMeasureId = 0; | |||
} | |||
template <class T> | |||
T JackGnuPlotMonitor<T>::Add(T measure_point) | |||
{ | |||
return fCurrentMeasure[fMeasureId++] = measure_point; | |||
} | |||
template <class T> | |||
uint32_t JackGnuPlotMonitor<T>::AddLast(T measure_point) | |||
{ | |||
fCurrentMeasure[fMeasureId] = measure_point; | |||
fMeasureId = 0; | |||
return Write(); | |||
} | |||
template <class T> | |||
uint32_t JackGnuPlotMonitor<T>::Write() | |||
{ | |||
for ( uint32_t point = 0; point < fMeasurePoints; point++ ) | |||
fMeasureTable[fTablePos][point] = fCurrentMeasure[point]; | |||
if ( ++fTablePos == fMeasureCnt ) | |||
fTablePos = 0; | |||
return fTablePos; | |||
} | |||
template <class T> | |||
int JackGnuPlotMonitor<T>::Save(std::string name) | |||
{ | |||
std::string filename = ( name.empty() ) ? fName : name; | |||
filename += ".log"; | |||
jack_log ( "JackGnuPlotMonitor::Save filename %s", filename.c_str() ); | |||
std::ofstream file ( filename.c_str() ); | |||
for ( uint32_t cnt = 0; cnt < fMeasureCnt; cnt++ ) | |||
{ | |||
for ( uint32_t point = 0; point < fMeasurePoints; point++ ) | |||
file << fMeasureTable[cnt][point] << " \t"; | |||
file << std::endl; | |||
} | |||
file.close(); | |||
return 0; | |||
} | |||
template <class T> | |||
int JackGnuPlotMonitor<T>::SetPlotFile(std::string* options_list, uint32_t options_number, | |||
std::string* field_names, uint32_t field_number, | |||
std::string name) | |||
{ | |||
std::string title = ( name.empty() ) ? fName : name; | |||
std::string plot_filename = title + ".plt"; | |||
std::string data_filename = title + ".log"; | |||
std::ofstream file ( plot_filename.c_str() ); | |||
file << "set multiplot" << std::endl; | |||
file << "set grid" << std::endl; | |||
file << "set title \"" << title << "\"" << std::endl; | |||
for ( uint32_t i = 0; i < options_number; i++ ) | |||
file << options_list[i] << std::endl; | |||
file << "plot "; | |||
for ( uint32_t row = 1; row <= field_number; row++ ) | |||
{ | |||
file << "\"" << data_filename << "\" using " << row << " title \"" << field_names[row-1] << "\" with lines"; | |||
file << ( ( row < field_number ) ? ", " : "\n" ); | |||
} | |||
jack_log ( "JackGnuPlotMonitor::SetPlotFile - Save GnuPlot file to '%s'", plot_filename.c_str() ); | |||
file.close(); | |||
return 0; | |||
} | |||
} // end of namespace | |||
@@ -36,10 +36,7 @@ | |||
#endif | |||
#include "jslist.h" | |||
#include "driver_interface.h" | |||
#include "JackCompilerDeps.h" | |||
#include "JackError.h" | |||
#include "JackException.h" | |||
#include <string> | |||
#include <algorithm> | |||
@@ -112,114 +109,26 @@ namespace Jack | |||
std::string fName; | |||
public: | |||
JackGnuPlotMonitor ( uint32_t measure_cnt = 512, uint32_t measure_points = 5, std::string name = std::string ( "default" ) ) | |||
{ | |||
jack_log ( "JackGnuPlotMonitor::JackGnuPlotMonitor %u measure points - %u measures", measure_points, measure_cnt ); | |||
fMeasureCnt = measure_cnt; | |||
fMeasurePoints = measure_points; | |||
fTablePos = 0; | |||
fName = name; | |||
fCurrentMeasure = new T[fMeasurePoints]; | |||
fMeasureTable = new T*[fMeasureCnt]; | |||
for ( uint32_t cnt = 0; cnt < fMeasureCnt; cnt++ ) | |||
{ | |||
fMeasureTable[cnt] = new T[fMeasurePoints]; | |||
fill_n ( fMeasureTable[cnt], fMeasurePoints, 0 ); | |||
} | |||
} | |||
~JackGnuPlotMonitor() | |||
{ | |||
jack_log ( "JackGnuPlotMonitor::~JackGnuPlotMonitor" ); | |||
for ( uint32_t cnt = 0; cnt < fMeasureCnt; cnt++ ) | |||
delete[] fMeasureTable[cnt]; | |||
delete[] fMeasureTable; | |||
delete[] fCurrentMeasure; | |||
} | |||
T AddNew ( T measure_point ) | |||
{ | |||
fMeasureId = 0; | |||
return fCurrentMeasure[fMeasureId++] = measure_point; | |||
} | |||
uint32_t New() | |||
{ | |||
return fMeasureId = 0; | |||
} | |||
T Add ( T measure_point ) | |||
{ | |||
return fCurrentMeasure[fMeasureId++] = measure_point; | |||
} | |||
uint32_t AddLast ( T measure_point ) | |||
{ | |||
fCurrentMeasure[fMeasureId] = measure_point; | |||
fMeasureId = 0; | |||
return Write(); | |||
} | |||
uint32_t Write() | |||
{ | |||
for ( uint32_t point = 0; point < fMeasurePoints; point++ ) | |||
fMeasureTable[fTablePos][point] = fCurrentMeasure[point]; | |||
if ( ++fTablePos == fMeasureCnt ) | |||
fTablePos = 0; | |||
return fTablePos; | |||
} | |||
JackGnuPlotMonitor(uint32_t measure_cnt = 512, uint32_t measure_points = 5, std::string name = std::string("default")); | |||
int Save ( std::string name = std::string ( "" ) ) | |||
{ | |||
std::string filename = ( name.empty() ) ? fName : name; | |||
filename += ".log"; | |||
~JackGnuPlotMonitor(); | |||
jack_log ( "JackGnuPlotMonitor::Save filename %s", filename.c_str() ); | |||
T AddNew(T measure_point); | |||
std::ofstream file ( filename.c_str() ); | |||
uint32_t New(); | |||
for ( uint32_t cnt = 0; cnt < fMeasureCnt; cnt++ ) | |||
{ | |||
for ( uint32_t point = 0; point < fMeasurePoints; point++ ) | |||
file << fMeasureTable[cnt][point] << " \t"; | |||
file << std::endl; | |||
} | |||
file.close(); | |||
return 0; | |||
} | |||
T Add(T measure_point); | |||
int SetPlotFile ( std::string* options_list = NULL, uint32_t options_number = 0, | |||
std::string* field_names = NULL, uint32_t field_number = 0, | |||
std::string name = std::string ( "" ) ) | |||
{ | |||
std::string title = ( name.empty() ) ? fName : name; | |||
std::string plot_filename = title + ".plt"; | |||
std::string data_filename = title + ".log"; | |||
uint32_t AddLast(T measure_point); | |||
std::ofstream file ( plot_filename.c_str() ); | |||
uint32_t Write(); | |||
file << "set multiplot" << std::endl; | |||
file << "set grid" << std::endl; | |||
file << "set title \"" << title << "\"" << std::endl; | |||
int Save(std::string name = std::string("")); | |||
for ( uint32_t i = 0; i < options_number; i++ ) | |||
file << options_list[i] << std::endl; | |||
file << "plot "; | |||
for ( uint32_t row = 1; row <= field_number; row++ ) | |||
{ | |||
file << "\"" << data_filename << "\" using " << row << " title \"" << field_names[row-1] << "\" with lines"; | |||
file << ( ( row < field_number ) ? ", " : "\n" ); | |||
} | |||
jack_log ( "JackGnuPlotMonitor::SetPlotFile - Save GnuPlot file to '%s'", plot_filename.c_str() ); | |||
file.close(); | |||
return 0; | |||
} | |||
int SetPlotFile(std::string* options_list = NULL, uint32_t options_number = 0, | |||
std::string* field_names = NULL, uint32_t field_number = 0, | |||
std::string name = std::string("")); | |||
}; | |||
void BuildClientPath(char* path_to_so, int path_len, const char* so_name); | |||
@@ -185,6 +185,9 @@ jackctl_get_parameter( | |||
return NULL; | |||
} | |||
// Prototype to be found in libjackserver | |||
extern "C" void silent_jack_error_callback(const char *desc); | |||
int main(int argc, char** argv) | |||
{ | |||
jackctl_server_t * server_ctl; | |||
@@ -46,6 +46,7 @@ def build(bld): | |||
'JackConnectionManager.cpp', | |||
'ringbuffer.c', | |||
'JackError.cpp', | |||
'JackException.cpp', | |||
'JackFrameTimer.cpp', | |||
'JackGraphManager.cpp', | |||
'JackPort.cpp', | |||
@@ -72,8 +73,8 @@ def build(bld): | |||
common_libsources += [ | |||
'../posix/JackPosixThread.cpp', | |||
'../posix/JackPosixSemaphore.cpp', | |||
'../posix/JackFifo.cpp', | |||
'../posix/JackProcessSync.cpp', | |||
'../posix/JackPosixMutex.cpp', | |||
'../posix/JackSocket.cpp', | |||
'../linux/JackLinuxTime.c', | |||
] | |||
@@ -86,6 +87,7 @@ def build(bld): | |||
'../posix/JackPosixThread.cpp', | |||
'../posix/JackFifo.cpp', | |||
'../posix/JackProcessSync.cpp', | |||
'../posix/JackPosixMutex.cpp', | |||
'../posix/JackSocket.cpp', | |||
'../solaris/JackSolarisTime.c', | |||
] | |||
@@ -197,6 +199,7 @@ def build(bld): | |||
'JackNetAPI.cpp', | |||
'JackNetInterface.cpp', | |||
'JackNetTool.cpp', | |||
'JackException.cpp', | |||
'JackAudioAdapterInterface.cpp', | |||
'JackLibSampleRateResampler.cpp', | |||
'JackResampler.cpp', | |||
@@ -23,6 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
#include "JackConstants.h" | |||
#if __GNUC__ | |||
#define PRE_PACKED_STRUCTURE | |||
#ifndef POST_PACKED_STRUCTURE | |||
@@ -159,6 +159,13 @@ | |||
4B32257F10A3195900838A8E /* netjack_packet.c in Sources */ = {isa = PBXBuildFile; fileRef = 4B3224EC10A315C400838A8E /* netjack_packet.c */; }; | |||
4B32258010A3195A00838A8E /* netjack_packet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3224ED10A315C400838A8E /* netjack_packet.h */; }; | |||
4B32258110A3195B00838A8E /* netsource.c in Sources */ = {isa = PBXBuildFile; fileRef = 4B32256310A318E300838A8E /* netsource.c */; }; | |||
4B327BA714B4B50400976483 /* JackPosixMutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B327BA614B4B50400976483 /* JackPosixMutex.cpp */; }; | |||
4B327BA814B4B50400976483 /* JackPosixMutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B327BA614B4B50400976483 /* JackPosixMutex.cpp */; }; | |||
4B327BA914B4B50400976483 /* JackPosixMutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B327BA614B4B50400976483 /* JackPosixMutex.cpp */; }; | |||
4B327BAA14B4B50400976483 /* JackPosixMutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B327BA614B4B50400976483 /* JackPosixMutex.cpp */; }; | |||
4B327BAB14B4B50400976483 /* JackPosixMutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B327BA614B4B50400976483 /* JackPosixMutex.cpp */; }; | |||
4B327BAC14B4B50400976483 /* JackPosixMutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B327BA614B4B50400976483 /* JackPosixMutex.cpp */; }; | |||
4B327BD614B4B6E700976483 /* JackException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B67AB8C14B4B03800B4AA9A /* JackException.cpp */; }; | |||
4B35C41E0D4731D1000DE7AE /* Jackdmp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BF8D2250834F06A00C94B91 /* Jackdmp.cpp */; }; | |||
4B35C42A0D4731D1000DE7AE /* JackError.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF8D1770834EE4800C94B91 /* JackError.h */; }; | |||
4B35C42B0D4731D1000DE7AE /* JackTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF8D1830834EE5800C94B91 /* JackTime.h */; }; | |||
@@ -493,6 +500,9 @@ | |||
4B60CE490AAABA31004956AA /* connect.c in Sources */ = {isa = PBXBuildFile; fileRef = 4B60CE480AAABA31004956AA /* connect.c */; }; | |||
4B60CE4A0AAABA31004956AA /* connect.c in Sources */ = {isa = PBXBuildFile; fileRef = 4B60CE480AAABA31004956AA /* connect.c */; }; | |||
4B6654FC127C350100753A79 /* server_control.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B6654FB127C350100753A79 /* server_control.cpp */; }; | |||
4B67AB8D14B4B03800B4AA9A /* JackException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B67AB8C14B4B03800B4AA9A /* JackException.cpp */; }; | |||
4B67AB8E14B4B03800B4AA9A /* JackException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B67AB8C14B4B03800B4AA9A /* JackException.cpp */; }; | |||
4B67AB8F14B4B03800B4AA9A /* JackException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B67AB8C14B4B03800B4AA9A /* JackException.cpp */; }; | |||
4B699BAA097D421600A18468 /* Jackdmp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BF8D2250834F06A00C94B91 /* Jackdmp.cpp */; }; | |||
4B699C03097D421600A18468 /* JackError.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF8D1770834EE4800C94B91 /* JackError.h */; }; | |||
4B699C04097D421600A18468 /* JackTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF8D1830834EE5800C94B91 /* JackTime.h */; }; | |||
@@ -1620,6 +1630,7 @@ | |||
4B32256110A3187800838A8E /* jack_netsource */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jack_netsource; sourceTree = BUILT_PRODUCTS_DIR; }; | |||
4B32256310A318E300838A8E /* netsource.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = netsource.c; path = "../example-clients/netsource.c"; sourceTree = SOURCE_ROOT; }; | |||
4B32257B10A3190C00838A8E /* jack_netsource */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jack_netsource; sourceTree = BUILT_PRODUCTS_DIR; }; | |||
4B327BA614B4B50400976483 /* JackPosixMutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JackPosixMutex.cpp; path = ../posix/JackPosixMutex.cpp; sourceTree = SOURCE_ROOT; }; | |||
4B349826133A6AF500D130AB /* JackALSARawMidiDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JackALSARawMidiDriver.cpp; path = ../linux/alsarawmidi/JackALSARawMidiDriver.cpp; sourceTree = SOURCE_ROOT; }; | |||
4B349827133A6AF500D130AB /* JackALSARawMidiDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JackALSARawMidiDriver.h; path = ../linux/alsarawmidi/JackALSARawMidiDriver.h; sourceTree = SOURCE_ROOT; }; | |||
4B349828133A6AF500D130AB /* JackALSARawMidiInputPort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JackALSARawMidiInputPort.cpp; path = ../linux/alsarawmidi/JackALSARawMidiInputPort.cpp; sourceTree = SOURCE_ROOT; }; | |||
@@ -1777,6 +1788,7 @@ | |||
4B6654F7127C34AE00753A79 /* jack_server_control */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jack_server_control; sourceTree = BUILT_PRODUCTS_DIR; }; | |||
4B6654FB127C350100753A79 /* server_control.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = server_control.cpp; path = "../example-clients/server_control.cpp"; sourceTree = SOURCE_ROOT; }; | |||
4B66A8580934964500A89560 /* JackConstants.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = JackConstants.h; path = ../common/JackConstants.h; sourceTree = SOURCE_ROOT; }; | |||
4B67AB8C14B4B03800B4AA9A /* JackException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JackException.cpp; path = ../common/JackException.cpp; sourceTree = SOURCE_ROOT; }; | |||
4B699BB1097D421600A18468 /* jackdmp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jackdmp; sourceTree = BUILT_PRODUCTS_DIR; }; | |||
4B699C47097D421600A18468 /* Jackmp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Jackmp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | |||
4B699CAC097D421600A18468 /* Jackservermp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Jackservermp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | |||
@@ -3091,6 +3103,7 @@ | |||
isa = PBXGroup; | |||
children = ( | |||
4B6C73780CC60A6D001AFFD4 /* jack */, | |||
4B67AB8C14B4B03800B4AA9A /* JackException.cpp */, | |||
4BE4CC000CDA153400CCF5BB /* JackTools.h */, | |||
4BE4CBFF0CDA153400CCF5BB /* JackTools.cpp */, | |||
4B4E9AF80E5F1090000A3278 /* JackControlAPI.cpp */, | |||
@@ -3141,6 +3154,7 @@ | |||
4BA3874007947A46008D8992 /* Synchro */ = { | |||
isa = PBXGroup; | |||
children = ( | |||
4B327BA614B4B50400976483 /* JackPosixMutex.cpp */, | |||
4BECB2F30F4451C10091B70A /* JackProcessSync.cpp */, | |||
4BECB2F40F4451C10091B70A /* JackProcessSync.h */, | |||
4BC3B6B70E703BAA0066E42F /* JackPosixSemaphore.cpp */, | |||
@@ -7057,6 +7071,7 @@ | |||
4BECB2F90F4451C10091B70A /* JackProcessSync.cpp in Sources */, | |||
4B8A38F1117B827E00664E07 /* JackSocketClientChannel.cpp in Sources */, | |||
4B8A38F6117B82AB00664E07 /* JackSocket.cpp in Sources */, | |||
4B327BAB14B4B50400976483 /* JackPosixMutex.cpp in Sources */, | |||
); | |||
runOnlyForDeploymentPostprocessing = 0; | |||
}; | |||
@@ -7125,6 +7140,8 @@ | |||
4B97B6791344B50F00794F57 /* JackMidiUtil.cpp in Sources */, | |||
4B97B67B1344B51D00794F57 /* JackMidiWriteQueue.cpp in Sources */, | |||
4B21795113E2EEA60095B3E5 /* JackTimedDriver.cpp in Sources */, | |||
4B67AB8E14B4B03800B4AA9A /* JackException.cpp in Sources */, | |||
4B327BA814B4B50400976483 /* JackPosixMutex.cpp in Sources */, | |||
); | |||
runOnlyForDeploymentPostprocessing = 0; | |||
}; | |||
@@ -7436,6 +7453,7 @@ | |||
4B47ACCD10B5890100469C67 /* JackPosixThread.cpp in Sources */, | |||
4B47ACCE10B5890100469C67 /* JackMachTime.c in Sources */, | |||
4B47ACCF10B5890100469C67 /* JackProcessSync.cpp in Sources */, | |||
4B327BAC14B4B50400976483 /* JackPosixMutex.cpp in Sources */, | |||
); | |||
runOnlyForDeploymentPostprocessing = 0; | |||
}; | |||
@@ -7519,6 +7537,7 @@ | |||
4BECB2F70F4451C10091B70A /* JackProcessSync.cpp in Sources */, | |||
4B2209EC12F6BC2100E5DC26 /* JackSocket.cpp in Sources */, | |||
4B2209EE12F6BC2300E5DC26 /* JackSocketClientChannel.cpp in Sources */, | |||
4B327BAA14B4B50400976483 /* JackPosixMutex.cpp in Sources */, | |||
); | |||
runOnlyForDeploymentPostprocessing = 0; | |||
}; | |||
@@ -7587,6 +7606,8 @@ | |||
4B97B65C1344B45D00794F57 /* JackMidiUtil.cpp in Sources */, | |||
4B97B65E1344B46B00794F57 /* JackMidiWriteQueue.cpp in Sources */, | |||
4B21794F13E2EEA60095B3E5 /* JackTimedDriver.cpp in Sources */, | |||
4B67AB8D14B4B03800B4AA9A /* JackException.cpp in Sources */, | |||
4B327BA714B4B50400976483 /* JackPosixMutex.cpp in Sources */, | |||
); | |||
runOnlyForDeploymentPostprocessing = 0; | |||
}; | |||
@@ -7717,6 +7738,7 @@ | |||
4B8693251371DD7E00D2D11B /* JackResampler.cpp in Sources */, | |||
4B86932C1371DD9B00D2D11B /* ringbuffer.c in Sources */, | |||
4B86934D1371DEBA00D2D11B /* JackLibSampleRateResampler.cpp in Sources */, | |||
4B327BD614B4B6E700976483 /* JackException.cpp in Sources */, | |||
); | |||
runOnlyForDeploymentPostprocessing = 0; | |||
}; | |||
@@ -7810,6 +7832,8 @@ | |||
4B6FE16613DDAD8F00B4B943 /* JackMidiBufferReadQueue.cpp in Sources */, | |||
4B6FE16813DDAD9F00B4B943 /* JackMidiAsyncWaitQueue.cpp in Sources */, | |||
4B21795313E2EEA60095B3E5 /* JackTimedDriver.cpp in Sources */, | |||
4B67AB8F14B4B03800B4AA9A /* JackException.cpp in Sources */, | |||
4B327BA914B4B50400976483 /* JackPosixMutex.cpp in Sources */, | |||
); | |||
runOnlyForDeploymentPostprocessing = 0; | |||
}; | |||
@@ -9008,6 +9032,7 @@ | |||
MACH_O_TYPE = mh_dylib; | |||
OTHER_CFLAGS = "-DJACK_32_64"; | |||
OTHER_CPLUSPLUSFLAGS = ( | |||
"-DSERVER_SIDE", | |||
"-DJACK_32_64", | |||
"-DHAVE_CELT", | |||
"-DHAVE_CELT_API_0_7", | |||
@@ -17403,7 +17428,11 @@ | |||
LIBRARY_STYLE = DYNAMIC; | |||
MACH_O_TYPE = mh_dylib; | |||
OTHER_CFLAGS = ""; | |||
OTHER_CPLUSPLUSFLAGS = "-DMACH_RPC_MACH_SEMA"; | |||
OTHER_CPLUSPLUSFLAGS = ( | |||
"-DSERVER_SIDE", | |||
"-DMACH_RPC_MACH_SEMA", | |||
"-DJACK_32_64", | |||
); | |||
OTHER_LDFLAGS = ( | |||
"-framework", | |||
Jackservermp, | |||
@@ -17450,7 +17479,7 @@ | |||
LIBRARY_STYLE = DYNAMIC; | |||
MACH_O_TYPE = mh_dylib; | |||
MACOSX_DEPLOYMENT_TARGET = 10.4; | |||
OTHER_CFLAGS = "-DJACK_32_64"; | |||
OTHER_CFLAGS = ""; | |||
OTHER_CPLUSPLUSFLAGS = ( | |||
"-DSERVER_SIDE", | |||
"-DMACH_RPC_MACH_SEMA", | |||
@@ -17549,7 +17578,9 @@ | |||
OTHER_CPLUSPLUSFLAGS = ( | |||
"-DHAVE_CELT_API_0_7", | |||
"-DHAVE_CELT", | |||
"-DSERVER_SIDE", | |||
"-DMACH_RPC_MACH_SEMA", | |||
"-DJACK_32_64", | |||
); | |||
OTHER_LDFLAGS = ( | |||
"-framework", | |||
@@ -17593,7 +17624,7 @@ | |||
LIBRARY_STYLE = DYNAMIC; | |||
MACH_O_TYPE = mh_dylib; | |||
MACOSX_DEPLOYMENT_TARGET = 10.4; | |||
OTHER_CFLAGS = "-DJACK_32_64"; | |||
OTHER_CFLAGS = ""; | |||
OTHER_CPLUSPLUSFLAGS = ( | |||
"-DHAVE_CELT_API_0_7", | |||
"-DHAVE_CELT", | |||
@@ -26,7 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
#include "JackDriverLoader.h" | |||
#include "JackGlobals.h" | |||
#include "JackTools.h" | |||
#include "JackCompilerDeps.h" | |||
#include "JackLockedEngine.h" | |||
#include <sstream> | |||
@@ -18,13 +18,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
*/ | |||
#include <stdexcept> | |||
#include <mach/mach_time.h> | |||
#include "JackCompilerDeps.h" | |||
#include "JackCoreMidiDriver.h" | |||
#include "JackCoreMidiUtil.h" | |||
#include "JackEngineControl.h" | |||
#include "driver_interface.h" | |||
#include <stdexcept> | |||
#include <mach/mach_time.h> | |||
using Jack::JackCoreMidiDriver; | |||
@@ -22,6 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
#include "JackCoreMidiInputPort.h" | |||
#include "JackMidiUtil.h" | |||
#include "JackError.h" | |||
using Jack::JackCoreMidiInputPort; | |||
@@ -26,6 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
#include "JackCoreMidiOutputPort.h" | |||
#include "JackMidiUtil.h" | |||
#include "JackTime.h" | |||
#include "JackError.h" | |||
using Jack::JackCoreMidiOutputPort; | |||
@@ -18,6 +18,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
*/ | |||
#include "JackNetUnixSocket.h" | |||
#include "JackError.h" | |||
#include <unistd.h> | |||
#include <fcntl.h> | |||
@@ -0,0 +1,106 @@ | |||
/* | |||
Copyright (C) 2006 Grame | |||
This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Lesser General Public | |||
License as published by the Free Software Foundation; either | |||
version 2.1 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Lesser General Public License for more details. | |||
You should have received a copy of the GNU Lesser General Public | |||
License along with this library; if not, write to the Free Software | |||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France | |||
grame@grame.fr | |||
*/ | |||
#include "JackPosixMutex.h" | |||
#include "JackError.h" | |||
namespace Jack | |||
{ | |||
bool JackBasePosixMutex::Lock() | |||
{ | |||
pthread_t current_thread = pthread_self(); | |||
if (!pthread_equal(current_thread, fOwner)) { | |||
int res = pthread_mutex_lock(&fMutex); | |||
if (res == 0) { | |||
fOwner = current_thread; | |||
return true; | |||
} else { | |||
jack_error("JackBasePosixMutex::Lock res = %d", res); | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackBasePosixMutex::Lock mutex already locked by thread = %d", current_thread); | |||
return false; | |||
} | |||
} | |||
bool JackBasePosixMutex::Trylock() | |||
{ | |||
pthread_t current_thread = pthread_self(); | |||
if (!pthread_equal(current_thread, fOwner)) { | |||
int res = pthread_mutex_trylock(&fMutex); | |||
if (res == 0) { | |||
fOwner = current_thread; | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackBasePosixMutex::Trylock mutex already locked by thread = %d", current_thread); | |||
return false; | |||
} | |||
} | |||
bool JackBasePosixMutex::Unlock() | |||
{ | |||
if (pthread_equal(pthread_self(), fOwner)) { | |||
fOwner = 0; | |||
int res = pthread_mutex_unlock(&fMutex); | |||
if (res == 0) { | |||
return true; | |||
} else { | |||
jack_error("JackBasePosixMutex::Unlock res = %d", res); | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackBasePosixMutex::Unlock mutex not locked by thread = %d owner %d", pthread_self(), fOwner); | |||
return false; | |||
} | |||
} | |||
bool JackPosixMutex::Lock() | |||
{ | |||
int res = pthread_mutex_lock(&fMutex); | |||
if (res != 0) { | |||
jack_log("JackPosixMutex::Lock res = %d", res); | |||
} | |||
return (res == 0); | |||
} | |||
bool JackPosixMutex::Trylock() | |||
{ | |||
return (pthread_mutex_trylock(&fMutex) == 0); | |||
} | |||
bool JackPosixMutex::Unlock() | |||
{ | |||
int res = pthread_mutex_unlock(&fMutex); | |||
if (res != 0) { | |||
jack_log("JackPosixMutex::Unlock res = %d", res); | |||
} | |||
return (res == 0); | |||
} | |||
} // namespace |
@@ -22,7 +22,6 @@ | |||
#ifndef __JackPosixMutex__ | |||
#define __JackPosixMutex__ | |||
#include "JackError.h" | |||
#include "JackException.h" | |||
#include <pthread.h> | |||
#include <stdio.h> | |||
@@ -55,59 +54,9 @@ class JackBasePosixMutex | |||
pthread_mutex_destroy(&fMutex); | |||
} | |||
bool Lock() | |||
{ | |||
pthread_t current_thread = pthread_self(); | |||
if (!pthread_equal(current_thread, fOwner)) { | |||
int res = pthread_mutex_lock(&fMutex); | |||
if (res == 0) { | |||
fOwner = current_thread; | |||
return true; | |||
} else { | |||
jack_error("JackBasePosixMutex::Lock res = %d", res); | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackBasePosixMutex::Lock mutex already locked by thread = %d", current_thread); | |||
return false; | |||
} | |||
} | |||
bool Trylock() | |||
{ | |||
pthread_t current_thread = pthread_self(); | |||
if (!pthread_equal(current_thread, fOwner)) { | |||
int res = pthread_mutex_trylock(&fMutex); | |||
if (res == 0) { | |||
fOwner = current_thread; | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackBasePosixMutex::Trylock mutex already locked by thread = %d", current_thread); | |||
return false; | |||
} | |||
} | |||
bool Unlock() | |||
{ | |||
if (pthread_equal(pthread_self(), fOwner)) { | |||
fOwner = 0; | |||
int res = pthread_mutex_unlock(&fMutex); | |||
if (res == 0) { | |||
return true; | |||
} else { | |||
jack_error("JackBasePosixMutex::Unlock res = %d", res); | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackBasePosixMutex::Unlock mutex not locked by thread = %d owner %d", pthread_self(), fOwner); | |||
return false; | |||
} | |||
} | |||
bool Lock(); | |||
bool Trylock(); | |||
bool Unlock(); | |||
}; | |||
@@ -138,29 +87,9 @@ class JackPosixMutex | |||
pthread_mutex_destroy(&fMutex); | |||
} | |||
bool Lock() | |||
{ | |||
int res = pthread_mutex_lock(&fMutex); | |||
if (res != 0) { | |||
jack_log("JackPosixMutex::Lock res = %d", res); | |||
} | |||
return (res == 0); | |||
} | |||
bool Trylock() | |||
{ | |||
return (pthread_mutex_trylock(&fMutex) == 0); | |||
} | |||
bool Unlock() | |||
{ | |||
int res = pthread_mutex_unlock(&fMutex); | |||
if (res != 0) { | |||
jack_log("JackPosixMutex::Unlock res = %d", res); | |||
} | |||
return (res == 0); | |||
} | |||
bool Lock(); | |||
bool Trylock(); | |||
bool Unlock(); | |||
}; | |||
@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
#include "JackRequest.h" | |||
#include "JackClient.h" | |||
#include "JackGlobals.h" | |||
#include "JackError.h" | |||
namespace Jack | |||
{ | |||
@@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
#include "JackSocket.h" | |||
#include "JackPlatformPlug.h" | |||
#include "JackRequest.h" | |||
#include "JackError.h" | |||
namespace Jack | |||
{ | |||
@@ -0,0 +1,98 @@ | |||
/* | |||
Copyright (C) 2004-2008 Grame | |||
This program is free software; you can redistribute it and/or modify | |||
it under the terms of the GNU Lesser General Public License as published by | |||
the Free Software Foundation; either version 2.1 of the License, or | |||
(at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU Lesser General Public License for more details. | |||
You should have received a copy of the GNU Lesser General Public License | |||
along with this program; if not, write to the Free Software | |||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
*/ | |||
#include "JackWinMutex.h" | |||
#include "JackError.h" | |||
namespace Jack | |||
{ | |||
class JackBaseWinMutex | |||
{ | |||
bool JackBaseWinMutex::Lock() | |||
{ | |||
if (fOwner != GetCurrentThreadId()) { | |||
DWORD res = WaitForSingleObject(fMutex, INFINITE); | |||
if (res == WAIT_OBJECT_0) { | |||
fOwner = GetCurrentThreadId(); | |||
return true; | |||
} else { | |||
jack_log("JackWinMutex::Lock res = %d", res); | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackWinMutex::Lock mutex already locked by thread = %d", GetCurrentThreadId()); | |||
return false; | |||
} | |||
} | |||
bool JackBaseWinMutex::Trylock() | |||
{ | |||
if (fOwner != GetCurrentThreadId()) { | |||
DWORD res = WaitForSingleObject(fMutex, 0); | |||
if (res == WAIT_OBJECT_0) { | |||
fOwner = GetCurrentThreadId(); | |||
return true; | |||
} else { | |||
jack_log("JackWinMutex::Trylock res = %d", res); | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackWinMutex::Trylock mutex already locked by thread = %d", GetCurrentThreadId()); | |||
return false; | |||
} | |||
} | |||
bool JackBaseWinMutex::Unlock() | |||
{ | |||
if (fOwner == GetCurrentThreadId()) { | |||
fOwner = 0; | |||
int res = ReleaseMutex(fMutex); | |||
if (res != 0) { | |||
return true; | |||
} else { | |||
jack_log("JackWinMutex::Unlock res = %d", res); | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackWinMutex::Unlock mutex not locked by thread = %d", GetCurrentThreadId()); | |||
return false; | |||
} | |||
} | |||
bool JackWinMutex::Lock() | |||
{ | |||
return (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, INFINITE)); | |||
} | |||
bool JackWinMutex::Trylock() | |||
{ | |||
return (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, 0)); | |||
} | |||
bool JackWinMutex::Unlock() | |||
{ | |||
return(ReleaseMutex(fMutex) != 0); | |||
} | |||
} // namespace | |||
@@ -20,13 +20,14 @@ | |||
#ifndef __JackWinMutex__ | |||
#define __JackWinMutex__ | |||
#include "JackError.h" | |||
#include "JackException.h" | |||
#include <windows.h> | |||
namespace Jack | |||
{ | |||
/*! | |||
\brief Mutex abstraction. | |||
*/ | |||
@@ -52,57 +53,10 @@ class JackBaseWinMutex | |||
CloseHandle(fMutex); | |||
} | |||
bool Lock() | |||
{ | |||
if (fOwner != GetCurrentThreadId()) { | |||
DWORD res = WaitForSingleObject(fMutex, INFINITE); | |||
if (res == WAIT_OBJECT_0) { | |||
fOwner = GetCurrentThreadId(); | |||
return true; | |||
} else { | |||
jack_log("JackWinMutex::Lock res = %d", res); | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackWinMutex::Lock mutex already locked by thread = %d", GetCurrentThreadId()); | |||
return false; | |||
} | |||
} | |||
bool Trylock() | |||
{ | |||
if (fOwner != GetCurrentThreadId()) { | |||
DWORD res = WaitForSingleObject(fMutex, 0); | |||
if (res == WAIT_OBJECT_0) { | |||
fOwner = GetCurrentThreadId(); | |||
return true; | |||
} else { | |||
jack_log("JackWinMutex::Trylock res = %d", res); | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackWinMutex::Trylock mutex already locked by thread = %d", GetCurrentThreadId()); | |||
return false; | |||
} | |||
} | |||
bool Unlock() | |||
{ | |||
if (fOwner == GetCurrentThreadId()) { | |||
fOwner = 0; | |||
int res = ReleaseMutex(fMutex); | |||
if (res != 0) { | |||
return true; | |||
} else { | |||
jack_log("JackWinMutex::Unlock res = %d", res); | |||
return false; | |||
} | |||
} else { | |||
jack_error("JackWinMutex::Unlock mutex not locked by thread = %d", GetCurrentThreadId()); | |||
return false; | |||
} | |||
} | |||
bool Lock(); | |||
bool Trylock(); | |||
bool Unlock(); | |||
}; | |||
class JackWinMutex | |||
@@ -125,20 +79,9 @@ class JackWinMutex | |||
CloseHandle(fMutex); | |||
} | |||
bool Lock() | |||
{ | |||
return (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, INFINITE)); | |||
} | |||
bool Trylock() | |||
{ | |||
return (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, 0)); | |||
} | |||
bool Unlock() | |||
{ | |||
return(ReleaseMutex(fMutex) != 0); | |||
} | |||
bool Lock(); | |||
bool Trylock(); | |||
bool Unlock(); | |||
}; | |||
@@ -146,3 +89,4 @@ class JackWinMutex | |||
} // namespace | |||
#endif | |||
@@ -309,6 +309,7 @@ | |||
<Option target="Win32 Profiling" /> | |||
</Unit> | |||
<Unit filename="..\common\JackError.cpp" /> | |||
<Unit filename="..\common\JackException.cpp" /> | |||
<Unit filename="..\common\JackFrameTimer.cpp" /> | |||
<Unit filename="..\common\JackGlobals.cpp" /> | |||
<Unit filename="..\common\JackGraphManager.cpp" /> | |||
@@ -335,6 +336,7 @@ | |||
<Unit filename="JackWinSemaphore.cpp" /> | |||
<Unit filename="JackWinServerLaunch.cpp" /> | |||
<Unit filename="JackWinThread.cpp" /> | |||
<Unit filename="JackWinMutex.cpp" /> | |||
<Unit filename="JackWinTime.c"> | |||
<Option compilerVar="CC" /> | |||
</Unit> | |||
@@ -232,6 +232,7 @@ | |||
<Unit filename="..\common\JackNetInterface.cpp" /> | |||
<Unit filename="..\common\JackNetTool.cpp" /> | |||
<Unit filename="..\common\JackResampler.cpp" /> | |||
<Unit filename="..\common\JackException.cpp" /> | |||
<Unit filename="..\common\ringbuffer.c"> | |||
<Option compilerVar="CC" /> | |||
</Unit> | |||
@@ -259,6 +259,7 @@ | |||
<Option target="Win32 Profiling" /> | |||
</Unit> | |||
<Unit filename="..\common\JackError.cpp" /> | |||
<Unit filename="..\common\JackException.cpp" /> | |||
<Unit filename="..\common\JackExternalClient.cpp" /> | |||
<Unit filename="..\common\JackFrameTimer.cpp" /> | |||
<Unit filename="..\common\JackFreewheelDriver.cpp" /> | |||
@@ -306,6 +307,7 @@ | |||
<Unit filename="JackWinProcessSync.cpp" /> | |||
<Unit filename="JackWinSemaphore.cpp" /> | |||
<Unit filename="JackWinThread.cpp" /> | |||
<Unit filename="JackWinMutex.cpp" /> | |||
<Unit filename="JackWinTime.c"> | |||
<Option compilerVar="CC" /> | |||
</Unit> | |||