summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsletz <sletz@0c269be4-1314-0410-8aa9-9f06e86f4224>2011-03-04 11:02:25 +0000
committersletz <sletz@0c269be4-1314-0410-8aa9-9f06e86f4224>2011-03-04 11:02:25 +0000
commit92c5da66da7cc4a8304014a00169c9c1b81b8d1b (patch)
tree9622783320020a2acb48a32063760cbdb285d552
parent4f249a336fa0b8813fa30df9d183c2c31a281ca6 (diff)
downloadjack2-92c5da66da7cc4a8304014a00169c9c1b81b8d1b.tar.gz
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.
git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4143 0c269be4-1314-0410-8aa9-9f06e86f4224
-rw-r--r--ChangeLog5
-rw-r--r--common/JackAudioDriver.cpp57
-rw-r--r--common/JackAudioDriver.h10
-rw-r--r--common/JackClient.cpp96
-rw-r--r--common/JackClient.h14
-rw-r--r--common/JackEngine.cpp16
-rw-r--r--common/JackServerGlobals.cpp10
-rw-r--r--common/JackServerGlobals.h3
-rw-r--r--linux/alsa/JackAlsaDriver.cpp146
-rw-r--r--linux/alsa/usx2y.c10
-rw-r--r--posix/JackSocketServerChannel.cpp32
-rw-r--r--posix/JackSocketServerNotifyChannel.cpp6
-rw-r--r--posix/JackSocketServerNotifyChannel.h2
13 files changed, 221 insertions, 186 deletions
diff --git a/ChangeLog b/ChangeLog
index 503e436f..309b5337 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,11 @@ Valerio Pilo
Jackdmp changes log
---------------------------
+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.
+
2011-02-09 Stephane Letz <letz@grame.fr>
* Remove JackPortIsActive flag.
diff --git a/common/JackAudioDriver.cpp b/common/JackAudioDriver.cpp
index 9748b46a..7e1389c2 100644
--- a/common/JackAudioDriver.cpp
+++ b/common/JackAudioDriver.cpp
@@ -188,13 +188,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 +214,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 +239,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 +279,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()
diff --git a/common/JackAudioDriver.h b/common/JackAudioDriver.h
index 6fb64e64..a495097b 100644
--- a/common/JackAudioDriver.h
+++ b/common/JackAudioDriver.h
@@ -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;
@@ -73,7 +73,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,13 +83,13 @@ 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);
diff --git a/common/JackClient.cpp b/common/JackClient.cpp
index 3a59140e..072a4b90 100644
--- a/common/JackClient.cpp
+++ b/common/JackClient.cpp
@@ -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.
*/
@@ -84,17 +84,17 @@ int JackClient::Close()
{
jack_log("JackClient::Close ref = %ld", GetClientControl()->fRefNum);
int result = 0;
-
+
Deactivate();
fChannel->Stop(); // Channels is stopped first to avoid receiving notifications while closing
-
+
// Request close only if server is still running
if (JackGlobals::fServerRunning) {
fChannel->ClientClose(GetClientControl()->fRefNum, &result);
} else {
- jack_log("JackClient::Close server is shutdown");
+ jack_log("JackClient::Close server is shutdown");
}
-
+
fChannel->Close();
fSynchroTable[GetClientControl()->fRefNum].Disconnect();
JackGlobals::fClientTable[GetClientControl()->fRefNum] = NULL;
@@ -188,7 +188,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
res = fBufferSize(value1, fBufferSizeArg);
}
break;
-
+
case kSampleRateCallback:
jack_log("JackClient::kSampleRateCallback sample_rate = %ld", value1);
if (fSampleRate) {
@@ -250,7 +250,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
fPortConnect(value1, value2, 0, fPortConnectArg);
}
break;
-
+
case kPortRenameCallback:
jack_log("JackClient::kPortRenameCallback port = %ld", value1);
if (fPortRename) {
@@ -264,7 +264,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
res = fXrun(fXrunArg);
}
break;
-
+
case kShutDownCallback:
jack_log("JackClient::kShutDownCallback");
if (fInfoShutdown) {
@@ -297,7 +297,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
/*!
\brief We need to start thread before activating in the server, otherwise the FW driver
- connected to the client may not be activated.
+connected to the client may not be activated.
*/
int JackClient::Activate()
{
@@ -310,13 +310,13 @@ int JackClient::Activate()
if (StartThread() < 0)
return -1;
}
-
+
/*
- Insertion of client in the graph will cause a kGraphOrderCallback notification
+ Insertion of client in the graph will cause a kGraphOrderCallback notification
to be delivered by the server, the client wants to receive it.
*/
GetClientControl()->fActive = true;
-
+
// Transport related callback become "active"
GetClientControl()->fTransportSync = true;
GetClientControl()->fTransportTimebase = true;
@@ -337,18 +337,18 @@ int JackClient::Deactivate()
return 0;
GetClientControl()->fActive = false;
-
+
// Transport related callback become "unactive"
GetClientControl()->fTransportSync = false;
GetClientControl()->fTransportTimebase = false;
-
+
// We need to wait for the new engine cycle before stopping the RT thread, but this is done by ClientDeactivate
int result = -1;
fChannel->ClientDeactivate(GetClientControl()->fRefNum, &result);
jack_log("JackClient::Deactivate res = %ld", result);
-
+
// RT thread is stopped only when needed...
- if (IsRealTime())
+ if (IsRealTime())
fThread.Kill();
return result;
}
@@ -399,21 +399,21 @@ int JackClient::StartThread()
bool JackClient::Execute()
{
- if (!jack_tls_set(JackGlobals::fRealTime, this))
+ if (!jack_tls_set(JackGlobals::fRealTime, this))
jack_error("failed to set thread realtime key");
-
- if (GetEngineControl()->fRealTime)
- set_threaded_log_function();
-
+
+ if (GetEngineControl()->fRealTime)
+ set_threaded_log_function();
+
// Execute a dummy cycle to be sure thread has the correct properties
DummyCycle();
-
+
if (fThreadFun) {
fThreadFun(fThreadFunArg);
} else {
ExecuteThread();
}
- return false;
+ return false;
}
void JackClient::DummyCycle()
@@ -424,15 +424,15 @@ void JackClient::DummyCycle()
inline void JackClient::ExecuteThread()
{
- while (true) {
+ while (true) {
CycleWaitAux();
- CycleSignalAux(CallProcessCallback());
- }
+ CycleSignalAux(CallProcessCallback());
+ }
}
inline jack_nframes_t JackClient::CycleWaitAux()
{
- if (!WaitSync())
+ if (!WaitSync())
Error(); // Terminates the thread
CallSyncCallbackAux();
return GetEngineControl()->fBufferSize;
@@ -443,7 +443,7 @@ inline void JackClient::CycleSignalAux(int status)
if (status == 0)
CallTimebaseCallbackAux();
SignalSync();
- if (status != 0)
+ if (status != 0)
End(); // Terminates the thread
}
@@ -531,7 +531,7 @@ int JackClient::PortRegister(const char* port_name, const char* port_type, unsig
int result = -1;
jack_port_id_t port_index = NO_PORT;
fChannel->PortRegister(GetClientControl()->fRefNum, name.c_str(), port_type, flags, buffer_size, &port_index, &result);
-
+
if (result == 0) {
jack_log("JackClient::PortRegister ref = %ld name = %s type = %s port_index = %ld", GetClientControl()->fRefNum, name.c_str(), port_type, port_index);
fPortList.push_back(port_index);
@@ -623,7 +623,7 @@ void JackClient::ShutDown()
{
jack_log("ShutDown");
JackGlobals::fServerRunning = false;
-
+
if (fInfoShutdown) {
fInfoShutdown(JackFailure, "JACK server has been closed", fInfoShutdownArg);
fInfoShutdown = NULL;
@@ -641,18 +641,18 @@ inline int JackClient::ActivateAux()
{
// If activated without RT thread...
if (IsActive() && fThread.GetStatus() != JackThread::kRunning) {
-
+
jack_log("ActivateAux");
-
+
// RT thread is started
if (StartThread() < 0)
return -1;
-
+
int result = -1;
GetClientControl()->fCallback[kRealTimeCallback] = IsRealTime();
fChannel->ClientActivate(GetClientControl()->fRefNum, IsRealTime(), &result);
return result;
-
+
} else {
return 0;
}
@@ -683,7 +683,7 @@ int JackClient::SetTimebaseCallback(int conditional, JackTimebaseCallback timeba
{
int result = -1;
fChannel->SetTimebaseCallback(GetClientControl()->fRefNum, conditional, &result);
-
+
if (result == 0) {
GetClientControl()->fTransportTimebase = true;
fTimebase = timebase_callback;
@@ -758,11 +758,11 @@ void JackClient::CallSyncCallback()
inline void JackClient::CallSyncCallbackAux()
{
if (GetClientControl()->fTransportSync) {
-
+
JackTransportEngine& transport = GetEngineControl()->fTransport;
jack_position_t* cur_pos = transport.ReadCurrentState();
jack_transport_state_t transport_state = transport.GetState();
-
+
if (fSync != NULL) {
if (fSync(transport_state, cur_pos, fSyncArg)) {
GetClientControl()->fTransportState = JackTransportRolling;
@@ -785,21 +785,21 @@ inline void JackClient::CallTimebaseCallbackAux()
JackTransportEngine& transport = GetEngineControl()->fTransport;
int master;
bool unused;
-
+
transport.GetTimebaseMaster(master, unused);
-
+
if (GetClientControl()->fRefNum == master && fTimebase) { // Client *is* timebase...
-
+
jack_transport_state_t transport_state = transport.GetState();
jack_position_t* cur_pos = transport.WriteNextStateStart(1);
-
+
if (GetClientControl()->fTransportTimebase) {
- fTimebase(transport_state, GetEngineControl()->fBufferSize, cur_pos, true, fTimebaseArg);
- GetClientControl()->fTransportTimebase = false; // Callback is called only once with "new_pos" = true
+ fTimebase(transport_state, GetEngineControl()->fBufferSize, cur_pos, true, fTimebaseArg);
+ GetClientControl()->fTransportTimebase = false; // Callback is called only once with "new_pos" = true
} else if (transport_state == JackTransportRolling) {
fTimebase(transport_state, GetEngineControl()->fBufferSize, cur_pos, false, fTimebaseArg);
- }
-
+ }
+
transport.WriteNextStateStop(1);
}
}
@@ -817,7 +817,7 @@ void JackClient::OnShutdown(JackShutdownCallback callback, void *arg)
fShutdown = callback;
}
}
-
+
void JackClient::OnInfoShutdown(JackInfoShutdownCallback callback, void *arg)
{
if (IsActive()) {
@@ -908,8 +908,8 @@ int JackClient::SetSampleRateCallback(JackSampleRateCallback callback, void *arg
GetClientControl()->fCallback[kSampleRateCallback] = (callback != NULL);
fSampleRateArg = arg;
fSampleRate = callback;
- // Now invoke it
- if (callback)
+ // Now invoke it
+ if (callback)
callback(GetEngineControl()->fSampleRate, arg);
return 0;
}
diff --git a/common/JackClient.h b/common/JackClient.h
index cd5ab090..588c5912 100644
--- a/common/JackClient.h
+++ b/common/JackClient.h
@@ -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.
*/
@@ -94,14 +94,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 +116,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
inline void CallSyncCallbackAux();
inline void CallTimebaseCallbackAux();
inline int ActivateAux();
-
+
public:
JackClient();
@@ -193,9 +193,9 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
// 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);
+ char* GetUUIDForClientName(const char* client_name);
+ char* GetClientNameForUUID(const char* uuid);
+ int ReserveClientName(const char *name, const char* uuid);
// JackRunnableInterface interface
bool Init();
diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp
index 564c8fcb..f9dd6052 100644
--- a/common/JackEngine.cpp
+++ b/common/JackEngine.cpp
@@ -138,8 +138,8 @@ void JackEngine::ProcessNext(jack_time_t cur_cycle_begin)
{
fLastSwitchUsecs = cur_cycle_begin;
if (fGraphManager->RunNextGraph()) { // True if the graph actually switched to a new state
- //fChannel.Notify(ALL_CLIENTS, kGraphOrderCallback, 0);
- NotifyGraphReorder();
+ fChannel.Notify(ALL_CLIENTS, kGraphOrderCallback, 0);
+ //NotifyGraphReorder();
}
fSignal.Signal(); // Signal for threads waiting for next cycle
}
@@ -196,14 +196,14 @@ void JackEngine::CheckXRun(jack_time_t callback_usecs) // REVOIR les conditions
if (status != NotTriggered && status != Finished) {
jack_error("JackEngine::XRun: client = %s was not run: state = %ld", client->GetClientControl()->fName, status);
- //fChannel.Notify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients
- NotifyXRun(ALL_CLIENTS);
+ fChannel.Notify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients
+ //NotifyXRun(ALL_CLIENTS);
}
if (status == Finished && (long)(finished_date - callback_usecs) > 0) {
jack_error("JackEngine::XRun: client %s finished after current callback", client->GetClientControl()->fName);
- //fChannel.Notify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients
- NotifyXRun(ALL_CLIENTS);
+ fChannel.Notify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients
+ //NotifyXRun(ALL_CLIENTS);
}
}
}
@@ -280,8 +280,8 @@ void JackEngine::NotifyXRun(jack_time_t callback_usecs, float delayed_usecs)
{
// Use the audio thread => request thread communication channel
fEngineControl->NotifyXRun(callback_usecs, delayed_usecs);
- //fChannel.Notify(ALL_CLIENTS, kXRunCallback, 0);
- NotifyXRun(ALL_CLIENTS);
+ fChannel.Notify(ALL_CLIENTS, kXRunCallback, 0);
+ //NotifyXRun(ALL_CLIENTS);
}
void JackEngine::NotifyXRun(int refnum)
diff --git a/common/JackServerGlobals.cpp b/common/JackServerGlobals.cpp
index fcad0a71..04489190 100644
--- a/common/JackServerGlobals.cpp
+++ b/common/JackServerGlobals.cpp
@@ -28,8 +28,10 @@ static char* server_name = NULL;
namespace Jack
{
-JackServer* JackServerGlobals::fInstance;
+JackServer* JackServerGlobals::fInstance;
unsigned int JackServerGlobals::fUserCount;
+int JackServerGlobals::fRTNotificationSocket;
+
bool (* JackServerGlobals::on_device_acquire)(const char * device_name) = NULL;
void (* JackServerGlobals::on_device_release)(const char * device_name) = NULL;
@@ -95,7 +97,7 @@ bool JackServerGlobals::Init()
int argc = 0;
char* argv[32];
jack_timer_type_t clock_source = JACK_TIMER_SYSTEM_CLOCK;
-
+
// First user starts the server
if (fUserCount++ == 0) {
@@ -158,7 +160,7 @@ bool JackServerGlobals::Init()
(opt = getopt_long(argc, argv, options, long_options, &option_index)) != EOF) {
switch (opt) {
-
+
case 'c':
if (tolower (optarg[0]) == 'h') {
clock_source = JACK_TIMER_HPET;
@@ -168,7 +170,7 @@ bool JackServerGlobals::Init()
clock_source = JACK_TIMER_SYSTEM_CLOCK;
} else {
jack_error("unknown option character %c", optopt);
- }
+ }
break;
case 'd':
diff --git a/common/JackServerGlobals.h b/common/JackServerGlobals.h
index b4b688c1..273912bc 100644
--- a/common/JackServerGlobals.h
+++ b/common/JackServerGlobals.h
@@ -38,9 +38,10 @@ struct SERVER_EXPORT JackServerGlobals
{
static JackServer* fInstance;
static unsigned int fUserCount;
+ static int fRTNotificationSocket; // For debugging purpose
static bool (* on_device_acquire)(const char * device_name);
static void (* on_device_release)(const char * device_name);
-
+
JackServerGlobals();
~JackServerGlobals();
diff --git a/linux/alsa/JackAlsaDriver.cpp b/linux/alsa/JackAlsaDriver.cpp
index 8b5512e6..756c2cdc 100644
--- a/linux/alsa/JackAlsaDriver.cpp
+++ b/linux/alsa/JackAlsaDriver.cpp
@@ -276,7 +276,7 @@ JackAlsaDriver::alsa_driver_setup_io_function_pointers (alsa_driver_t *driver)
} else {
driver->channel_copy = memcpy_fake;
}
-
+
switch (driver->dither) {
case Rectangular:
jack_info("Rectangular dithering at 16 bits");
@@ -284,42 +284,42 @@ JackAlsaDriver::alsa_driver_setup_io_function_pointers (alsa_driver_t *driver)
sample_move_dither_rect_d16_sSs:
sample_move_dither_rect_d16_sS;
break;
-
+
case Triangular:
jack_info("Triangular dithering at 16 bits");
driver->write_via_copy = driver->quirk_bswap?
sample_move_dither_tri_d16_sSs:
sample_move_dither_tri_d16_sS;
break;
-
+
case Shaped:
jack_info("Noise-shaped dithering at 16 bits");
driver->write_via_copy = driver->quirk_bswap?
sample_move_dither_shaped_d16_sSs:
sample_move_dither_shaped_d16_sS;
break;
-
+
default:
driver->write_via_copy = driver->quirk_bswap?
- sample_move_d16_sSs :
+ sample_move_d16_sSs :
sample_move_d16_sS;
break;
}
break;
-
+
case 3: /* NO DITHER */
if (driver->playback_interleaved) {
driver->channel_copy = memcpy_interleave_d24_s24;
} else {
driver->channel_copy = memcpy_fake;
}
-
+
driver->write_via_copy = driver->quirk_bswap?
- sample_move_d24_sSs:
+ sample_move_d24_sSs:
sample_move_d24_sS;
break;
-
+
case 4: /* NO DITHER */
if (driver->playback_interleaved) {
driver->channel_copy = memcpy_interleave_d32_s32;
@@ -328,7 +328,7 @@ JackAlsaDriver::alsa_driver_setup_io_function_pointers (alsa_driver_t *driver)
}
driver->write_via_copy = driver->quirk_bswap?
- sample_move_d32u24_sSs:
+ sample_move_d32u24_sSs:
sample_move_d32u24_sS;
break;
@@ -339,27 +339,27 @@ JackAlsaDriver::alsa_driver_setup_io_function_pointers (alsa_driver_t *driver)
}
}
}
-
+
if (driver->capture_handle) {
switch (driver->capture_sample_bytes) {
case 2:
driver->read_via_copy = driver->quirk_bswap?
- sample_move_dS_s16s:
+ sample_move_dS_s16s:
sample_move_dS_s16;
break;
case 3:
driver->read_via_copy = driver->quirk_bswap?
- sample_move_dS_s24s:
+ sample_move_dS_s24s:
sample_move_dS_s24;
break;
case 4:
driver->read_via_copy = driver->quirk_bswap?
- sample_move_dS_s32u24s:
+ sample_move_dS_s32u24s:
sample_move_dS_s32u24;
break;
}
}
-
+
return 0;
}
@@ -418,7 +418,7 @@ JackAlsaDriver::alsa_driver_configure_stream (alsa_driver_t *driver, char *devic
}
}
}
-
+
format = (sample_width == 4) ? 0 : NUMFORMATS - 1;
while (1) {
@@ -444,7 +444,7 @@ JackAlsaDriver::alsa_driver_configure_stream (alsa_driver_t *driver, char *devic
jack_info ("ALSA: final selected sample format for %s: %s", stream_name, formats[format].Name);
break;
}
- }
+ }
frame_rate = driver->frame_rate ;
err = snd_pcm_hw_params_set_rate_near (handle, hw_params,
@@ -464,7 +464,7 @@ JackAlsaDriver::alsa_driver_configure_stream (alsa_driver_t *driver, char *devic
&channels_max);
*nchns = channels_max ;
- if (*nchns > 1024) {
+ if (*nchns > 1024) {
/* the hapless user is an unwitting victim of
the "default" ALSA PCM device, which can
@@ -481,9 +481,9 @@ JackAlsaDriver::alsa_driver_configure_stream (alsa_driver_t *driver, char *devic
"instead rather than using the plug layer. Usually the name of the\n"
"hardware device that corresponds to the first sound card is hw:0\n"
);
- *nchns = 2;
+ *nchns = 2;
}
- }
+ }
if ((err = snd_pcm_hw_params_set_channels (handle, hw_params,
*nchns)) < 0) {
@@ -491,7 +491,7 @@ JackAlsaDriver::alsa_driver_configure_stream (alsa_driver_t *driver, char *devic
*nchns, stream_name);
return -1;
}
-
+
if ((err = snd_pcm_hw_params_set_period_size (handle, hw_params,
driver->frames_per_cycle,
0))
@@ -520,7 +520,7 @@ JackAlsaDriver::alsa_driver_configure_stream (alsa_driver_t *driver, char *devic
return -1;
}
jack_info ("ALSA: use %d periods for %s", *nperiodsp, stream_name);
-#if 0
+#if 0
if (!jack_power_of_two(driver->frames_per_cycle)) {
jack_error("JACK: frames must be a power of two "
"(64, 512, 1024, ...)\n");
@@ -557,7 +557,7 @@ JackAlsaDriver::alsa_driver_configure_stream (alsa_driver_t *driver, char *devic
if (driver->soft_mode) {
stop_th = (snd_pcm_uframes_t)-1;
}
-
+
if ((err = snd_pcm_sw_params_set_stop_threshold (
handle, sw_params, stop_th)) < 0) {
jack_error ("ALSA: cannot set stop mode for %s",
@@ -594,7 +594,7 @@ JackAlsaDriver::alsa_driver_configure_stream (alsa_driver_t *driver, char *devic
else
err = snd_pcm_sw_params_set_avail_min (
handle, sw_params, driver->frames_per_cycle);
-
+
if (err < 0) {
jack_error ("ALSA: cannot set avail min for %s", stream_name);
return -1;
@@ -1158,7 +1158,7 @@ int
JackAlsaDriver::alsa_driver_restart (alsa_driver_t *driver)
{
int res;
-
+
driver->xrun_recovery = 1;
if ((res = Stop()) == 0)
res = Start();
@@ -1188,25 +1188,25 @@ JackAlsaDriver::alsa_driver_xrun_recovery (alsa_driver_t *driver, float *delayed
jack_error("status error: %s", snd_strerror(res));
}
}
-
- if (snd_pcm_status_get_state(status) == SND_PCM_STATE_SUSPENDED) {
- jack_error("**** alsa_pcm: pcm in suspended state, resuming it" );
- if (driver->capture_handle) {
- if ((res = snd_pcm_prepare(driver->capture_handle)) < 0) {
- jack_error("error preparing after suspend: %s", snd_strerror(res));
- }
- } else {
- if ((res = snd_pcm_prepare(driver->playback_handle)) < 0) {
- jack_error("error preparing after suspend: %s", snd_strerror(res));
- }
- }
- }
+
+ if (snd_pcm_status_get_state(status) == SND_PCM_STATE_SUSPENDED) {
+ jack_error("**** alsa_pcm: pcm in suspended state, resuming it" );
+ if (driver->capture_handle) {
+ if ((res = snd_pcm_prepare(driver->capture_handle)) < 0) {
+ jack_error("error preparing after suspend: %s", snd_strerror(res));
+ }
+ } else {
+ if ((res = snd_pcm_prepare(driver->playback_handle)) < 0) {
+ jack_error("error preparing after suspend: %s", snd_strerror(res));
+ }
+ }
+ }
if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN
&& driver->process_count > XRUN_REPORT_DELAY) {
struct timeval now, diff, tstamp;
driver->xrun_count++;
- snd_pcm_status_get_tstamp(status,&now);
+ snd_pcm_status_get_tstamp(status,&now);
snd_pcm_status_get_trigger_tstamp(status, &tstamp);
timersub(&now, &tstamp, &diff);
*delayed_usecs = diff.tv_sec * 1000000.0 + diff.tv_usec;
@@ -1266,7 +1266,7 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat
}
again:
-
+
while (need_playback || need_capture) {
int poll_result;
@@ -1282,7 +1282,7 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat
driver->playback_nfds);
nfds += driver->playback_nfds;
}
-
+
if (need_capture) {
snd_pcm_poll_descriptors (driver->capture_handle,
&driver->pfd[nfds],
@@ -1292,7 +1292,7 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat
}
/* ALSA doesn't set POLLERR in some versions of 0.9.X */
-
+
for (i = 0; i < nfds; i++) {
driver->pfd[i].events |= POLLERR;
}
@@ -1329,12 +1329,12 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat
*status = -2;
return 0;
}
-
+
jack_error ("ALSA: poll call failed (%s)",
strerror (errno));
*status = -3;
return 0;
-
+
}
poll_ret = jack_get_microseconds ();
@@ -1345,12 +1345,12 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat
if (extra_fd < 0) {
if (driver->poll_next && poll_ret > driver->poll_next) {
*delayed_usecs = poll_ret - driver->poll_next;
- }
+ }
driver->poll_last = poll_ret;
driver->poll_next = poll_ret + driver->period_usecs;
// steph
/*
- driver->engine->transport_cycle_start (driver->engine,
+ driver->engine->transport_cycle_start (driver->engine,
poll_ret);
*/
}
@@ -1371,7 +1371,7 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat
*status = -4;
return -1;
- }
+ }
/* if POLLIN was the only bit set, we're OK */
@@ -1427,14 +1427,14 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat
#endif
}
}
-
+
if (poll_result == 0) {
jack_error ("ALSA: poll time out, polled for %" PRIu64
" usecs",
poll_ret - poll_enter);
*status = -5;
return 0;
- }
+ }
}
@@ -1450,7 +1450,7 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat
}
} else {
/* odd, but see min() computation below */
- capture_avail = INT_MAX;
+ capture_avail = INT_MAX;
}
if (driver->playback_handle) {
@@ -1465,7 +1465,7 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat
}
} else {
/* odd, but see min() computation below */
- playback_avail = INT_MAX;
+ playback_avail = INT_MAX;
}
if (xrun_detected) {
@@ -1544,7 +1544,7 @@ JackAlsaDriver::alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
if (!driver->capture_handle) {
return 0;
}
-
+
nread = 0;
contiguous = 0;
orig_nframes = nframes;
@@ -1572,11 +1572,11 @@ JackAlsaDriver::alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
/* // steph
for (chn = 0, node = driver->capture_ports; node;
node = jack_slist_next (node), chn++) {
-
+
port = (jack_port_t *) node->data;
-
+
if (!jack_port_connected (port)) {
- // no-copy optimization
+ // no-copy optimization
continue;
}
buf = jack_port_get_buffer (port, orig_nframes);
@@ -1587,7 +1587,7 @@ JackAlsaDriver::alsa_driver_read (alsa_driver_t *driver, jack_nframes_t nframes)
if ((err = snd_pcm_mmap_commit (driver->capture_handle,
offset, contiguous)) < 0) {
-
+
jack_error ("ALSA: could not complete read of %"
PRIu32 " frames: error = %d\n", contiguous, err);
return -1;
@@ -1715,7 +1715,7 @@ JackAlsaDriver::alsa_driver_write (alsa_driver_t* driver, jack_nframes_t nframes
}
monbuf = jack_port_get_buffer (port, orig_nframes);
memcpy (monbuf + nwritten, buf + nwritten, contiguous * sizeof(jack_default_audio_sample_t));
- mon_node = jack_slist_next (mon_node);
+ mon_node = jack_slist_next (mon_node);
}
}
*/
@@ -1729,7 +1729,7 @@ JackAlsaDriver::alsa_driver_write (alsa_driver_t* driver, jack_nframes_t nframes
offset, contiguous)) < 0) {
jack_error ("ALSA: could not complete playback of %"
PRIu32 " frames: error = %d", contiguous, err);
- if (err != EPIPE && err != ESTRPIPE)
+ if (err != -EPIPE && err != -ESTRPIPE)
return -1;
}
@@ -1752,11 +1752,11 @@ JackAlsaDriver::alsa_driver_delete (alsa_driver_t *driver)
free (node->data);
}
jack_slist_free (driver->clock_sync_listeners);
-
+
if (driver->ctl_handle) {
snd_ctl_close (driver->ctl_handle);
driver->ctl_handle = 0;
- }
+ }
if (driver->capture_handle) {
snd_pcm_close (driver->capture_handle);
@@ -1834,14 +1834,14 @@ JackAlsaDriver::alsa_driver_new (const char *name, char *playback_alsa_device,
jack_info ("creating alsa driver ... %s|%s|%" PRIu32 "|%" PRIu32
"|%" PRIu32"|%" PRIu32"|%" PRIu32 "|%s|%s|%s|%s",
playing ? playback_alsa_device : "-",
- capturing ? capture_alsa_device : "-",
+ capturing ? capture_alsa_device : "-",
frames_per_cycle, user_nperiods, rate,
user_capture_nchnls,user_playback_nchnls,
hw_monitoring ? "hwmon": "nomon",
hw_metering ? "hwmeter":"swmeter",
soft_mode ? "soft-mode":"-",
shorts_first ? "16bit":"32bit");
-
+
driver = (alsa_driver_t *) calloc (1, sizeof (alsa_driver_t));
jack_driver_nt_init ((jack_driver_nt_t *) driver);
@@ -1875,8 +1875,8 @@ JackAlsaDriver::alsa_driver_new (const char *name, char *playback_alsa_device,
driver->playback_addr = 0;
driver->capture_addr = 0;
- driver->playback_interleave_skip = NULL;
- driver->capture_interleave_skip = NULL;
+ driver->playback_interleave_skip = NULL;
+ driver->capture_interleave_skip = NULL;
driver->silent = 0;
driver->all_monitor_in = FALSE;
@@ -2164,7 +2164,7 @@ int JackAlsaDriver::Detach()
return JackAudioDriver::Detach();
}
-static int card_to_num(const char* device)
+static int card_to_num(const char* device)
{
int err;
char* ctl_name;
@@ -2329,13 +2329,13 @@ int JackAlsaDriver::Read()
retry:
nframes = alsa_driver_wait((alsa_driver_t *)fDriver, -1, &wait_status, &fDelayedUsecs);
-
+
if (wait_status < 0)
return -1; /* driver failed */
if (nframes == 0) {
/* we detected an xrun and restarted: notify
- * clients about the delay.
+ * clients about the delay.
*/
jack_log("ALSA XRun wait_status = %d", wait_status);
NotifyXRun(fBeginDateUst, fDelayedUsecs);
@@ -2344,7 +2344,7 @@ retry:
if (nframes != fEngineControl->fBufferSize)
jack_log("JackAlsaDriver::Read warning nframes = %ld", nframes);
-
+
// Has to be done before read
JackDriver::CycleIncTime();
@@ -2632,7 +2632,7 @@ get_dither_constraint()
}
static int
-dither_opt (char c, DitherAlgorithm* dither)
+dither_opt (char c, DitherAlgorithm* dither)
{
switch (c) {
case '-':
@@ -2659,17 +2659,17 @@ dither_opt (char c, DitherAlgorithm* dither)
return 0;
}
-SERVER_EXPORT const jack_driver_desc_t* driver_get_descriptor ()
+SERVER_EXPORT const jack_driver_desc_t* driver_get_descriptor ()
{
jack_driver_desc_t * desc;
jack_driver_param_desc_t * params;
unsigned int i;
desc = (jack_driver_desc_t*)calloc (1, sizeof (jack_driver_desc_t));
-
+
strcpy(desc->name, "alsa"); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy(desc->desc, "Linux ALSA API based audio backend"); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
-
+
desc->nparams = 18;
params = (jack_driver_param_desc_t*)calloc (desc->nparams, sizeof (jack_driver_param_desc_t));
@@ -2838,7 +2838,7 @@ SERVER_EXPORT const jack_driver_desc_t* driver_get_descriptor ()
return desc;
}
-SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params)
+SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLockedEngine* engine, Jack::JackSynchro* table, const JSList* params)
{
jack_nframes_t srate = 48000;
jack_nframes_t frames_per_interrupt = 1024;
diff --git a/linux/alsa/usx2y.c b/linux/alsa/usx2y.c
index 92236925..a6b696dd 100644
--- a/linux/alsa/usx2y.c
+++ b/linux/alsa/usx2y.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2001 Paul Davis
+ Copyright (C) 2001 Paul Davis
Copyright (C) 2005 Karsten Wiese, Rui Nuno Capela
This program is free software; you can redistribute it and/or modify
@@ -33,14 +33,14 @@
int dbg_offset;
char dbg_buffer[8096];
#endif
-static
+static
int usx2y_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask)
{
return -1;
}
static
-int usx2y_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
+int usx2y_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode)
{
return -1;
}
@@ -52,7 +52,7 @@ usx2y_release (jack_hardware_t *hw)
if (h == 0)
return;
-
+
if (h->hwdep_handle)
snd_hwdep_close(h->hwdep_handle);
@@ -622,7 +622,7 @@ usx2y_driver_write (alsa_driver_t* driver, jack_nframes_t nframes)
offset, nframes_)) < 0) {
jack_error ("ALSA/USX2Y: could not complete playback of %"
PRIu32 " frames: error = %d", nframes_, err);
- if (err != EPIPE && err != ESTRPIPE)
+ if (err != -EPIPE && err != -ESTRPIPE)
return -1;
}
diff --git a/posix/JackSocketServerChannel.cpp b/posix/JackSocketServerChannel.cpp
index e9176230..c3741d55 100644
--- a/posix/JackSocketServerChannel.cpp
+++ b/posix/JackSocketServerChannel.cpp
@@ -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.
*/
@@ -51,7 +51,7 @@ JackSocketServerChannel::~JackSocketServerChannel()
int JackSocketServerChannel::Open(const char* server_name, JackServer* server)
{
jack_log("JackSocketServerChannel::Open");
-
+
// Prepare request socket
if (fRequestListenSocket.Bind(jack_server_dir, server_name, 0) < 0) {
jack_log("JackSocketServerChannel::Open : cannot create result listen socket");
@@ -79,14 +79,14 @@ void JackSocketServerChannel::Close()
delete socket;
}
}
-
+
int JackSocketServerChannel::Start()
{
if (fThread.Start() != 0) {
jack_error("Cannot start Jack server listener");
return -1;
- }
-
+ }
+
return 0;
}
@@ -168,6 +168,12 @@ bool JackSocketServerChannel::HandleRequest(int fd)
return false;
}
+ if (fd == JackServerGlobals::fRTNotificationSocket && header.fType != JackRequest::kNotification) {
+ jack_error("fRTNotificationSocket = %d", JackServerGlobals::fRTNotificationSocket);
+ jack_error("JackSocketServerChannel::HandleRequest : incorrect notification !!");
+ return true;
+ }
+
// Read data
switch (header.fType) {
@@ -292,7 +298,7 @@ bool JackSocketServerChannel::HandleRequest(int fd)
jack_error("JackRequest::DisconnectPorts write error ref = %d", req.fRefNum);
break;
}
-
+
case JackRequest::kPortRename: {
jack_log("JackRequest::PortRename");
JackPortRenameRequest req;
@@ -470,7 +476,7 @@ bool JackSocketServerChannel::HandleRequest(int fd)
jack_error("Unknown request %ld", header.fType);
break;
}
-
+
return true;
}
@@ -511,7 +517,7 @@ bool JackSocketServerChannel::Init()
bool JackSocketServerChannel::Execute()
{
try {
-
+
// Global poll
if ((poll(fPollTable, fSocketTable.size() + 1, 10000) < 0) && (errno != EINTR)) {
jack_error("Engine poll failed err = %s request thread quits...", strerror(errno));
@@ -526,22 +532,22 @@ bool JackSocketServerChannel::Execute()
jack_log("Poll client error err = %s", strerror(errno));
ClientKill(fd);
} else if (fPollTable[i].revents & POLLIN) {
- if (!HandleRequest(fd))
+ if (!HandleRequest(fd))
jack_log("Could not handle external client request");
}
}
// Check the server request socket */
- if (fPollTable[0].revents & POLLERR)
+ if (fPollTable[0].revents & POLLERR)
jack_error("Error on server request socket err = %s", strerror(errno));
-
- if (fPollTable[0].revents & POLLIN)
+
+ if (fPollTable[0].revents & POLLIN)
ClientCreate();
}
BuildPoolTable();
return true;
-
+
} catch (JackQuitException& e) {
jack_log("JackMachServerChannel::Execute JackQuitException");
return false;
diff --git a/posix/JackSocketServerNotifyChannel.cpp b/posix/JackSocketServerNotifyChannel.cpp
index df7381f1..c9d25509 100644
--- a/posix/JackSocketServerNotifyChannel.cpp
+++ b/posix/JackSocketServerNotifyChannel.cpp
@@ -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 "JackRequest.h"
#include "JackConstants.h"
#include "JackNotification.h"
+#include "JackServerGlobals.h"
namespace Jack
{
@@ -33,6 +34,7 @@ int JackSocketServerNotifyChannel::Open(const char* server_name)
return -1;
} else {
fRequestSocket.SetNonBlocking(true);
+ JackServerGlobals::fRTNotificationSocket = fRequestSocket.GetFd();
return 0;
}
}
@@ -63,7 +65,7 @@ void JackSocketServerNotifyChannel::NotifyQuit()
jack_error("Could not write request ref = %d notify = %d", -1, kQUIT);
}
}
-
+
} // end of namespace
diff --git a/posix/JackSocketServerNotifyChannel.h b/posix/JackSocketServerNotifyChannel.h
index 261ddbd4..31008164 100644
--- a/posix/JackSocketServerNotifyChannel.h
+++ b/posix/JackSocketServerNotifyChannel.h
@@ -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.
*/