wip alsa buffersizes
This commit is contained in:
parent
7eb45bca6f
commit
7081c3bbd6
|
@ -22,7 +22,8 @@ hound = "3.4"
|
||||||
ringbuf = "0.1.6"
|
ringbuf = "0.1.6"
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
winapi = { version = "0.3", features = ["audiosessiontypes", "audioclient", "coml2api", "combaseapi", "debug", "devpkey", "handleapi", "ksmedia", "mmdeviceapi", "objbase", "profileapi", "std", "synchapi", "winbase", "winuser"] }
|
winapi = { path = "../winapi-rs", version = "0.3", features = ["audiosessiontypes", "audioclient", "coml2api", "combaseapi", "debug", "devpkey", "errhandlingapi", "handleapi", "ksmedia", "mmdeviceapi", "objbase", "std", "synchapi", "winbase", "winuser"] }
|
||||||
|
# winapi = { version = "0.3", features = ["audiosessiontypes", "audioclient", "coml2api", "combaseapi", "debug", "devpkey", "handleapi", "ksmedia", "mmdeviceapi", "objbase", "profileapi", "std", "synchapi", "winbase", "winuser"] }
|
||||||
asio-sys = { version = "0.1", path = "asio-sys", optional = true }
|
asio-sys = { version = "0.1", path = "asio-sys", optional = true }
|
||||||
parking_lot = "0.9"
|
parking_lot = "0.9"
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ extern crate libc;
|
||||||
|
|
||||||
use self::alsa::poll::Descriptors;
|
use self::alsa::poll::Descriptors;
|
||||||
use crate::{
|
use crate::{
|
||||||
BackendSpecificError, BuildStreamError, ChannelCount, Data, DefaultStreamConfigError,
|
BackendSpecificError, BufferSize, BuildStreamError, ChannelCount, Data, DefaultStreamConfigError,
|
||||||
DeviceNameError, DevicesError, InputCallbackInfo, OutputCallbackInfo, PauseStreamError,
|
DeviceNameError, DevicesError, InputCallbackInfo, OutputCallbackInfo, PauseStreamError,
|
||||||
PlayStreamError, SampleFormat, SampleRate, StreamConfig, StreamError, SupportedStreamConfig,
|
PlayStreamError, SampleFormat, SampleRate, StreamConfig, StreamError, SupportedBufferSizeRange, SupportedStreamConfig,
|
||||||
SupportedStreamConfigRange, SupportedStreamConfigsError,
|
SupportedStreamConfigRange, SupportedStreamConfigsError,
|
||||||
};
|
};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
@ -339,6 +339,15 @@ impl Device {
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let min_buffer_size = hw_params.get_buffer_size_min()?;
|
||||||
|
let max_buffer_size = hw_params.get_buffer_size_max()?;
|
||||||
|
|
||||||
|
let buffer_size_range = SupportedBufferSizeRange {
|
||||||
|
min: min_buffer_size,
|
||||||
|
max: max_buffer_size,
|
||||||
|
requires_power_of_two: false,
|
||||||
|
};
|
||||||
|
|
||||||
let mut output = Vec::with_capacity(
|
let mut output = Vec::with_capacity(
|
||||||
supported_formats.len() * supported_channels.len() * sample_rates.len(),
|
supported_formats.len() * supported_channels.len() * sample_rates.len(),
|
||||||
);
|
);
|
||||||
|
@ -349,6 +358,7 @@ impl Device {
|
||||||
channels: channels.clone(),
|
channels: channels.clone(),
|
||||||
min_sample_rate: SampleRate(min_rate as u32),
|
min_sample_rate: SampleRate(min_rate as u32),
|
||||||
max_sample_rate: SampleRate(max_rate as u32),
|
max_sample_rate: SampleRate(max_rate as u32),
|
||||||
|
buffer_size: buffer_size_range,
|
||||||
sample_format: sample_format,
|
sample_format: sample_format,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use self::coreaudio::audio_unit::render_callback::{self, data};
|
||||||
use self::coreaudio::audio_unit::{AudioUnit, Element, Scope};
|
use self::coreaudio::audio_unit::{AudioUnit, Element, Scope};
|
||||||
use self::coreaudio::sys::{
|
use self::coreaudio::sys::{
|
||||||
kAudioDevicePropertyAvailableNominalSampleRates, kAudioDevicePropertyDeviceNameCFString,
|
kAudioDevicePropertyAvailableNominalSampleRates, kAudioDevicePropertyDeviceNameCFString,
|
||||||
kAudioDevicePropertyNominalSampleRate, kAudioDevicePropertyScopeOutput,
|
kAudioDevicePropertyBufferFrameSizeRange,kAudioDevicePropertyNominalSampleRate, kAudioDevicePropertyScopeOutput,
|
||||||
kAudioDevicePropertyStreamConfiguration, kAudioDevicePropertyStreamFormat,
|
kAudioDevicePropertyStreamConfiguration, kAudioDevicePropertyStreamFormat,
|
||||||
kAudioFormatFlagIsFloat, kAudioFormatFlagIsPacked, kAudioFormatLinearPCM,
|
kAudioFormatFlagIsFloat, kAudioFormatFlagIsPacked, kAudioFormatLinearPCM,
|
||||||
kAudioObjectPropertyElementMaster, kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyElementMaster, kAudioObjectPropertyScopeGlobal,
|
||||||
|
@ -20,10 +20,10 @@ use self::coreaudio::sys::{
|
||||||
};
|
};
|
||||||
use crate::traits::{DeviceTrait, HostTrait, StreamTrait};
|
use crate::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||||
use crate::{
|
use crate::{
|
||||||
BackendSpecificError, BuildStreamError, ChannelCount, Data, DefaultStreamConfigError,
|
BackendSpecificError, BufferSize, BuildStreamError, ChannelCount, Data, DefaultStreamConfigError,
|
||||||
DeviceNameError, DevicesError, InputCallbackInfo, OutputCallbackInfo, PauseStreamError,
|
DeviceNameError, DevicesError, InputCallbackInfo, OutputCallbackInfo, PauseStreamError,
|
||||||
PlayStreamError, SampleFormat, SampleRate, StreamConfig, StreamError, SupportedStreamConfig,
|
PlayStreamError, SampleFormat, SampleRate, StreamConfig, StreamError, SupportedBufferSizeRange,
|
||||||
SupportedStreamConfigRange, SupportedStreamConfigsError,
|
SupportedStreamConfig, SupportedStreamConfigRange, SupportedStreamConfigsError,
|
||||||
};
|
};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
@ -276,6 +276,18 @@ impl Device {
|
||||||
let ranges: *mut AudioValueRange = ranges.as_mut_ptr() as *mut _;
|
let ranges: *mut AudioValueRange = ranges.as_mut_ptr() as *mut _;
|
||||||
let ranges: &'static [AudioValueRange] = slice::from_raw_parts(ranges, n_ranges);
|
let ranges: &'static [AudioValueRange] = slice::from_raw_parts(ranges, n_ranges);
|
||||||
|
|
||||||
|
let mut audio_unit = audio_unit_from_device(self, true)?;
|
||||||
|
let buffer_size_range = audio_unit.get_property(
|
||||||
|
kAudioDevicePropertyBufferFrameSizeRange,
|
||||||
|
Scope::Global,
|
||||||
|
Element::Output)?;
|
||||||
|
|
||||||
|
let buffer_size = SupportedBufferSizeRange {
|
||||||
|
min: buffer_size_range.mMinimum;
|
||||||
|
max: buffer_size_range.mMaximum;
|
||||||
|
requires_power_of_two: false,
|
||||||
|
};
|
||||||
|
|
||||||
// Collect the supported formats for the device.
|
// Collect the supported formats for the device.
|
||||||
let mut fmts = vec![];
|
let mut fmts = vec![];
|
||||||
for range in ranges {
|
for range in ranges {
|
||||||
|
@ -283,6 +295,7 @@ impl Device {
|
||||||
channels: n_channels as ChannelCount,
|
channels: n_channels as ChannelCount,
|
||||||
min_sample_rate: SampleRate(range.mMinimum as _),
|
min_sample_rate: SampleRate(range.mMinimum as _),
|
||||||
max_sample_rate: SampleRate(range.mMaximum as _),
|
max_sample_rate: SampleRate(range.mMaximum as _),
|
||||||
|
buffer_size,
|
||||||
sample_format: sample_format,
|
sample_format: sample_format,
|
||||||
};
|
};
|
||||||
fmts.push(fmt);
|
fmts.push(fmt);
|
||||||
|
|
Loading…
Reference in New Issue