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.

731 lines
29KB

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