History

Fixes for new --driver commandline option.

Dana Batali committed 5 years ago

Commit f2b7d9e1 parent 04676c23 files · +44 −22Browse files

Unified · Split

3 files
  1. src/host/chuck_audio.cpp +35 −13
  2. src/host/chuck_audio.h +5 −4
  3. src/host/chuck_main.cpp +4 −5
src/host/chuck_audio.cpp+35−13
@@ -130,6 +130,23 @@ static RtAudio::Api driverNameToApi(char const *driver) · 129 unmodified lines
130 return api;130 return api;
131}131}
132 132
133static char const *apiToDriverName(RtAudio::Api api)
134{
135 static char const *drivers[] = {
136 "unspecified",
137 "ALSA",
138 "Pulse",
139 "OSS",
140 "JACK",
141 "MacOSXCore",
142 "ASIO",
143 "DS",
144 "DUMMY",
145 "Invalid"
146 };
147 return drivers[(int) api];
148}
149
133//-----------------------------------------------------------------------------150//-----------------------------------------------------------------------------
134// name: print()151// name: print()
135// desc: ...152// desc: ...
@@ -179,7 +196,8 @@ void print( const RtAudio::DeviceInfo & info ) · 43 unmodified lines
179//-----------------------------------------------------------------------------196//-----------------------------------------------------------------------------
180void ChuckAudio::probe(char const *driver)197void ChuckAudio::probe(char const *driver)
181{198{
182 RtAudio::Api api = driverNameToApi(driver);199 RtAudio::Api api = driverNameToApi(driver); // handles driver=NULL case
200 char const *dnm = apiToDriverName(api);
183 // rtaduio pointer201 // rtaduio pointer
184 RtAudio * audio = NULL;202 RtAudio * audio = NULL;
185 // device info struct203 // device info struct
@@ -190,13 +208,13 @@ void ChuckAudio::probe(char const *driver) · 4 unmodified lines
190 catch( RtAudioError err )208 catch( RtAudioError err )
191 {209 {
192 // problem finding audio devices, most likely210 // problem finding audio devices, most likely
193 EM_error2b( 0, "%s", err.getMessage().c_str() );211 EM_error2b( 0, "%s: %s", dnm, err.getMessage().c_str() );
194 return;212 return;
195 }213 }
196 214
197 // get count215 // get count
198 int devices = audio->getDeviceCount();216 int devices = audio->getDeviceCount();
199 EM_error2b( 0, "found %d device(s) ...", devices );217 EM_error2b( 0, "%s found %d device(s) ...", dnm, devices );
200 218
201 // reset -- what does this do219 // reset -- what does this do
202 EM_reset_msg();220 EM_reset_msg();
@@ -235,16 +253,19 @@ void ChuckAudio::probe(char const *driver) · 32 unmodified lines
235// desc: get device number by name; needs_dac/adc prompts further checks on253// desc: get device number by name; needs_dac/adc prompts further checks on
236// requested device having > 0 channels254// requested device having > 0 channels
237//-----------------------------------------------------------------------------255//-----------------------------------------------------------------------------
238t_CKUINT ChuckAudio::device_named( const std::string & name, t_CKBOOL needs_dac,256t_CKUINT ChuckAudio::device_named( char const *driver,
257 const std::string & name, t_CKBOOL needs_dac,
239 t_CKBOOL needs_adc )258 t_CKBOOL needs_adc )
240{259{
241 // rtaudio pointer260 // rtaudio pointer
242 RtAudio * audio = NULL;261 RtAudio * audio = NULL;
243 // device info struct262 // device info struct
244 RtAudio::DeviceInfo info;263 RtAudio::DeviceInfo info;
264 RtAudio::Api api = driverNameToApi(driver); // handles driver=NULL case
265 char const *dnm = apiToDriverName(api);
245 266
246 // allocate RtAudio267 // allocate RtAudio
247 try { audio = new RtAudio(); }268 try { audio = new RtAudio(api); }
248 catch( RtAudioError err )269 catch( RtAudioError err )
249 {270 {
250 // problem finding audio devices, most likely271 // problem finding audio devices, most likely
@@ -469,15 +490,15 @@ t_CKBOOL ChuckAudio::watchdog_stop() · 218 unmodified lines
469// name: initialize()490// name: initialize()
470// desc: ...491// desc: ...
471//-----------------------------------------------------------------------------492//-----------------------------------------------------------------------------
472t_CKBOOL ChuckAudio::initialize( t_CKUINT num_dac_channels,493t_CKBOOL ChuckAudio::initialize( char const *driver,
494 t_CKUINT num_dac_channels,
473 t_CKUINT num_adc_channels,495 t_CKUINT num_adc_channels,
474 t_CKUINT sample_rate,496 t_CKUINT sample_rate,
475 t_CKUINT buffer_size,497 t_CKUINT buffer_size,
476 t_CKUINT num_buffers,498 t_CKUINT num_buffers,
477 f_audio_cb callback,499 f_audio_cb callback,
478 void * data,500 void * data,
479 t_CKBOOL force_srate,501 t_CKBOOL force_srate )
480 char const *driver )
481{502{
482 if( m_init )503 if( m_init )
483 return FALSE;504 return FALSE;
@@ -506,11 +527,12 @@ t_CKBOOL ChuckAudio::initialize( t_CKUINT num_dac_channels, · 22 unmodified lines
506 527
507 // allocate RtAudio528 // allocate RtAudio
508 RtAudio::Api api = driverNameToApi(driver);529 RtAudio::Api api = driverNameToApi(driver);
530 char const *dnm = apiToDriverName(api);
509 try { m_rtaudio = new RtAudio(api); }531 try { m_rtaudio = new RtAudio(api); }
510 catch( RtAudioError err )532 catch( RtAudioError err )
511 {533 {
512 // problem finding audio devices, most likely534 // problem finding audio devices, most likely
513 EM_error2( 0, "%s", err.getMessage().c_str() );535 EM_error2( 0, "%s: %s", dnm, err.getMessage().c_str() );
514 // clean up536 // clean up
515 goto error;537 goto error;
516 }538 }
@@ -735,8 +757,8 @@ t_CKBOOL ChuckAudio::initialize( t_CKUINT num_dac_channels, · 218 unmodified lines
735 // open device757 // open device
736 try {758 try {
737 // log759 // log
738 EM_log( CK_LOG_FINE, "trying %d input %d output...",760 EM_log( CK_LOG_FINE, "%s trying %d input %d output...",
739 m_num_channels_in, m_num_channels_out );761 dnm, m_num_channels_in, m_num_channels_out );
740 762
741 RtAudio::StreamParameters output_parameters;763 RtAudio::StreamParameters output_parameters;
742 output_parameters.deviceId = m_dac_n;764 output_parameters.deviceId = m_dac_n;
@@ -763,8 +785,8 @@ t_CKBOOL ChuckAudio::initialize( t_CKUINT num_dac_channels, · 20 unmodified lines
763 &stream_options );785 &stream_options );
764 } catch( RtAudioError err ) {786 } catch( RtAudioError err ) {
765 // log787 // log
766 EM_log( CK_LOG_INFO, "exception caught: '%s'...", err.getMessage().c_str() );788 EM_log( CK_LOG_INFO, "%s exception caught: '%s'...", dnm, err.getMessage().c_str() );
767 EM_error2( 0, "%s", err.getMessage().c_str() );789 EM_error2( 0, "%s: %s", dnm, err.getMessage().c_str() );
768 SAFE_DELETE( m_rtaudio );790 SAFE_DELETE( m_rtaudio );
769 // clean up791 // clean up
770 goto error;792 goto error;
src/host/chuck_audio.h+5−4
@@ -89,7 +89,8 @@ extern t_CKFLOAT g_watchdog_timeout; · 88 unmodified lines
89class ChuckAudio89class ChuckAudio
90{90{
91public:91public:
92 static t_CKBOOL initialize( t_CKUINT num_dac_channels,92 static t_CKBOOL initialize( char const *driver, // NULL means default for build
93 t_CKUINT num_dac_channels,
93 t_CKUINT num_adc_channels,94 t_CKUINT num_adc_channels,
94 t_CKUINT sample_rate,95 t_CKUINT sample_rate,
95 t_CKUINT buffer_size,96 t_CKUINT buffer_size,
@@ -97,8 +98,7 @@ public: · 1 unmodified line
97 f_audio_cb callback,98 f_audio_cb callback,
98 void * data,99 void * data,
99 // force_srate added 1.3.1.2100 // force_srate added 1.3.1.2
100 t_CKBOOL force_srate,101 t_CKBOOL force_srate
101 char const *driver // NULL means default for build
102 );102 );
103 static void shutdown();103 static void shutdown();
104 static t_CKBOOL start();104 static t_CKBOOL start();
@@ -112,7 +112,8 @@ public: // device info · 7 unmodified lines
112 // probe audio devices112 // probe audio devices
113 static void probe(char const *driver); // NULL means default for build113 static void probe(char const *driver); // NULL means default for build
114 // get device number by name?114 // get device number by name?
115 static t_CKUINT device_named( const std::string & name,115 static t_CKUINT device_named( char const *driver,
116 const std::string & name,
116 t_CKBOOL needs_dac = FALSE,117 t_CKBOOL needs_dac = FALSE,
117 t_CKBOOL needs_adc = FALSE );118 t_CKBOOL needs_adc = FALSE );
118 119
src/host/chuck_main.cpp+4−5
@@ -848,7 +848,7 @@ bool go( int argc, const char ** argv ) · 847 unmodified lines
848 if( dac_name.size() > 0 )848 if( dac_name.size() > 0 )
849 {849 {
850 // check with RtAudio850 // check with RtAudio
851 int dev = ChuckAudio::device_named( dac_name, TRUE, FALSE );851 int dev = ChuckAudio::device_named( audioDriver, dac_name, TRUE, FALSE );
852 if( dev >= 0 )852 if( dev >= 0 )
853 {853 {
854 dac = dev;854 dac = dev;
@@ -865,7 +865,7 @@ bool go( int argc, const char ** argv ) · 10 unmodified lines
865 if( adc_name.size() > 0 )865 if( adc_name.size() > 0 )
866 {866 {
867 // check with RtAudio867 // check with RtAudio
868 int dev = ChuckAudio::device_named( adc_name, FALSE, TRUE );868 int dev = ChuckAudio::device_named( audioDriver, adc_name, FALSE, TRUE );
869 if( dev >= 0 )869 if( dev >= 0 )
870 {870 {
871 adc = dev;871 adc = dev;
@@ -921,9 +921,8 @@ bool go( int argc, const char ** argv ) · 49 unmodified lines
921 // TODO: refactor initialize() to take in the dac and adc nums921 // TODO: refactor initialize() to take in the dac and adc nums
922 ChuckAudio::m_adc_n = adc;922 ChuckAudio::m_adc_n = adc;
923 ChuckAudio::m_dac_n = dac;923 ChuckAudio::m_dac_n = dac;
924 t_CKBOOL retval = ChuckAudio::initialize( dac_chans, adc_chans,924 t_CKBOOL retval = ChuckAudio::initialize( audioDriver, dac_chans, adc_chans,
925 srate, buffer_size, num_buffers, cb, (void *)the_chuck, force_srate,925 srate, buffer_size, num_buffers, cb, (void *)the_chuck, force_srate);
926 audioDriver );
927 // check926 // check
928 if( !retval )927 if( !retval )
929 {928 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t