Changeset 3955
- Timestamp:
- 03/11/10 02:18:41 (5 months ago)
- Files:
-
- jack2/branches/libjacknet/common/JackAudioAdapterInterface.h (modified) (2 diffs)
- jack2/branches/libjacknet/common/JackNetAdapter.cpp (modified) (3 diffs)
- jack2/branches/libjacknet/common/JackNetAPI.cpp (modified) (3 diffs)
- jack2/branches/libjacknet/common/JackNetDriver.cpp (modified) (1 diff)
- jack2/branches/libjacknet/common/JackNetInterface.cpp (modified) (8 diffs)
- jack2/branches/libjacknet/common/JackNetInterface.h (modified) (2 diffs)
- jack2/branches/libjacknet/common/JackNetManager.cpp (modified) (1 diff)
- jack2/branches/libjacknet/common/JackNetTool.cpp (modified) (6 diffs)
- jack2/branches/libjacknet/common/JackNetTool.h (modified) (1 diff)
- jack2/branches/libjacknet/common/JackWaitThreadedDriver.h (modified) (1 diff)
- jack2/branches/libjacknet/macosx/iphone/iPhoneNet.xcodeproj/project.pbxproj (modified) (13 diffs)
- jack2/branches/libjacknet/macosx/iphone/main_master.mm (modified) (5 diffs)
- jack2/branches/libjacknet/macosx/iphone/main_slave.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
jack2/branches/libjacknet/common/JackAudioAdapterInterface.h
r3953 r3955 213 213 int GetInputs() 214 214 { 215 jack_log ( "JackAudioAdapterInterface::GetInputs %d", fCaptureChannels);215 //jack_log("JackAudioAdapterInterface::GetInputs %d", fCaptureChannels); 216 216 return fCaptureChannels; 217 217 } … … 219 219 int GetOutputs() 220 220 { 221 jack_log ( "JackAudioAdapterInterface::GetOutputs %d", fPlaybackChannels);221 //jack_log ("JackAudioAdapterInterface::GetOutputs %d", fPlaybackChannels); 222 222 return fPlaybackChannels; 223 223 } jack2/branches/libjacknet/common/JackNetAdapter.cpp
r3814 r3955 118 118 JackNetAdapter::~JackNetAdapter() 119 119 { 120 jack_log ( "JackNetAdapter::~JackNetAdapter");120 jack_log ("JackNetAdapter::~JackNetAdapter"); 121 121 122 122 int port_index; 123 if ( fSoftCaptureBuffer)124 { 125 for ( port_index = 0; port_index < fCaptureChannels; port_index++)123 if (fSoftCaptureBuffer) 124 { 125 for (port_index = 0; port_index < fCaptureChannels; port_index++) 126 126 delete[] fSoftCaptureBuffer[port_index]; 127 127 delete[] fSoftCaptureBuffer; 128 128 } 129 if ( fSoftPlaybackBuffer)130 { 131 for ( port_index = 0; port_index < fPlaybackChannels; port_index++ )129 if (fSoftPlaybackBuffer) 130 { 131 for ( port_index = 0; port_index < fPlaybackChannels; port_index++) 132 132 delete[] fSoftPlaybackBuffer[port_index]; 133 133 delete[] fSoftPlaybackBuffer; … … 195 195 196 196 //thread------------------------------------------------------------------------------ 197 // TODO : if failure, thread exist... need to restart ? 198 197 199 bool JackNetAdapter::Init() 198 200 { … … 202 204 203 205 //init network connection 204 if ( !JackNetSlaveInterface::Init() ) 206 if (!JackNetSlaveInterface::Init()) { 207 jack_error("JackNetSlaveInterface::Init() error..." ); 205 208 return false; 209 } 206 210 207 211 //then set global parameters 208 SetParams(); 212 if (!SetParams()) { 213 jack_error("SetParams error..." ); 214 return false; 215 } 209 216 210 217 //set buffers jack2/branches/libjacknet/common/JackNetAPI.cpp
r3954 r3955 215 215 goto error; 216 216 } 217 jack_info ( "Waiting for a slave..." ); 217 218 break; 218 219 … … 788 789 } 789 790 790 intFlush()791 void Flush() 791 792 { 792 793 for (int i = 0; i < fCaptureChannels; i++ ) { … … 882 883 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) 883 884 { 884 JackNetExtMaster* slave= (JackNetExtMaster*)net;885 return slave->Read(audio_input, audio_input_buffer, midi_input, midi_input_buffer);885 JackNetExtMaster* master = (JackNetExtMaster*)net; 886 return master->Read(audio_input, audio_input_buffer, midi_input, midi_input_buffer); 886 887 } 887 888 888 889 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) 889 890 { 890 JackNetExtMaster* slave= (JackNetExtMaster*)net;891 return slave->Write(audio_output, audio_output_buffer, midi_output, midi_output_buffer);891 JackNetExtMaster* master = (JackNetExtMaster*)net; 892 return master->Write(audio_output, audio_output_buffer, midi_output, midi_output_buffer); 892 893 } 893 894 jack2/branches/libjacknet/common/JackNetDriver.cpp
r3939 r3955 143 143 144 144 //init network 145 if (!JackNetSlaveInterface::Init()) 145 if (!JackNetSlaveInterface::Init()) { 146 jack_error("JackNetSlaveInterface::Init() error..." ); 146 147 return false; 148 } 147 149 148 150 //set global parameters 149 if (!SetParams()) 151 if (!SetParams()) { 152 jack_error("SetParams error..." ); 150 153 return false; 151 154 } 155 152 156 //allocate midi ports lists 153 157 fMidiCapturePortList = new jack_port_id_t [fParams.fSendMidiChannels]; jack2/branches/libjacknet/common/JackNetInterface.cpp
r3954 r3955 68 68 } 69 69 70 void JackNetInterface::FreeNetworkBuffers() 71 { 72 delete fNetMidiCaptureBuffer; 73 delete fNetMidiPlaybackBuffer; 74 delete fNetAudioCaptureBuffer; 75 delete fNetAudioPlaybackBuffer; 76 fNetMidiCaptureBuffer = NULL; 77 fNetMidiPlaybackBuffer = NULL; 78 fNetAudioCaptureBuffer = NULL; 79 fNetAudioPlaybackBuffer = NULL; 80 } 81 70 82 JackNetInterface::~JackNetInterface() 71 83 { 72 jack_log ( "JackNetInterface::~JackNetInterface");84 jack_log ("JackNetInterface::~JackNetInterface"); 73 85 74 86 fSocket.Close(); … … 271 283 272 284 error: 273 274 delete fNetMidiCaptureBuffer; 275 delete fNetMidiPlaybackBuffer; 276 delete fNetAudioCaptureBuffer; 277 delete fNetAudioPlaybackBuffer; 285 FreeNetworkBuffers(); 278 286 return false; 279 287 } … … 651 659 } 652 660 653 net_status_t JackNetSlaveInterface::SendAvailableToMaster( intcount)661 net_status_t JackNetSlaveInterface::SendAvailableToMaster(long try_count) 654 662 { 655 663 jack_log ( "JackNetSlaveInterface::SendAvailableToMaster()" ); … … 699 707 } 700 708 } 701 while (strcmp(host_params.fPacketType, fParams.fPacketType) && (GetPacketType(&host_params) != SLAVE_SETUP) && (-- count > 0));709 while (strcmp(host_params.fPacketType, fParams.fPacketType) && (GetPacketType(&host_params) != SLAVE_SETUP) && (--try_count > 0)); 702 710 703 711 // Time out failure.. 704 if (count == 0) { 712 if (try_count == 0) { 713 jack_error("Time out error in connect"); 705 714 return NET_CONNECT_ERROR; 706 715 } … … 711 720 712 721 //connect the socket 713 if ( fSocket.Connect() == SOCKET_ERROR) {714 jack_error ( "Error in connect : %s", StrError ( NET_ERROR_CODE ));722 if (fSocket.Connect() == SOCKET_ERROR) { 723 jack_error("Error in connect : %s", StrError(NET_ERROR_CODE)); 715 724 return NET_CONNECT_ERROR; 716 725 } … … 720 729 net_status_t JackNetSlaveInterface::SendStartToMaster() 721 730 { 722 jack_log ( "JackNetSlaveInterface::SendStartToMaster");731 jack_log("JackNetSlaveInterface::SendStartToMaster"); 723 732 724 733 //tell the master to start … … 727 736 SetPacketType ( &fParams, START_MASTER ); 728 737 SessionParamsHToN(&fParams, &net_params); 729 if ( fSocket.Send ( &net_params, sizeof ( session_params_t ), 0 ) == SOCKET_ERROR)730 { 731 jack_error ( "Error in send : %s", StrError ( NET_ERROR_CODE ));732 return ( fSocket.GetError() == NET_CONN_ERROR) ? NET_ERROR : NET_SEND_ERROR;738 if (fSocket.Send(&net_params, sizeof(session_params_t), 0) == SOCKET_ERROR) 739 { 740 jack_error("Error in send : %s", StrError(NET_ERROR_CODE)); 741 return (fSocket.GetError() == NET_CONN_ERROR) ? NET_ERROR : NET_SEND_ERROR; 733 742 } 734 743 return NET_ROLLING; … … 785 794 786 795 error: 787 delete fNetMidiCaptureBuffer; 788 delete fNetMidiPlaybackBuffer; 789 delete fNetAudioCaptureBuffer; 790 delete fNetAudioPlaybackBuffer; 796 FreeNetworkBuffers(); 791 797 return false; 792 798 } jack2/branches/libjacknet/common/JackNetInterface.h
r3954 r3955 64 64 //utility methods 65 65 int SetNetBufferSize(); 66 void FreeNetworkBuffers(); 66 67 67 68 //virtual methods : depends on the sub class master/slave … … 149 150 bool InitRendering(); 150 151 151 net_status_t SendAvailableToMaster( int count = LONG_MAX);152 net_status_t SendAvailableToMaster(long count = LONG_MAX); // long here (and not int...) 152 153 net_status_t SendStartToMaster(); 153 154 jack2/branches/libjacknet/common/JackNetManager.cpp
r3949 r3955 114 114 { 115 115 //network init 116 if (!JackNetMasterInterface::Init()) 116 if (!JackNetMasterInterface::Init()){ 117 jack_error("JackNetMasterInterface::Init() error..." ); 117 118 return false; 119 } 118 120 119 121 //set global parameters 120 if (!SetParams()) 122 if (!SetParams()) { 123 jack_error("SetParams error..." ); 121 124 return false; 125 } 122 126 123 127 //jack client and process jack2/branches/libjacknet/common/JackNetTool.cpp
r3952 r3955 50 50 mach_timebase_info(&info); 51 51 m_clockToSeconds = (double)info.numer/info.denom/1000000000.0; 52 53 52 Reset(); 54 53 } … … 58 57 m_startAbsTime = mach_absolute_time(); 59 58 m_lastAbsTime = m_startAbsTime; 60 61 59 m_time = m_startAbsTime*m_clockToSeconds; 62 60 m_deltaTime = 1.0f/60.0f; … … 70 68 m_time = currentTime*m_clockToSeconds; 71 69 m_deltaTime = (double)dt*m_clockToSeconds; 72 73 70 m_lastAbsTime = currentTime; 74 71 } … … 201 198 { 202 199 int size = total_size - subcycle * fMaxPcktSize; 203 int copy_size = ( size <= fMaxPcktSize) ? size : fMaxPcktSize;204 memcpy ( fNetBuffer, fBuffer + subcycle * fMaxPcktSize, copy_size);200 int copy_size = (size <= fMaxPcktSize) ? size : fMaxPcktSize; 201 memcpy(fNetBuffer, fBuffer + subcycle * fMaxPcktSize, copy_size); 205 202 return copy_size; 206 203 } … … 415 412 } 416 413 417 HardwareClock clock; 418 //network<->buffer 414 //network<->buffer 419 415 int NetCeltAudioBuffer::RenderFromNetwork(int cycle, int subcycle, size_t copy_size) 420 416 { 421 //clock.Update();422 423 417 if (subcycle == fNumPackets - 1) { 424 418 for (int port_index = 0; port_index < fNPorts; port_index++) … … 433 427 434 428 fLastSubCycle = subcycle; 435 436 //clock.Update();437 //const float dt = clock.GetDeltaTime();438 //printf("Delta: %f s\n", dt);439 440 429 return copy_size; 441 430 } jack2/branches/libjacknet/common/JackNetTool.h
r3952 r3955 279 279 280 280 //network<->buffer 281 virtual int RenderFromNetwork ( int cycle, int subcycle, size_t copy_size ) = 0;281 virtual int RenderFromNetwork ( int cycle, int subcycle, size_t copy_size ) = 0; 282 282 virtual int RenderToNetwork (int subcycle, size_t total_size ) = 0; 283 283 jack2/branches/libjacknet/common/JackWaitThreadedDriver.h
r3614 r3955 65 65 bool Execute() 66 66 { 67 // Blocks until decorated driver is started (that is when it's Init method returns).68 fDriver->Initialize();67 // Blocks until decorated driver is started (that is when it's Initialize method returns true). 68 while (!fDriver->Initialize()) {} 69 69 fRunning = true; 70 70 return false; jack2/branches/libjacknet/macosx/iphone/iPhoneNet.xcodeproj/project.pbxproj
r3950 r3955 154 154 /* Begin PBXFileReference section */ 155 155 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 156 1D6058910D05DD3D006BFB54 /* NetJack .app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetJack.app; sourceTree = BUILT_PRODUCTS_DIR; };156 1D6058910D05DD3D006BFB54 /* NetJackSlave.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetJackSlave.app; sourceTree = BUILT_PRODUCTS_DIR; }; 157 157 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 158 158 288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 159 159 28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; }; 160 160 32CA4F630368D1EE00C91783 /* iPhoneNet_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iPhoneNet_Prefix.pch; sourceTree = "<group>"; }; 161 4B0772380F54018C000DC657 /* iPhoneNetMaster.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneNetMaster.app; sourceTree = BUILT_PRODUCTS_DIR; };161 4B0772380F54018C000DC657 /* NetJackMaster.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetJackMaster.app; sourceTree = BUILT_PRODUCTS_DIR; }; 162 162 4B0772490F54021B000DC657 /* main_slave.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main_slave.mm; sourceTree = SOURCE_ROOT; }; 163 163 4B0772500F54022D000DC657 /* main_master.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main_master.mm; sourceTree = SOURCE_ROOT; }; … … 183 183 4BCB37D5112D64B4008C7BC1 /* HardwareClock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HardwareClock.cpp; sourceTree = SOURCE_ROOT; }; 184 184 4BCB37D8112D64D8008C7BC1 /* iphone-faust.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "iphone-faust.mm"; sourceTree = SOURCE_ROOT; }; 185 4BCF75F210BC2FD90082C526 /* iPhone FaustNet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneFaustNet.app; sourceTree = BUILT_PRODUCTS_DIR; };185 4BCF75F210BC2FD90082C526 /* iPhoneThruNet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iPhoneThruNet.app; sourceTree = BUILT_PRODUCTS_DIR; }; 186 186 4BCF75F610BC30140082C526 /* audio_thru.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = audio_thru.mm; sourceTree = SOURCE_ROOT; }; 187 187 4BDFCCD7113DB30500D77992 /* Info copy.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info copy.plist"; sourceTree = "<group>"; }; … … 291 291 isa = PBXGroup; 292 292 children = ( 293 1D6058910D05DD3D006BFB54 /* NetJack .app */,293 1D6058910D05DD3D006BFB54 /* NetJackSlave.app */, 294 294 4BFF45120F4D59DB00106083 /* libjacknet.a */, 295 295 4BFF45770F4D5D9700106083 /* iPhoneFaustNet.app */, 296 4B0772380F54018C000DC657 /* iPhoneNetMaster.app */,297 4BCF75F210BC2FD90082C526 /* iPhone FaustNet.app */,296 4B0772380F54018C000DC657 /* NetJackMaster.app */, 297 4BCF75F210BC2FD90082C526 /* iPhoneThruNet.app */, 298 298 4B4146B010BD3C4300C12F0C /* iPhoneFaustNet.app */, 299 299 4BCB37CE112D647C008C7BC1 /* iPhoneFaust.app */, … … 405 405 name = iPhoneNetSlave; 406 406 productName = iPhoneNet; 407 productReference = 1D6058910D05DD3D006BFB54 /* NetJack .app */;407 productReference = 1D6058910D05DD3D006BFB54 /* NetJackSlave.app */; 408 408 productType = "com.apple.product-type.application"; 409 409 }; … … 422 422 name = iPhoneNetMaster; 423 423 productName = iPhoneNet; 424 productReference = 4B0772380F54018C000DC657 /* iPhoneNetMaster.app */;424 productReference = 4B0772380F54018C000DC657 /* NetJackMaster.app */; 425 425 productType = "com.apple.product-type.application"; 426 426 }; … … 490 490 name = iPhoneThruNet; 491 491 productName = iPhoneNet; 492 productReference = 4BCF75F210BC2FD90082C526 /* iPhone FaustNet.app */;492 productReference = 4BCF75F210BC2FD90082C526 /* iPhoneThruNet.app */; 493 493 productType = "com.apple.product-type.application"; 494 494 }; … … 794 794 ); 795 795 OTHER_LDFLAGS = libcelt.a; 796 PRODUCT_NAME = iPhoneNetSlave;796 PRODUCT_NAME = NetJackSlave; 797 797 SDKROOT = iphoneos3.1.3; 798 798 }; … … 823 823 ); 824 824 OTHER_LDFLAGS = libcelt.a; 825 PRODUCT_NAME = NetJack ;825 PRODUCT_NAME = NetJackSlave; 826 826 SDKROOT = iphoneos3.1.3; 827 827 }; … … 838 838 GCC_PREFIX_HEADER = iPhoneNet_Prefix.pch; 839 839 HEADER_SEARCH_PATHS = ( 840 /usr/local/include, 840 841 ../../macosx/coreaudio, 841 842 ../../macosx, … … 849 850 "\\\"$(SRCROOT)/build/Debug-iphonesimulator\\\"", 850 851 ); 851 OTHER_LDFLAGS = "";852 PRODUCT_NAME = iPhoneNetMaster;852 OTHER_LDFLAGS = libcelt.a; 853 PRODUCT_NAME = NetJackMaster; 853 854 SDKROOT = iphoneos3.1.3; 854 855 }; … … 863 864 GCC_PREFIX_HEADER = iPhoneNet_Prefix.pch; 864 865 HEADER_SEARCH_PATHS = ( 866 /usr/local/include, 865 867 ../../macosx/coreaudio, 866 868 ../../common/jack, … … 874 876 "\\\"$(SRCROOT)/build/Debug-iphonesimulator\\\"", 875 877 ); 876 PRODUCT_NAME = iPhoneNetMaster; 878 OTHER_LDFLAGS = libcelt.a; 879 PRODUCT_NAME = NetJackMaster; 877 880 }; 878 881 name = Release; … … 1098 1101 ); 1099 1102 OTHER_LDFLAGS = "-ljacknet"; 1100 PRODUCT_NAME = iPhoneNetSlave;1103 PRODUCT_NAME = NetJackSlave; 1101 1104 SDKROOT = iphoneos3.1.3; 1102 1105 }; jack2/branches/libjacknet/macosx/iphone/main_master.mm
r3932 r3955 21 21 float** audio_output_buffer; 22 22 23 int buffer_size = 4096;23 int buffer_size = 1024; 24 24 int sample_rate = 44100; 25 25 … … 31 31 int i; 32 32 33 // Copy from iPod input to network 33 // Copy from iPod input to network buffers 34 34 for (i = 0; i < result.audio_input; i++) { 35 35 memcpy(audio_output_buffer[i], inputs[i], buffer_size * sizeof(float)); 36 36 } 37 38 // Send network buffers 37 39 if (jack_net_master_send(net, result.audio_output, audio_output_buffer, 0, NULL) < 0) { 38 40 printf("jack_net_master_send error..\n"); 39 41 } 40 42 41 // Copy from network to iPod output43 // Recv network buffers 42 44 if (jack_net_master_recv(net, result.audio_input, audio_input_buffer, 0, NULL) < 0) { 43 45 printf("jack_net_master_recv error..\n"); 44 46 } 47 48 // Copy from network buffers to iPod output 45 49 for (i = 0; i < result.audio_output; i++) { 46 50 memcpy(outputs[i], audio_input_buffer[i], buffer_size * sizeof(float)); … … 58 62 59 63 if ((net = jack_net_master_open(DEFAULT_MULTICAST_IP, DEFAULT_PORT, "iPhone", &request, &result)) == 0) { 64 printf("jack_net_master_open error..\n"); 60 65 return -1; 61 66 } … … 83 88 84 89 // Run until interrupted 85 while (1) {}90 //while (1) {} 86 91 87 92 /* … … 106 111 */ 107 112 113 int retVal = UIApplicationMain(argc, argv, nil, nil); 114 108 115 audio_device.Stop(); 109 116 audio_device.Close(); 110 111 int retVal = UIApplicationMain(argc, argv, nil, nil); 117 112 118 113 119 // Wait for application end jack2/branches/libjacknet/macosx/iphone/main_slave.mm
r3953 r3955 71 71 //if ((net = jack_net_slave_open("169.254.112.119", DEFAULT_PORT, "iPhone", &request, &result)) == 0) { 72 72 if ((net = jack_net_slave_open(DEFAULT_MULTICAST_IP, DEFAULT_PORT, "iPod", &request, &result)) == 0) { 73 printf("jack_net_slave_open error..\n"); 73 74 return -1; 74 75 }
