git-svn-id: http://subversion.jackaudio.org/jack/jack2/branches/libjacknet@3955 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.9.8
@@ -212,13 +212,13 @@ namespace Jack | |||||
int GetInputs() | int GetInputs() | ||||
{ | { | ||||
jack_log ( "JackAudioAdapterInterface::GetInputs %d", fCaptureChannels ); | |||||
//jack_log("JackAudioAdapterInterface::GetInputs %d", fCaptureChannels); | |||||
return fCaptureChannels; | return fCaptureChannels; | ||||
} | } | ||||
int GetOutputs() | int GetOutputs() | ||||
{ | { | ||||
jack_log ( "JackAudioAdapterInterface::GetOutputs %d", fPlaybackChannels ); | |||||
//jack_log ("JackAudioAdapterInterface::GetOutputs %d", fPlaybackChannels); | |||||
return fPlaybackChannels; | return fPlaybackChannels; | ||||
} | } | ||||
@@ -214,6 +214,7 @@ struct JackNetExtMaster : public JackNetMasterInterface { | |||||
fprintf(stderr, "Can't init new net master...\n"); | fprintf(stderr, "Can't init new net master...\n"); | ||||
goto error; | goto error; | ||||
} | } | ||||
jack_info ( "Waiting for a slave..." ); | |||||
break; | break; | ||||
case KILL_MASTER: | case KILL_MASTER: | ||||
@@ -787,7 +788,7 @@ struct JackNetAdapter : public JackAudioAdapterInterface { | |||||
Destroy(); | Destroy(); | ||||
} | } | ||||
int Flush() | |||||
void Flush() | |||||
{ | { | ||||
for (int i = 0; i < fCaptureChannels; i++ ) { | for (int i = 0; i < fCaptureChannels; i++ ) { | ||||
fCaptureRingBuffer[i]->Reset(fRingbufferCurSize); | fCaptureRingBuffer[i]->Reset(fRingbufferCurSize); | ||||
@@ -881,14 +882,14 @@ SERVER_EXPORT int jack_net_master_close(jack_net_master_t* net) | |||||
} | } | ||||
SERVER_EXPORT int jack_net_master_recv(jack_net_master_t* net, int audio_input, float** audio_input_buffer, int midi_input, void** midi_input_buffer) | SERVER_EXPORT int jack_net_master_recv(jack_net_master_t* net, int audio_input, float** audio_input_buffer, int midi_input, void** midi_input_buffer) | ||||
{ | { | ||||
JackNetExtMaster* slave = (JackNetExtMaster*)net; | |||||
return slave->Read(audio_input, audio_input_buffer, midi_input, midi_input_buffer); | |||||
JackNetExtMaster* master = (JackNetExtMaster*)net; | |||||
return master->Read(audio_input, audio_input_buffer, midi_input, midi_input_buffer); | |||||
} | } | ||||
SERVER_EXPORT int jack_net_master_send(jack_net_master_t* net, int audio_output, float** audio_output_buffer, int midi_output, void** midi_output_buffer) | SERVER_EXPORT int jack_net_master_send(jack_net_master_t* net, int audio_output, float** audio_output_buffer, int midi_output, void** midi_output_buffer) | ||||
{ | { | ||||
JackNetExtMaster* slave = (JackNetExtMaster*)net; | |||||
return slave->Write(audio_output, audio_output_buffer, midi_output, midi_output_buffer); | |||||
JackNetExtMaster* master = (JackNetExtMaster*)net; | |||||
return master->Write(audio_output, audio_output_buffer, midi_output, midi_output_buffer); | |||||
} | } | ||||
// Adapter API | // Adapter API | ||||
@@ -117,18 +117,18 @@ namespace Jack | |||||
JackNetAdapter::~JackNetAdapter() | JackNetAdapter::~JackNetAdapter() | ||||
{ | { | ||||
jack_log ( "JackNetAdapter::~JackNetAdapter" ); | |||||
jack_log ("JackNetAdapter::~JackNetAdapter"); | |||||
int port_index; | int port_index; | ||||
if ( fSoftCaptureBuffer ) | |||||
if (fSoftCaptureBuffer) | |||||
{ | { | ||||
for ( port_index = 0; port_index < fCaptureChannels; port_index++ ) | |||||
for (port_index = 0; port_index < fCaptureChannels; port_index++) | |||||
delete[] fSoftCaptureBuffer[port_index]; | delete[] fSoftCaptureBuffer[port_index]; | ||||
delete[] fSoftCaptureBuffer; | delete[] fSoftCaptureBuffer; | ||||
} | } | ||||
if ( fSoftPlaybackBuffer ) | |||||
if (fSoftPlaybackBuffer) | |||||
{ | { | ||||
for ( port_index = 0; port_index < fPlaybackChannels; port_index++ ) | |||||
for ( port_index = 0; port_index < fPlaybackChannels; port_index++) | |||||
delete[] fSoftPlaybackBuffer[port_index]; | delete[] fSoftPlaybackBuffer[port_index]; | ||||
delete[] fSoftPlaybackBuffer; | delete[] fSoftPlaybackBuffer; | ||||
} | } | ||||
@@ -194,6 +194,8 @@ namespace Jack | |||||
} | } | ||||
//thread------------------------------------------------------------------------------ | //thread------------------------------------------------------------------------------ | ||||
// TODO : if failure, thread exist... need to restart ? | |||||
bool JackNetAdapter::Init() | bool JackNetAdapter::Init() | ||||
{ | { | ||||
jack_log ( "JackNetAdapter::Init" ); | jack_log ( "JackNetAdapter::Init" ); | ||||
@@ -201,11 +203,16 @@ namespace Jack | |||||
int port_index; | int port_index; | ||||
//init network connection | //init network connection | ||||
if ( !JackNetSlaveInterface::Init() ) | |||||
if (!JackNetSlaveInterface::Init()) { | |||||
jack_error("JackNetSlaveInterface::Init() error..." ); | |||||
return false; | return false; | ||||
} | |||||
//then set global parameters | //then set global parameters | ||||
SetParams(); | |||||
if (!SetParams()) { | |||||
jack_error("SetParams error..." ); | |||||
return false; | |||||
} | |||||
//set buffers | //set buffers | ||||
fSoftCaptureBuffer = new sample_t*[fCaptureChannels]; | fSoftCaptureBuffer = new sample_t*[fCaptureChannels]; | ||||
@@ -142,13 +142,17 @@ namespace Jack | |||||
( fParams.fSlaveSyncMode ) ? "sync" : "async", ( fParams.fTransportSync ) ? "with" : "without" ); | ( fParams.fSlaveSyncMode ) ? "sync" : "async", ( fParams.fTransportSync ) ? "with" : "without" ); | ||||
//init network | //init network | ||||
if (!JackNetSlaveInterface::Init()) | |||||
if (!JackNetSlaveInterface::Init()) { | |||||
jack_error("JackNetSlaveInterface::Init() error..." ); | |||||
return false; | return false; | ||||
} | |||||
//set global parameters | //set global parameters | ||||
if (!SetParams()) | |||||
if (!SetParams()) { | |||||
jack_error("SetParams error..." ); | |||||
return false; | return false; | ||||
} | |||||
//allocate midi ports lists | //allocate midi ports lists | ||||
fMidiCapturePortList = new jack_port_id_t [fParams.fSendMidiChannels]; | fMidiCapturePortList = new jack_port_id_t [fParams.fSendMidiChannels]; | ||||
fMidiPlaybackPortList = new jack_port_id_t [fParams.fReturnMidiChannels]; | fMidiPlaybackPortList = new jack_port_id_t [fParams.fReturnMidiChannels]; | ||||
@@ -67,9 +67,21 @@ namespace Jack | |||||
memset(&fReturnTransportData, 0, sizeof(net_transport_data_t)); | memset(&fReturnTransportData, 0, sizeof(net_transport_data_t)); | ||||
} | } | ||||
void JackNetInterface::FreeNetworkBuffers() | |||||
{ | |||||
delete fNetMidiCaptureBuffer; | |||||
delete fNetMidiPlaybackBuffer; | |||||
delete fNetAudioCaptureBuffer; | |||||
delete fNetAudioPlaybackBuffer; | |||||
fNetMidiCaptureBuffer = NULL; | |||||
fNetMidiPlaybackBuffer = NULL; | |||||
fNetAudioCaptureBuffer = NULL; | |||||
fNetAudioPlaybackBuffer = NULL; | |||||
} | |||||
JackNetInterface::~JackNetInterface() | JackNetInterface::~JackNetInterface() | ||||
{ | { | ||||
jack_log ( "JackNetInterface::~JackNetInterface" ); | |||||
jack_log ("JackNetInterface::~JackNetInterface"); | |||||
fSocket.Close(); | fSocket.Close(); | ||||
delete[] fTxBuffer; | delete[] fTxBuffer; | ||||
@@ -270,11 +282,7 @@ namespace Jack | |||||
return true; | return true; | ||||
error: | error: | ||||
delete fNetMidiCaptureBuffer; | |||||
delete fNetMidiPlaybackBuffer; | |||||
delete fNetAudioCaptureBuffer; | |||||
delete fNetAudioPlaybackBuffer; | |||||
FreeNetworkBuffers(); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -650,7 +658,7 @@ namespace Jack | |||||
return true; | return true; | ||||
} | } | ||||
net_status_t JackNetSlaveInterface::SendAvailableToMaster(int count) | |||||
net_status_t JackNetSlaveInterface::SendAvailableToMaster(long try_count) | |||||
{ | { | ||||
jack_log ( "JackNetSlaveInterface::SendAvailableToMaster()" ); | jack_log ( "JackNetSlaveInterface::SendAvailableToMaster()" ); | ||||
//utility | //utility | ||||
@@ -698,10 +706,11 @@ namespace Jack | |||||
return NET_RECV_ERROR; | return NET_RECV_ERROR; | ||||
} | } | ||||
} | } | ||||
while (strcmp(host_params.fPacketType, fParams.fPacketType) && (GetPacketType(&host_params) != SLAVE_SETUP) && (--count > 0)); | |||||
while (strcmp(host_params.fPacketType, fParams.fPacketType) && (GetPacketType(&host_params) != SLAVE_SETUP) && (--try_count > 0)); | |||||
// Time out failure.. | // Time out failure.. | ||||
if (count == 0) { | |||||
if (try_count == 0) { | |||||
jack_error("Time out error in connect"); | |||||
return NET_CONNECT_ERROR; | return NET_CONNECT_ERROR; | ||||
} | } | ||||
@@ -710,8 +719,8 @@ namespace Jack | |||||
fParams = host_params; | fParams = host_params; | ||||
//connect the socket | //connect the socket | ||||
if ( fSocket.Connect() == SOCKET_ERROR ) { | |||||
jack_error ( "Error in connect : %s", StrError ( NET_ERROR_CODE ) ); | |||||
if (fSocket.Connect() == SOCKET_ERROR) { | |||||
jack_error("Error in connect : %s", StrError(NET_ERROR_CODE)); | |||||
return NET_CONNECT_ERROR; | return NET_CONNECT_ERROR; | ||||
} | } | ||||
return NET_CONNECTED; | return NET_CONNECTED; | ||||
@@ -719,17 +728,17 @@ namespace Jack | |||||
net_status_t JackNetSlaveInterface::SendStartToMaster() | net_status_t JackNetSlaveInterface::SendStartToMaster() | ||||
{ | { | ||||
jack_log ( "JackNetSlaveInterface::SendStartToMaster" ); | |||||
jack_log("JackNetSlaveInterface::SendStartToMaster"); | |||||
//tell the master to start | //tell the master to start | ||||
session_params_t net_params; | session_params_t net_params; | ||||
memset(&net_params, 0, sizeof ( session_params_t )); | memset(&net_params, 0, sizeof ( session_params_t )); | ||||
SetPacketType ( &fParams, START_MASTER ); | SetPacketType ( &fParams, START_MASTER ); | ||||
SessionParamsHToN(&fParams, &net_params); | SessionParamsHToN(&fParams, &net_params); | ||||
if ( fSocket.Send ( &net_params, sizeof ( session_params_t ), 0 ) == SOCKET_ERROR ) | |||||
if (fSocket.Send(&net_params, sizeof(session_params_t), 0) == SOCKET_ERROR) | |||||
{ | { | ||||
jack_error ( "Error in send : %s", StrError ( NET_ERROR_CODE ) ); | |||||
return ( fSocket.GetError() == NET_CONN_ERROR ) ? NET_ERROR : NET_SEND_ERROR; | |||||
jack_error("Error in send : %s", StrError(NET_ERROR_CODE)); | |||||
return (fSocket.GetError() == NET_CONN_ERROR) ? NET_ERROR : NET_SEND_ERROR; | |||||
} | } | ||||
return NET_ROLLING; | return NET_ROLLING; | ||||
} | } | ||||
@@ -784,10 +793,7 @@ namespace Jack | |||||
return true; | return true; | ||||
error: | error: | ||||
delete fNetMidiCaptureBuffer; | |||||
delete fNetMidiPlaybackBuffer; | |||||
delete fNetAudioCaptureBuffer; | |||||
delete fNetAudioPlaybackBuffer; | |||||
FreeNetworkBuffers(); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -63,6 +63,7 @@ namespace Jack | |||||
//utility methods | //utility methods | ||||
int SetNetBufferSize(); | int SetNetBufferSize(); | ||||
void FreeNetworkBuffers(); | |||||
//virtual methods : depends on the sub class master/slave | //virtual methods : depends on the sub class master/slave | ||||
virtual bool SetParams(); | virtual bool SetParams(); | ||||
@@ -148,7 +149,7 @@ namespace Jack | |||||
bool InitConnection(int time_out); | bool InitConnection(int time_out); | ||||
bool InitRendering(); | bool InitRendering(); | ||||
net_status_t SendAvailableToMaster(int count = LONG_MAX); | |||||
net_status_t SendAvailableToMaster(long count = LONG_MAX); // long here (and not int...) | |||||
net_status_t SendStartToMaster(); | net_status_t SendStartToMaster(); | ||||
bool SetParams(); | bool SetParams(); | ||||
@@ -113,12 +113,16 @@ namespace Jack | |||||
bool JackNetMaster::Init(bool auto_connect) | bool JackNetMaster::Init(bool auto_connect) | ||||
{ | { | ||||
//network init | //network init | ||||
if (!JackNetMasterInterface::Init()) | |||||
if (!JackNetMasterInterface::Init()){ | |||||
jack_error("JackNetMasterInterface::Init() error..." ); | |||||
return false; | return false; | ||||
} | |||||
//set global parameters | //set global parameters | ||||
if (!SetParams()) | |||||
if (!SetParams()) { | |||||
jack_error("SetParams error..." ); | |||||
return false; | return false; | ||||
} | |||||
//jack client and process | //jack client and process | ||||
jack_status_t status; | jack_status_t status; | ||||
@@ -49,7 +49,6 @@ HardwareClock::HardwareClock() | |||||
mach_timebase_info_data_t info; | mach_timebase_info_data_t info; | ||||
mach_timebase_info(&info); | mach_timebase_info(&info); | ||||
m_clockToSeconds = (double)info.numer/info.denom/1000000000.0; | m_clockToSeconds = (double)info.numer/info.denom/1000000000.0; | ||||
Reset(); | Reset(); | ||||
} | } | ||||
@@ -57,7 +56,6 @@ void HardwareClock::Reset() | |||||
{ | { | ||||
m_startAbsTime = mach_absolute_time(); | m_startAbsTime = mach_absolute_time(); | ||||
m_lastAbsTime = m_startAbsTime; | m_lastAbsTime = m_startAbsTime; | ||||
m_time = m_startAbsTime*m_clockToSeconds; | m_time = m_startAbsTime*m_clockToSeconds; | ||||
m_deltaTime = 1.0f/60.0f; | m_deltaTime = 1.0f/60.0f; | ||||
} | } | ||||
@@ -69,7 +67,6 @@ void HardwareClock::Update() | |||||
m_time = currentTime*m_clockToSeconds; | m_time = currentTime*m_clockToSeconds; | ||||
m_deltaTime = (double)dt*m_clockToSeconds; | m_deltaTime = (double)dt*m_clockToSeconds; | ||||
m_lastAbsTime = currentTime; | m_lastAbsTime = currentTime; | ||||
} | } | ||||
@@ -200,8 +197,8 @@ namespace Jack | |||||
int NetMidiBuffer::RenderToNetwork ( int subcycle, size_t total_size ) | int NetMidiBuffer::RenderToNetwork ( int subcycle, size_t total_size ) | ||||
{ | { | ||||
int size = total_size - subcycle * fMaxPcktSize; | int size = total_size - subcycle * fMaxPcktSize; | ||||
int copy_size = ( size <= fMaxPcktSize ) ? size : fMaxPcktSize; | |||||
memcpy ( fNetBuffer, fBuffer + subcycle * fMaxPcktSize, copy_size ); | |||||
int copy_size = (size <= fMaxPcktSize) ? size : fMaxPcktSize; | |||||
memcpy(fNetBuffer, fBuffer + subcycle * fMaxPcktSize, copy_size); | |||||
return copy_size; | return copy_size; | ||||
} | } | ||||
@@ -414,12 +411,9 @@ namespace Jack | |||||
return 0; | return 0; | ||||
} | } | ||||
HardwareClock clock; | |||||
//network<->buffer | |||||
//network<->buffer | |||||
int NetCeltAudioBuffer::RenderFromNetwork(int cycle, int subcycle, size_t copy_size) | int NetCeltAudioBuffer::RenderFromNetwork(int cycle, int subcycle, size_t copy_size) | ||||
{ | { | ||||
//clock.Update(); | |||||
if (subcycle == fNumPackets - 1) { | if (subcycle == fNumPackets - 1) { | ||||
for (int port_index = 0; port_index < fNPorts; port_index++) | for (int port_index = 0; port_index < fNPorts; port_index++) | ||||
memcpy(fCompressedBuffer[port_index] + subcycle * fSubPeriodBytesSize, fNetBuffer + port_index * fLastSubPeriodBytesSize, fLastSubPeriodBytesSize); | memcpy(fCompressedBuffer[port_index] + subcycle * fSubPeriodBytesSize, fNetBuffer + port_index * fLastSubPeriodBytesSize, fLastSubPeriodBytesSize); | ||||
@@ -432,11 +426,6 @@ namespace Jack | |||||
jack_error("Packet(s) missing from... %d %d", fLastSubCycle, subcycle); | jack_error("Packet(s) missing from... %d %d", fLastSubCycle, subcycle); | ||||
fLastSubCycle = subcycle; | fLastSubCycle = subcycle; | ||||
//clock.Update(); | |||||
//const float dt = clock.GetDeltaTime(); | |||||
//printf("Delta: %f s\n", dt); | |||||
return copy_size; | return copy_size; | ||||
} | } | ||||
@@ -278,7 +278,7 @@ namespace Jack | |||||
virtual int RenderToJackPorts () = 0; | virtual int RenderToJackPorts () = 0; | ||||
//network<->buffer | //network<->buffer | ||||
virtual int RenderFromNetwork ( int cycle, int subcycle, size_t copy_size ) = 0; | |||||
virtual int RenderFromNetwork ( int cycle, int subcycle, size_t copy_size ) = 0; | |||||
virtual int RenderToNetwork (int subcycle, size_t total_size ) = 0; | virtual int RenderToNetwork (int subcycle, size_t total_size ) = 0; | ||||
virtual void SetBuffer ( int index, sample_t* buffer ) = 0; | virtual void SetBuffer ( int index, sample_t* buffer ) = 0; | ||||
@@ -64,8 +64,8 @@ class SERVER_EXPORT JackWaitThreadedDriver : public JackThreadedDriver | |||||
// JackRunnableInterface interface | // JackRunnableInterface interface | ||||
bool Execute() | bool Execute() | ||||
{ | { | ||||
// Blocks until decorated driver is started (that is when it's Init method returns). | |||||
fDriver->Initialize(); | |||||
// Blocks until decorated driver is started (that is when it's Initialize method returns true). | |||||
while (!fDriver->Initialize()) {} | |||||
fRunning = true; | fRunning = true; | ||||
return false; | return false; | ||||
} | } | ||||
@@ -153,12 +153,12 @@ | |||||
/* Begin PBXFileReference section */ | /* Begin PBXFileReference section */ | ||||
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; | ||||
1D6058910D05DD3D006BFB54 /* NetJack.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetJack.app; sourceTree = BUILT_PRODUCTS_DIR; }; | |||||
1D6058910D05DD3D006BFB54 /* NetJackSlave.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetJackSlave.app; sourceTree = BUILT_PRODUCTS_DIR; }; | |||||
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; | ||||
288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; | 288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; | ||||
28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; }; | 28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; }; | ||||
32CA4F630368D1EE00C91783 /* iPhoneNet_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iPhoneNet_Prefix.pch; sourceTree = "<group>"; }; | 32CA4F630368D1EE00C91783 /* iPhoneNet_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iPhoneNet_Prefix.pch; sourceTree = "<group>"; }; | ||||
4B0772380F54018C000DC657 /* iPhoneNetMaster.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneNetMaster.app; sourceTree = BUILT_PRODUCTS_DIR; }; | |||||
4B0772380F54018C000DC657 /* NetJackMaster.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetJackMaster.app; sourceTree = BUILT_PRODUCTS_DIR; }; | |||||
4B0772490F54021B000DC657 /* main_slave.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main_slave.mm; sourceTree = SOURCE_ROOT; }; | 4B0772490F54021B000DC657 /* main_slave.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main_slave.mm; sourceTree = SOURCE_ROOT; }; | ||||
4B0772500F54022D000DC657 /* main_master.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main_master.mm; sourceTree = SOURCE_ROOT; }; | 4B0772500F54022D000DC657 /* main_master.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main_master.mm; sourceTree = SOURCE_ROOT; }; | ||||
4B0773840F541EE2000DC657 /* iPhoneNetAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iPhoneNetAppDelegate.h; sourceTree = "<group>"; }; | 4B0773840F541EE2000DC657 /* iPhoneNetAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iPhoneNetAppDelegate.h; sourceTree = "<group>"; }; | ||||
@@ -182,7 +182,7 @@ | |||||
4BCB37CE112D647C008C7BC1 /* iPhoneFaust.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneFaust.app; sourceTree = BUILT_PRODUCTS_DIR; }; | 4BCB37CE112D647C008C7BC1 /* iPhoneFaust.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneFaust.app; sourceTree = BUILT_PRODUCTS_DIR; }; | ||||
4BCB37D5112D64B4008C7BC1 /* HardwareClock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HardwareClock.cpp; sourceTree = SOURCE_ROOT; }; | 4BCB37D5112D64B4008C7BC1 /* HardwareClock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HardwareClock.cpp; sourceTree = SOURCE_ROOT; }; | ||||
4BCB37D8112D64D8008C7BC1 /* iphone-faust.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "iphone-faust.mm"; sourceTree = SOURCE_ROOT; }; | 4BCB37D8112D64D8008C7BC1 /* iphone-faust.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "iphone-faust.mm"; sourceTree = SOURCE_ROOT; }; | ||||
4BCF75F210BC2FD90082C526 /* iPhoneFaustNet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneFaustNet.app; sourceTree = BUILT_PRODUCTS_DIR; }; | |||||
4BCF75F210BC2FD90082C526 /* iPhoneThruNet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneThruNet.app; sourceTree = BUILT_PRODUCTS_DIR; }; | |||||
4BCF75F610BC30140082C526 /* audio_thru.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = audio_thru.mm; sourceTree = SOURCE_ROOT; }; | 4BCF75F610BC30140082C526 /* audio_thru.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = audio_thru.mm; sourceTree = SOURCE_ROOT; }; | ||||
4BDFCCD7113DB30500D77992 /* Info copy.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info copy.plist"; sourceTree = "<group>"; }; | 4BDFCCD7113DB30500D77992 /* Info copy.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info copy.plist"; sourceTree = "<group>"; }; | ||||
4BDFCD57113DB6B700D77992 /* NetJackSlave.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetJackSlave.app; sourceTree = BUILT_PRODUCTS_DIR; }; | 4BDFCD57113DB6B700D77992 /* NetJackSlave.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetJackSlave.app; sourceTree = BUILT_PRODUCTS_DIR; }; | ||||
@@ -290,11 +290,11 @@ | |||||
19C28FACFE9D520D11CA2CBB /* Products */ = { | 19C28FACFE9D520D11CA2CBB /* Products */ = { | ||||
isa = PBXGroup; | isa = PBXGroup; | ||||
children = ( | children = ( | ||||
1D6058910D05DD3D006BFB54 /* NetJack.app */, | |||||
1D6058910D05DD3D006BFB54 /* NetJackSlave.app */, | |||||
4BFF45120F4D59DB00106083 /* libjacknet.a */, | 4BFF45120F4D59DB00106083 /* libjacknet.a */, | ||||
4BFF45770F4D5D9700106083 /* iPhoneFaustNet.app */, | 4BFF45770F4D5D9700106083 /* iPhoneFaustNet.app */, | ||||
4B0772380F54018C000DC657 /* iPhoneNetMaster.app */, | |||||
4BCF75F210BC2FD90082C526 /* iPhoneFaustNet.app */, | |||||
4B0772380F54018C000DC657 /* NetJackMaster.app */, | |||||
4BCF75F210BC2FD90082C526 /* iPhoneThruNet.app */, | |||||
4B4146B010BD3C4300C12F0C /* iPhoneFaustNet.app */, | 4B4146B010BD3C4300C12F0C /* iPhoneFaustNet.app */, | ||||
4BCB37CE112D647C008C7BC1 /* iPhoneFaust.app */, | 4BCB37CE112D647C008C7BC1 /* iPhoneFaust.app */, | ||||
4BDFCD57113DB6B700D77992 /* NetJackSlave.app */, | 4BDFCD57113DB6B700D77992 /* NetJackSlave.app */, | ||||
@@ -404,7 +404,7 @@ | |||||
); | ); | ||||
name = iPhoneNetSlave; | name = iPhoneNetSlave; | ||||
productName = iPhoneNet; | productName = iPhoneNet; | ||||
productReference = 1D6058910D05DD3D006BFB54 /* NetJack.app */; | |||||
productReference = 1D6058910D05DD3D006BFB54 /* NetJackSlave.app */; | |||||
productType = "com.apple.product-type.application"; | productType = "com.apple.product-type.application"; | ||||
}; | }; | ||||
4B07721F0F54018C000DC657 /* iPhoneNetMaster */ = { | 4B07721F0F54018C000DC657 /* iPhoneNetMaster */ = { | ||||
@@ -421,7 +421,7 @@ | |||||
); | ); | ||||
name = iPhoneNetMaster; | name = iPhoneNetMaster; | ||||
productName = iPhoneNet; | productName = iPhoneNet; | ||||
productReference = 4B0772380F54018C000DC657 /* iPhoneNetMaster.app */; | |||||
productReference = 4B0772380F54018C000DC657 /* NetJackMaster.app */; | |||||
productType = "com.apple.product-type.application"; | productType = "com.apple.product-type.application"; | ||||
}; | }; | ||||
4B1A940F0F49BDE000D3626B /* libjacknet */ = { | 4B1A940F0F49BDE000D3626B /* libjacknet */ = { | ||||
@@ -489,7 +489,7 @@ | |||||
); | ); | ||||
name = iPhoneThruNet; | name = iPhoneThruNet; | ||||
productName = iPhoneNet; | productName = iPhoneNet; | ||||
productReference = 4BCF75F210BC2FD90082C526 /* iPhoneFaustNet.app */; | |||||
productReference = 4BCF75F210BC2FD90082C526 /* iPhoneThruNet.app */; | |||||
productType = "com.apple.product-type.application"; | productType = "com.apple.product-type.application"; | ||||
}; | }; | ||||
4BDFCD3B113DB6B700D77992 /* iPhoneNetSlaveLib */ = { | 4BDFCD3B113DB6B700D77992 /* iPhoneNetSlaveLib */ = { | ||||
@@ -793,7 +793,7 @@ | |||||
"\"$(SRCROOT)/build/Debug-iphonesimulator\"", | "\"$(SRCROOT)/build/Debug-iphonesimulator\"", | ||||
); | ); | ||||
OTHER_LDFLAGS = libcelt.a; | OTHER_LDFLAGS = libcelt.a; | ||||
PRODUCT_NAME = iPhoneNetSlave; | |||||
PRODUCT_NAME = NetJackSlave; | |||||
SDKROOT = iphoneos3.1.3; | SDKROOT = iphoneos3.1.3; | ||||
}; | }; | ||||
name = Debug; | name = Debug; | ||||
@@ -822,7 +822,7 @@ | |||||
"\"$(SRCROOT)/build/Debug-iphonesimulator\"", | "\"$(SRCROOT)/build/Debug-iphonesimulator\"", | ||||
); | ); | ||||
OTHER_LDFLAGS = libcelt.a; | OTHER_LDFLAGS = libcelt.a; | ||||
PRODUCT_NAME = NetJack; | |||||
PRODUCT_NAME = NetJackSlave; | |||||
SDKROOT = iphoneos3.1.3; | SDKROOT = iphoneos3.1.3; | ||||
}; | }; | ||||
name = Release; | name = Release; | ||||
@@ -837,6 +837,7 @@ | |||||
GCC_PRECOMPILE_PREFIX_HEADER = YES; | GCC_PRECOMPILE_PREFIX_HEADER = YES; | ||||
GCC_PREFIX_HEADER = iPhoneNet_Prefix.pch; | GCC_PREFIX_HEADER = iPhoneNet_Prefix.pch; | ||||
HEADER_SEARCH_PATHS = ( | HEADER_SEARCH_PATHS = ( | ||||
/usr/local/include, | |||||
../../macosx/coreaudio, | ../../macosx/coreaudio, | ||||
../../macosx, | ../../macosx, | ||||
../../posix, | ../../posix, | ||||
@@ -848,8 +849,8 @@ | |||||
"$(inherited)", | "$(inherited)", | ||||
"\\\"$(SRCROOT)/build/Debug-iphonesimulator\\\"", | "\\\"$(SRCROOT)/build/Debug-iphonesimulator\\\"", | ||||
); | ); | ||||
OTHER_LDFLAGS = ""; | |||||
PRODUCT_NAME = iPhoneNetMaster; | |||||
OTHER_LDFLAGS = libcelt.a; | |||||
PRODUCT_NAME = NetJackMaster; | |||||
SDKROOT = iphoneos3.1.3; | SDKROOT = iphoneos3.1.3; | ||||
}; | }; | ||||
name = Debug; | name = Debug; | ||||
@@ -862,6 +863,7 @@ | |||||
GCC_PRECOMPILE_PREFIX_HEADER = YES; | GCC_PRECOMPILE_PREFIX_HEADER = YES; | ||||
GCC_PREFIX_HEADER = iPhoneNet_Prefix.pch; | GCC_PREFIX_HEADER = iPhoneNet_Prefix.pch; | ||||
HEADER_SEARCH_PATHS = ( | HEADER_SEARCH_PATHS = ( | ||||
/usr/local/include, | |||||
../../macosx/coreaudio, | ../../macosx/coreaudio, | ||||
../../common/jack, | ../../common/jack, | ||||
../../common, | ../../common, | ||||
@@ -873,7 +875,8 @@ | |||||
"$(inherited)", | "$(inherited)", | ||||
"\\\"$(SRCROOT)/build/Debug-iphonesimulator\\\"", | "\\\"$(SRCROOT)/build/Debug-iphonesimulator\\\"", | ||||
); | ); | ||||
PRODUCT_NAME = iPhoneNetMaster; | |||||
OTHER_LDFLAGS = libcelt.a; | |||||
PRODUCT_NAME = NetJackMaster; | |||||
}; | }; | ||||
name = Release; | name = Release; | ||||
}; | }; | ||||
@@ -1097,7 +1100,7 @@ | |||||
"\\\"$(SRCROOT)/build/Debug-iphonesimulator\\\"", | "\\\"$(SRCROOT)/build/Debug-iphonesimulator\\\"", | ||||
); | ); | ||||
OTHER_LDFLAGS = "-ljacknet"; | OTHER_LDFLAGS = "-ljacknet"; | ||||
PRODUCT_NAME = iPhoneNetSlave; | |||||
PRODUCT_NAME = NetJackSlave; | |||||
SDKROOT = iphoneos3.1.3; | SDKROOT = iphoneos3.1.3; | ||||
}; | }; | ||||
name = Debug; | name = Debug; | ||||
@@ -20,7 +20,7 @@ jack_adapter_t* adapter; | |||||
float** audio_input_buffer; | float** audio_input_buffer; | ||||
float** audio_output_buffer; | float** audio_output_buffer; | ||||
int buffer_size = 4096; | |||||
int buffer_size = 1024; | |||||
int sample_rate = 44100; | int sample_rate = 44100; | ||||
jack_master_t request = { buffer_size, sample_rate, "master" }; | jack_master_t request = { buffer_size, sample_rate, "master" }; | ||||
@@ -30,18 +30,22 @@ static void MasterAudioCallback(int frames, float** inputs, float** outputs, voi | |||||
{ | { | ||||
int i; | int i; | ||||
// Copy from iPod input to network | |||||
// Copy from iPod input to network buffers | |||||
for (i = 0; i < result.audio_input; i++) { | for (i = 0; i < result.audio_input; i++) { | ||||
memcpy(audio_output_buffer[i], inputs[i], buffer_size * sizeof(float)); | memcpy(audio_output_buffer[i], inputs[i], buffer_size * sizeof(float)); | ||||
} | } | ||||
// Send network buffers | |||||
if (jack_net_master_send(net, result.audio_output, audio_output_buffer, 0, NULL) < 0) { | if (jack_net_master_send(net, result.audio_output, audio_output_buffer, 0, NULL) < 0) { | ||||
printf("jack_net_master_send error..\n"); | printf("jack_net_master_send error..\n"); | ||||
} | } | ||||
// Copy from network to iPod output | |||||
// Recv network buffers | |||||
if (jack_net_master_recv(net, result.audio_input, audio_input_buffer, 0, NULL) < 0) { | if (jack_net_master_recv(net, result.audio_input, audio_input_buffer, 0, NULL) < 0) { | ||||
printf("jack_net_master_recv error..\n"); | printf("jack_net_master_recv error..\n"); | ||||
} | } | ||||
// Copy from network buffers to iPod output | |||||
for (i = 0; i < result.audio_output; i++) { | for (i = 0; i < result.audio_output; i++) { | ||||
memcpy(outputs[i], audio_input_buffer[i], buffer_size * sizeof(float)); | memcpy(outputs[i], audio_input_buffer[i], buffer_size * sizeof(float)); | ||||
} | } | ||||
@@ -57,6 +61,7 @@ int main(int argc, char *argv[]) { | |||||
TiPhoneCoreAudioRenderer audio_device(NUM_INPUT, NUM_OUTPUT); | TiPhoneCoreAudioRenderer audio_device(NUM_INPUT, NUM_OUTPUT); | ||||
if ((net = jack_net_master_open(DEFAULT_MULTICAST_IP, DEFAULT_PORT, "iPhone", &request, &result)) == 0) { | if ((net = jack_net_master_open(DEFAULT_MULTICAST_IP, DEFAULT_PORT, "iPhone", &request, &result)) == 0) { | ||||
printf("jack_net_master_open error..\n"); | |||||
return -1; | return -1; | ||||
} | } | ||||
@@ -82,7 +87,7 @@ int main(int argc, char *argv[]) { | |||||
} | } | ||||
// Run until interrupted | // Run until interrupted | ||||
while (1) {} | |||||
//while (1) {} | |||||
/* | /* | ||||
// Quite brutal way, the application actually does not start completely, the netjack audio processing loop is used instead... | // Quite brutal way, the application actually does not start completely, the netjack audio processing loop is used instead... | ||||
@@ -105,10 +110,11 @@ int main(int argc, char *argv[]) { | |||||
}; | }; | ||||
*/ | */ | ||||
int retVal = UIApplicationMain(argc, argv, nil, nil); | |||||
audio_device.Stop(); | audio_device.Stop(); | ||||
audio_device.Close(); | audio_device.Close(); | ||||
int retVal = UIApplicationMain(argc, argv, nil, nil); | |||||
// Wait for application end | // Wait for application end | ||||
jack_net_master_close(net); | jack_net_master_close(net); | ||||
@@ -70,6 +70,7 @@ int main(int argc, char *argv[]) { | |||||
//if ((net = jack_net_slave_open("169.254.112.119", DEFAULT_PORT, "iPhone", &request, &result)) == 0) { | //if ((net = jack_net_slave_open("169.254.112.119", DEFAULT_PORT, "iPhone", &request, &result)) == 0) { | ||||
if ((net = jack_net_slave_open(DEFAULT_MULTICAST_IP, DEFAULT_PORT, "iPod", &request, &result)) == 0) { | if ((net = jack_net_slave_open(DEFAULT_MULTICAST_IP, DEFAULT_PORT, "iPod", &request, &result)) == 0) { | ||||
printf("jack_net_slave_open error..\n"); | |||||
return -1; | return -1; | ||||
} | } | ||||