diff --git a/AUTHORS.rst b/AUTHORS.rst index 6f386b03..7266fd00 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -12,6 +12,7 @@ Andrew Kelley Andrzej Szombierski Andy Wingo Anthony Van Groningen +Arnout Diels Arnaud Rebillout Arnold Krille Bernhard M. Wiedemann @@ -62,6 +63,7 @@ Marc-Olivier Barre Mario Lang Markus Seeber Matt Flax +Matthias Geier Maxim Grishin Melanie Thielker Michael Voigt @@ -96,5 +98,6 @@ Tom Szilagyi Torben Hohn Valentin David Valerio Pilo +Viktor Wilhelmsson Yasuhiro Fujii Youri Westerman diff --git a/common/JackAC3Encoder.cpp b/common/JackAC3Encoder.cpp index d535c086..3f609f16 100644 --- a/common/JackAC3Encoder.cpp +++ b/common/JackAC3Encoder.cpp @@ -29,93 +29,89 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. namespace Jack { - + #ifndef __ppc__ JackAC3Encoder::JackAC3Encoder(const JackAC3EncoderParams& params) { - aften_set_defaults(&fAftenContext); - - fAftenContext.channels = params.channels; + aften_set_defaults(&fAftenContext); + + fAftenContext.channels = params.channels; fAftenContext.samplerate = params.sample_rate; fAftenContext.params.bitrate = params.bitrate; int acmod = A52_ACMOD_MONO; int lfe = params.lfe; - + switch (params.channels) { - - case 1: acmod = A52_ACMOD_MONO; break; - case 2: acmod = A52_ACMOD_STEREO; break; - case 3: acmod = A52_ACMOD_3_0; break; - case 4: acmod = A52_ACMOD_2_2; break; - case 5: acmod = A52_ACMOD_3_2; break; - break; - - default: - break; + case 1: acmod = A52_ACMOD_MONO; break; + case 2: acmod = A52_ACMOD_STEREO; break; + case 3: acmod = A52_ACMOD_3_0; break; + case 4: acmod = A52_ACMOD_2_2; break; + case 5: acmod = A52_ACMOD_3_2; break; + default: + break; } if (lfe) { fAftenContext.channels += 1; } - + fAftenContext.acmod = acmod; fAftenContext.lfe = lfe; fAftenContext.sample_format = A52_SAMPLE_FMT_FLT; fAftenContext.verbose = 1; fAftenContext.system.n_threads = 1; - - // create interleaved framebuffer for MAX_AC3_CHANNELS + + // create interleaved framebuffer for MAX_AC3_CHANNELS fSampleBuffer = new float[MAX_AC3_CHANNELS * A52_SAMPLES_PER_FRAME]; - - // create AC3 buffer + + // create AC3 buffer fAC3Buffer = new unsigned char[A52_MAX_CODED_FRAME_SIZE]; memset(fAC3Buffer, 0, A52_MAX_CODED_FRAME_SIZE); - - fZeroBuffer = new unsigned char[SPDIF_FRAME_SIZE]; + + fZeroBuffer = new unsigned char[SPDIF_FRAME_SIZE]; memset(fZeroBuffer, 0, SPDIF_FRAME_SIZE); - - fRingBuffer = jack_ringbuffer_create(32768); + + fRingBuffer = jack_ringbuffer_create(32768); - fOutSizeByte = 0; - fFramePos = 0; - - fSampleRate = 0; - fByteRate = 0; + fOutSizeByte = 0; + fFramePos = 0; + + fSampleRate = 0; + fByteRate = 0; } bool JackAC3Encoder::Init(jack_nframes_t sample_rate) { - fSampleRate = sample_rate; + fSampleRate = sample_rate; fByteRate = fSampleRate * sizeof(short) * 2; - return (aften_encode_init(&fAftenContext) == 0); + return (aften_encode_init(&fAftenContext) == 0); } - + JackAC3Encoder::~JackAC3Encoder() { - aften_encode_close(&fAftenContext); - - delete [] fSampleBuffer; - delete [] fAC3Buffer; - delete [] fZeroBuffer; - - if (fRingBuffer) { - jack_ringbuffer_free(fRingBuffer); - } + aften_encode_close(&fAftenContext); + + delete [] fSampleBuffer; + delete [] fAC3Buffer; + delete [] fZeroBuffer; + + if (fRingBuffer) { + jack_ringbuffer_free(fRingBuffer); + } } void JackAC3Encoder::Process(float** inputs_buffer, float** outputs_buffer, int nframes) { - // fill and process frame buffers as appropriate + // fill and process frame buffers as appropriate jack_nframes_t frames_left = A52_SAMPLES_PER_FRAME - fFramePos; jack_nframes_t offset = 0; while (offset < nframes) { if ((nframes - offset) >= frames_left) { - // copy only frames_left more data jack_nframes_t pos = fFramePos * fAftenContext.channels; for (jack_nframes_t spos = offset; spos < offset + frames_left; ++spos) { @@ -124,33 +120,39 @@ void JackAC3Encoder::Process(float** inputs_buffer, float** outputs_buffer, int } pos += fAftenContext.channels; } - + // use interleaved version - int res = aften_encode_frame(&fAftenContext, fAC3Buffer + SPDIF_HEADER_SIZE, fSampleBuffer); - if (res < 0) { - jack_error("aften_encode_frame error !!"); - return; - } - - fOutSizeByte = res; - +#ifdef HAVE_AFTEN_NEW_API + // note additional parameter 'nframes' + // added in commit e1cbb66628de8aa496a75092d8d694234c67aa95 git://aften.git.sourceforge.net/gitroot/aften/aften + int res = aften_encode_frame(&fAftenContext, fAC3Buffer + SPDIF_HEADER_SIZE, fSampleBuffer, nframes); +#else + // released version 0.0.8 hasn't the 'count' parameter + int res = aften_encode_frame(&fAftenContext, fAC3Buffer + SPDIF_HEADER_SIZE, fSampleBuffer); +#endif + + if (res < 0) { + jack_error("aften_encode_frame error !!"); + return; + } + + fOutSizeByte = res; + FillSpdifHeader(fAC3Buffer, fOutSizeByte + SPDIF_HEADER_SIZE); - + // push AC3 output to SPDIF ring buffer float calc_ac3byterate = (fOutSizeByte * fSampleRate / (float) A52_SAMPLES_PER_FRAME); jack_nframes_t silencebytes = (jack_nframes_t) (fOutSizeByte * (fByteRate / calc_ac3byterate)) - fOutSizeByte - SPDIF_HEADER_SIZE; - - jack_ringbuffer_write(fRingBuffer, (const char *)fAC3Buffer, fOutSizeByte + SPDIF_HEADER_SIZE); - // write the proper remainder of zero padding (inefficient, should be memsetting) - jack_ringbuffer_write(fRingBuffer, (const char *)fZeroBuffer, silencebytes); - + jack_ringbuffer_write(fRingBuffer, (const char *)fAC3Buffer, fOutSizeByte + SPDIF_HEADER_SIZE); + + // write the proper remainder of zero padding (inefficient, should be memsetting) + jack_ringbuffer_write(fRingBuffer, (const char *)fZeroBuffer, silencebytes); + offset += frames_left; frames_left = A52_SAMPLES_PER_FRAME; fFramePos = 0; - } else { - // copy incoming data into frame buffers without processing jack_nframes_t pos = fFramePos * fAftenContext.channels; for (jack_nframes_t spos = offset; spos < nframes; ++spos) { @@ -172,7 +174,7 @@ void JackAC3Encoder::FillSpdifHeader(unsigned char* buf, int outsize) { // todo, use outsize and not assume the fixed frame size? int ac3outsize = outsize - SPDIF_HEADER_SIZE; - + buf[0] = 0x72; buf[1] = 0xf8; /* spdif syncword */ buf[2] = 0x1f; buf[3] = 0x4e; /* .............. */ buf[4] = 0x01; /* AC3 data */ @@ -189,24 +191,24 @@ int JackAC3Encoder::Output2Driver(float** outputs, jack_nframes_t nframes) { int wrotebytes = 0; jack_nframes_t nframes_left = nframes; - + if (jack_ringbuffer_read_space(fRingBuffer) == 0) { - + // just write silence memset(outputs[0], 0, nframes * sizeof(jack_default_audio_sample_t)); memset(outputs[1], 0, nframes * sizeof(jack_default_audio_sample_t)); - + } else { - - jack_ringbuffer_data_t rb_data[2]; + + jack_ringbuffer_data_t rb_data[2]; jack_ringbuffer_get_read_vector(fRingBuffer, rb_data); - + while (nframes_left > 0 && rb_data[0].len > 4) { - + jack_nframes_t towrite_frames = (rb_data[0].len) / (sizeof(short) * 2); towrite_frames = min(towrite_frames, nframes_left); - + // write and deinterleave into the two channels #if 1 sample_move_dS_s16(outputs[0] + (nframes - nframes_left), (char *) rb_data[0].buf, towrite_frames, sizeof(short) * 2); @@ -217,7 +219,7 @@ int JackAC3Encoder::Output2Driver(float** outputs, jack_nframes_t nframes) #endif wrotebytes = towrite_frames * sizeof(short) * 2; nframes_left -= towrite_frames; - + jack_ringbuffer_read_advance(fRingBuffer, wrotebytes); jack_ringbuffer_get_read_vector(fRingBuffer, rb_data); } @@ -254,64 +256,64 @@ void JackAC3Encoder::sample_move_dS_s16_24ph(jack_default_audio_sample_t* dst, c void JackAC3Encoder::GetChannelName(const char* name, const char* alias, char* portname, int channel) { - /* + /* * 2 channels = L, R * 3 channels = L, C, R * 4 channels = L, R, LS, RS * 5 ch = L, C, R, LS, RS * 6 ch = L, C, R, LS, RS, LFE */ - - const char* AC3_name = ""; - - switch (channel) { - - case 0: - AC3_name = "AC3_1_Left"; - break; - - case 1: - if (fAftenContext.channels == 2 || fAftenContext.channels == 4) { - AC3_name = "AC3_2_Right"; - } else { - AC3_name = "AC3_2_Center"; - } - break; - - case 2: - if (fAftenContext.channels == 4) { - AC3_name = "AC3_3_LeftSurround"; - } else { - AC3_name = "AC3_3_Right"; - } - break; - - case 3: - if (fAftenContext.channels == 4) { - AC3_name = "AC3_4_RightSurround"; - } else { - AC3_name = "AC3_4_LeftSurround"; - } - break; - - case 4: - if (fAftenContext.channels > 4) { - AC3_name = "AC3_5_RightSurround"; + + const char* AC3_name = ""; + + switch (channel) { + + case 0: + AC3_name = "AC3_1_Left"; + break; + + case 1: + if (fAftenContext.channels == 2 || fAftenContext.channels == 4) { + AC3_name = "AC3_2_Right"; + } else { + AC3_name = "AC3_2_Center"; } - break; - - default: - break; - } - - // Last channel - if (fAftenContext.lfe && (channel == fAftenContext.channels - 1)) { - sprintf(portname, "%s:%s:AC3_%d_LFE", name, alias, fAftenContext.channels); - } else { - sprintf(portname, "%s:%s:%s", name, alias, AC3_name); - } + break; + + case 2: + if (fAftenContext.channels == 4) { + AC3_name = "AC3_3_LeftSurround"; + } else { + AC3_name = "AC3_3_Right"; + } + break; + + case 3: + if (fAftenContext.channels == 4) { + AC3_name = "AC3_4_RightSurround"; + } else { + AC3_name = "AC3_4_LeftSurround"; + } + break; + + case 4: + if (fAftenContext.channels > 4) { + AC3_name = "AC3_5_RightSurround"; + } + break; + + default: + break; + } + + // Last channel + if (fAftenContext.lfe && (channel == fAftenContext.channels - 1)) { + sprintf(portname, "%s:%s:AC3_%d_LFE", name, alias, fAftenContext.channels); + } else { + sprintf(portname, "%s:%s:%s", name, alias, AC3_name); + } } - + #endif -} // end of namespace \ No newline at end of file +} // end of namespace diff --git a/common/JackAC3Encoder.h b/common/JackAC3Encoder.h index 45d629c4..d8975863 100644 --- a/common/JackAC3Encoder.h +++ b/common/JackAC3Encoder.h @@ -53,43 +53,43 @@ class JackAC3Encoder private: - AftenContext fAftenContext; - jack_ringbuffer_t* fRingBuffer; + AftenContext fAftenContext; + jack_ringbuffer_t* fRingBuffer; - float* fSampleBuffer; - unsigned char* fAC3Buffer; - unsigned char* fZeroBuffer; + float* fSampleBuffer; + unsigned char* fAC3Buffer; + unsigned char* fZeroBuffer; - int fOutSizeByte; + int fOutSizeByte; - jack_nframes_t fFramePos; - jack_nframes_t fSampleRate; - jack_nframes_t fByteRate; + jack_nframes_t fFramePos; + jack_nframes_t fSampleRate; + jack_nframes_t fByteRate; - void FillSpdifHeader(unsigned char* buf, int outsize); - int Output2Driver(float** outputs, jack_nframes_t nframes); + void FillSpdifHeader(unsigned char* buf, int outsize); + int Output2Driver(float** outputs, jack_nframes_t nframes); - void sample_move_dS_s16(jack_default_audio_sample_t* dst, char *src, jack_nframes_t nsamples, unsigned long src_skip); - void sample_move_dS_s16_24ph(jack_default_audio_sample_t* dst, char *src, jack_nframes_t nsamples, unsigned long src_skip); + void sample_move_dS_s16(jack_default_audio_sample_t* dst, char *src, jack_nframes_t nsamples, unsigned long src_skip); + void sample_move_dS_s16_24ph(jack_default_audio_sample_t* dst, char *src, jack_nframes_t nsamples, unsigned long src_skip); public: #ifdef __ppc__ - JackAC3Encoder(const JackAC3EncoderParams& params) {} - virtual ~JackAC3Encoder() {} + JackAC3Encoder(const JackAC3EncoderParams& params) {} + virtual ~JackAC3Encoder() {} - bool Init(jack_nframes_t sample_rate) {return false;} + bool Init(jack_nframes_t sample_rate) {return false;} - void Process(float** inputs, float** outputs, int nframes) {} - void GetChannelName(const char* name, const char* alias, char* portname, int channel) {} + void Process(float** inputs, float** outputs, int nframes) {} + void GetChannelName(const char* name, const char* alias, char* portname, int channel) {} #else - JackAC3Encoder(const JackAC3EncoderParams& params); - virtual ~JackAC3Encoder(); + JackAC3Encoder(const JackAC3EncoderParams& params); + virtual ~JackAC3Encoder(); - bool Init(jack_nframes_t sample_rate); + bool Init(jack_nframes_t sample_rate); - void Process(float** inputs, float** outputs, int nframes); - void GetChannelName(const char* name, const char* alias, char* portname, int channel); + void Process(float** inputs, float** outputs, int nframes); + void GetChannelName(const char* name, const char* alias, char* portname, int channel); #endif }; diff --git a/common/JackAPI.cpp b/common/JackAPI.cpp index b3d7c343..60142df9 100644 --- a/common/JackAPI.cpp +++ b/common/JackAPI.cpp @@ -1982,8 +1982,8 @@ LIB_EXPORT char *jack_client_get_uuid(jack_client_t* ext_client) jack_error("jack_client_get_uuid called with a NULL client"); return NULL; } else { - char retval[16]; - snprintf(retval, sizeof(retval), "%d", client->GetClientControl()->fSessionID); + char retval[JACK_UUID_STRING_SIZE]; + jack_uuid_unparse(client->GetClientControl()->fSessionID, retval); return strdup(retval); } } diff --git a/common/JackChannel.h b/common/JackChannel.h index c4188b3c..56687043 100644 --- a/common/JackChannel.h +++ b/common/JackChannel.h @@ -99,7 +99,7 @@ class JackClientChannelInterface {} // Open the Server/Client connection - virtual int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) + virtual int Open(const char* server_name, const char* name, jack_uuid_t uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) { return 0; } @@ -123,9 +123,9 @@ class JackClientChannelInterface return -1; } - virtual void ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status, int* result, int open) + virtual void ClientCheck(const char* name, jack_uuid_t uuid, char* name_res, int protocol, int options, int* status, int* result, int open) {} - virtual void ClientOpen(const char* name, int pid, int uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result) + virtual void ClientOpen(const char* name, int pid, jack_uuid_t uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result) {} virtual void ClientOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, int* result) {} @@ -169,7 +169,7 @@ class JackClientChannelInterface {} virtual void InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result) {} - virtual void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int uuid, int* result) + virtual void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, jack_uuid_t uuid, int* result) {} virtual void InternalClientUnload(int refnum, int int_ref, int* status, int* result) {} diff --git a/common/JackClient.cpp b/common/JackClient.cpp index 5befdfbd..5fcab377 100644 --- a/common/JackClient.cpp +++ b/common/JackClient.cpp @@ -304,12 +304,12 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, jack_log("JackClient::kSessionCallback"); if (fSession) { jack_session_event_t* event = (jack_session_event_t*)malloc( sizeof(jack_session_event_t)); - char uuid_buf[JACK_UUID_SIZE]; + char uuid_buf[JACK_UUID_STRING_SIZE]; event->type = (jack_session_event_type_t)value1; event->session_dir = strdup(message); event->command_line = NULL; event->flags = (jack_session_flags_t)0; - snprintf(uuid_buf, sizeof(uuid_buf), "%d", GetClientControl()->fSessionID); + jack_uuid_unparse(GetClientControl()->fSessionID, uuid_buf); event->client_uuid = strdup(uuid_buf); fSessionReply = kPendingSessionReply; // Session callback may change fSessionReply by directly using jack_session_reply @@ -1306,7 +1306,7 @@ int JackClient::SessionReply(jack_session_event_t* ev) char* JackClient::GetUUIDForClientName(const char* client_name) { - char uuid_res[JACK_UUID_SIZE]; + char uuid_res[JACK_UUID_STRING_SIZE]; int result = -1; fChannel->GetUUIDForClientName(GetClientControl()->fRefNum, client_name, uuid_res, &result); return (result) ? NULL : strdup(uuid_res); diff --git a/common/JackClient.h b/common/JackClient.h index 67cd611d..3270933a 100644 --- a/common/JackClient.h +++ b/common/JackClient.h @@ -131,7 +131,7 @@ class SERVER_EXPORT JackClient : public JackClientInterface, public JackRunnable JackClient(JackSynchro* table); virtual ~JackClient(); - virtual int Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status) = 0; + virtual int Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status) = 0; virtual int Close(); virtual JackGraphManager* GetGraphManager() const = 0; diff --git a/common/JackClientControl.h b/common/JackClientControl.h index 23b536af..f84ed648 100644 --- a/common/JackClientControl.h +++ b/common/JackClientControl.h @@ -46,26 +46,26 @@ struct JackClientControl : public JackShmMemAble int fPID; bool fActive; - int fSessionID; + jack_uuid_t fSessionID; char fSessionCommand[JACK_SESSION_COMMAND_SIZE]; jack_session_flags_t fSessionFlags; - JackClientControl(const char* name, int pid, int refnum, int uuid) + JackClientControl(const char* name, int pid, int refnum, jack_uuid_t uuid) { Init(name, pid, refnum, uuid); } - JackClientControl(const char* name) + JackClientControl(const char* name, jack_uuid_t uuid) { - Init(name, 0, -1, -1); + Init(name, 0, -1, uuid); } JackClientControl() { - Init("", 0, -1, -1); + Init("", 0, -1, JACK_UUID_EMPTY_INITIALIZER); } - void Init(const char* name, int pid, int refnum, int uuid) + void Init(const char* name, int pid, int refnum, jack_uuid_t uuid) { strcpy(fName, name); for (int i = 0; i < kMaxNotification; i++) { diff --git a/common/JackCompilerDeps.h b/common/JackCompilerDeps.h index 04f87c19..fe3aad88 100644 --- a/common/JackCompilerDeps.h +++ b/common/JackCompilerDeps.h @@ -1,19 +1,19 @@ /* -Copyright (C) 2004-2005 Grame + Copyright (C) 2004-2005 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 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 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. + 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. */ diff --git a/common/JackConstants.h b/common/JackConstants.h index 0cf34045..f46c7efd 100644 --- a/common/JackConstants.h +++ b/common/JackConstants.h @@ -2,18 +2,18 @@ Copyright (C) 2004-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 + 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 General Public License for more details. - - You should have received a copy of the GNU General Public License + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -36,6 +36,7 @@ #define JACK_MESSAGE_SIZE 256 #define JACK_UUID_SIZE 36 // to match jack1 and uuid.h #define JACK_UUID_STRING_SIZE (JACK_UUID_SIZE+1) /* includes trailing null */ +#define JACK_UUID_EMPTY_INITIALIZER 0 #define JACK_SESSION_COMMAND_SIZE 256 #define SYNC_MAX_NAME_SIZE 256 diff --git a/common/JackControlAPI.cpp b/common/JackControlAPI.cpp index 4d597e7d..11abb4e6 100644 --- a/common/JackControlAPI.cpp +++ b/common/JackControlAPI.cpp @@ -219,6 +219,7 @@ jackctl_free_driver_parameters( while (driver_ptr->parameters) { next_node_ptr = driver_ptr->parameters->next; + jack_constraint_free(((jackctl_parameter *)driver_ptr->parameters->data)->constraint_ptr); free(driver_ptr->parameters->data); free(driver_ptr->parameters); driver_ptr->parameters = next_node_ptr; @@ -526,6 +527,7 @@ jackctl_server_free_parameters( while (server_ptr->parameters) { next_node_ptr = server_ptr->parameters->next; + jack_constraint_free(((jackctl_parameter *)server_ptr->parameters->data)->constraint_ptr); free(server_ptr->parameters->data); free(server_ptr->parameters); server_ptr->parameters = next_node_ptr; @@ -1070,7 +1072,7 @@ jackctl_server_open( return true; - } catch (std::exception e) { + } catch (std::exception&) { jack_error("jackctl_server_open error..."); jackctl_destroy_param_list(paramlist); } @@ -1433,5 +1435,3 @@ SERVER_EXPORT bool jackctl_server_switch_master(jackctl_server * server_ptr, jac return false; } } - - diff --git a/common/JackDebugClient.cpp b/common/JackDebugClient.cpp index 7c1f539a..a7d11f9e 100644 --- a/common/JackDebugClient.cpp +++ b/common/JackDebugClient.cpp @@ -79,7 +79,7 @@ JackDebugClient::~JackDebugClient() delete fClient; } -int JackDebugClient::Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status) +int JackDebugClient::Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status) { int res = fClient->Open(server_name, name, uuid, options, status); char provstr[256]; diff --git a/common/JackDebugClient.h b/common/JackDebugClient.h index efe71dee..9e82f1d4 100644 --- a/common/JackDebugClient.h +++ b/common/JackDebugClient.h @@ -68,7 +68,7 @@ class JackDebugClient : public JackClient JackDebugClient(JackClient* fTheClient); virtual ~JackDebugClient(); - virtual int Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status); + virtual int Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status); int Close(); virtual JackGraphManager* GetGraphManager() const; diff --git a/common/JackDriver.cpp b/common/JackDriver.cpp index aae7ee7b..8700b1c9 100644 --- a/common/JackDriver.cpp +++ b/common/JackDriver.cpp @@ -40,8 +40,9 @@ namespace Jack JackDriver::JackDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table) :fCaptureChannels(0), fPlaybackChannels(0), - fClientControl(name), - fWithMonitorPorts(false){ + fClientControl(name, jack_client_uuid_generate()), + fWithMonitorPorts(false) +{ assert(strlen(name) < JACK_CLIENT_NAME_SIZE); fSynchroTable = table; strcpy(fAliasName, alias); diff --git a/common/JackDriverLoader.h b/common/JackDriverLoader.h index e7748565..1562f76e 100644 --- a/common/JackDriverLoader.h +++ b/common/JackDriverLoader.h @@ -1,20 +1,20 @@ /* -Copyright (C) 2001-2005 Paul Davis -Copyright (C) 2004-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. + Copyright (C) 2001-2005 Paul Davis + 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. */ diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp index 610d15d1..bac1d876 100644 --- a/common/JackEngine.cpp +++ b/common/JackEngine.cpp @@ -42,7 +42,8 @@ JackEngine::JackEngine(JackGraphManager* manager, JackEngineControl* control, char self_connect_mode) : JackLockAble(control->fServerName), - fSignal(control->fServerName) + fSignal(control->fServerName), + fMetadata(NULL) // FIXME use control->fServerName? { fGraphManager = manager; fSynchroTable = table; @@ -475,7 +476,7 @@ int JackEngine::InternalClientUnload(int refnum, int* status) // Client management //------------------- -int JackEngine::ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status) +int JackEngine::ClientCheck(const char* name, jack_uuid_t uuid, char* name_res, int protocol, int options, int* status) { // Clear status *status = 0; @@ -563,15 +564,17 @@ bool JackEngine::ClientCheckName(const char* name) return false; } -void JackEngine::EnsureUUID(int uuid) +void JackEngine::EnsureUUID(jack_uuid_t uuid) { - if (uuid == 0) + if (jack_uuid_empty(uuid)) return; for (int i = 0; i < CLIENT_NUM; i++) { JackClientInterface* client = fClientTable[i]; - if (client && (client->GetClientControl()->fSessionID == uuid)) { - client->GetClientControl()->fSessionID = 0; + if (client && jack_uuid_compare(client->GetClientControl()->fSessionID, uuid) == 0) { + // FIXME? this code does nothing, but jack1 has it like this too.. + jack_uuid_clear (&uuid); + // client->GetClientControl()->fSessionID = jack_client_uuid_generate(); } } } @@ -601,11 +604,15 @@ int JackEngine::GetClientRefNum(const char* name) } // Used for external clients -int JackEngine::ClientExternalOpen(const char* name, int pid, int uuid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager) +int JackEngine::ClientExternalOpen(const char* name, int pid, jack_uuid_t uuid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager) { char real_name[JACK_CLIENT_NAME_SIZE + 1]; +<<<<<<< HEAD if (uuid < 0) { +======= + if (jack_uuid_empty(uuid)) { +>>>>>>> f7f2244b07ee0a723853e838de85e25471b8903f uuid = jack_client_uuid_generate(); strncpy(real_name, name, JACK_CLIENT_NAME_SIZE); } else { @@ -737,6 +744,9 @@ int JackEngine::ClientCloseAux(int refnum, bool wait) JackClientInterface* client = fClientTable[refnum]; fEngineControl->fTransport.ResetTimebase(refnum); + jack_uuid_t uuid = JACK_UUID_EMPTY_INITIALIZER; + jack_uuid_copy (&uuid, client->GetClientControl()->fSessionID); + // Unregister all ports ==> notifications are sent jack_int_t ports[PORT_NUM_FOR_CLIENT]; int i; @@ -767,6 +777,12 @@ int JackEngine::ClientCloseAux(int refnum, bool wait) // Notify running clients NotifyRemoveClient(client->GetClientControl()->fName, refnum); + fMetadata.RemoveProperties(NULL, uuid); + /* have to do the notification ourselves, since the client argument + to fMetadata->RemoveProperties() was NULL + */ + PropertyChangeNotify(uuid, NULL, PropertyDeleted); + // Cleanup... fSynchroTable[refnum].Destroy(); fEngineControl->ResetRollingUsecs(); @@ -1075,7 +1091,11 @@ void JackEngine::SessionNotify(int refnum, const char *target, jack_session_even for (int i = 0; i < CLIENT_NUM; i++) { JackClientInterface* client = fClientTable[i]; +<<<<<<< HEAD if (client && (client->GetClientControl()->fSessionID < 0)) { +======= + if (client && jack_uuid_empty(client->GetClientControl()->fSessionID)) { +>>>>>>> f7f2244b07ee0a723853e838de85e25471b8903f client->GetClientControl()->fSessionID = jack_client_uuid_generate(); } } @@ -1107,8 +1127,8 @@ void JackEngine::SessionNotify(int refnum, const char *target, jack_session_even if (result == kPendingSessionReply) { fSessionPendingReplies += 1; } else if (result == kImmediateSessionReply) { - char uuid_buf[JACK_UUID_SIZE]; - snprintf(uuid_buf, sizeof(uuid_buf), "%d", client->GetClientControl()->fSessionID); + char uuid_buf[JACK_UUID_STRING_SIZE]; + jack_uuid_unparse(client->GetClientControl()->fSessionID, uuid_buf); fSessionResult->fCommandList.push_back(JackSessionCommand(uuid_buf, client->GetClientControl()->fName, client->GetClientControl()->fSessionCommand, @@ -1132,8 +1152,8 @@ int JackEngine::SessionReply(int refnum) { JackClientInterface* client = fClientTable[refnum]; assert(client); - char uuid_buf[JACK_UUID_SIZE]; - snprintf(uuid_buf, sizeof(uuid_buf), "%d", client->GetClientControl()->fSessionID); + char uuid_buf[JACK_UUID_STRING_SIZE]; + jack_uuid_unparse(client->GetClientControl()->fSessionID, uuid_buf); fSessionResult->fCommandList.push_back(JackSessionCommand(uuid_buf, client->GetClientControl()->fName, client->GetClientControl()->fSessionCommand, @@ -1157,7 +1177,7 @@ int JackEngine::GetUUIDForClientName(const char *client_name, char *uuid_res) JackClientInterface* client = fClientTable[i]; if (client && (strcmp(client_name, client->GetClientControl()->fName) == 0)) { - snprintf(uuid_res, JACK_UUID_SIZE, "%d", client->GetClientControl()->fSessionID); + jack_uuid_unparse(client->GetClientControl()->fSessionID, uuid_res); return 0; } } @@ -1165,8 +1185,12 @@ int JackEngine::GetUUIDForClientName(const char *client_name, char *uuid_res) return -1; } -int JackEngine::GetClientNameForUUID(const char *uuid, char *name_res) +int JackEngine::GetClientNameForUUID(const char *uuid_buf, char *name_res) { + jack_uuid_t uuid; + if (jack_uuid_parse(uuid_buf, &uuid) != 0) + return -1; + for (int i = 0; i < CLIENT_NUM; i++) { JackClientInterface* client = fClientTable[i]; @@ -1174,10 +1198,7 @@ int JackEngine::GetClientNameForUUID(const char *uuid, char *name_res) continue; } - char uuid_buf[JACK_UUID_SIZE]; - snprintf(uuid_buf, JACK_UUID_SIZE, "%d", client->GetClientControl()->fSessionID); - - if (strcmp(uuid,uuid_buf) == 0) { + if (jack_uuid_compare(client->GetClientControl()->fSessionID, uuid) == 0) { strncpy(name_res, client->GetClientControl()->fName, JACK_CLIENT_NAME_SIZE); return 0; } @@ -1186,17 +1207,23 @@ int JackEngine::GetClientNameForUUID(const char *uuid, char *name_res) return -1; } -int JackEngine::ReserveClientName(const char *name, const char *uuid) +int JackEngine::ReserveClientName(const char *name, const char *uuidstr) { - jack_log("JackEngine::ReserveClientName ( name = %s, uuid = %s )", name, uuid); + jack_log("JackEngine::ReserveClientName ( name = %s, uuid = %s )", name, uuidstr); if (ClientCheckName(name)) { jack_log("name already taken"); return -1; } - EnsureUUID(atoi(uuid)); - fReservationMap[atoi(uuid)] = name; + jack_uuid_t uuid; + if (jack_uuid_parse(uuidstr, &uuid) != 0) { + jack_error("JackEngine::ReserveClientName invalid uuid %s", uuidstr); + return -1; + } + + EnsureUUID(uuid); + fReservationMap[uuid] = name; return 0; } diff --git a/common/JackEngine.h b/common/JackEngine.h index d7549f17..8b5136c9 100644 --- a/common/JackEngine.h +++ b/common/JackEngine.h @@ -55,6 +55,7 @@ class SERVER_EXPORT JackEngine : public JackLockAble JackServerNotifyChannel fChannel; /*! To communicate between the RT thread and server */ JackProcessSync fSignal; jack_time_t fLastSwitchUsecs; + JackMetadata fMetadata; int fSessionPendingReplies; detail::JackChannelTransactionInterface* fSessionTransaction; @@ -86,7 +87,7 @@ class SERVER_EXPORT JackEngine : public JackLockAble void NotifyPortRename(jack_port_id_t src, const char* old_name); void NotifyActivate(int refnum); - void EnsureUUID(int uuid); + void EnsureUUID(jack_uuid_t uuid); bool CheckClient(int refnum) { @@ -104,9 +105,9 @@ class SERVER_EXPORT JackEngine : public JackLockAble int Close(); // Client management - int ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status); + int ClientCheck(const char* name, jack_uuid_t uuid, char* name_res, int protocol, int options, int* status); - int ClientExternalOpen(const char* name, int pid, int uuid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager); + int ClientExternalOpen(const char* name, int pid, jack_uuid_t uuid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager); int ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait); int ClientExternalClose(int refnum); diff --git a/common/JackException.cpp b/common/JackException.cpp index 53eebdb4..91333f40 100644 --- a/common/JackException.cpp +++ b/common/JackException.cpp @@ -1,19 +1,19 @@ /* -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. + Copyright (C) 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. */ diff --git a/common/JackException.h b/common/JackException.h index ac8d81ce..aa5f409f 100644 --- a/common/JackException.h +++ b/common/JackException.h @@ -1,19 +1,19 @@ /* -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. + Copyright (C) 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. */ diff --git a/common/JackExternalClient.cpp b/common/JackExternalClient.cpp index 5fd1b60f..8a4995cc 100644 --- a/common/JackExternalClient.cpp +++ b/common/JackExternalClient.cpp @@ -41,7 +41,7 @@ int JackExternalClient::ClientNotify(int refnum, const char* name, int notify, i return result; } -int JackExternalClient::Open(const char* name, int pid, int refnum, int uuid, int* shared_client) +int JackExternalClient::Open(const char* name, int pid, int refnum, jack_uuid_t uuid, int* shared_client) { try { @@ -64,7 +64,7 @@ int JackExternalClient::Open(const char* name, int pid, int refnum, int uuid, in jack_log("JackExternalClient::Open name = %s index = %ld base = %x", name, shared_mem->GetShmIndex(), shared_mem->GetShmAddress()); return 0; - } catch (std::exception e) { + } catch (std::exception&) { return -1; } } diff --git a/common/JackExternalClient.h b/common/JackExternalClient.h index 19318a33..00b26818 100644 --- a/common/JackExternalClient.h +++ b/common/JackExternalClient.h @@ -46,7 +46,7 @@ class JackExternalClient : public JackClientInterface JackExternalClient(); virtual ~JackExternalClient(); - int Open(const char* name, int pid, int refnum, int uuid, int* shared_client); + int Open(const char* name, int pid, int refnum, jack_uuid_t uuid, int* shared_client); int Close(); int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2); diff --git a/common/JackGenericClientChannel.cpp b/common/JackGenericClientChannel.cpp index 047d7bfa..96401d29 100644 --- a/common/JackGenericClientChannel.cpp +++ b/common/JackGenericClientChannel.cpp @@ -97,7 +97,7 @@ void JackGenericClientChannel::ServerAsyncCall(JackRequest* req, JackResult* res } } -void JackGenericClientChannel::ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status, int* result, int open) +void JackGenericClientChannel::ClientCheck(const char* name, jack_uuid_t uuid, char* name_res, int protocol, int options, int* status, int* result, int open) { JackClientCheckRequest req(name, protocol, options, uuid, open); JackClientCheckResult res; @@ -106,7 +106,7 @@ void JackGenericClientChannel::ClientCheck(const char* name, int uuid, char* nam strcpy(name_res, res.fName); } -void JackGenericClientChannel::ClientOpen(const char* name, int pid, int uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result) +void JackGenericClientChannel::ClientOpen(const char* name, int pid, jack_uuid_t uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result) { JackClientOpenRequest req(name, pid, uuid); JackClientOpenResult res; @@ -285,7 +285,7 @@ void JackGenericClientChannel::InternalClientHandle(int refnum, const char* clie *status = res.fStatus; } -void JackGenericClientChannel::InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int uuid, int* result) +void JackGenericClientChannel::InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, jack_uuid_t uuid, int* result) { JackInternalClientLoadRequest req(refnum, client_name, so_name, objet_data, options, uuid); JackInternalClientLoadResult res; diff --git a/common/JackGenericClientChannel.h b/common/JackGenericClientChannel.h index 04195a2a..b2c7b4ad 100644 --- a/common/JackGenericClientChannel.h +++ b/common/JackGenericClientChannel.h @@ -47,7 +47,7 @@ class JackGenericClientChannel : public detail::JackClientChannelInterface JackGenericClientChannel(); virtual ~JackGenericClientChannel(); - virtual int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) { return -1; } + virtual int Open(const char* server_name, const char* name, jack_uuid_t uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status) { return -1; } virtual void Close() {} virtual int Start() { return -1; } @@ -55,8 +55,8 @@ class JackGenericClientChannel : public detail::JackClientChannelInterface int ServerCheck(const char* server_name); - void ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status, int* result, int open); - void ClientOpen(const char* name, int pid, int uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result); + void ClientCheck(const char* name, jack_uuid_t uuid, char* name_res, int protocol, int options, int* status, int* result, int open); + void ClientOpen(const char* name, int pid, jack_uuid_t uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result); void ClientClose(int refnum, int* result); void ClientActivate(int refnum, int is_real_time, int* result); @@ -83,7 +83,7 @@ class JackGenericClientChannel : public detail::JackClientChannelInterface void GetInternalClientName(int refnum, int int_ref, char* name_res, int* result); void InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result); - void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int uuid, int* result); + void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, jack_uuid_t uuid, int* result); void InternalClientUnload(int refnum, int int_ref, int* status, int* result); // Session API diff --git a/common/JackInternalClient.cpp b/common/JackInternalClient.cpp index 0668516a..ca19316d 100644 --- a/common/JackInternalClient.cpp +++ b/common/JackInternalClient.cpp @@ -63,7 +63,7 @@ JackInternalClient::~JackInternalClient() delete fChannel; } -int JackInternalClient::Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status) +int JackInternalClient::Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status) { int result; jack_log("JackInternalClient::Open name = %s", name); @@ -215,7 +215,7 @@ JackLoadableInternalClient::~JackLoadableInternalClient() } } -int JackLoadableInternalClient1::Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status) +int JackLoadableInternalClient1::Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status) { int res = -1; @@ -231,7 +231,7 @@ int JackLoadableInternalClient1::Open(const char* server_name, const char* name, return res; } -int JackLoadableInternalClient2::Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status) +int JackLoadableInternalClient2::Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status) { int res = -1; diff --git a/common/JackInternalClient.h b/common/JackInternalClient.h index 28c11d4d..ca5ac0bd 100644 --- a/common/JackInternalClient.h +++ b/common/JackInternalClient.h @@ -46,7 +46,7 @@ class JackInternalClient : public JackClient JackInternalClient(JackServer* server, JackSynchro* table); virtual ~JackInternalClient(); - int Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status); + int Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status); void ShutDown(jack_status_t code, const char* message); JackGraphManager* GetGraphManager() const; @@ -100,7 +100,7 @@ class JackLoadableInternalClient1 : public JackLoadableInternalClient {} int Init(const char* so_name); - int Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status); + int Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status); }; @@ -119,7 +119,7 @@ class JackLoadableInternalClient2 : public JackLoadableInternalClient {} int Init(const char* so_name); - int Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status); + int Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status); }; diff --git a/common/JackInternalClientChannel.h b/common/JackInternalClientChannel.h index ce0084c4..fd75e27f 100644 --- a/common/JackInternalClientChannel.h +++ b/common/JackInternalClientChannel.h @@ -44,7 +44,7 @@ class JackInternalClientChannel : public detail::JackClientChannelInterface virtual ~JackInternalClientChannel() {} - void ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status, int* result, int open) + void ClientCheck(const char* name, jack_uuid_t uuid, char* name_res, int protocol, int options, int* status, int* result, int open) { *result = fEngine->ClientCheck(name, uuid, name_res, protocol, options, status); } @@ -128,7 +128,7 @@ class JackInternalClientChannel : public detail::JackClientChannelInterface *result = fEngine->InternalClientHandle(client_name, status, int_ref); } - void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int uuid, int* result) + void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, jack_uuid_t uuid, int* result) { *result = fServer->InternalClientLoad1(client_name, so_name, objet_data, options, int_ref, uuid, status); } diff --git a/common/JackLibClient.cpp b/common/JackLibClient.cpp index 515a5f02..65e70a13 100644 --- a/common/JackLibClient.cpp +++ b/common/JackLibClient.cpp @@ -91,7 +91,7 @@ JackLibClient::~JackLibClient() delete fChannel; } -int JackLibClient::Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status) +int JackLibClient::Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status) { int shared_engine, shared_client, shared_graph, result; bool res; diff --git a/common/JackLibClient.h b/common/JackLibClient.h index 6077ebe8..9fe5d783 100644 --- a/common/JackLibClient.h +++ b/common/JackLibClient.h @@ -44,7 +44,7 @@ class JackLibClient : public JackClient JackLibClient(JackSynchro* table); virtual ~JackLibClient(); - int Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status); + int Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status); void ShutDown(jack_status_t code, const char* message); int ClientNotifyImp(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2); diff --git a/common/JackLockedEngine.h b/common/JackLockedEngine.h index a07eb38e..3e3c8186 100644 --- a/common/JackLockedEngine.h +++ b/common/JackLockedEngine.h @@ -109,14 +109,14 @@ class SERVER_EXPORT JackLockedEngine } // Client management - int ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status) + int ClientCheck(const char* name, jack_uuid_t uuid, char* name_res, int protocol, int options, int* status) { TRY_CALL JackLock lock(&fEngine); return fEngine.ClientCheck(name, uuid, name_res, protocol, options, status); CATCH_EXCEPTION_RETURN } - int ClientExternalOpen(const char* name, int pid, int uuid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager) + int ClientExternalOpen(const char* name, int pid, jack_uuid_t uuid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager) { TRY_CALL JackLock lock(&fEngine); diff --git a/common/JackNetOneDriver.cpp b/common/JackNetOneDriver.cpp index 72cc879d..3985e475 100644 --- a/common/JackNetOneDriver.cpp +++ b/common/JackNetOneDriver.cpp @@ -287,7 +287,7 @@ int JackNetOneDriver::Read() } if ((netj.num_lost_packets * netj.period_size / netj.sample_rate) > 2) - JackTools::ThrowJackNetException(); + throw JackNetException(); //netjack_read(&netj, netj.period_size); JackDriver::CycleTakeBeginTime(); diff --git a/common/JackNetSocket.h b/common/JackNetSocket.h index ea4f98c8..bd42006a 100644 --- a/common/JackNetSocket.h +++ b/common/JackNetSocket.h @@ -1,19 +1,19 @@ /* -Copyright (C) 2008-2011 Romain Moret at 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. + Copyright (C) 2008-2011 Romain Moret at 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. */ diff --git a/common/JackNetTool.cpp b/common/JackNetTool.cpp index b34711c3..c21e5fca 100644 --- a/common/JackNetTool.cpp +++ b/common/JackNetTool.cpp @@ -884,7 +884,7 @@ namespace Jack for (int port_index = 0; port_index < fNPorts; port_index++) { if (fPortBuffer[port_index]) { int res = opus_custom_decode_float(fOpusDecoder[port_index], fCompressedBuffer[port_index], fCompressedSizesByte[port_index], fPortBuffer[port_index], ((nframes == -1) ? fPeriodSize : nframes)); - if (res < 0 || res != ((nframes == -1) ? fPeriodSize : nframes)) { + if (res < 0 || res != ((nframes == -1) ? (int)fPeriodSize : nframes)) { jack_error("opus_custom_decode_float error fCompressedSizeByte = %d res = %d", fCompressedSizesByte[port_index], res); } } diff --git a/common/JackRequest.h b/common/JackRequest.h index 314f84fc..2025bdc3 100644 --- a/common/JackRequest.h +++ b/common/JackRequest.h @@ -161,15 +161,15 @@ struct JackClientCheckRequest : public JackRequest char fName[JACK_CLIENT_NAME_SIZE+1]; int fProtocol; int fOptions; - int fUUID; int fOpen; + jack_uuid_t fUUID; - JackClientCheckRequest() : fProtocol(0), fOptions(0), fUUID(0), fOpen(0) + JackClientCheckRequest() : fProtocol(0), fOptions(0), fOpen(0), fUUID(JACK_UUID_EMPTY_INITIALIZER) { memset(fName, 0, sizeof(fName)); } - JackClientCheckRequest(const char* name, int protocol, int options, int uuid, int open = false) - : JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options), fUUID(uuid), fOpen(open) + JackClientCheckRequest(const char* name, int protocol, int options, jack_uuid_t uuid, int open = false) + : JackRequest(JackRequest::kClientCheck), fProtocol(protocol), fOptions(options), fOpen(open), fUUID(uuid) { memset(fName, 0, sizeof(fName)); snprintf(fName, sizeof(fName), "%s", name); @@ -181,7 +181,7 @@ struct JackClientCheckRequest : public JackRequest CheckRes(trans->Read(&fName, sizeof(fName))); CheckRes(trans->Read(&fProtocol, sizeof(int))); CheckRes(trans->Read(&fOptions, sizeof(int))); - CheckRes(trans->Read(&fUUID, sizeof(int))); + CheckRes(trans->Read(&fUUID, sizeof(jack_uuid_t))); return trans->Read(&fOpen, sizeof(int)); } @@ -191,11 +191,11 @@ struct JackClientCheckRequest : public JackRequest CheckRes(trans->Write(&fName, sizeof(fName))); CheckRes(trans->Write(&fProtocol, sizeof(int))); CheckRes(trans->Write(&fOptions, sizeof(int))); - CheckRes(trans->Write(&fUUID, sizeof(int))); + CheckRes(trans->Write(&fUUID, sizeof(jack_uuid_t))); return trans->Write(&fOpen, sizeof(int)); } - int Size() { return sizeof(fName) + 4 * sizeof(int); } + int Size() { return sizeof(fName) + 3 * sizeof(int) + sizeof(jack_uuid_t); } }; @@ -246,14 +246,14 @@ struct JackClientOpenRequest : public JackRequest { int fPID; - int fUUID; + jack_uuid_t fUUID; char fName[JACK_CLIENT_NAME_SIZE+1]; - JackClientOpenRequest() : fPID(0), fUUID(0) + JackClientOpenRequest() : fPID(0), fUUID(JACK_UUID_EMPTY_INITIALIZER) { memset(fName, 0, sizeof(fName)); } - JackClientOpenRequest(const char* name, int pid, int uuid): JackRequest(JackRequest::kClientOpen) + JackClientOpenRequest(const char* name, int pid, jack_uuid_t uuid): JackRequest(JackRequest::kClientOpen) { memset(fName, 0, sizeof(fName)); snprintf(fName, sizeof(fName), "%s", name); @@ -265,7 +265,7 @@ struct JackClientOpenRequest : public JackRequest { CheckSize(); CheckRes(trans->Read(&fPID, sizeof(int))); - CheckRes(trans->Read(&fUUID, sizeof(int))); + CheckRes(trans->Read(&fUUID, sizeof(jack_uuid_t))); return trans->Read(&fName, sizeof(fName)); } @@ -273,11 +273,11 @@ struct JackClientOpenRequest : public JackRequest { CheckRes(JackRequest::Write(trans, Size())); CheckRes(trans->Write(&fPID, sizeof(int))); - CheckRes(trans->Write(&fUUID, sizeof(int))); + CheckRes(trans->Write(&fUUID, sizeof(jack_uuid_t))); return trans->Write(&fName, sizeof(fName)); } - int Size() { return 2 * sizeof(int) + sizeof(fName); } + int Size() { return sizeof(int) + sizeof(jack_uuid_t) + sizeof(fName); } }; @@ -1048,23 +1048,23 @@ struct JackInternalClientLoadRequest : public JackRequest char fDllName[MAX_PATH+1]; char fLoadInitName[JACK_LOAD_INIT_LIMIT+1]; int fOptions; - int fUUID; + jack_uuid_t fUUID; - JackInternalClientLoadRequest() : fRefNum(0), fOptions(0), fUUID(0) + JackInternalClientLoadRequest() : fRefNum(0), fOptions(0), fUUID(JACK_UUID_EMPTY_INITIALIZER) { memset(fName, 0, sizeof(fName)); memset(fDllName, 0, sizeof(fDllName)); memset(fLoadInitName, 0, sizeof(fLoadInitName)); } - JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int uuid ) + JackInternalClientLoadRequest(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, jack_uuid_t uuid ) : JackRequest(JackRequest::kInternalClientLoad), fRefNum(refnum), fOptions(options), fUUID(uuid) { memset(fName, 0, sizeof(fName)); memset(fDllName, 0, sizeof(fDllName)); memset(fLoadInitName, 0, sizeof(fLoadInitName)); - snprintf(fName, sizeof(fName), "%s", client_name); - snprintf(fDllName, sizeof(fDllName), "%s", so_name); - snprintf(fLoadInitName, sizeof(fLoadInitName), "%s", objet_data); + strncpy(fName, client_name, sizeof(fName)-1); + strncpy(fDllName, so_name, sizeof(fDllName)-1); + strncpy(fLoadInitName, objet_data, sizeof(fLoadInitName)-1); } int Read(detail::JackChannelTransactionInterface* trans) @@ -1074,7 +1074,7 @@ struct JackInternalClientLoadRequest : public JackRequest CheckRes(trans->Read(&fName, sizeof(fName))); CheckRes(trans->Read(&fDllName, sizeof(fDllName))); CheckRes(trans->Read(&fLoadInitName, sizeof(fLoadInitName))); - CheckRes(trans->Read(&fUUID, sizeof(int))); + CheckRes(trans->Read(&fUUID, sizeof(jack_uuid_t))); return trans->Read(&fOptions, sizeof(int)); } @@ -1085,11 +1085,11 @@ struct JackInternalClientLoadRequest : public JackRequest CheckRes(trans->Write(&fName, sizeof(fName))); CheckRes(trans->Write(&fDllName, sizeof(fDllName))); CheckRes(trans->Write(&fLoadInitName, sizeof(fLoadInitName))); - CheckRes(trans->Write(&fUUID, sizeof(int))); + CheckRes(trans->Write(&fUUID, sizeof(jack_uuid_t))); return trans->Write(&fOptions, sizeof(int)); } - int Size() { return sizeof(int) + sizeof(fName) + sizeof(fDllName) + sizeof(fLoadInitName) + 2 * sizeof(int); } + int Size() { return sizeof(int) + sizeof(fName) + sizeof(fDllName) + sizeof(fLoadInitName) + sizeof(int) + sizeof(jack_uuid_t); } }; /*! @@ -1233,9 +1233,9 @@ struct JackClientNotificationRequest : public JackRequest struct JackSessionCommand { - char fUUID[JACK_UUID_SIZE]; + char fUUID[JACK_UUID_STRING_SIZE]; char fClientName[JACK_CLIENT_NAME_SIZE+1]; - char fCommand[JACK_SESSION_COMMAND_SIZE]; + char fCommand[JACK_SESSION_COMMAND_SIZE+1]; jack_session_flags_t fFlags; JackSessionCommand() : fFlags(JackSessionSaveError) @@ -1303,8 +1303,8 @@ struct JackSessionNotifyResult : public JackResult return 0; } - char terminator[JACK_UUID_SIZE]; - terminator[0] = '\0'; + char terminator[JACK_UUID_STRING_SIZE]; + memset(terminator, 0, sizeof(terminator)); CheckRes(JackResult::Write(trans)); for (std::list::iterator i = fCommandList.begin(); i != fCommandList.end(); i++) { @@ -1363,11 +1363,9 @@ struct JackSessionNotifyRequest : public JackRequest { memset(fPath, 0, sizeof(fPath)); memset(fDst, 0, sizeof(fDst)); - snprintf(fPath, sizeof(fPath), "%s", path); - fPath[JACK_MESSAGE_SIZE] = 0; + strncpy(fPath, path, sizeof(fPath)-1); if (dst) { - snprintf(fDst, sizeof(fDst), "%s", dst); - fDst[JACK_CLIENT_NAME_SIZE] = 0; + strncpy(fDst, dst, sizeof(fDst)-1); } } @@ -1435,7 +1433,7 @@ struct JackClientNameResult : public JackResult : JackResult(result) { memset(fName, 0, sizeof(fName)); - snprintf(fName, sizeof(fName), "%s", name); + strncpy(fName, name, sizeof(fName)-1); } int Read(detail::JackChannelTransactionInterface* trans) @@ -1456,7 +1454,7 @@ struct JackClientNameResult : public JackResult struct JackUUIDResult : public JackResult { - char fUUID[JACK_UUID_SIZE]; + char fUUID[JACK_UUID_STRING_SIZE]; JackUUIDResult(): JackResult() { @@ -1466,7 +1464,7 @@ struct JackUUIDResult : public JackResult : JackResult(result) { memset(fUUID, 0, sizeof(fUUID)); - snprintf(fUUID, sizeof(fUUID), "%s", uuid); + strncpy(fUUID, uuid, sizeof(fUUID)-1); } int Read(detail::JackChannelTransactionInterface* trans) @@ -1521,7 +1519,7 @@ struct JackGetUUIDRequest : public JackRequest struct JackGetClientNameRequest : public JackRequest { - char fUUID[JACK_UUID_SIZE]; + char fUUID[JACK_UUID_STRING_SIZE]; JackGetClientNameRequest() { @@ -1557,7 +1555,7 @@ struct JackReserveNameRequest : public JackRequest { int fRefNum; char fName[JACK_CLIENT_NAME_SIZE+1]; - char fUUID[JACK_UUID_SIZE]; + char fUUID[JACK_UUID_STRING_SIZE]; JackReserveNameRequest() : fRefNum(0) { @@ -1634,7 +1632,7 @@ struct JackClientHasSessionCallbackRequest : public JackRequest struct JackPropertyChangeNotifyRequest : public JackRequest { jack_uuid_t fSubject; - char fKey[JACK_UUID_STRING_SIZE]; + char fKey[MAX_PATH+1]; jack_property_change_t fChange; JackPropertyChangeNotifyRequest() : fChange((jack_property_change_t)0) @@ -1697,8 +1695,10 @@ struct JackClientNotification { memset(fName, 0, sizeof(fName)); memset(fMessage, 0, sizeof(fMessage)); - snprintf(fName, sizeof(fName), "%s", name); - snprintf(fMessage, sizeof(fMessage), "%s", message); + strncpy(fName, name, sizeof(fName)-1); + if (message) { + strncpy(fMessage, message, sizeof(fMessage)-1); + } fSize = Size(); } diff --git a/common/JackServer.cpp b/common/JackServer.cpp index 5e88cf48..02273f5a 100644 --- a/common/JackServer.cpp +++ b/common/JackServer.cpp @@ -194,21 +194,21 @@ bool JackServer::IsRunning() // Internal clients //------------------ -int JackServer::InternalClientLoad1(const char* client_name, const char* so_name, const char* objet_data, int options, int* int_ref, int uuid, int* status) +int JackServer::InternalClientLoad1(const char* client_name, const char* so_name, const char* objet_data, int options, int* int_ref, jack_uuid_t uuid, int* status) { JackLoadableInternalClient* client = new JackLoadableInternalClient1(JackServerGlobals::fInstance, GetSynchroTable(), objet_data); assert(client); return InternalClientLoadAux(client, so_name, client_name, options, int_ref, uuid, status); } -int JackServer::InternalClientLoad2(const char* client_name, const char* so_name, const JSList * parameters, int options, int* int_ref, int uuid, int* status) +int JackServer::InternalClientLoad2(const char* client_name, const char* so_name, const JSList * parameters, int options, int* int_ref, jack_uuid_t uuid, int* status) { JackLoadableInternalClient* client = new JackLoadableInternalClient2(JackServerGlobals::fInstance, GetSynchroTable(), parameters); assert(client); return InternalClientLoadAux(client, so_name, client_name, options, int_ref, uuid, status); } -int JackServer::InternalClientLoadAux(JackLoadableInternalClient* client, const char* so_name, const char* client_name, int options, int* int_ref, int uuid, int* status) +int JackServer::InternalClientLoadAux(JackLoadableInternalClient* client, const char* so_name, const char* client_name, int options, int* int_ref, jack_uuid_t uuid, int* status) { // Clear status *status = 0; diff --git a/common/JackServer.h b/common/JackServer.h index c1b5b0d8..71192e9e 100644 --- a/common/JackServer.h +++ b/common/JackServer.h @@ -60,7 +60,7 @@ class SERVER_EXPORT JackServer JackSynchro fSynchroTable[CLIENT_NUM]; bool fFreewheel; - int InternalClientLoadAux(JackLoadableInternalClient* client, const char* so_name, const char* client_name, int options, int* int_ref, int uuid, int* status); + int InternalClientLoadAux(JackLoadableInternalClient* client, const char* so_name, const char* client_name, int options, int* int_ref, jack_uuid_t uuid, int* status); public: @@ -84,8 +84,8 @@ class SERVER_EXPORT JackServer int SetFreewheel(bool onoff); // Internals clients - int InternalClientLoad1(const char* client_name, const char* so_name, const char* objet_data, int options, int* int_ref, int uuid, int* status); - int InternalClientLoad2(const char* client_name, const char* so_name, const JSList * parameters, int options, int* int_ref, int uuid, int* status); + int InternalClientLoad1(const char* client_name, const char* so_name, const char* objet_data, int options, int* int_ref, jack_uuid_t uuid, int* status); + int InternalClientLoad2(const char* client_name, const char* so_name, const JSList * parameters, int options, int* int_ref, jack_uuid_t uuid, int* status); // Internal session file int LoadInternalSessionFile(const char* file); diff --git a/common/JackSystemDeps.h b/common/JackSystemDeps.h index adcc51fa..6e159ac1 100644 --- a/common/JackSystemDeps.h +++ b/common/JackSystemDeps.h @@ -1,20 +1,20 @@ /* -Copyright (C) 2004-2006 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. + Copyright (C) 2004-2006 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. + */ #ifndef __JackSystemDeps__ diff --git a/common/JackTools.cpp b/common/JackTools.cpp index 84a49950..f5be038e 100644 --- a/common/JackTools.cpp +++ b/common/JackTools.cpp @@ -18,7 +18,7 @@ */ #include "JackConstants.h" -#include "JackDriverLoader.h" +#include "driver_interface.h" #include "JackTools.h" #include "JackError.h" #include @@ -44,11 +44,6 @@ namespace Jack { #endif } - void JackTools::ThrowJackNetException() - { - throw JackNetException(); - } - int JackTools::MkDir(const char* path) { #ifdef WIN32 @@ -299,4 +294,3 @@ void BuildClientPath(char* path_to_so, int path_len, const char* so_name) } // end of namespace - diff --git a/common/jack/metadata.h b/common/jack/metadata.h index 5f9bbfe2..e787f08c 100644 --- a/common/jack/metadata.h +++ b/common/jack/metadata.h @@ -129,7 +129,7 @@ jack_free_description (jack_description_t* desc, int free_description_itself); * @param subject The subject to get all properties of. * @param desc Set to the description of subject if found, or NULL otherwise. * The caller must free this value with jack_free_description(). - * @return 0 on success, -1 if no @p subject with any properties exists. + * @return the number of properties, -1 if no @p subject with any properties exists. */ int jack_get_properties (jack_uuid_t subject, @@ -137,10 +137,10 @@ jack_get_properties (jack_uuid_t subject, /** * Get descriptions for all subjects with metadata. - * @param descs Set to a NULL-terminated array of descriptions. + * @param descs Set to an array of descriptions. * The caller must free each of these with jack_free_description(), * and the array itself with jack_free(). - * @return 0 on success. + * @return the number of descriptions, or -1 on error. */ int jack_get_all_properties (jack_description_t** descs); diff --git a/common/promiscuous.c b/common/promiscuous.c index aa6850c1..c6fed3c6 100644 --- a/common/promiscuous.c +++ b/common/promiscuous.c @@ -2,18 +2,18 @@ Copyright (C) 2014-2017 Cédric Schieli 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 + 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 General Public License for more details. + GNU Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ diff --git a/common/promiscuous.h b/common/promiscuous.h index 437fc03c..17373565 100644 --- a/common/promiscuous.h +++ b/common/promiscuous.h @@ -2,18 +2,18 @@ Copyright (C) 2014-2017 Cédric Schieli 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 + 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 General Public License for more details. + GNU Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ diff --git a/common/varargs.h b/common/varargs.h index f4a50948..24fa7d6e 100644 --- a/common/varargs.h +++ b/common/varargs.h @@ -35,7 +35,7 @@ extern "C" char *server_name; /* server name */ char *load_name; /* load module name */ char *load_init; /* initialization string */ - int session_id; /* requested session_id */ + jack_uuid_t session_id; /* requested session_id */ } jack_varargs_t; @@ -51,7 +51,6 @@ extern "C" { memset (va, 0, sizeof(jack_varargs_t)); va->server_name = (char*)jack_default_server_name(); - va->session_id = -1; } static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va) @@ -70,8 +69,11 @@ extern "C" va->load_init = va_arg(ap, char *); if ((options & JackSessionID)) { char *sid = va_arg(ap, char *); - if (sid) - va->session_id = atoi( sid ); + if (sid) { + const long long id = atoll( sid ); + if (id > 0) + va->session_id = id; + } } } diff --git a/common/wscript b/common/wscript index 48c0ad9d..afc251a2 100644 --- a/common/wscript +++ b/common/wscript @@ -250,6 +250,7 @@ def build(bld): 'JackMidiSendQueue.cpp', 'JackMidiUtil.cpp', 'JackMidiWriteQueue.cpp', + 'JackMetadata.cpp', ] if bld.env['IS_LINUX']: diff --git a/dbus/controller_iface_patchbay.c b/dbus/controller_iface_patchbay.c index 8e754afc..765d4690 100644 --- a/dbus/controller_iface_patchbay.c +++ b/dbus/controller_iface_patchbay.c @@ -1647,7 +1647,7 @@ jack_controller_port_connect_callback( } } -int jack_controller_port_rename_callback(jack_port_id_t port, const char * old_name, const char * new_name, void * context) +void jack_controller_port_rename_callback(jack_port_id_t port, const char * old_name, const char * new_name, void * context) { struct jack_graph_port * port_ptr; const char * port_new_short_name; @@ -1660,7 +1660,7 @@ int jack_controller_port_rename_callback(jack_port_id_t port, const char * old_n if (port_new_short_name == NULL) { jack_error("renamed port new name '%s' does not contain ':' separator char", new_name); - return -1; + return; } port_new_short_name++; /* skip ':' separator char */ @@ -1669,7 +1669,7 @@ int jack_controller_port_rename_callback(jack_port_id_t port, const char * old_n if (port_old_short_name == NULL) { jack_error("renamed port old name '%s' does not contain ':' separator char", old_name); - return -1; + return; } port_old_short_name++; /* skip ':' separator char */ @@ -1678,14 +1678,14 @@ int jack_controller_port_rename_callback(jack_port_id_t port, const char * old_n if (port_ptr == NULL) { jack_error("renamed port '%s' not found", old_name); - return -1; + return; } name_buffer = strdup(port_new_short_name); if (name_buffer == NULL) { jack_error("strdup() call for port name '%s' failed.", port_new_short_name); - return 1; + return; } free(port_ptr->name); @@ -1702,8 +1702,6 @@ int jack_controller_port_rename_callback(jack_port_id_t port, const char * old_n port_ptr->name); jack_controller_patchbay_send_signal_graph_changed(patchbay_ptr->graph.version); pthread_mutex_unlock(&patchbay_ptr->lock); - - return 0; } #undef controller_ptr diff --git a/dbus/sigsegv.c b/dbus/sigsegv.c index c5321f1d..de316429 100644 --- a/dbus/sigsegv.c +++ b/dbus/sigsegv.c @@ -61,10 +61,12 @@ static void signal_segv(int signum, siginfo_t* info, void*ptr) static void signal_segv(int signum, siginfo_t* info, void*ptr) { static const char *si_codes[3] = {"", "SEGV_MAPERR", "SEGV_ACCERR"}; - size_t i; const char *si_code_str; ucontext_t *ucontext = (ucontext_t*)ptr; +#if defined(HAVE_UCONTEXT) && defined(HAVE_NGREG) + size_t i; +#endif #if defined(SIGSEGV_STACK_X86) || defined(SIGSEGV_STACK_IA64) int f = 0; Dl_info dlinfo; diff --git a/example-clients/netsource.c b/example-clients/netsource.c index 6cf8c698..bc63c732 100644 --- a/example-clients/netsource.c +++ b/example-clients/netsource.c @@ -62,6 +62,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include #endif +#ifndef CUSTOM_MODES +#define CUSTOM_MODES // for opus_custom_decoder_init +#endif + #if HAVE_OPUS #include #include diff --git a/example-clients/property.c b/example-clients/property.c index a7e35349..e0278b46 100644 --- a/example-clients/property.c +++ b/example-clients/property.c @@ -11,8 +11,8 @@ static int subject_is_client = 0; static int subject_is_port = 0; -static jack_uuid_t uuid; -static char* subject; +static jack_uuid_t uuid = JACK_UUID_EMPTY_INITIALIZER; +static char* subject = NULL; static void show_usage (void) @@ -46,7 +46,7 @@ get_subject (jack_client_t* client, char* argv[], int* optind) } if (jack_uuid_parse (ustr, &uuid)) { - fprintf (stderr, "cannot parse client UUID as UUID\n"); + fprintf (stderr, "cannot parse client UUID as UUID '%s' '%s'\n", cstr, ustr); return -1; } @@ -289,13 +289,13 @@ int main (int argc, char* argv[]) /* list all properties */ jack_description_t* description; - size_t cnt; + int cnt; size_t p; - size_t n; + int n; char buf[JACK_UUID_STRING_SIZE]; if ((cnt = jack_get_all_properties (&description)) < 0) { - fprintf (stderr, "could not retrieve properties for %s\n", subject); + fprintf (stderr, "could not retrieve all properties\n"); exit (1); } diff --git a/linux/JackLinuxFutex.cpp b/linux/JackLinuxFutex.cpp index 415a8b95..deff006b 100644 --- a/linux/JackLinuxFutex.cpp +++ b/linux/JackLinuxFutex.cpp @@ -138,7 +138,10 @@ bool JackLinuxFutex::Allocate(const char* name, const char* server_name, int val return false; } - ftruncate(fSharedMem, sizeof(FutexData)); + if (ftruncate(fSharedMem, sizeof(FutexData)) != 0) { + jack_error("Allocate: can't set shared memory size in named futex name = %s err = %s", fName, strerror(errno)); + return false; + } if (fPromiscuous && (jack_promiscuous_perms(fSharedMem, fName, fPromiscuousGid) < 0)) { close(fSharedMem); diff --git a/linux/alsa/alsa_driver.c b/linux/alsa/alsa_driver.c index 39be0624..7b425669 100644 --- a/linux/alsa/alsa_driver.c +++ b/linux/alsa/alsa_driver.c @@ -1213,7 +1213,8 @@ alsa_driver_xrun_recovery (alsa_driver_t *driver, float *delayed_usecs) < 0) { jack_error("error preparing after suspend: %s", snd_strerror(res)); } - } else { + } + if (driver->playback_handle) { if ((res = snd_pcm_prepare(driver->playback_handle)) < 0) { jack_error("error preparing after suspend: %s", snd_strerror(res)); @@ -1230,6 +1231,18 @@ alsa_driver_xrun_recovery (alsa_driver_t *driver, float *delayed_usecs) timersub(&now, &tstamp, &diff); *delayed_usecs = diff.tv_sec * 1000000.0 + diff.tv_usec; jack_log("**** alsa_pcm: xrun of at least %.3f msecs",*delayed_usecs / 1000.0); + if (driver->capture_handle) { + jack_log("Repreparing capture"); + if ((res = snd_pcm_prepare(driver->capture_handle)) < 0) { + jack_error("error preparing after xrun: %s", snd_strerror(res)); + } + } + if (driver->playback_handle) { + jack_log("Repreparing playback"); + if ((res = snd_pcm_prepare(driver->playback_handle)) < 0) { + jack_error("error preparing after xrun: %s", snd_strerror(res)); + } + } } if (alsa_driver_restart (driver)) { diff --git a/linux/alsarawmidi/JackALSARawMidiDriver.cpp b/linux/alsarawmidi/JackALSARawMidiDriver.cpp index 5e4e61df..8435f40c 100644 --- a/linux/alsarawmidi/JackALSARawMidiDriver.cpp +++ b/linux/alsarawmidi/JackALSARawMidiDriver.cpp @@ -408,7 +408,7 @@ JackALSARawMidiDriver::Open(bool capturing, bool playing, int in_channels, if (potential_inputs) { try { input_ports = new JackALSARawMidiInputPort *[potential_inputs]; - } catch (std::exception e) { + } catch (std::exception& e) { jack_error("JackALSARawMidiDriver::Open - while creating input " "port array: %s", e.what()); FreeDeviceInfo(&in_info_list, &out_info_list); @@ -418,7 +418,7 @@ JackALSARawMidiDriver::Open(bool capturing, bool playing, int in_channels, if (potential_outputs) { try { output_ports = new JackALSARawMidiOutputPort *[potential_outputs]; - } catch (std::exception e) { + } catch (std::exception& e) { jack_error("JackALSARawMidiDriver::Open - while creating output " "port array: %s", e.what()); FreeDeviceInfo(&in_info_list, &out_info_list); @@ -430,7 +430,7 @@ JackALSARawMidiDriver::Open(bool capturing, bool playing, int in_channels, try { input_ports[num_inputs] = new JackALSARawMidiInputPort(info, i); num_inputs++; - } catch (std::exception e) { + } catch (std::exception& e) { jack_error("JackALSARawMidiDriver::Open - while creating new " "JackALSARawMidiInputPort: %s", e.what()); } @@ -441,7 +441,7 @@ JackALSARawMidiDriver::Open(bool capturing, bool playing, int in_channels, try { output_ports[num_outputs] = new JackALSARawMidiOutputPort(info, i); num_outputs++; - } catch (std::exception e) { + } catch (std::exception& e) { jack_error("JackALSARawMidiDriver::Open - while creating new " "JackALSARawMidiOutputPort: %s", e.what()); } @@ -504,7 +504,7 @@ JackALSARawMidiDriver::Start() } try { poll_fds = new pollfd[poll_fd_count]; - } catch (std::exception e) { + } catch (std::exception& e) { jack_error("JackALSARawMidiDriver::Start - creating poll descriptor " "structures failed: %s", e.what()); return -1; @@ -512,7 +512,7 @@ JackALSARawMidiDriver::Start() if (fPlaybackChannels) { try { output_port_timeouts = new jack_nframes_t[fPlaybackChannels]; - } catch (std::exception e) { + } catch (std::exception& e) { jack_error("JackALSARawMidiDriver::Start - creating array for " "output port timeout values failed: %s", e.what()); goto free_poll_descriptors; @@ -521,7 +521,7 @@ JackALSARawMidiDriver::Start() struct pollfd *poll_fd_iter; try { CreateNonBlockingPipe(fds); - } catch (std::exception e) { + } catch (std::exception& e) { jack_error("JackALSARawMidiDriver::Start - while creating wake pipe: " "%s", e.what()); goto free_output_port_timeouts; diff --git a/linux/firewire/ffado_driver.h b/linux/firewire/ffado_driver.h index a06c1361..8ee387b2 100644 --- a/linux/firewire/ffado_driver.h +++ b/linux/firewire/ffado_driver.h @@ -86,7 +86,7 @@ #define debugError(format, args...) jack_error( "firewire ERR: %s:%d (%s): " format, __FILE__, __LINE__, __FUNCTION__, ##args ) #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & (Level)) jack_error("DEBUG %s:%d (%s) :" format, __FILE__, __LINE__, __FUNCTION__, ##args ); #define debugPrintShort(Level, format, args...) if(DEBUG_LEVEL & (Level)) jack_error( format,##args ); -#define debugPrintWithTimeStamp(Level, format, args...) if(DEBUG_LEVEL & (Level)) jack_error( "%16lu: "format, debugGetCurrentUTime(),##args ); +#define debugPrintWithTimeStamp(Level, format, args...) if(DEBUG_LEVEL & (Level)) jack_error( "%16lu: " format, debugGetCurrentUTime(), ##args ); #define SEGFAULT int *test=NULL; *test=1; #else #define DEBUG_LEVEL diff --git a/posix/JackCompilerDeps_os.h b/posix/JackCompilerDeps_os.h index 591db5c3..5332277a 100644 --- a/posix/JackCompilerDeps_os.h +++ b/posix/JackCompilerDeps_os.h @@ -1,19 +1,19 @@ /* -Copyright (C) 2004-2005 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. + Copyright (C) 2004-2005 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. */ diff --git a/posix/JackNetUnixSocket.h b/posix/JackNetUnixSocket.h index 7bba0ed9..3ae542f1 100644 --- a/posix/JackNetUnixSocket.h +++ b/posix/JackNetUnixSocket.h @@ -1,19 +1,19 @@ /* -Copyright (C) 2008-2011 Romain Moret at 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. + Copyright (C) 2008-2011 Romain Moret at 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. */ diff --git a/posix/JackShmMem_os.h b/posix/JackShmMem_os.h index 651eee9c..b572342c 100644 --- a/posix/JackShmMem_os.h +++ b/posix/JackShmMem_os.h @@ -1,20 +1,20 @@ /* -Copyright (C) 2001 Paul Davis -Copyright (C) 2004-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. + Copyright (C) 2001 Paul Davis + 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. */ diff --git a/posix/JackSocketClientChannel.cpp b/posix/JackSocketClientChannel.cpp index 8538f034..3f02daff 100644 --- a/posix/JackSocketClientChannel.cpp +++ b/posix/JackSocketClientChannel.cpp @@ -39,7 +39,7 @@ JackSocketClientChannel::~JackSocketClientChannel() delete fNotificationSocket; } -int JackSocketClientChannel::Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status) +int JackSocketClientChannel::Open(const char* server_name, const char* name, jack_uuid_t uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status) { int result = 0; jack_log("JackSocketClientChannel::Open name = %s", name); diff --git a/posix/JackSocketClientChannel.h b/posix/JackSocketClientChannel.h index ff753d20..1dc0ed7b 100644 --- a/posix/JackSocketClientChannel.h +++ b/posix/JackSocketClientChannel.h @@ -49,7 +49,7 @@ class JackSocketClientChannel : public JackGenericClientChannel, public JackRunn JackSocketClientChannel(); virtual ~JackSocketClientChannel(); - int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status); + int Open(const char* server_name, const char* name, jack_uuid_t uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status); void Close(); int Start(); diff --git a/posix/JackSystemDeps_os.h b/posix/JackSystemDeps_os.h index 516b805b..18ea74c2 100644 --- a/posix/JackSystemDeps_os.h +++ b/posix/JackSystemDeps_os.h @@ -1,19 +1,19 @@ /* -Copyright (C) 2004-2006 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. + Copyright (C) 2004-2006 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. */ diff --git a/windows/JackWinNamedPipeClientChannel.cpp b/windows/JackWinNamedPipeClientChannel.cpp index 8d94b9e5..64c56102 100644 --- a/windows/JackWinNamedPipeClientChannel.cpp +++ b/windows/JackWinNamedPipeClientChannel.cpp @@ -38,7 +38,7 @@ JackWinNamedPipeClientChannel::~JackWinNamedPipeClientChannel() delete fRequest; } -int JackWinNamedPipeClientChannel::Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status) +int JackWinNamedPipeClientChannel::Open(const char* server_name, const char* name, jack_uuid_t uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status) { int result = 0; jack_log("JackWinNamedPipeClientChannel::Open name = %s", name); diff --git a/windows/JackWinNamedPipeClientChannel.h b/windows/JackWinNamedPipeClientChannel.h index 6542399d..298cb5c2 100644 --- a/windows/JackWinNamedPipeClientChannel.h +++ b/windows/JackWinNamedPipeClientChannel.h @@ -49,7 +49,7 @@ class JackWinNamedPipeClientChannel : public JackGenericClientChannel, public Ja JackWinNamedPipeClientChannel(); virtual ~JackWinNamedPipeClientChannel(); - int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status); + int Open(const char* server_name, const char* name, jack_uuid_t uuid, char* name_res, JackClient* client, jack_options_t options, jack_status_t* status); void Close(); int Start(); diff --git a/wscript b/wscript index 442dd200..5bac4241 100644 --- a/wscript +++ b/wscript @@ -216,6 +216,22 @@ def configure(conf): if conf.env['IS_MACOSX']: conf.check(lib='aften', uselib='AFTEN', define_name='AFTEN') + conf.check_cxx( + fragment='' + + '#include \n' + + 'int\n' + + 'main(void)\n' + + '{\n' + + 'AftenContext fAftenContext;\n' + + 'aften_set_defaults(&fAftenContext);\n' + + 'unsigned char *fb;\n' + + 'float *buf=new float[10];\n' + + 'int res = aften_encode_frame(&fAftenContext, fb, buf, 1);\n' + + '}\n', + lib='aften', + msg='Checking for aften_encode_frame()', + define_name='HAVE_AFTEN_NEW_API', + mandatory=False) conf.load('autooptions')