Commit 8146837a authored by sletz's avatar sletz
Browse files

First working version of native MIDI backend (JackCoreMidiDriver, JackWinMMEDriver).

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3526 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 573a0f16
......@@ -25,6 +25,10 @@ Paul Davis
Jackdmp changes log
---------------------------
2009-05-05 Stephane Letz <letz@grame.fr>
* First working version of native MIDI backend (JackCoreMidiDriver, JackWinMMEDriver).
2009-04-22 Stephane Letz <letz@grame.fr>
* jackctl_server_load_master renamed to jackctl_server_switch_master, jackctl_server_unload_master is removed.
......
......@@ -118,14 +118,13 @@ void JackClient::SetupDriverSync(bool freewheel)
{
if (!freewheel && !GetEngineControl()->fSyncMode) {
jack_log("JackClient::SetupDriverSync driver sem in flush mode");
fSynchroTable[AUDIO_DRIVER_REFNUM].SetFlush(true);
fSynchroTable[FREEWHEEL_DRIVER_REFNUM].SetFlush(true);
fSynchroTable[MIDI_DRIVER_REFNUM].SetFlush(true);
for (int i = 0; i < GetEngineControl()->fDriverNum; i++) {
fSynchroTable[i].SetFlush(true);
}
} else {
jack_log("JackClient::SetupDriverSync driver sem in normal mode");
fSynchroTable[AUDIO_DRIVER_REFNUM].SetFlush(false);
fSynchroTable[FREEWHEEL_DRIVER_REFNUM].SetFlush(false);
fSynchroTable[MIDI_DRIVER_REFNUM].SetFlush(false);
for (int i = 0; i < GetEngineControl()->fDriverNum; i++)
fSynchroTable[i].SetFlush(false);
}
}
......
......@@ -17,11 +17,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <iostream>
#include <assert.h>
#include "JackConnectionManager.h"
#include "JackClientControl.h"
#include "JackEngineControl.h"
#include "JackGlobals.h"
#include "JackError.h"
#include <iostream>
#include <assert.h>
namespace Jack
{
......@@ -54,12 +56,15 @@ bool JackConnectionManager::IsLoopPathAux(int ref1, int ref2) const
{
jack_log("JackConnectionManager::IsLoopPathAux ref1 = %ld ref2 = %ld", ref1, ref2);
/*
if (ref1 == AUDIO_DRIVER_REFNUM // Driver is reached
|| ref2 == AUDIO_DRIVER_REFNUM
|| ref1 == FREEWHEEL_DRIVER_REFNUM
|| ref2 == FREEWHEEL_DRIVER_REFNUM
|| ref1 == MIDI_DRIVER_REFNUM
|| ref2 == MIDI_DRIVER_REFNUM) {
*/
if (ref1 < GetEngineControl()->fDriverNum || ref2 < GetEngineControl()->fDriverNum) {
return false;
} else if (ref1 == ref2) { // Same refnum
return true;
......
......@@ -49,8 +49,6 @@
#define AUDIO_DRIVER_REFNUM 0 // Audio driver is initialized first, it will get the refnum 0
#define FREEWHEEL_DRIVER_REFNUM 1 // Freewheel driver is initialized second, it will get the refnum 1
#define MIDI_DRIVER_REFNUM 2 // Loopback driver is initialized third, it will get the refnum 2
#define REAL_REFNUM MIDI_DRIVER_REFNUM + 1 // Real clients start at MIDI_DRIVER_REFNUM + 1
#define JACK_DEFAULT_SERVER_NAME "default"
......
......@@ -47,7 +47,7 @@ JackDriver::JackDriver(const char* name, const char* alias, JackLockedEngine* en
fBeginDateUst = 0;
fDelayedUsecs = 0.f;
fIsMaster = true;
}
}
JackDriver::JackDriver()
{
......@@ -74,6 +74,7 @@ int JackDriver::Open()
fClientControl.fRefNum = refnum;
fClientControl.fActive = true;
fEngineControl->fDriverNum++;
fGraphManager->DirectConnect(fClientControl.fRefNum, fClientControl.fRefNum); // Connect driver to itself for "sync" mode
SetupDriverSync(fClientControl.fRefNum, false);
return 0;
......@@ -100,6 +101,7 @@ int JackDriver::Open (bool capturing,
fClientControl.fRefNum = refnum;
fClientControl.fActive = true;
fEngineControl->fDriverNum++;
fCaptureLatency = capture_latency;
fPlaybackLatency = playback_latency;
......@@ -113,7 +115,6 @@ int JackDriver::Open (bool capturing,
if (!fEngineControl->fTimeOut)
fEngineControl->fTimeOutUsecs = jack_time_t(2.f * fEngineControl->fPeriodUsecs);
//fGraphManager->SetBufferSize(fEngineControl->fBufferSize);
fGraphManager->DirectConnect(fClientControl.fRefNum, fClientControl.fRefNum); // Connect driver to itself for "sync" mode
SetupDriverSync(fClientControl.fRefNum, false);
return 0;
......@@ -142,6 +143,7 @@ int JackDriver::Open(jack_nframes_t buffer_size,
fClientControl.fRefNum = refnum;
fClientControl.fActive = true;
fEngineControl->fDriverNum++;
fEngineControl->fBufferSize = buffer_size;
fEngineControl->fSampleRate = samplerate;
fCaptureLatency = capture_latency;
......@@ -168,6 +170,7 @@ int JackDriver::Close()
jack_log("JackDriver::Close");
fGraphManager->DirectDisconnect(fClientControl.fRefNum, fClientControl.fRefNum); // Disconnect driver from itself for sync
fClientControl.fActive = false;
fEngineControl->fDriverNum--;
return fEngine->ClientInternalClose(fClientControl.fRefNum, false);
}
......
......@@ -27,6 +27,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackInternalClient.h"
#include "JackEngineControl.h"
#include "JackClientControl.h"
#include "JackServerGlobals.h"
#include "JackGlobals.h"
#include "JackChannel.h"
#include "JackError.h"
......@@ -71,7 +72,7 @@ int JackEngine::Close()
fChannel.Close();
// Close remaining clients (RT is stopped)
for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
for (int i = fEngineControl->fDriverNum; i < CLIENT_NUM; i++) {
if (JackLoadableInternalClient* loadable_client = dynamic_cast<JackLoadableInternalClient*>(fClientTable[i])) {
jack_log("JackEngine::Close loadable client = %s", loadable_client->GetClientControl()->fName);
loadable_client->Close();
......@@ -110,7 +111,7 @@ void JackEngine::ReleaseRefnum(int ref)
if (fEngineControl->fTemporary) {
int i;
for (i = REAL_REFNUM; i < CLIENT_NUM; i++) {
for (i = fEngineControl->fDriverNum; i < CLIENT_NUM; i++) {
if (fClientTable[i])
break;
}
......@@ -180,7 +181,7 @@ correctly mixed in the time window: callbackUsecs <==> Read <==> Write.
void JackEngine::CheckXRun(jack_time_t callback_usecs) // REVOIR les conditions de fin
{
for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
for (int i = fEngineControl->fDriverNum; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (client && client->GetClientControl()->fActive) {
JackClientTiming* timing = fGraphManager->GetClientTiming(i);
......
......@@ -44,7 +44,7 @@ void JackEngineControl::CalcCPULoad(JackClientInterface** table,
// In Asynchronous mode, last cycle end is the max of client end dates
if (!fSyncMode) {
for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
for (int i = fDriverNum; i < CLIENT_NUM; i++) {
JackClientInterface* client = table[i];
JackClientTiming* timing = manager->GetClientTiming(i);
if (client && client->GetClientControl()->fActive && timing->fStatus == Finished)
......
......@@ -64,6 +64,7 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem
char fServerName[64];
JackTransportEngine fTransport;
jack_timer_type_t fClockSource;
int fDriverNum;
bool fVerbose;
// CPU Load
......@@ -115,7 +116,8 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem
fMaxDelayedUsecs = 0.f;
fXrunDelayedUsecs = 0.f;
fClockSource = clock;
}
fDriverNum = 0;
}
~JackEngineControl()
{}
......
......@@ -20,7 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackEngineProfiling.h"
#include "JackGraphManager.h"
#include "JackClientControl.h"
#include "JackEngineControl.h"
#include "JackClientInterface.h"
#include "JackGlobals.h"
#include "JackTime.h"
namespace Jack
......@@ -312,7 +314,7 @@ void JackEngineProfiling::Profile(JackClientInterface** table,
fProfileTable[fAudioCycle].fPrevCycleEnd = prev_cycle_end;
fProfileTable[fAudioCycle].fAudioCycle = fAudioCycle;
for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
for (int i = GetEngineControl()->fDriverNum; i < CLIENT_NUM; i++) {
JackClientInterface* client = table[i];
JackClientTiming* timing = manager->GetClientTiming(i);
if (client && client->GetClientControl()->fActive && client->GetClientControl()->fCallback[kRealTimeCallback]) {
......
......@@ -51,7 +51,6 @@ JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long pr
fEngineControl = new JackEngineControl(sync, temporary, timeout, rt, priority, verbose, clock, server_name);
fEngine = new JackLockedEngine(fGraphManager, GetSynchroTable(), fEngineControl);
fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver(fEngine, GetSynchroTable()));
fLoopbackDriver = new JackLoopbackDriver(fEngine, GetSynchroTable());
fDriverInfo = new JackDriverInfo();
fAudioDriver = NULL;
fFreewheel = false;
......@@ -67,7 +66,6 @@ JackServer::~JackServer()
delete fAudioDriver;
delete fDriverInfo;
delete fFreewheelDriver;
delete fLoopbackDriver;
delete fEngine;
delete fEngineControl;
}
......@@ -96,37 +94,19 @@ int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params)
jack_error("Cannot open driver");
goto fail_close4;
}
if (fLoopbackDriver->Open(fEngineControl->fBufferSize, fEngineControl->fSampleRate, 1, 1, fLoopback, fLoopback, false, "loopback", "loopback", 0, 0) != 0) {
jack_error("Cannot open driver");
goto fail_close5;
}
if (fAudioDriver->Attach() != 0) {
jack_error("Cannot attach audio driver");
goto fail_close6;
goto fail_close5;
}
if (fLoopback > 0 && fLoopbackDriver->Attach() != 0) {
jack_error("Cannot attach loopback driver");
goto fail_close7;
}
fFreewheelDriver->SetMaster(false);
fAudioDriver->SetMaster(true);
if (fLoopback > 0)
fAudioDriver->AddSlave(fLoopbackDriver);
fAudioDriver->AddSlave(fFreewheelDriver); // After ???
InitTime();
SetClockSource(fEngineControl->fClockSource);
return 0;
fail_close7:
fAudioDriver->Detach();
fail_close6:
fLoopbackDriver->Close();
fail_close5:
fFreewheelDriver->Close();
......@@ -149,11 +129,8 @@ int JackServer::Close()
jack_log("JackServer::Close");
fChannel.Close();
fAudioDriver->Detach();
if (fLoopback > 0)
fLoopbackDriver->Detach();
fAudioDriver->Close();
fFreewheelDriver->Close();
fLoopbackDriver->Close();
fEngine->Close();
// TODO: move that in reworked JackServerGlobals::Destroy()
JackMessageBuffer::Destroy();
......
......@@ -50,7 +50,6 @@ class SERVER_EXPORT JackServer
JackDriverInfo* fDriverInfo;
JackDriverClientInterface* fAudioDriver;
JackDriverClientInterface* fFreewheelDriver;
JackDriverClientInterface* fLoopbackDriver;
JackLockedEngine* fEngine;
JackEngineControl* fEngineControl;
JackGraphManager* fGraphManager;
......
......@@ -22,8 +22,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "driver_interface.h"
#include "JackDriverLoader.h"
#include "JackCompilerDeps.h"
#include "JackServer.h"
#include <assert.h>
namespace Jack
{
......
......@@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackTransportEngine.h"
#include "JackClientInterface.h"
#include "JackClientControl.h"
#include "JackEngineControl.h"
#include "JackGlobals.h"
#include "JackError.h"
#include "JackTime.h"
#include <assert.h>
......@@ -89,7 +91,7 @@ int JackTransportEngine::SetTimebaseMaster(int refnum, bool conditionnal)
// RT
bool JackTransportEngine::CheckAllRolling(JackClientInterface** table)
{
for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
for (int i = GetEngineControl()->fDriverNum; i < CLIENT_NUM; i++) {
JackClientInterface* client = table[i];
if (client && client->GetClientControl()->fTransportState != JackTransportRolling) {
jack_log("CheckAllRolling ref = %ld is not rolling", i);
......@@ -103,7 +105,7 @@ bool JackTransportEngine::CheckAllRolling(JackClientInterface** table)
// RT
void JackTransportEngine::MakeAllStartingLocating(JackClientInterface** table)
{
for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
for (int i = GetEngineControl()->fDriverNum; i < CLIENT_NUM; i++) {
JackClientInterface* client = table[i];
if (client) {
JackClientControl* control = client->GetClientControl();
......@@ -119,7 +121,7 @@ void JackTransportEngine::MakeAllStartingLocating(JackClientInterface** table)
// RT
void JackTransportEngine::MakeAllStopping(JackClientInterface** table)
{
for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
for (int i = GetEngineControl()->fDriverNum; i < CLIENT_NUM; i++) {
JackClientInterface* client = table[i];
if (client) {
JackClientControl* control = client->GetClientControl();
......@@ -134,7 +136,7 @@ void JackTransportEngine::MakeAllStopping(JackClientInterface** table)
// RT
void JackTransportEngine::MakeAllLocating(JackClientInterface** table)
{
for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
for (int i = GetEngineControl()->fDriverNum; i < CLIENT_NUM; i++) {
JackClientInterface* client = table[i];
if (client) {
JackClientControl* control = client->GetClientControl();
......
......@@ -406,7 +406,6 @@ int main(int argc, char* argv[])
goto fail_free;
}
/*
// MIDI driver
if (seen_midi_driver) {
......@@ -418,7 +417,6 @@ int main(int argc, char* argv[])
jackctl_server_add_slave(server_ctl, midi_driver_ctl);
}
*/
notify_server_start(server_name);
......
......@@ -511,10 +511,10 @@ jack_log(
/* @} */
/**
* Call this function to add a slave in the backend slave list.
* Call this function to add a slave in the driver slave list.
*
* @param server server object handle
* @param driver driver to add in the backend slave list.
* @param driver driver to add in the driver slave list.
*
* @return success status: true - success, false - fail
*/
......@@ -523,10 +523,10 @@ jackctl_server_add_slave(jackctl_server_t * server,
jackctl_driver_t * driver);
/**
* Call this function to remove a slave from the backend slave list.
* Call this function to remove a slave from the driver slave list.
*
* @param server server object handle
* @param driver driver to remove from the backend slave list.
* @param driver driver to remove from the driver slave list.
*
* @return success status: true - success, false - fail
*/
......@@ -535,7 +535,7 @@ jackctl_server_remove_slave(jackctl_server_t * server,
jackctl_driver_t * driver);
/**
* Call this function to switch master backend.
* Call this function to switch master driver.
*
* @param server server object handle
* @param driver driver to switch to
......
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