Audio plugin host https://kx.studio/carla
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.

rtaudio.diff 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. diff --git a/RtAudio.cpp b/RtAudio.cpp
  2. index 2ac2179..c658295 100644
  3. --- a/RtAudio.cpp
  4. +++ b/RtAudio.cpp
  5. @@ -282,7 +282,7 @@ void RtApi :: openStream( RtAudio::StreamParameters *oParams,
  6. return;
  7. }
  8. - if ( oParams == NULL && iParams == NULL ) {
  9. + if ( oParams == NULL && iParams == NULL && getCurrentApi() != RtAudio::RTAUDIO_DUMMY ) {
  10. errorText_ = "RtApi::openStream: input and output StreamParameters structures are both NULL!";
  11. error( RtAudioError::INVALID_USE );
  12. return;
  13. @@ -1587,6 +1587,8 @@ static void *coreStopStream( void *ptr )
  14. object->stopStream();
  15. pthread_exit( NULL );
  16. +
  17. + return NULL;
  18. }
  19. bool RtApiCore :: callbackEvent( AudioDeviceID deviceId,
  20. @@ -1925,7 +1927,7 @@ const char* RtApiCore :: getErrorCode( OSStatus code )
  21. // devices are available (i.e., the JACK server is not running), a
  22. // stream cannot be opened.
  23. -#include <jack/jack.h>
  24. +#include "jackbridge/JackBridge.hpp"
  25. #include <unistd.h>
  26. #include <cstdio>
  27. @@ -1944,17 +1946,9 @@ struct JackHandle {
  28. :client(0), drainCounter(0), internalDrain(false) { ports[0] = 0; ports[1] = 0; xrun[0] = false; xrun[1] = false; }
  29. };
  30. -#if !defined(__RTAUDIO_DEBUG__)
  31. -static void jackSilentError( const char * ) {};
  32. -#endif
  33. -
  34. RtApiJack :: RtApiJack()
  35. :shouldAutoconnect_(true) {
  36. // Nothing to do here.
  37. -#if !defined(__RTAUDIO_DEBUG__)
  38. - // Turn off Jack's internal error reporting.
  39. - jack_set_error_function( &jackSilentError );
  40. -#endif
  41. }
  42. RtApiJack :: ~RtApiJack()
  43. @@ -1967,13 +1961,13 @@ unsigned int RtApiJack :: getDeviceCount( void )
  44. // See if we can become a jack client.
  45. jack_options_t options = (jack_options_t) ( JackNoStartServer ); //JackNullOption;
  46. jack_status_t *status = NULL;
  47. - jack_client_t *client = jack_client_open( "RtApiJackCount", options, status );
  48. + jack_client_t *client = jackbridge_client_open( "CarlaJackCount", options, status );
  49. if ( client == 0 ) return 0;
  50. const char **ports;
  51. std::string port, previousPort;
  52. unsigned int nChannels = 0, nDevices = 0;
  53. - ports = jack_get_ports( client, NULL, NULL, 0 );
  54. + ports = jackbridge_get_ports( client, NULL, NULL, 0 );
  55. if ( ports ) {
  56. // Parse the port names up to the first colon (:).
  57. size_t iColon = 0;
  58. @@ -1988,10 +1982,10 @@ unsigned int RtApiJack :: getDeviceCount( void )
  59. }
  60. }
  61. } while ( ports[++nChannels] );
  62. - free( ports );
  63. + jackbridge_free( ports );
  64. }
  65. - jack_client_close( client );
  66. + jackbridge_client_close( client );
  67. return nDevices;
  68. }
  69. @@ -2002,7 +1996,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device )
  70. jack_options_t options = (jack_options_t) ( JackNoStartServer ); //JackNullOption
  71. jack_status_t *status = NULL;
  72. - jack_client_t *client = jack_client_open( "RtApiJackInfo", options, status );
  73. + jack_client_t *client = jackbridge_client_open( "CarlaJackInfo", options, status );
  74. if ( client == 0 ) {
  75. errorText_ = "RtApiJack::getDeviceInfo: Jack server not found or connection error!";
  76. error( RtAudioError::WARNING );
  77. @@ -2012,7 +2006,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device )
  78. const char **ports;
  79. std::string port, previousPort;
  80. unsigned int nPorts = 0, nDevices = 0;
  81. - ports = jack_get_ports( client, NULL, NULL, 0 );
  82. + ports = jackbridge_get_ports( client, NULL, NULL, 0 );
  83. if ( ports ) {
  84. // Parse the port names up to the first colon (:).
  85. size_t iColon = 0;
  86. @@ -2028,11 +2022,11 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device )
  87. }
  88. }
  89. } while ( ports[++nPorts] );
  90. - free( ports );
  91. + jackbridge_free( ports );
  92. }
  93. if ( device >= nDevices ) {
  94. - jack_client_close( client );
  95. + jackbridge_client_close( client );
  96. errorText_ = "RtApiJack::getDeviceInfo: device ID is invalid!";
  97. error( RtAudioError::INVALID_USE );
  98. return info;
  99. @@ -2041,30 +2035,30 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device )
  100. // Get the current jack server sample rate.
  101. info.sampleRates.clear();
  102. - info.preferredSampleRate = jack_get_sample_rate( client );
  103. + info.preferredSampleRate = jackbridge_get_sample_rate( client );
  104. info.sampleRates.push_back( info.preferredSampleRate );
  105. // Count the available ports containing the client name as device
  106. // channels. Jack "input ports" equal RtAudio output channels.
  107. unsigned int nChannels = 0;
  108. - ports = jack_get_ports( client, info.name.c_str(), NULL, JackPortIsInput );
  109. + ports = jackbridge_get_ports( client, info.name.c_str(), NULL, JackPortIsInput );
  110. if ( ports ) {
  111. while ( ports[ nChannels ] ) nChannels++;
  112. - free( ports );
  113. + jackbridge_free( ports );
  114. info.outputChannels = nChannels;
  115. }
  116. // Jack "output ports" equal RtAudio input channels.
  117. nChannels = 0;
  118. - ports = jack_get_ports( client, info.name.c_str(), NULL, JackPortIsOutput );
  119. + ports = jackbridge_get_ports( client, info.name.c_str(), NULL, JackPortIsOutput );
  120. if ( ports ) {
  121. while ( ports[ nChannels ] ) nChannels++;
  122. - free( ports );
  123. + jackbridge_free( ports );
  124. info.inputChannels = nChannels;
  125. }
  126. if ( info.outputChannels == 0 && info.inputChannels == 0 ) {
  127. - jack_client_close(client);
  128. + jackbridge_client_close(client);
  129. errorText_ = "RtApiJack::getDeviceInfo: error determining Jack input/output channels!";
  130. error( RtAudioError::WARNING );
  131. return info;
  132. @@ -2083,7 +2077,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device )
  133. if ( device == 0 && info.inputChannels > 0 )
  134. info.isDefaultInput = true;
  135. - jack_client_close(client);
  136. + jackbridge_client_close(client);
  137. info.probed = true;
  138. return info;
  139. }
  140. @@ -2101,7 +2095,7 @@ static int jackCallbackHandler( jack_nframes_t nframes, void *infoPointer )
  141. // This function will be called by a spawned thread when the Jack
  142. // server signals that it is shutting down. It is necessary to handle
  143. // it this way because the jackShutdown() function must return before
  144. -// the jack_deactivate() function (in closeStream()) will return.
  145. +// the jackbridge_deactivate() function (in closeStream()) will return.
  146. static void *jackCloseStream( void *ptr )
  147. {
  148. CallbackInfo *info = (CallbackInfo *) ptr;
  149. @@ -2110,6 +2104,8 @@ static void *jackCloseStream( void *ptr )
  150. object->closeStream();
  151. pthread_exit( NULL );
  152. +
  153. + return NULL;
  154. }
  155. static void jackShutdown( void *infoPointer )
  156. {
  157. @@ -2151,9 +2147,9 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
  158. jack_options_t jackoptions = (jack_options_t) ( JackNoStartServer ); //JackNullOption;
  159. jack_status_t *status = NULL;
  160. if ( options && !options->streamName.empty() )
  161. - client = jack_client_open( options->streamName.c_str(), jackoptions, status );
  162. + client = jackbridge_client_open( options->streamName.c_str(), jackoptions, status );
  163. else
  164. - client = jack_client_open( "RtApiJack", jackoptions, status );
  165. + client = jackbridge_client_open( "CarlaJack", jackoptions, status );
  166. if ( client == 0 ) {
  167. errorText_ = "RtApiJack::probeDeviceOpen: Jack server not found or connection error!";
  168. error( RtAudioError::WARNING );
  169. @@ -2168,7 +2164,7 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
  170. const char **ports;
  171. std::string port, previousPort, deviceName;
  172. unsigned int nPorts = 0, nDevices = 0;
  173. - ports = jack_get_ports( client, NULL, NULL, 0 );
  174. + ports = jackbridge_get_ports( client, NULL, NULL, 0 );
  175. if ( ports ) {
  176. // Parse the port names up to the first colon (:).
  177. size_t iColon = 0;
  178. @@ -2184,7 +2180,7 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
  179. }
  180. }
  181. } while ( ports[++nPorts] );
  182. - free( ports );
  183. + jackbridge_free( ports );
  184. }
  185. if ( device >= nDevices ) {
  186. @@ -2197,10 +2193,10 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
  187. unsigned int nChannels = 0;
  188. unsigned long flag = JackPortIsInput;
  189. if ( mode == INPUT ) flag = JackPortIsOutput;
  190. - ports = jack_get_ports( client, deviceName.c_str(), NULL, flag );
  191. + ports = jackbridge_get_ports( client, deviceName.c_str(), NULL, flag );
  192. if ( ports ) {
  193. while ( ports[ nChannels ] ) nChannels++;
  194. - free( ports );
  195. + jackbridge_free( ports );
  196. }
  197. // Compare the jack ports for specified client to the requested number of channels.
  198. @@ -2211,9 +2207,9 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
  199. }
  200. // Check the jack server sample rate.
  201. - unsigned int jackRate = jack_get_sample_rate( client );
  202. + unsigned int jackRate = jackbridge_get_sample_rate( client );
  203. if ( sampleRate != jackRate ) {
  204. - jack_client_close( client );
  205. + jackbridge_client_close( client );
  206. errorStream_ << "RtApiJack::probeDeviceOpen: the requested sample rate (" << sampleRate << ") is different than the JACK server rate (" << jackRate << ").";
  207. errorText_ = errorStream_.str();
  208. return FAILURE;
  209. @@ -2221,19 +2217,19 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
  210. stream_.sampleRate = jackRate;
  211. // Get the latency of the JACK port.
  212. - ports = jack_get_ports( client, deviceName.c_str(), NULL, flag );
  213. + ports = jackbridge_get_ports( client, deviceName.c_str(), NULL, flag );
  214. if ( ports[ firstChannel ] ) {
  215. // Added by Ge Wang
  216. jack_latency_callback_mode_t cbmode = (mode == INPUT ? JackCaptureLatency : JackPlaybackLatency);
  217. // the range (usually the min and max are equal)
  218. jack_latency_range_t latrange; latrange.min = latrange.max = 0;
  219. // get the latency range
  220. - jack_port_get_latency_range( jack_port_by_name( client, ports[firstChannel] ), cbmode, &latrange );
  221. + jackbridge_port_get_latency_range( jackbridge_port_by_name( client, ports[firstChannel] ), cbmode, &latrange );
  222. // be optimistic, use the min!
  223. stream_.latency[mode] = latrange.min;
  224. - //stream_.latency[mode] = jack_port_get_latency( jack_port_by_name( client, ports[ firstChannel ] ) );
  225. + //stream_.latency[mode] = jack_port_get_latency( jackbridge_port_by_name( client, ports[ firstChannel ] ) );
  226. }
  227. - free( ports );
  228. + jackbridge_free( ports );
  229. // The jack server always uses 32-bit floating-point data.
  230. stream_.deviceFormat[mode] = RTAUDIO_FLOAT32;
  231. @@ -2250,7 +2246,7 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
  232. // Get the buffer size. The buffer size and number of buffers
  233. // (periods) is set when the jack server is started.
  234. - stream_.bufferSize = (int) jack_get_buffer_size( client );
  235. + stream_.bufferSize = (int) jackbridge_get_buffer_size( client );
  236. *bufferSize = stream_.bufferSize;
  237. stream_.nDeviceChannels[mode] = channels;
  238. @@ -2333,24 +2329,24 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
  239. stream_.mode = DUPLEX;
  240. else {
  241. stream_.mode = mode;
  242. - jack_set_process_callback( handle->client, jackCallbackHandler, (void *) &stream_.callbackInfo );
  243. - jack_set_xrun_callback( handle->client, jackXrun, (void *) &stream_.apiHandle );
  244. - jack_on_shutdown( handle->client, jackShutdown, (void *) &stream_.callbackInfo );
  245. + jackbridge_set_process_callback( handle->client, jackCallbackHandler, (void *) &stream_.callbackInfo );
  246. + jackbridge_set_xrun_callback( handle->client, jackXrun, (void *) &stream_.apiHandle );
  247. + jackbridge_on_shutdown( handle->client, jackShutdown, (void *) &stream_.callbackInfo );
  248. }
  249. // Register our ports.
  250. char label[64];
  251. if ( mode == OUTPUT ) {
  252. for ( unsigned int i=0; i<stream_.nUserChannels[0]; i++ ) {
  253. - snprintf( label, 64, "outport %d", i );
  254. - handle->ports[0][i] = jack_port_register( handle->client, (const char *)label,
  255. + snprintf( label, 64, "audio-out%d", i+1 );
  256. + handle->ports[0][i] = jackbridge_port_register( handle->client, (const char *)label,
  257. JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 );
  258. }
  259. }
  260. else {
  261. for ( unsigned int i=0; i<stream_.nUserChannels[1]; i++ ) {
  262. - snprintf( label, 64, "inport %d", i );
  263. - handle->ports[1][i] = jack_port_register( handle->client, (const char *)label,
  264. + snprintf( label, 64, "audio-in%d", i+1 );
  265. + handle->ports[1][i] = jackbridge_port_register( handle->client, (const char *)label,
  266. JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0 );
  267. }
  268. }
  269. @@ -2367,7 +2363,7 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
  270. error:
  271. if ( handle ) {
  272. pthread_cond_destroy( &handle->condition );
  273. - jack_client_close( handle->client );
  274. + jackbridge_client_close( handle->client );
  275. if ( handle->ports[0] ) free( handle->ports[0] );
  276. if ( handle->ports[1] ) free( handle->ports[1] );
  277. @@ -2403,9 +2399,9 @@ void RtApiJack :: closeStream( void )
  278. if ( handle ) {
  279. if ( stream_.state == STREAM_RUNNING )
  280. - jack_deactivate( handle->client );
  281. + jackbridge_deactivate( handle->client );
  282. - jack_client_close( handle->client );
  283. + jackbridge_client_close( handle->client );
  284. }
  285. if ( handle ) {
  286. @@ -2442,8 +2438,8 @@ void RtApiJack :: startStream( void )
  287. }
  288. JackHandle *handle = (JackHandle *) stream_.apiHandle;
  289. - int result = jack_activate( handle->client );
  290. - if ( result ) {
  291. + bool result = jackbridge_activate( handle->client );
  292. + if ( ! result ) {
  293. errorText_ = "RtApiJack::startStream(): unable to activate JACK client!";
  294. goto unlock;
  295. }
  296. @@ -2452,8 +2448,8 @@ void RtApiJack :: startStream( void )
  297. // Get the list of available ports.
  298. if ( shouldAutoconnect_ && (stream_.mode == OUTPUT || stream_.mode == DUPLEX) ) {
  299. - result = 1;
  300. - ports = jack_get_ports( handle->client, handle->deviceName[0].c_str(), NULL, JackPortIsInput);
  301. + result = false;
  302. + ports = jackbridge_get_ports( handle->client, handle->deviceName[0].c_str(), NULL, JackPortIsInput);
  303. if ( ports == NULL) {
  304. errorText_ = "RtApiJack::startStream(): error determining available JACK input ports!";
  305. goto unlock;
  306. @@ -2463,21 +2459,21 @@ void RtApiJack :: startStream( void )
  307. // allow the user to select particular channels of a device, we'll
  308. // just open the first "nChannels" ports with offset.
  309. for ( unsigned int i=0; i<stream_.nUserChannels[0]; i++ ) {
  310. - result = 1;
  311. + result = false;
  312. if ( ports[ stream_.channelOffset[0] + i ] )
  313. - result = jack_connect( handle->client, jack_port_name( handle->ports[0][i] ), ports[ stream_.channelOffset[0] + i ] );
  314. - if ( result ) {
  315. - free( ports );
  316. + result = jackbridge_connect( handle->client, jackbridge_port_name( handle->ports[0][i] ), ports[ stream_.channelOffset[0] + i ] );
  317. + if ( ! result ) {
  318. + jackbridge_free( ports );
  319. errorText_ = "RtApiJack::startStream(): error connecting output ports!";
  320. goto unlock;
  321. }
  322. }
  323. - free(ports);
  324. + jackbridge_free(ports);
  325. }
  326. if ( shouldAutoconnect_ && (stream_.mode == INPUT || stream_.mode == DUPLEX) ) {
  327. - result = 1;
  328. - ports = jack_get_ports( handle->client, handle->deviceName[1].c_str(), NULL, JackPortIsOutput );
  329. + result = false;
  330. + ports = jackbridge_get_ports( handle->client, handle->deviceName[1].c_str(), NULL, JackPortIsOutput );
  331. if ( ports == NULL) {
  332. errorText_ = "RtApiJack::startStream(): error determining available JACK output ports!";
  333. goto unlock;
  334. @@ -2485,16 +2481,16 @@ void RtApiJack :: startStream( void )
  335. // Now make the port connections. See note above.
  336. for ( unsigned int i=0; i<stream_.nUserChannels[1]; i++ ) {
  337. - result = 1;
  338. + result = false;
  339. if ( ports[ stream_.channelOffset[1] + i ] )
  340. - result = jack_connect( handle->client, ports[ stream_.channelOffset[1] + i ], jack_port_name( handle->ports[1][i] ) );
  341. - if ( result ) {
  342. - free( ports );
  343. + result = jackbridge_connect( handle->client, ports[ stream_.channelOffset[1] + i ], jackbridge_port_name( handle->ports[1][i] ) );
  344. + if ( ! result ) {
  345. + jackbridge_free( ports );
  346. errorText_ = "RtApiJack::startStream(): error connecting input ports!";
  347. goto unlock;
  348. }
  349. }
  350. - free(ports);
  351. + jackbridge_free(ports);
  352. }
  353. handle->drainCounter = 0;
  354. @@ -2502,7 +2498,7 @@ void RtApiJack :: startStream( void )
  355. stream_.state = STREAM_RUNNING;
  356. unlock:
  357. - if ( result == 0 ) return;
  358. + if ( result ) return;
  359. error( RtAudioError::SYSTEM_ERROR );
  360. }
  361. @@ -2524,7 +2520,7 @@ void RtApiJack :: stopStream( void )
  362. }
  363. }
  364. - jack_deactivate( handle->client );
  365. + jackbridge_deactivate( handle->client );
  366. stream_.state = STREAM_STOPPED;
  367. }
  368. @@ -2546,7 +2542,7 @@ void RtApiJack :: abortStream( void )
  369. // This function will be called by a spawned thread when the user
  370. // callback function signals that the stream should be stopped or
  371. // aborted. It is necessary to handle it this way because the
  372. -// callbackEvent() function must return before the jack_deactivate()
  373. +// callbackEvent() function must return before the jackbridge_deactivate()
  374. // function will return.
  375. static void *jackStopStream( void *ptr )
  376. {
  377. @@ -2555,6 +2551,8 @@ static void *jackStopStream( void *ptr )
  378. object->stopStream();
  379. pthread_exit( NULL );
  380. +
  381. + return NULL;
  382. }
  383. bool RtApiJack :: callbackEvent( unsigned long nframes )
  384. @@ -2621,7 +2619,7 @@ bool RtApiJack :: callbackEvent( unsigned long nframes )
  385. if ( handle->drainCounter > 1 ) { // write zeros to the output stream
  386. for ( unsigned int i=0; i<stream_.nDeviceChannels[0]; i++ ) {
  387. - jackbuffer = (jack_default_audio_sample_t *) jack_port_get_buffer( handle->ports[0][i], (jack_nframes_t) nframes );
  388. + jackbuffer = (jack_default_audio_sample_t *) jackbridge_port_get_buffer( handle->ports[0][i], (jack_nframes_t) nframes );
  389. memset( jackbuffer, 0, bufferBytes );
  390. }
  391. @@ -2631,13 +2629,13 @@ bool RtApiJack :: callbackEvent( unsigned long nframes )
  392. convertBuffer( stream_.deviceBuffer, stream_.userBuffer[0], stream_.convertInfo[0] );
  393. for ( unsigned int i=0; i<stream_.nDeviceChannels[0]; i++ ) {
  394. - jackbuffer = (jack_default_audio_sample_t *) jack_port_get_buffer( handle->ports[0][i], (jack_nframes_t) nframes );
  395. + jackbuffer = (jack_default_audio_sample_t *) jackbridge_port_get_buffer( handle->ports[0][i], (jack_nframes_t) nframes );
  396. memcpy( jackbuffer, &stream_.deviceBuffer[i*bufferBytes], bufferBytes );
  397. }
  398. }
  399. else { // no buffer conversion
  400. for ( unsigned int i=0; i<stream_.nUserChannels[0]; i++ ) {
  401. - jackbuffer = (jack_default_audio_sample_t *) jack_port_get_buffer( handle->ports[0][i], (jack_nframes_t) nframes );
  402. + jackbuffer = (jack_default_audio_sample_t *) jackbridge_port_get_buffer( handle->ports[0][i], (jack_nframes_t) nframes );
  403. memcpy( jackbuffer, &stream_.userBuffer[0][i*bufferBytes], bufferBytes );
  404. }
  405. }
  406. @@ -2653,14 +2651,14 @@ bool RtApiJack :: callbackEvent( unsigned long nframes )
  407. if ( stream_.doConvertBuffer[1] ) {
  408. for ( unsigned int i=0; i<stream_.nDeviceChannels[1]; i++ ) {
  409. - jackbuffer = (jack_default_audio_sample_t *) jack_port_get_buffer( handle->ports[1][i], (jack_nframes_t) nframes );
  410. + jackbuffer = (jack_default_audio_sample_t *) jackbridge_port_get_buffer( handle->ports[1][i], (jack_nframes_t) nframes );
  411. memcpy( &stream_.deviceBuffer[i*bufferBytes], jackbuffer, bufferBytes );
  412. }
  413. convertBuffer( stream_.userBuffer[1], stream_.deviceBuffer, stream_.convertInfo[1] );
  414. }
  415. else { // no buffer conversion
  416. for ( unsigned int i=0; i<stream_.nUserChannels[1]; i++ ) {
  417. - jackbuffer = (jack_default_audio_sample_t *) jack_port_get_buffer( handle->ports[1][i], (jack_nframes_t) nframes );
  418. + jackbuffer = (jack_default_audio_sample_t *) jackbridge_port_get_buffer( handle->ports[1][i], (jack_nframes_t) nframes );
  419. memcpy( &stream_.userBuffer[1][i*bufferBytes], jackbuffer, bufferBytes );
  420. }
  421. }
  422. @@ -2691,10 +2689,10 @@ bool RtApiJack :: callbackEvent( unsigned long nframes )
  423. // on information found in
  424. // http://www.cs.wustl.edu/~schmidt/win32-cv-1.html.
  425. -#include "asiosys.h"
  426. -#include "asio.h"
  427. -#include "iasiothiscallresolver.h"
  428. -#include "asiodrivers.h"
  429. +#include "asio.cpp"
  430. +#include "asiodrivers.cpp"
  431. +#include "asiolist.cpp"
  432. +#include "iasiothiscallresolver.cpp"
  433. #include <cmath>
  434. static AsioDrivers drivers;
  435. @@ -8012,6 +8010,8 @@ static void *alsaCallbackHandler( void *ptr )
  436. }
  437. pthread_exit( NULL );
  438. +
  439. + return NULL;
  440. }
  441. //******************** End of __LINUX_ALSA__ *********************//
  442. @@ -8092,6 +8092,8 @@ static void *pulseaudio_callback( void * user )
  443. }
  444. pthread_exit( NULL );
  445. +
  446. + return NULL;
  447. }
  448. void RtApiPulse::closeStream( void )
  449. @@ -9446,6 +9448,8 @@ static void *ossCallbackHandler( void *ptr )
  450. }
  451. pthread_exit( NULL );
  452. +
  453. + return NULL;
  454. }
  455. //******************** End of __LINUX_OSS__ *********************//
  456. diff --git a/RtAudio.h b/RtAudio.h
  457. index 34a2534..4c32cab 100644
  458. --- a/RtAudio.h
  459. +++ b/RtAudio.h
  460. @@ -46,16 +46,7 @@
  461. #define __RTAUDIO_H
  462. #define RTAUDIO_VERSION "5.0.0"
  463. -
  464. -#if defined _WIN32 || defined __CYGWIN__
  465. - #define RTAUDIO_DLL_PUBLIC
  466. -#else
  467. - #if __GNUC__ >= 4
  468. - #define RTAUDIO_DLL_PUBLIC __attribute__( (visibility( "default" )) )
  469. - #else
  470. - #define RTAUDIO_DLL_PUBLIC
  471. - #endif
  472. -#endif
  473. +#define RTAUDIO_DLL_PUBLIC
  474. #include <string>
  475. #include <vector>
  476. @@ -416,7 +407,7 @@ class RTAUDIO_DLL_PUBLIC RtAudio
  477. ~RtAudio();
  478. //! Returns the audio API specifier for the current instance of RtAudio.
  479. - RtAudio::Api getCurrentApi( void );
  480. + RtAudio::Api getCurrentApi( void ) const;
  481. //! A public function that queries for the number of audio devices available.
  482. /*!
  483. @@ -687,7 +678,7 @@ public:
  484. RtApi();
  485. virtual ~RtApi();
  486. - virtual RtAudio::Api getCurrentApi( void ) = 0;
  487. + virtual RtAudio::Api getCurrentApi( void ) const = 0;
  488. virtual unsigned int getDeviceCount( void ) = 0;
  489. virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0;
  490. virtual unsigned int getDefaultInputDevice( void );
  491. @@ -836,7 +827,7 @@ protected:
  492. //
  493. // **************************************************************** //
  494. -inline RtAudio::Api RtAudio :: getCurrentApi( void ) { return rtapi_->getCurrentApi(); }
  495. +inline RtAudio::Api RtAudio :: getCurrentApi( void ) const { return rtapi_->getCurrentApi(); }
  496. inline unsigned int RtAudio :: getDeviceCount( void ) { return rtapi_->getDeviceCount(); }
  497. inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); }
  498. inline unsigned int RtAudio :: getDefaultInputDevice( void ) { return rtapi_->getDefaultInputDevice(); }
  499. @@ -865,7 +856,7 @@ public:
  500. RtApiCore();
  501. ~RtApiCore();
  502. - RtAudio::Api getCurrentApi( void ) { return RtAudio::MACOSX_CORE; }
  503. + RtAudio::Api getCurrentApi( void ) const { return RtAudio::MACOSX_CORE; }
  504. unsigned int getDeviceCount( void );
  505. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  506. unsigned int getDefaultOutputDevice( void );
  507. @@ -903,7 +894,7 @@ public:
  508. RtApiJack();
  509. ~RtApiJack();
  510. - RtAudio::Api getCurrentApi( void ) { return RtAudio::UNIX_JACK; }
  511. + RtAudio::Api getCurrentApi( void ) const { return RtAudio::UNIX_JACK; }
  512. unsigned int getDeviceCount( void );
  513. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  514. void closeStream( void );
  515. @@ -938,7 +929,7 @@ public:
  516. RtApiAsio();
  517. ~RtApiAsio();
  518. - RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_ASIO; }
  519. + RtAudio::Api getCurrentApi( void ) const { return RtAudio::WINDOWS_ASIO; }
  520. unsigned int getDeviceCount( void );
  521. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  522. void closeStream( void );
  523. @@ -974,7 +965,7 @@ public:
  524. RtApiDs();
  525. ~RtApiDs();
  526. - RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_DS; }
  527. + RtAudio::Api getCurrentApi( void ) const { return RtAudio::WINDOWS_DS; }
  528. unsigned int getDeviceCount( void );
  529. unsigned int getDefaultOutputDevice( void );
  530. unsigned int getDefaultInputDevice( void );
  531. @@ -1015,7 +1006,7 @@ public:
  532. RtApiWasapi();
  533. ~RtApiWasapi();
  534. - RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_WASAPI; }
  535. + RtAudio::Api getCurrentApi( void ) const { return RtAudio::WINDOWS_WASAPI; }
  536. unsigned int getDeviceCount( void );
  537. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  538. unsigned int getDefaultOutputDevice( void );
  539. @@ -1050,7 +1041,7 @@ public:
  540. RtApiAlsa();
  541. ~RtApiAlsa();
  542. - RtAudio::Api getCurrentApi() { return RtAudio::LINUX_ALSA; }
  543. + RtAudio::Api getCurrentApi() const { return RtAudio::LINUX_ALSA; }
  544. unsigned int getDeviceCount( void );
  545. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  546. void closeStream( void );
  547. @@ -1082,7 +1073,7 @@ class RtApiPulse: public RtApi
  548. {
  549. public:
  550. ~RtApiPulse();
  551. - RtAudio::Api getCurrentApi() { return RtAudio::LINUX_PULSE; }
  552. + RtAudio::Api getCurrentApi() const { return RtAudio::LINUX_PULSE; }
  553. unsigned int getDeviceCount( void );
  554. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  555. void closeStream( void );
  556. @@ -1116,7 +1107,7 @@ public:
  557. RtApiOss();
  558. ~RtApiOss();
  559. - RtAudio::Api getCurrentApi() { return RtAudio::LINUX_OSS; }
  560. + RtAudio::Api getCurrentApi() const { return RtAudio::LINUX_OSS; }
  561. unsigned int getDeviceCount( void );
  562. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  563. void closeStream( void );
  564. @@ -1147,7 +1138,7 @@ class RtApiDummy: public RtApi
  565. public:
  566. RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( RtAudioError::WARNING ); }
  567. - RtAudio::Api getCurrentApi( void ) { return RtAudio::RTAUDIO_DUMMY; }
  568. + RtAudio::Api getCurrentApi( void ) const { return RtAudio::RTAUDIO_DUMMY; }
  569. unsigned int getDeviceCount( void ) { return 0; }
  570. RtAudio::DeviceInfo getDeviceInfo( unsigned int /*device*/ ) { RtAudio::DeviceInfo info; return info; }
  571. void closeStream( void ) {}
  572. diff --git a/include/iasiodrv.h b/include/iasiodrv.h
  573. index 64d2dbb..860675c 100644
  574. --- a/include/iasiodrv.h
  575. +++ b/include/iasiodrv.h
  576. @@ -1,3 +1,4 @@
  577. +#pragma once
  578. #include "asiosys.h"
  579. #include "asio.h"