Commit a7e83774 authored by sletz's avatar sletz
Browse files

rebase from trunk 4083:4180

git-svn-id: http://subversion.jackaudio.org/jack/jack2/branches/libjacknet@4181 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 4828d0c8
......@@ -27,16 +27,75 @@ Mario Lang
Arnold Krille
Jan Engelhardt
Adrian Knoth
David Garcia Garzon
David Garcia Garzon
Valerio Pilo
---------------------------
Jackdmp changes log
---------------------------
2011-03-11 Stephane Letz <letz@grame.fr>
* Correct JackNetMaster::SetBufferSize.
2011-03-10 Stephane Letz <letz@grame.fr>
* Latency callback must always be activated.
* Correct TopologicalSort.
* Add jack_midi_dump client.
* Synchronize netjack1 with JACK1 version.
* Synchronize jack_connect/jack_disconnect with JACK1 version.
2011-03-09 Stephane Letz <letz@grame.fr>
* jack_client_has_session_callback implementation.
* Fix jdelay for new latency API.
* Check requested buffer size and limit to 1..8192 - avoids wierd behaviour caused by jack_bufsize foobar.
* jack_port_type_get_buffer_size implementation.
* Stop using alloca and allocate buffer on the heap for alsa_io.
* Rename jdelay to jack_iodelay as per Fons' request.
* Call buffer size callback in activate (actually this is done on client side in the RT thread Init method).
* JackEngine::ComputeTotalLatencies in progress.
2011-03-08 Stephane Letz <letz@grame.fr>
* Use of latency range in all backends.
* ComputeTotalLatencies now a client/server call.
* Add latent test client for latency API.
* Also print playback and capture latency in jack_lsp.
2011-03-04 Stephane Letz <letz@grame.fr>
* Revert r4119 (RT notification in the server). JackAudioDriver::ProcessSync now skip backend write in case of graph process failure.
* Fix incorrect error codes in alsa/usx2y.c and alsa/JackAlsaDriver.cpp.
* Synchronize public headers with JACK1. Update OSX project.
* New latency API implementation (in progress).
2011-02-09 Stephane Letz <letz@grame.fr>
* Remove JackPortIsActive flag.
2011-02-07 Stephane Letz <letz@grame.fr>
* Valerio Pilo second CAS for ARMv7 patch.
2011-02-03 Stephane Letz <letz@grame.fr>
* Valerio Pilo CAS for ARMv7 patch.
2011-01-11 Stephane Letz <letz@grame.fr>
* Adrian Knoth jack_lsp patch.
2010-11-17 Stephane Letz <letz@grame.fr>
* ALSA backend : suspend/resume handling (jack1 r4075).
* Correct dummy driver.
2010-11-05 Stephane Letz <letz@grame.fr>
* In jackdmp.cpp, jackctl_setup_signals moved before jackctl_server_start.
* Correct symbols export in backends.
* Correct symbols export in backends on OSX.
2010-11-03 Stephane Letz <letz@grame.fr>
......
This diff is collapsed.
......@@ -101,6 +101,7 @@ int JackAudioDriver::Attach()
jack_port_id_t port_index;
char name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
char alias[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
jack_latency_range_t range;
int i;
jack_log("JackAudioDriver::Attach fBufferSize = %ld fSampleRate = %ld", fEngineControl->fBufferSize, fEngineControl->fSampleRate);
......@@ -114,7 +115,8 @@ int JackAudioDriver::Attach()
}
port = fGraphManager->GetPort(port_index);
port->SetAlias(alias);
port->SetLatency(fEngineControl->fBufferSize + fCaptureLatency);
range.min = range.max = fEngineControl->fBufferSize + fCaptureLatency;
port->SetLatencyRange(JackCaptureLatency, &range);
fCapturePortList[i] = port_index;
jack_log("JackAudioDriver::Attach fCapturePortList[i] port_index = %ld", port_index);
}
......@@ -129,7 +131,8 @@ int JackAudioDriver::Attach()
port = fGraphManager->GetPort(port_index);
port->SetAlias(alias);
// Add more latency if "async" mode is used...
port->SetLatency(fEngineControl->fBufferSize + ((fEngineControl->fSyncMode) ? 0 : fEngineControl->fBufferSize) + fPlaybackLatency);
range.min = range.max = fEngineControl->fBufferSize + ((fEngineControl->fSyncMode) ? 0 : fEngineControl->fBufferSize) + fPlaybackLatency;
port->SetLatencyRange(JackPlaybackLatency, &range);
fPlaybackPortList[i] = port_index;
jack_log("JackAudioDriver::Attach fPlaybackPortList[i] port_index = %ld", port_index);
......@@ -143,7 +146,8 @@ int JackAudioDriver::Attach()
} else {
port = fGraphManager->GetPort(port_index);
port->SetAlias(alias);
port->SetLatency(fEngineControl->fBufferSize);
range.min = range.max = fEngineControl->fBufferSize;
port->SetLatencyRange(JackCaptureLatency, &range);
fMonitorPortList[i] = port_index;
}
}
......@@ -188,13 +192,13 @@ int JackAudioDriver::ProcessNull()
{
// Keep begin cycle time
JackDriver::CycleTakeBeginTime();
if (fEngineControl->fSyncMode) {
ProcessGraphSync();
} else {
ProcessGraphAsync();
}
// Keep end cycle time
JackDriver::CycleTakeEndTime();
WaitUntilNextCycle();
......@@ -214,23 +218,24 @@ synchronize to the end of client graph execution.
int JackAudioDriver::ProcessAsync()
{
// Read input buffers for the current cycle
if (Read() < 0) {
if (Read() < 0) {
jack_error("JackAudioDriver::ProcessAsync: read error, stopping...");
return -1;
return -1;
}
// Write output buffers from the previous cycle
if (Write() < 0) {
jack_error("JackAudioDriver::ProcessAsync: write error, stopping...");
return -1;
return -1;
}
// Process graph
if (fIsMaster) {
ProcessGraphAsync();
} else {
fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable);
}
// Keep end cycle time
JackDriver::CycleTakeEndTime();
return 0;
......@@ -238,29 +243,38 @@ int JackAudioDriver::ProcessAsync()
/*
The driver SYNC mode: the server does synchronize to the end of client graph execution,
output buffers computed at the *current cycle* are used.
if graph process succeed, output buffers computed at the *current cycle* are used.
*/
int JackAudioDriver::ProcessSync()
{
// Read input buffers for the current cycle
if (Read() < 0) {
if (Read() < 0) {
jack_error("JackAudioDriver::ProcessSync: read error, stopping...");
return -1;
return -1;
}
// Process graph
if (fIsMaster) {
ProcessGraphSync();
if (ProcessGraphSync() < 0) {
jack_error("JackAudioDriver::ProcessSync: process error, skip cycle...");
goto end;
}
} else {
fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable);
if (fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable) < 0) {
jack_error("JackAudioDriver::ProcessSync: process error, skip cycle...");
goto end;
}
}
// Write output buffers from the current cycle
if (Write() < 0) {
jack_error("JackAudioDriver::ProcessSync: write error, stopping...");
return -1;
return -1;
}
end:
// Keep end cycle time
JackDriver::CycleTakeEndTime();
return 0;
......@@ -269,25 +283,34 @@ int JackAudioDriver::ProcessSync()
void JackAudioDriver::ProcessGraphAsync()
{
// fBeginDateUst is set in the "low level" layer, fEndDateUst is from previous cycle
if (!fEngine->Process(fBeginDateUst, fEndDateUst))
if (!fEngine->Process(fBeginDateUst, fEndDateUst))
jack_error("JackAudioDriver::ProcessGraphAsync: Process error");
fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable);
if (ProcessSlaves() < 0)
jack_error("JackAudioDriver::ProcessGraphAsync: ProcessSlaves error");
}
void JackAudioDriver::ProcessGraphSync()
int JackAudioDriver::ProcessGraphSync()
{
int res = 0;
// fBeginDateUst is set in the "low level" layer, fEndDateUst is from previous cycle
if (fEngine->Process(fBeginDateUst, fEndDateUst)) {
if (fEngine->Process(fBeginDateUst, fEndDateUst)) {
fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable);
if (ProcessSlaves() < 0)
if (ProcessSlaves() < 0) {
jack_error("JackAudioDriver::ProcessGraphSync: ProcessSlaves error, engine may now behave abnormally!!");
if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0)
res = -1;
}
if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) {
jack_error("JackAudioDriver::ProcessGraphSync: SuspendRefNum error, engine may now behave abnormally!!");
res = -1;
}
} else { // Graph not finished: do not activate it
jack_error("JackAudioDriver::ProcessGraphSync: Process error");
res = -1;
}
return res;
}
void JackAudioDriver::WaitUntilNextCycle()
......@@ -316,4 +339,37 @@ jack_default_audio_sample_t* JackAudioDriver::GetMonitorBuffer(int port_index)
return (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fMonitorPortList[port_index], fEngineControl->fBufferSize);
}
int JackAudioDriver::ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2)
{
switch (notify) {
case kLatencyCallback:
HandleLatencyCallback(value1);
break;
default:
JackDriver::ClientNotify(refnum, name, notify, sync, message, value1, value2);
break;
}
return 0;
}
void JackAudioDriver::HandleLatencyCallback(int status)
{
jack_latency_callback_mode_t mode = (status == 0) ? JackCaptureLatency : JackPlaybackLatency;
for (int i = 0; i < fCaptureChannels; i++) {
if (mode == JackPlaybackLatency) {
fGraphManager->RecalculateLatency(fCapturePortList[i], mode);
}
}
for (int i = 0; i < fPlaybackChannels; i++) {
if (mode == JackCaptureLatency) {
fGraphManager->RecalculateLatency(fPlaybackPortList[i], mode);
}
}
}
} // end of namespace
......@@ -36,12 +36,12 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
protected:
void ProcessGraphAsync();
void ProcessGraphSync();
int ProcessGraphSync();
void WaitUntilNextCycle();
virtual int ProcessAsync();
virtual int ProcessSync();
int fCaptureChannels;
int fPlaybackChannels;
......@@ -57,6 +57,8 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
jack_default_audio_sample_t* GetOutputBuffer(int port_index);
jack_default_audio_sample_t* GetMonitorBuffer(int port_index);
void HandleLatencyCallback(int status);
public:
JackAudioDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table);
......@@ -73,7 +75,7 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
const char* playback_driver_name,
jack_nframes_t capture_latency,
jack_nframes_t playback_latency);
virtual int Open(bool capturing,
bool playing,
int inchannels,
......@@ -83,18 +85,20 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
const char* playback_driver_name,
jack_nframes_t capture_latency,
jack_nframes_t playback_latency);
virtual int Process();
virtual int ProcessNull();
virtual int Attach();
virtual int Detach();
virtual int Write();
virtual int SetBufferSize(jack_nframes_t buffer_size);
virtual int SetSampleRate(jack_nframes_t sample_rate);
virtual int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);
};
} // end of namespace
......
......@@ -18,7 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "JackGlobals.h"
#include "JackEngineControl.h"
#include "JackPortType.h"
#include <string.h>
#if defined (__APPLE__)
......@@ -46,7 +49,7 @@ static inline void MixAudioBuffer(float* mixbuffer, float* buffer, jack_nframes_
frames = frames % 4;
while (frames_group > 0) {
#if defined (__SSE__) && !defined (__sun__)
#if defined (__SSE__) && !defined (__sun__)
__m128 vec = _mm_add_ps(_mm_load_ps(mixbuffer), _mm_load_ps(buffer));
_mm_store_ps(mixbuffer, vec);
......@@ -97,7 +100,7 @@ static void AudioBufferMixdown(void* mixbuffer, void** src_buffers, int src_coun
void* buffer;
// Copy first buffer
#if defined (__SSE__) && !defined (__sun__)
#if defined (__SSE__) && !defined (__sun__)
jack_nframes_t frames_group = nframes / 4;
jack_nframes_t remaining_frames = nframes % 4;
......@@ -127,12 +130,18 @@ static void AudioBufferMixdown(void* mixbuffer, void** src_buffers, int src_coun
}
}
static size_t AudioBufferSize()
{
return GetEngineControl()->fBufferSize * sizeof(float);
}
const JackPortType gAudioPortType =
{
JACK_DEFAULT_AUDIO_TYPE,
AudioBufferInit,
AudioBufferMixdown
};
{
JACK_DEFAULT_AUDIO_TYPE,
AudioBufferSize,
AudioBufferInit,
AudioBufferMixdown
};
} // namespace Jack
......@@ -12,7 +12,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.
*/
......@@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef __JackChannel__
#define __JackChannel__
#include "types.h"
#include "session.h"
namespace Jack
......@@ -108,43 +107,39 @@ class JackClientChannelInterface
{}
virtual void SetFreewheel(int onoff, int* result)
{}
virtual void ComputeTotalLatencies(int* result)
{}
virtual void ReleaseTimebase(int refnum, int* result)
{}
virtual void SetTimebaseCallback(int refnum, int conditional, int* result)
{}
virtual void GetInternalClientName(int refnum, int int_ref, char* name_res, int* result)
{}
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 InternalClientUnload(int refnum, int int_ref, int* status, int* result)
{}
virtual void SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char *path, jack_session_command_t **result)
{}
virtual void SessionReply(int refnum, int *result)
virtual void SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char* path, jack_session_command_t** result)
{}
virtual void GetUUIDForClientName(int refnum, const char *client_name, char *uuid_res, int *result)
virtual void SessionReply(int refnum, int* result)
{}
virtual void GetClientNameForUUID(int refnum, const char *uuid, char *name_res, int *result)
virtual void GetUUIDForClientName(int refnum, const char* client_name, char* uuid_res, int* result)
{}
virtual void ReserveClientName(int refnum, const char *client_name, const char *uuid, int *result)
virtual void GetClientNameForUUID(int refnum, const char* uuid, char* name_res, int* result)
{}
virtual void ReserveClientName(int refnum, const char* client_name, const char *uuid, int* result)
{}
virtual void ClientHasSessionCallback(const char* client_name, int* result)
{}
virtual bool IsChannelThread()
{
return false;
{
return false;
}
};
......
This diff is collapsed.
......@@ -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.
*/
......@@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackSynchro.h"
#include "JackPlatformPlug.h"
#include "JackChannel.h"
#include "types.h"
#include "session.h"
#include "varargs.h"
#include <list>
......@@ -68,6 +67,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
JackSyncCallback fSync;
JackThreadCallback fThreadFun;
JackSessionCallback fSession;
JackLatencyCallback fLatency;
void* fProcessArg;
void* fGraphOrderArg;
......@@ -86,6 +86,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
void* fSyncArg;
void* fThreadFunArg;
void* fSessionArg;
void* fLatencyArg;
char fServerName[64];
JackThread fThread; /*! Thread to execute the Process function */
......@@ -94,14 +95,14 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
std::list<jack_port_id_t> fPortList;
bool fImmediateSessionReply;
int StartThread();
void SetupDriverSync(bool freewheel);
bool IsActive();
void CallSyncCallback();
void CallTimebaseCallback();
virtual int ClientNotifyImp(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value);
inline void DummyCycle();
......@@ -116,7 +117,10 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
inline void CallSyncCallbackAux();
inline void CallTimebaseCallbackAux();
inline int ActivateAux();
inline void InitAux();
int HandleLatencyCallback(int status);
public:
JackClient();
......@@ -138,8 +142,9 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
// Context
virtual int SetBufferSize(jack_nframes_t buffer_size);
virtual int SetFreeWheel(int onoff);
virtual int ComputeTotalLatencies();
virtual void ShutDown();
virtual pthread_t GetThreadID();
virtual jack_native_thread_t GetThreadID();
// Port management
virtual int PortRegister(const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size);
......@@ -179,6 +184,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
virtual int SetPortConnectCallback(JackPortConnectCallback callback, void *arg);
virtual int SetPortRenameCallback(JackPortRenameCallback callback, void *arg);
virtual int SetSessionCallback(JackSessionCallback callback, void *arg);
virtual int SetLatencyCallback(JackLatencyCallback callback, void *arg);
// Internal clients
virtual char* GetInternalClientName(int ref);
......@@ -186,16 +192,18 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
virtual int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va);
virtual void InternalClientUnload(int ref, jack_status_t* status);
// RT Thread
jack_nframes_t CycleWait();
void CycleSignal(int status);
int SetProcessThread(JackThreadCallback fun, void *arg);
// Session api
virtual jack_session_command_t *SessionNotify(const char *target, jack_session_event_type_t type, const char *path);
virtual int SessionReply(jack_session_event_t *ev);
char* GetUUIDForClientName(const char* client_name);
char* GetClientNameForUUID(const char* uuid);
int ReserveClientName(const char *name, const char* uuid);
// Session API
virtual jack_session_command_t* SessionNotify(const char* target, jack_session_event_type_t type, const char* path);
virtual int SessionReply(jack_session_event_t* ev);
char* GetUUIDForClientName(const char* client_name);
char* GetClientNameByUUID(const char* uuid);
int ReserveClientName(const char* client_name, const char* uuid);
int ClientHasSessionCallback(const char* client_name);
// JackRunnableInterface interface
bool Init();
......
......@@ -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.
*/
......@@ -25,8 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackPort.h"
#include "JackSynchro.h"
#include "JackNotification.h"
#include "jack/session.h"
#include "session.h"
namespace Jack
{
......@@ -74,6 +73,7 @@ struct JackClientControl : public JackShmMemAble
fCallback[kAddClient] = true;
fCallback[kRemoveClient] = true;
fCallback[kActivateClient] = true;
fCallback[kLatencyCallback] = true;
// So that driver synchro are correctly setup in "flush" or "normal" mode
fCallback[kStartFreewheelCallback] = true;
fCallback[kStopFreewheelCallback] = true;
......
......@@ -12,7 +12,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.
*/
......@@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackEngineControl.h"
#include "JackGlobals.h"
#include "JackError.h"
#include <set>
#include <iostream>
#include <assert.h>
......@@ -246,7 +247,7 @@ int JackConnectionManager::SuspendRefNum(JackClientControl* control, JackSynchro
int JackConnectionManager::ResumeRefNum(JackClientControl* control, JackSynchro* table, JackClientTiming* timing)
{
jack_time_t current_date = GetMicroSeconds();
const jack_int_t* outputRef = fConnectionRef.GetItems(control->fRefNum);
const jack_int_t* output_ref = fConnectionRef.GetItems(control->fRefNum);
int res = 0;
// Update state and timestamp of current client
......@@ -256,7 +257,7 @@ int JackConnectionManager::ResumeRefNum(JackClientControl* control, JackSynchro*
for (int i = 0; i < CLIENT_NUM; i++) {
// Signal connected clients or drivers
if (outputRef[i] > 0) {
if (output_ref[i] > 0) {
// Update state and timestamp of destination clients
timing[i].fStatus = Triggered;