1 #include "portaudiocpp/AsioDeviceAdapter.hxx" 2 3 #include "portaudio.h" 4 #include "pa_asio.h" 5 6 #include "portaudiocpp/Device.hxx" 7 #include "portaudiocpp/HostApi.hxx" 8 #include "portaudiocpp/Exception.hxx" 9 10 namespace portaudio 11 { AsioDeviceAdapter(Device & device)12 AsioDeviceAdapter::AsioDeviceAdapter(Device &device) 13 { 14 if (device.hostApi().typeId() != paASIO) 15 throw PaCppException(PaCppException::UNABLE_TO_ADAPT_DEVICE); 16 17 device_ = &device; 18 19 PaError err = PaAsio_GetAvailableLatencyValues(device_->index(), &minBufferSize_, &maxBufferSize_, 20 &preferredBufferSize_, &granularity_); 21 22 if (err != paNoError) 23 throw PaException(err); 24 25 } 26 device()27 Device &AsioDeviceAdapter::device() 28 { 29 return *device_; 30 } 31 minBufferSize() const32 long AsioDeviceAdapter::minBufferSize() const 33 { 34 return minBufferSize_; 35 } 36 maxBufferSize() const37 long AsioDeviceAdapter::maxBufferSize() const 38 { 39 return maxBufferSize_; 40 } 41 preferredBufferSize() const42 long AsioDeviceAdapter::preferredBufferSize() const 43 { 44 return preferredBufferSize_; 45 } 46 granularity() const47 long AsioDeviceAdapter::granularity() const 48 { 49 return granularity_; 50 } 51 showControlPanel(void * systemSpecific)52 void AsioDeviceAdapter::showControlPanel(void *systemSpecific) 53 { 54 PaError err = PaAsio_ShowControlPanel(device_->index(), systemSpecific); 55 56 if (err != paNoError) 57 throw PaException(err); 58 } 59 inputChannelName(int channelIndex) const60 const char *AsioDeviceAdapter::inputChannelName(int channelIndex) const 61 { 62 const char *channelName; 63 PaError err = PaAsio_GetInputChannelName(device_->index(), channelIndex, &channelName); 64 65 if (err != paNoError) 66 throw PaException(err); 67 68 return channelName; 69 } 70 outputChannelName(int channelIndex) const71 const char *AsioDeviceAdapter::outputChannelName(int channelIndex) const 72 { 73 const char *channelName; 74 PaError err = PaAsio_GetOutputChannelName(device_->index(), channelIndex, &channelName); 75 76 if (err != paNoError) 77 throw PaException(err); 78 79 return channelName; 80 } 81 } 82 83 84