Browse Source

Offline/freewheel callback for our fake libjack

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc1
falkTX 6 years ago
parent
commit
fabfb7f312
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 33 additions and 14 deletions
  1. +24
    -9
      source/libjack/libjack.cpp
  2. +9
    -5
      source/utils/CarlaMutex.hpp

+ 24
- 9
source/libjack/libjack.cpp View File

@@ -512,7 +512,8 @@ bool CarlaJackAppClient::handleRtData()
JackClientState* const jclient(it.getValue(nullptr)); JackClientState* const jclient(it.getValue(nullptr));
CARLA_SAFE_ASSERT_CONTINUE(jclient != nullptr); CARLA_SAFE_ASSERT_CONTINUE(jclient != nullptr);


jclient->bufferSizeCb(fServer.bufferSize, jclient->bufferSizeCbPtr);
if (jclient->bufferSizeCb != nullptr)
jclient->bufferSizeCb(fServer.bufferSize, jclient->bufferSizeCbPtr);
} }


delete[] fAudioTmpBuf; delete[] fAudioTmpBuf;
@@ -536,16 +537,31 @@ bool CarlaJackAppClient::handleRtData()
JackClientState* const jclient(it.getValue(nullptr)); JackClientState* const jclient(it.getValue(nullptr));
CARLA_SAFE_ASSERT_CONTINUE(jclient != nullptr); CARLA_SAFE_ASSERT_CONTINUE(jclient != nullptr);


jclient->sampleRateCb(static_cast<uint32_t>(fServer.sampleRate), jclient->sampleRateCbPtr);
if (jclient->sampleRateCb != nullptr)
jclient->sampleRateCb(static_cast<uint32_t>(fServer.sampleRate), jclient->sampleRateCbPtr);
} }
} }
} break; } break;


case kPluginBridgeRtClientSetOnline:
// TODO inform changes
fIsOffline = fShmRtClientControl.readBool();
//offlineModeChanged(fIsOffline);
break;
case kPluginBridgeRtClientSetOnline: {
const bool offline = fShmRtClientControl.readBool();

if (fIsOffline != offline)
{
const CarlaMutexLocker cml(fRealtimeThreadMutex);

fIsOffline = offline;

for (LinkedList<JackClientState*>::Itenerator it = fClients.begin2(); it.valid(); it.next())
{
JackClientState* const jclient(it.getValue(nullptr));
CARLA_SAFE_ASSERT_CONTINUE(jclient != nullptr);

if (jclient->freewheelCb != nullptr)
jclient->freewheelCb(offline ? 1 : 0, jclient->freewheelCbPtr);
}
}
} break;


case kPluginBridgeRtClientControlEventParameter: case kPluginBridgeRtClientControlEventParameter:
case kPluginBridgeRtClientControlEventMidiBank: case kPluginBridgeRtClientControlEventMidiBank:
@@ -593,8 +609,7 @@ bool CarlaJackAppClient::handleRtData()


// TODO tell client of xrun in case buffersize does not match // TODO tell client of xrun in case buffersize does not match


// FIXME - lock if offline
const CarlaMutexTryLocker cmtl(fRealtimeThreadMutex);
const CarlaMutexTryLocker cmtl(fRealtimeThreadMutex, fIsOffline);


if (cmtl.wasLocked()) if (cmtl.wasLocked())
{ {


+ 9
- 5
source/utils/CarlaMutex.hpp View File

@@ -66,9 +66,9 @@ public:
/* /*
* Lock the mutex. * Lock the mutex.
*/ */
void lock() const noexcept
bool lock() const noexcept
{ {
pthread_mutex_lock(&fMutex);
return (pthread_mutex_lock(&fMutex) == 0);
} }


/* /*
@@ -143,12 +143,12 @@ public:
/* /*
* Lock the mutex. * Lock the mutex.
*/ */
void lock() const noexcept
bool lock() const noexcept
{ {
#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
EnterCriticalSection(&fSection);
return (EnterCriticalSection(&fSection) != FALSE);
#else #else
pthread_mutex_lock(&fMutex);
return (pthread_mutex_lock(&fMutex) == 0);
#endif #endif
} }


@@ -304,6 +304,10 @@ public:
: fMutex(mutex), : fMutex(mutex),
fLocked(mutex.tryLock()) {} fLocked(mutex.tryLock()) {}


CarlaScopeTryLocker(const Mutex& mutex, const bool forceLock) noexcept
: fMutex(mutex),
fLocked(forceLock ? mutex.lock() : mutex.tryLock()) {}

~CarlaScopeTryLocker() noexcept ~CarlaScopeTryLocker() noexcept
{ {
if (fLocked) if (fLocked)


Loading…
Cancel
Save