From 7295bb645426f471282e415cd8ae3d1c3afe51c4 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Tue, 4 Aug 2015 12:25:46 +1000 Subject: [PATCH] Refactor methods in PortaudioBackend to get ASIO buffer sizes --- libs/backends/portaudio/portaudio_io.cc | 35 ++++++++++++++++++++----- libs/backends/portaudio/portaudio_io.h | 6 +++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/libs/backends/portaudio/portaudio_io.cc b/libs/backends/portaudio/portaudio_io.cc index 665df97823..c007e29436 100644 --- a/libs/backends/portaudio/portaudio_io.cc +++ b/libs/backends/portaudio/portaudio_io.cc @@ -160,7 +160,11 @@ PortAudioIO::available_sample_rates(int device_id, std::vector& sampleRat #ifdef WITH_ASIO bool -PortAudioIO::get_asio_buffer_sizes (int device_id, std::vector& buffer_sizes) +PortAudioIO::get_asio_buffer_properties (int device_id, + long& min_size_frames, + long& max_size_frames, + long& preferred_size_frames, + long& granularity) { // we shouldn't really need all these checks but it shouldn't hurt const PaDeviceInfo* device_info = Pa_GetDeviceInfo(device_id); @@ -185,20 +189,37 @@ PortAudioIO::get_asio_buffer_sizes (int device_id, std::vector& buffer return false; } - long min_size, max_size, preferred_size, granularity; - - PaError err = PaAsio_GetAvailableBufferSizes ( - device_id, &min_size, &max_size, &preferred_size, &granularity); + PaError err = PaAsio_GetAvailableBufferSizes (device_id, + &min_size_frames, + &max_size_frames, + &preferred_size_frames, + &granularity); if (err != paNoError) { DEBUG_AUDIO (string_compose ( "Unable to determine available buffer sizes for device %1\n", device_id)); return false; } - - buffer_sizes.push_back(preferred_size); return true; } + +bool +PortAudioIO::get_asio_buffer_sizes (int device_id, std::vector& buffer_sizes) +{ + long min_size_frames, max_size_frames, preferred_size_frames, granularity; + + if (!get_asio_buffer_properties (device_id, + min_size_frames, + max_size_frames, + preferred_size_frames, + granularity)) { + DEBUG_AUDIO (string_compose ( + "Unable to get device buffer properties from device index %1\n", device_id)); + return false; + } + + buffer_sizes.push_back(preferred_size_frames); +} #endif bool diff --git a/libs/backends/portaudio/portaudio_io.h b/libs/backends/portaudio/portaudio_io.h index 1a122e7074..3d52ae6509 100644 --- a/libs/backends/portaudio/portaudio_io.h +++ b/libs/backends/portaudio/portaudio_io.h @@ -56,6 +56,12 @@ public: bool get_default_buffer_sizes (int device_id, std::vector& buffer_sizes); #ifdef WITH_ASIO + bool get_asio_buffer_properties (int device_id, + long& min_size_frames, + long& max_size_frames, + long& preferred_size_frames, + long& granularity); + bool get_asio_buffer_sizes (int device_id, std::vector& buffer_size); #endif