jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

511 lines
22KB

  1. /*
  2. Copyright (C) 2008 Romain Moret at Grame
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #include "JackNetTool.h"
  16. using namespace std;
  17. namespace Jack
  18. {
  19. // NetMidiBuffer**********************************************************************************
  20. NetMidiBuffer::NetMidiBuffer ( session_params_t* params, uint32_t nports, char* net_buffer )
  21. {
  22. fNPorts = nports;
  23. fMaxBufsize = fNPorts * sizeof ( sample_t ) * params->fPeriodSize ;
  24. fMaxPcktSize = params->fMtu - sizeof ( packet_header_t );
  25. fBuffer = new char[fMaxBufsize];
  26. fPortBuffer = new JackMidiBuffer* [fNPorts];
  27. for ( int port_index = 0; port_index < fNPorts; port_index++ )
  28. fPortBuffer[port_index] = NULL;
  29. fNetBuffer = net_buffer;
  30. }
  31. NetMidiBuffer::~NetMidiBuffer()
  32. {
  33. delete[] fBuffer;
  34. delete[] fPortBuffer;
  35. }
  36. size_t NetMidiBuffer::GetSize()
  37. {
  38. return fMaxBufsize;
  39. }
  40. void NetMidiBuffer::SetBuffer ( int index, JackMidiBuffer* buffer )
  41. {
  42. fPortBuffer[index] = buffer;
  43. }
  44. JackMidiBuffer* NetMidiBuffer::GetBuffer ( int index )
  45. {
  46. return fPortBuffer[index];
  47. }
  48. void NetMidiBuffer::DisplayEvents()
  49. {
  50. for ( int port_index = 0; port_index < fNPorts; port_index++ )
  51. {
  52. for ( uint event = 0; event < fPortBuffer[port_index]->event_count; event++ )
  53. if ( fPortBuffer[port_index]->IsValid() )
  54. jack_info ( "port %d : midi event %u/%u -> time : %u, size : %u",
  55. port_index + 1, event + 1, fPortBuffer[port_index]->event_count,
  56. fPortBuffer[port_index]->events[event].time, fPortBuffer[port_index]->events[event].size );
  57. }
  58. }
  59. int NetMidiBuffer::RenderFromJackPorts()
  60. {
  61. int pos = 0;
  62. size_t copy_size;
  63. for ( int port_index = 0; port_index < fNPorts; port_index++ )
  64. {
  65. char* write_pos = fBuffer + pos;
  66. copy_size = sizeof ( JackMidiBuffer ) + fPortBuffer[port_index]->event_count * sizeof ( JackMidiEvent );
  67. memcpy ( fBuffer + pos, fPortBuffer[port_index], copy_size );
  68. pos += copy_size;
  69. memcpy ( fBuffer + pos, fPortBuffer[port_index] + ( fPortBuffer[port_index]->buffer_size - fPortBuffer[port_index]->write_pos ),
  70. fPortBuffer[port_index]->write_pos );
  71. pos += fPortBuffer[port_index]->write_pos;
  72. JackMidiBuffer* midi_buffer = reinterpret_cast<JackMidiBuffer*>(write_pos);
  73. MidiBufferHToN(midi_buffer, midi_buffer);
  74. }
  75. return pos;
  76. }
  77. int NetMidiBuffer::RenderToJackPorts()
  78. {
  79. int pos = 0;
  80. int copy_size;
  81. for ( int port_index = 0; port_index < fNPorts; port_index++ )
  82. {
  83. JackMidiBuffer* midi_buffer = reinterpret_cast<JackMidiBuffer*>(fBuffer + pos);
  84. MidiBufferNToH(midi_buffer, midi_buffer);
  85. copy_size = sizeof ( JackMidiBuffer ) + reinterpret_cast<JackMidiBuffer*> ( fBuffer + pos )->event_count * sizeof ( JackMidiEvent );
  86. memcpy ( fPortBuffer[port_index], fBuffer + pos, copy_size );
  87. pos += copy_size;
  88. memcpy ( fPortBuffer[port_index] + ( fPortBuffer[port_index]->buffer_size - fPortBuffer[port_index]->write_pos ),
  89. fBuffer + pos, fPortBuffer[port_index]->write_pos );
  90. pos += fPortBuffer[port_index]->write_pos;
  91. }
  92. return pos;
  93. }
  94. int NetMidiBuffer::RenderFromNetwork ( int subcycle, size_t copy_size )
  95. {
  96. memcpy ( fBuffer + subcycle * fMaxPcktSize, fNetBuffer, copy_size );
  97. return copy_size;
  98. }
  99. int NetMidiBuffer::RenderToNetwork ( int subcycle, size_t total_size )
  100. {
  101. int size = total_size - subcycle * fMaxPcktSize;
  102. int copy_size = ( size <= fMaxPcktSize ) ? size : fMaxPcktSize;
  103. memcpy ( fNetBuffer, fBuffer + subcycle * fMaxPcktSize, copy_size );
  104. return copy_size;
  105. }
  106. // net audio buffer *********************************************************************************
  107. NetSingleAudioBuffer::NetSingleAudioBuffer ( session_params_t* params, uint32_t nports, char* net_buffer )
  108. : fPortBuffer(params, nports), fNetBuffer(net_buffer)
  109. {}
  110. NetSingleAudioBuffer::~NetSingleAudioBuffer()
  111. {}
  112. size_t NetSingleAudioBuffer::GetSize()
  113. {
  114. return fPortBuffer.GetSize();
  115. }
  116. void NetSingleAudioBuffer::SetBuffer ( int index, sample_t* buffer )
  117. {
  118. fPortBuffer.SetBuffer(index, buffer);
  119. }
  120. sample_t* NetSingleAudioBuffer::GetBuffer ( int index )
  121. {
  122. return fPortBuffer.GetBuffer(index);
  123. }
  124. void NetSingleAudioBuffer::RenderFromJackPorts (int subcycle)
  125. {
  126. fPortBuffer.RenderFromJackPorts(fNetBuffer, subcycle);
  127. }
  128. void NetSingleAudioBuffer::RenderToJackPorts (int cycle, int subcycle)
  129. {
  130. fPortBuffer.RenderToJackPorts(fNetBuffer, subcycle);
  131. }
  132. // Buffered
  133. NetBufferedAudioBuffer::NetBufferedAudioBuffer ( session_params_t* params, uint32_t nports, char* net_buffer )
  134. {
  135. fMaxCycle = 0;
  136. fNetBuffer = net_buffer;
  137. for (int i = 0; i < AUDIO_BUFFER_SIZE; i++) {
  138. fPortBuffer[i].Init(params, nports);
  139. }
  140. fJackPortBuffer = new sample_t* [nports];
  141. for ( int port_index = 0; port_index < nports; port_index++ )
  142. fJackPortBuffer[port_index] = NULL;
  143. }
  144. NetBufferedAudioBuffer::~NetBufferedAudioBuffer()
  145. {
  146. delete [] fJackPortBuffer;
  147. }
  148. size_t NetBufferedAudioBuffer::GetSize()
  149. {
  150. return fPortBuffer[0].GetSize();
  151. }
  152. void NetBufferedAudioBuffer::SetBuffer ( int index, sample_t* buffer )
  153. {
  154. fJackPortBuffer[index] = buffer;
  155. }
  156. sample_t* NetBufferedAudioBuffer::GetBuffer ( int index )
  157. {
  158. return fJackPortBuffer[index];
  159. }
  160. void NetBufferedAudioBuffer::RenderFromJackPorts (int subcycle )
  161. {
  162. fPortBuffer[0].RenderFromJackPorts(fNetBuffer, subcycle); // Always use first buffer...
  163. }
  164. void NetBufferedAudioBuffer::RenderToJackPorts (int cycle, int subcycle)
  165. {
  166. if (cycle < fMaxCycle) {
  167. jack_info("Wrong order fCycle %d subcycle %d fMaxCycle %d", cycle, subcycle, fMaxCycle);
  168. }
  169. fPortBuffer[cycle % AUDIO_BUFFER_SIZE].RenderToJackPorts(fNetBuffer, subcycle);
  170. }
  171. void NetBufferedAudioBuffer::FinishRenderToJackPorts (int cycle)
  172. {
  173. fMaxCycle = std::max(fMaxCycle, cycle);
  174. fPortBuffer[(cycle + 1) % AUDIO_BUFFER_SIZE].Copy(fJackPortBuffer); // Copy internal buffer in JACK ports
  175. }
  176. // SessionParams ************************************************************************************
  177. SERVER_EXPORT void SessionParamsHToN ( session_params_t* src_params, session_params_t* dst_params )
  178. {
  179. memcpy(dst_params, src_params, sizeof(session_params_t));
  180. dst_params->fPacketID = htonl ( src_params->fPacketID );
  181. dst_params->fMtu = htonl ( src_params->fMtu );
  182. dst_params->fID = htonl ( src_params->fID );
  183. dst_params->fTransportSync = htonl ( src_params->fTransportSync );
  184. dst_params->fSendAudioChannels = htonl ( src_params->fSendAudioChannels );
  185. dst_params->fReturnAudioChannels = htonl ( src_params->fReturnAudioChannels );
  186. dst_params->fSendMidiChannels = htonl ( src_params->fSendMidiChannels );
  187. dst_params->fReturnMidiChannels = htonl ( src_params->fReturnMidiChannels );
  188. dst_params->fSampleRate = htonl ( src_params->fSampleRate );
  189. dst_params->fPeriodSize = htonl ( src_params->fPeriodSize );
  190. dst_params->fFramesPerPacket = htonl ( src_params->fFramesPerPacket );
  191. dst_params->fBitdepth = htonl ( src_params->fBitdepth );
  192. dst_params->fSlaveSyncMode = htonl ( src_params->fSlaveSyncMode );
  193. }
  194. SERVER_EXPORT void SessionParamsNToH ( session_params_t* src_params, session_params_t* dst_params )
  195. {
  196. memcpy(dst_params, src_params, sizeof(session_params_t));
  197. dst_params->fPacketID = ntohl ( src_params->fPacketID );
  198. dst_params->fMtu = ntohl ( src_params->fMtu );
  199. dst_params->fID = ntohl ( src_params->fID );
  200. dst_params->fTransportSync = ntohl ( src_params->fTransportSync );
  201. dst_params->fSendAudioChannels = ntohl ( src_params->fSendAudioChannels );
  202. dst_params->fReturnAudioChannels = ntohl ( src_params->fReturnAudioChannels );
  203. dst_params->fSendMidiChannels = ntohl ( src_params->fSendMidiChannels );
  204. dst_params->fReturnMidiChannels = ntohl ( src_params->fReturnMidiChannels );
  205. dst_params->fSampleRate = ntohl ( src_params->fSampleRate );
  206. dst_params->fPeriodSize = ntohl ( src_params->fPeriodSize );
  207. dst_params->fFramesPerPacket = ntohl ( src_params->fFramesPerPacket );
  208. dst_params->fBitdepth = ntohl ( src_params->fBitdepth );
  209. dst_params->fSlaveSyncMode = ntohl ( src_params->fSlaveSyncMode );
  210. }
  211. SERVER_EXPORT void SessionParamsDisplay ( session_params_t* params )
  212. {
  213. char bitdepth[16];
  214. ( params->fBitdepth ) ? sprintf ( bitdepth, "%u", params->fBitdepth ) : sprintf ( bitdepth, "%s", "float" );
  215. char mode[8];
  216. switch ( params->fNetworkMode )
  217. {
  218. case 's' :
  219. strcpy ( mode, "slow" );
  220. break;
  221. case 'n' :
  222. strcpy ( mode, "normal" );
  223. break;
  224. case 'f' :
  225. strcpy ( mode, "fast" );
  226. break;
  227. }
  228. jack_info ( "**************** Network parameters ****************" );
  229. jack_info ( "Name : %s", params->fName );
  230. jack_info ( "Protocol revision : %d", params->fProtocolVersion );
  231. jack_info ( "MTU : %u", params->fMtu );
  232. jack_info ( "Master name : %s", params->fMasterNetName );
  233. jack_info ( "Slave name : %s", params->fSlaveNetName );
  234. jack_info ( "ID : %u", params->fID );
  235. jack_info ( "Transport Sync : %s", ( params->fTransportSync ) ? "yes" : "no" );
  236. jack_info ( "Send channels (audio - midi) : %d - %d", params->fSendAudioChannels, params->fSendMidiChannels );
  237. jack_info ( "Return channels (audio - midi) : %d - %d", params->fReturnAudioChannels, params->fReturnMidiChannels );
  238. jack_info ( "Sample rate : %u frames per second", params->fSampleRate );
  239. jack_info ( "Period size : %u frames per period", params->fPeriodSize );
  240. jack_info ( "Frames per packet : %u", params->fFramesPerPacket );
  241. jack_info ( "Packet per period : %u", (params->fFramesPerPacket != 0) ? params->fPeriodSize / params->fFramesPerPacket : 0);
  242. jack_info ( "Bitdepth : %s", bitdepth );
  243. jack_info ( "Slave mode : %s", ( params->fSlaveSyncMode ) ? "sync" : "async" );
  244. jack_info ( "Network mode : %s", mode );
  245. jack_info ( "****************************************************" );
  246. }
  247. SERVER_EXPORT sync_packet_type_t GetPacketType ( session_params_t* params )
  248. {
  249. switch ( params->fPacketID )
  250. {
  251. case 0:
  252. return SLAVE_AVAILABLE;
  253. case 1:
  254. return SLAVE_SETUP;
  255. case 2:
  256. return START_MASTER;
  257. case 3:
  258. return START_SLAVE;
  259. case 4:
  260. return KILL_MASTER;
  261. }
  262. return INVALID;
  263. }
  264. SERVER_EXPORT int SetPacketType ( session_params_t* params, sync_packet_type_t packet_type )
  265. {
  266. switch ( packet_type )
  267. {
  268. case INVALID:
  269. return -1;
  270. case SLAVE_AVAILABLE:
  271. params->fPacketID = 0;
  272. break;
  273. case SLAVE_SETUP:
  274. params->fPacketID = 1;
  275. break;
  276. case START_MASTER:
  277. params->fPacketID = 2;
  278. break;
  279. case START_SLAVE:
  280. params->fPacketID = 3;
  281. break;
  282. case KILL_MASTER:
  283. params->fPacketID = 4;
  284. }
  285. return 0;
  286. }
  287. // Packet header **********************************************************************************
  288. SERVER_EXPORT void PacketHeaderHToN ( packet_header_t* src_header, packet_header_t* dst_header )
  289. {
  290. memcpy(dst_header, src_header, sizeof(packet_header_t));
  291. dst_header->fID = htonl ( src_header->fID );
  292. dst_header->fMidiDataSize = htonl ( src_header->fMidiDataSize );
  293. dst_header->fBitdepth = htonl ( src_header->fBitdepth );
  294. dst_header->fNMidiPckt = htonl ( src_header->fNMidiPckt );
  295. dst_header->fPacketSize = htonl ( src_header->fPacketSize );
  296. dst_header->fCycle = htonl ( src_header->fCycle );
  297. dst_header->fSubCycle = htonl ( src_header->fSubCycle );
  298. dst_header->fIsLastPckt = htonl ( src_header->fIsLastPckt );
  299. }
  300. SERVER_EXPORT void PacketHeaderNToH ( packet_header_t* src_header, packet_header_t* dst_header )
  301. {
  302. memcpy(dst_header, src_header, sizeof(packet_header_t));
  303. dst_header->fID = ntohl ( src_header->fID );
  304. dst_header->fMidiDataSize = ntohl ( src_header->fMidiDataSize );
  305. dst_header->fBitdepth = ntohl ( src_header->fBitdepth );
  306. dst_header->fNMidiPckt = ntohl ( src_header->fNMidiPckt );
  307. dst_header->fPacketSize = ntohl ( src_header->fPacketSize );
  308. dst_header->fCycle = ntohl ( src_header->fCycle );
  309. dst_header->fSubCycle = ntohl ( src_header->fSubCycle );
  310. dst_header->fIsLastPckt = ntohl ( src_header->fIsLastPckt );
  311. }
  312. SERVER_EXPORT void PacketHeaderDisplay ( packet_header_t* header )
  313. {
  314. char bitdepth[16];
  315. ( header->fBitdepth ) ? sprintf ( bitdepth, "%u", header->fBitdepth ) : sprintf ( bitdepth, "%s", "float" );
  316. jack_info ( "********************Header********************" );
  317. jack_info ( "Data type : %c", header->fDataType );
  318. jack_info ( "Data stream : %c", header->fDataStream );
  319. jack_info ( "ID : %u", header->fID );
  320. jack_info ( "Cycle : %u", header->fCycle );
  321. jack_info ( "SubCycle : %u", header->fSubCycle );
  322. jack_info ( "Midi packets : %u", header->fNMidiPckt );
  323. jack_info ( "Midi data size : %u", header->fMidiDataSize );
  324. jack_info ( "Last packet : '%s'", ( header->fIsLastPckt ) ? "yes" : "no" );
  325. jack_info ( "Bitdepth : %s", bitdepth );
  326. jack_info ( "**********************************************" );
  327. }
  328. SERVER_EXPORT void NetTransportDataDisplay ( net_transport_data_t* data )
  329. {
  330. jack_info ( "********************Network Transport********************" );
  331. jack_info ( "Transport new state : %u", data->fNewState );
  332. jack_info ( "Transport timebase master : %u", data->fTimebaseMaster );
  333. jack_info ( "Transport cycle state : %u", data->fState );
  334. jack_info ( "**********************************************" );
  335. }
  336. SERVER_EXPORT void MidiBufferHToN ( JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer )
  337. {
  338. dst_buffer->magic = htonl(src_buffer->magic);
  339. dst_buffer->buffer_size = htonl(src_buffer->buffer_size);
  340. dst_buffer->nframes = htonl(src_buffer->nframes);
  341. dst_buffer->write_pos = htonl(src_buffer->write_pos);
  342. dst_buffer->event_count = htonl(src_buffer->event_count);
  343. dst_buffer->lost_events = htonl(src_buffer->lost_events);
  344. dst_buffer->mix_index = htonl(src_buffer->mix_index);
  345. }
  346. SERVER_EXPORT void MidiBufferNToH ( JackMidiBuffer* src_buffer, JackMidiBuffer* dst_buffer )
  347. {
  348. dst_buffer->magic = ntohl(src_buffer->magic);
  349. dst_buffer->buffer_size = ntohl(src_buffer->buffer_size);
  350. dst_buffer->nframes = ntohl(src_buffer->nframes);
  351. dst_buffer->write_pos = ntohl(src_buffer->write_pos);
  352. dst_buffer->event_count = ntohl(src_buffer->event_count);
  353. dst_buffer->lost_events = ntohl(src_buffer->lost_events);
  354. dst_buffer->mix_index = ntohl(src_buffer->mix_index);
  355. }
  356. SERVER_EXPORT void TransportDataHToN ( net_transport_data_t* src_params, net_transport_data_t* dst_params )
  357. {
  358. dst_params->fNewState = htonl(src_params->fNewState);
  359. dst_params->fTimebaseMaster = htonl(src_params->fTimebaseMaster);
  360. dst_params->fState = htonl(src_params->fState);
  361. dst_params->fPosition.unique_1 = htonll(src_params->fPosition.unique_1);
  362. dst_params->fPosition.usecs = htonl(src_params->fPosition.usecs);
  363. dst_params->fPosition.frame_rate = htonl(src_params->fPosition.frame_rate);
  364. dst_params->fPosition.frame = htonl(src_params->fPosition.frame);
  365. dst_params->fPosition.valid = (jack_position_bits_t)htonl((uint32_t)src_params->fPosition.valid);
  366. dst_params->fPosition.bar = htonl(src_params->fPosition.bar);
  367. dst_params->fPosition.beat = htonl(src_params->fPosition.beat);
  368. dst_params->fPosition.tick = htonl(src_params->fPosition.tick);
  369. dst_params->fPosition.bar_start_tick = htonll((uint64_t)src_params->fPosition.bar_start_tick);
  370. dst_params->fPosition.beats_per_bar = htonl((uint32_t)src_params->fPosition.beats_per_bar);
  371. dst_params->fPosition.beat_type = htonl((uint32_t)src_params->fPosition.beat_type);
  372. dst_params->fPosition.ticks_per_beat = htonll((uint64_t)src_params->fPosition.ticks_per_beat);
  373. dst_params->fPosition.beats_per_minute = htonll((uint64_t)src_params->fPosition.beats_per_minute);
  374. dst_params->fPosition.frame_time = htonll((uint64_t)src_params->fPosition.frame_time);
  375. dst_params->fPosition.next_time = htonll((uint64_t)src_params->fPosition.next_time);
  376. dst_params->fPosition.bbt_offset = htonl(src_params->fPosition.bbt_offset);
  377. dst_params->fPosition.audio_frames_per_video_frame = htonl((uint32_t)src_params->fPosition.audio_frames_per_video_frame);
  378. dst_params->fPosition.video_offset = htonl(src_params->fPosition.video_offset);
  379. dst_params->fPosition.unique_2 = htonll(src_params->fPosition.unique_2);
  380. }
  381. SERVER_EXPORT void TransportDataNToH ( net_transport_data_t* src_params, net_transport_data_t* dst_params )
  382. {
  383. dst_params->fNewState = ntohl(src_params->fNewState);
  384. dst_params->fTimebaseMaster = ntohl(src_params->fTimebaseMaster);
  385. dst_params->fState = ntohl(src_params->fState);
  386. dst_params->fPosition.unique_1 = ntohll(src_params->fPosition.unique_1);
  387. dst_params->fPosition.usecs = ntohl(src_params->fPosition.usecs);
  388. dst_params->fPosition.frame_rate = ntohl(src_params->fPosition.frame_rate);
  389. dst_params->fPosition.frame = ntohl(src_params->fPosition.frame);
  390. dst_params->fPosition.valid = (jack_position_bits_t)ntohl((uint32_t)src_params->fPosition.valid);
  391. dst_params->fPosition.bar = ntohl(src_params->fPosition.bar);
  392. dst_params->fPosition.beat = ntohl(src_params->fPosition.beat);
  393. dst_params->fPosition.tick = ntohl(src_params->fPosition.tick);
  394. dst_params->fPosition.bar_start_tick = ntohll((uint64_t)src_params->fPosition.bar_start_tick);
  395. dst_params->fPosition.beats_per_bar = ntohl((uint32_t)src_params->fPosition.beats_per_bar);
  396. dst_params->fPosition.beat_type = ntohl((uint32_t)src_params->fPosition.beat_type);
  397. dst_params->fPosition.ticks_per_beat = ntohll((uint64_t)src_params->fPosition.ticks_per_beat);
  398. dst_params->fPosition.beats_per_minute = ntohll((uint64_t)src_params->fPosition.beats_per_minute);
  399. dst_params->fPosition.frame_time = ntohll((uint64_t)src_params->fPosition.frame_time);
  400. dst_params->fPosition.next_time = ntohll((uint64_t)src_params->fPosition.next_time);
  401. dst_params->fPosition.bbt_offset = ntohl(src_params->fPosition.bbt_offset);
  402. dst_params->fPosition.audio_frames_per_video_frame = ntohl((uint32_t)src_params->fPosition.audio_frames_per_video_frame);
  403. dst_params->fPosition.video_offset = ntohl(src_params->fPosition.video_offset);
  404. dst_params->fPosition.unique_2 = ntohll(src_params->fPosition.unique_2);
  405. }
  406. // Utility *******************************************************************************************************
  407. SERVER_EXPORT int SocketAPIInit()
  408. {
  409. #ifdef WIN32
  410. WORD wVersionRequested = MAKEWORD ( 2, 2 );
  411. WSADATA wsaData;
  412. if ( WSAStartup ( wVersionRequested, &wsaData ) != 0 )
  413. {
  414. jack_error ( "WSAStartup error : %s", strerror ( NET_ERROR_CODE ) );
  415. return -1;
  416. }
  417. if ( LOBYTE ( wsaData.wVersion ) != 2 || HIBYTE ( wsaData.wVersion ) != 2 )
  418. {
  419. jack_error ( "Could not find a useable version of Winsock.dll\n" );
  420. WSACleanup();
  421. return -1;
  422. }
  423. #endif
  424. return 0;
  425. }
  426. SERVER_EXPORT int SocketAPIEnd()
  427. {
  428. #ifdef WIN32
  429. return WSACleanup();
  430. #endif
  431. return 0;
  432. }
  433. SERVER_EXPORT const char* GetTransportState ( int transport_state )
  434. {
  435. switch ( transport_state )
  436. {
  437. case JackTransportRolling:
  438. return "rolling";
  439. case JackTransportStarting:
  440. return "starting";
  441. case JackTransportStopped:
  442. return "stopped";
  443. case JackTransportNetStarting:
  444. return "netstarting";
  445. }
  446. return NULL;
  447. }
  448. }