@@ -125,7 +125,7 @@ static void s_bufferSwitch(long index, ASIOBool /*processNow*/)
125125 }
126126
127127 uint8_t * stream = reinterpret_cast <uint8_t *>(&proc_buf[0 ]);
128- active.callback (nullptr , stream, (int )(procSamplesTotal * sizeof (float )));
128+ active.callback (stream, (int )(procSamplesTotal * sizeof (float )));
129129
130130 constexpr float MAX_S16 = 32767 .0f ;
131131 constexpr float MAX_S18 = 131071 .0f ;
@@ -397,23 +397,23 @@ static ASIOError create_asio_buffers(long bufferSize, long outputChannels, long
397397 return ASE_OK;
398398}
399399
400- bool AsioAudioDriver::open ( const Spec& spec, Spec* activeSpec)
400+ AudioDeviceID AsioAudioDriver::defaultDevice () const
401401{
402- if (m_deviceId.empty ()) {
403- AudioDeviceList devices = availableOutputDevices ();
404- if (devices.empty ()) {
405- return false ;
406- }
407- m_deviceId = devices.at (0 ).id ;
402+ AudioDeviceList devices = availableOutputDevices ();
403+ if (devices.empty ()) {
404+ return AudioDeviceID ();
408405 }
409-
410- return doOpen (m_deviceId, spec, activeSpec);
406+ return devices.at (0 ).id ;
411407}
412408
413- bool AsioAudioDriver::doOpen ( const AudioDeviceID& device, const Spec& spec, Spec* activeSpec)
409+ bool AsioAudioDriver::open ( const Spec& spec, Spec* activeSpec)
414410{
415- LOGI () << " try open: " << device;
416- const char * name = device.c_str ();
411+ LOGI () << " try open: " << spec.deviceId ;
412+ IF_ASSERT_FAILED (!spec.deviceId .empty ()) {
413+ return false ;
414+ }
415+
416+ const char * name = spec.deviceId .c_str ();
417417 bool ok = s_adata.drivers .loadDriver (const_cast <char *>(name));
418418 if (!ok) {
419419 LOGE () << " failed load driver: " << name;
@@ -579,53 +579,7 @@ async::Channel<AsioAudioDriver::Spec> AsioAudioDriver::activeSpecChanged() const
579579 return m_activeSpecChanged;
580580}
581581
582- bool AsioAudioDriver::setOutputDeviceBufferSize (unsigned int bufferSize)
583- {
584- bool result = true ;
585-
586- if (isOpened ()) {
587- close ();
588- Spec spec = s_adata.activeSpec ;
589- spec.output .samplesPerChannel = bufferSize;
590- result = open (spec, nullptr );
591- }
592-
593- if (result) {
594- m_outputDeviceBufferSizeChanged.notify ();
595- }
596-
597- return result;
598- }
599-
600- async::Notification AsioAudioDriver::outputDeviceBufferSizeChanged () const
601- {
602- return m_outputDeviceBufferSizeChanged;
603- }
604-
605- bool AsioAudioDriver::setOutputDeviceSampleRate (unsigned int sampleRate)
606- {
607- bool result = true ;
608-
609- if (isOpened ()) {
610- close ();
611- Spec spec = s_adata.activeSpec ;
612- spec.output .sampleRate = sampleRate;
613- result = open (spec, nullptr );
614- }
615-
616- if (result) {
617- m_outputDeviceSampleRateChanged.notify ();
618- }
619-
620- return result;
621- }
622-
623- async::Notification AsioAudioDriver::outputDeviceSampleRateChanged () const
624- {
625- return m_outputDeviceSampleRateChanged;
626- }
627-
628- std::vector<unsigned int > AsioAudioDriver::availableOutputDeviceBufferSizes () const
582+ std::vector<samples_t > AsioAudioDriver::availableOutputDeviceBufferSizes () const
629583{
630584 if (!isOpened ()) {
631585 return {
@@ -637,69 +591,27 @@ std::vector<unsigned int> AsioAudioDriver::availableOutputDeviceBufferSizes() co
637591 };
638592 }
639593
640- std::vector<unsigned int > result;
594+ std::vector<samples_t > result;
641595
642596 samples_t n = s_adata.deviceMetrics .maxSize ;
643597 samples_t min = s_adata.deviceMetrics .minSize ;
644598
645599 while (n >= min) {
646- result.push_back (static_cast < unsigned int >(n) );
600+ result.push_back (n );
647601 n /= 2 ;
648602 }
649603
650604 return result;
651605}
652606
653- std::vector<unsigned int > AsioAudioDriver::availableOutputDeviceSampleRates () const
607+ std::vector<sample_rate_t > AsioAudioDriver::availableOutputDeviceSampleRates () const
654608{
655609 return {
656610 44100 ,
657611 48000
658612 };
659613}
660614
661- AudioDeviceID AsioAudioDriver::outputDevice () const
662- {
663- return m_deviceId;
664- }
665-
666- bool AsioAudioDriver::selectOutputDevice (const AudioDeviceID& id)
667- {
668- bool result = true ;
669-
670- if (m_deviceId == id) {
671- return result;
672- }
673-
674- m_deviceId = id;
675-
676- if (isOpened ()) {
677- close ();
678- Spec spec = s_adata.activeSpec ;
679-
680- // ! NOTE We are trying to open a new device with the default value;
681- // ! it is not known what it was before.
682- spec.output .samplesPerChannel = DEFAULT_BUFFER_SIZE;
683- result = open (spec, nullptr );
684- }
685-
686- if (result) {
687- m_outputDeviceChanged.notify ();
688- }
689-
690- return result;
691- }
692-
693- bool AsioAudioDriver::resetToDefaultOutputDevice ()
694- {
695- return selectOutputDevice (AudioDeviceID ());
696- }
697-
698- async::Notification AsioAudioDriver::outputDeviceChanged () const
699- {
700- return m_outputDeviceChanged;
701- }
702-
703615AudioDeviceList AsioAudioDriver::availableOutputDevices () const
704616{
705617 char names[16 ][32 ];
@@ -727,11 +639,3 @@ async::Notification AsioAudioDriver::availableOutputDevicesChanged() const
727639{
728640 return m_availableOutputDevicesChanged;
729641}
730-
731- void AsioAudioDriver::resume ()
732- {
733- }
734-
735- void AsioAudioDriver::suspend ()
736- {
737- }
0 commit comments