Commit a5096190 authored by sletz's avatar sletz
Browse files

Add a fNetworkSync state in JackTransportEngine used in network.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2797 0c269be4-1314-0410-8aa9-9f06e86f4224
parent b38a30bc
......@@ -25,6 +25,7 @@ Florian Faber
2008-08-22 Stephane Letz <letz@grame.fr>
* Move GetCurrentTransportFrame code from JackClient to JackTransportEngine.
* Add a fNetworkSync state in JackTransportEngine used in network.
2008-08-03 Stephane Letz <letz@grame.fr>
......
......@@ -45,6 +45,7 @@ JackTransportEngine::JackTransportEngine(): JackAtomicArrayState<jack_position_t
fTimeBaseMaster = -1;
fWriteCounter = 0;
fPendingPos = false;
fNetworkSync = false;
}
// compute the number of cycle for timeout
......@@ -196,8 +197,13 @@ void JackTransportEngine::CycleEnd(JackClientInterface** table, jack_nframes_t f
MakeAllStartingLocating(table);
SyncTimeout(frame_rate, buffer_size);
} else if (--fSyncTimeLeft == 0 || CheckAllRolling(table)) { // Slow clients may still catch up
jack_log("transport starting ==> rolling fSyncTimeLeft = %ld", fSyncTimeLeft);
fTransportState = JackTransportRolling;
if (fNetworkSync) {
jack_log("transport starting ==> netstarting");
fTransportState = JackTransportNetStarting;
} else {
jack_log("transport starting ==> rolling fSyncTimeLeft = %ld", fSyncTimeLeft);
fTransportState = JackTransportRolling;
}
}
break;
......
......@@ -101,6 +101,7 @@ class EXPORT JackTransportEngine : public JackAtomicArrayState<jack_position_t>
int fSyncTimeLeft;
int fTimeBaseMaster;
bool fPendingPos;
bool fNetworkSync;
SInt32 fWriteCounter;
bool CheckAllRolling(JackClientInterface** table);
......@@ -126,6 +127,11 @@ class EXPORT JackTransportEngine : public JackAtomicArrayState<jack_position_t>
{
return fTransportState;
}
void GetState(jack_transport_state_t state)
{
fTransportState = state;
}
int GetTimebaseMaster() const
{
......@@ -174,6 +180,16 @@ class EXPORT JackTransportEngine : public JackAtomicArrayState<jack_position_t>
jack_nframes_t GetCurrentFrame();
static void CopyPosition(jack_position_t* from, jack_position_t* to);
bool GetNetworkSync() const
{
return fNetworkSync;
}
void SetNetworkSync(bool sync)
{
fNetworkSync = sync;
}
};
......
......@@ -437,10 +437,11 @@ typedef enum JackStatus jack_status_t;
typedef enum {
/* the order matters for binary compatibility */
JackTransportStopped = 0, /**< Transport halted */
JackTransportRolling = 1, /**< Transport playing */
JackTransportLooping = 2, /**< For OLD_TRANSPORT, now ignored */
JackTransportStarting = 3, /**< Waiting for sync ready */
JackTransportStopped = 0, /**< Transport halted */
JackTransportRolling = 1, /**< Transport playing */
JackTransportLooping = 2, /**< For OLD_TRANSPORT, now ignored */
JackTransportStarting = 3, /**< Waiting for sync ready */
JackTransportNetStarting = 4, /**< Waiting for sync ready on the network*/
} jack_transport_state_t;
......
......@@ -363,8 +363,8 @@ int JackCoreAudioAdapter::SetupBuffers(int inchannels, int outchannels)
fInputData->mNumberBuffers = inchannels;
for (int i = 0; i < fCaptureChannels; i++) {
fInputData->mBuffers[i].mNumberChannels = 1;
fInputData->mBuffers[i].mDataByteSize = fBufferSize * sizeof(float);
fInputData->mBuffers[i].mData = malloc(fBufferSize * sizeof(float));
fInputData->mBuffers[i].mDataByteSize = fAdaptedBufferSize * sizeof(float);
fInputData->mBuffers[i].mData = malloc(fAdaptedBufferSize * sizeof(float));
}
return 0;
}
......@@ -575,10 +575,10 @@ int JackCoreAudioAdapter::Open()
if (SetupChannels(true, true, fCaptureChannels, fPlaybackChannels, in_nChannels, out_nChannels, true) < 0)
return -1;
if (SetupBufferSizeAndSampleRate(fBufferSize, fSampleRate) < 0)
if (SetupBufferSizeAndSampleRate(fAdaptedBufferSize, fAdaptedSampleRate) < 0)
return -1;
if (OpenAUHAL(true, true, fCaptureChannels, fPlaybackChannels, in_nChannels, out_nChannels, fBufferSize, fSampleRate, true) < 0)
if (OpenAUHAL(true, true, fCaptureChannels, fPlaybackChannels, in_nChannels, out_nChannels, fAdaptedBufferSize, fAdaptedSampleRate, true) < 0)
goto error;
if (SetupBuffers(fCaptureChannels, fPlaybackChannels) < 0)
......
......@@ -489,6 +489,9 @@ static void display_transport_state()
case JackTransportStarting:
Log("Transport is starting...\n");
break;
case JackTransportNetStarting:
Log("Transport is starting with network sync...\n");
break;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment