Skip to content

Commit

Permalink
Bump cubeb-rs to 0.12 and handle ABI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pehrsons committed Jan 16, 2024
1 parent c378825 commit 8d99194
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 11 deletions.
4 changes: 2 additions & 2 deletions audioipc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "audioipc2"
version = "0.5.0"
version = "0.6.0"
authors = [
"Matthew Gregan <[email protected]>",
"Dan Glastonbury <[email protected]>",
Expand All @@ -13,7 +13,7 @@ edition = "2018"
bincode = "1.3"
byteorder = "1"
bytes = "1"
cubeb = "0.10"
cubeb = "0.12"
log = "0.4"
serde = "1"
serde_derive = "1"
Expand Down
6 changes: 6 additions & 0 deletions audioipc/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ pub enum ServerMessage {
ContextGetMaxChannelCount,
ContextGetMinLatency(StreamParams),
ContextGetPreferredSampleRate,
ContextGetSupportedInputProcessingParams,
ContextGetDeviceEnumeration(ffi::cubeb_device_type),
ContextSetupDeviceCollectionCallback,
ContextRegisterDeviceCollectionChanged(ffi::cubeb_device_type, bool),
Expand All @@ -225,6 +226,8 @@ pub enum ServerMessage {
StreamSetVolume(usize, f32),
StreamSetName(usize, CString),
StreamGetCurrentDevice(usize),
StreamSetInputMute(usize, bool),
StreamSetInputProcessingParams(usize, ffi::cubeb_input_processing_params),
StreamRegisterDeviceChangeCallback(usize, bool),

#[cfg(target_os = "linux")]
Expand All @@ -242,6 +245,7 @@ pub enum ClientMessage {
ContextMaxChannelCount(u32),
ContextMinLatency(u32),
ContextPreferredSampleRate(u32),
ContextSupportedInputProcessingParams(ffi::cubeb_input_processing_params),
ContextEnumeratedDevices(Vec<DeviceInfo>),
ContextSetupDeviceCollectionCallback(RegisterDeviceCollectionChanged),
ContextRegisteredDeviceCollectionChanged,
Expand All @@ -258,6 +262,8 @@ pub enum ClientMessage {
StreamVolumeSet,
StreamNameSet,
StreamCurrentDevice(Device),
StreamInputMuteSet,
StreamInputProcessingParamsSet,
StreamRegisterDeviceChangeCallback,

#[cfg(target_os = "linux")]
Expand Down
4 changes: 2 additions & 2 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "audioipc2-client"
version = "0.5.0"
version = "0.6.0"
authors = [
"Matthew Gregan <[email protected]>",
"Dan Glastonbury <[email protected]>",
Expand All @@ -11,6 +11,6 @@ edition = "2018"

[dependencies]
audioipc = { package = "audioipc2", path = "../audioipc" }
cubeb-backend = "0.10"
cubeb-backend = "0.12"
log = "0.4"
audio_thread_priority = { version = "0.30", default-features = false }
12 changes: 10 additions & 2 deletions client/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use audioipc::{
ServerMessage,
};
use cubeb_backend::{
capi_new, ffi, Context, ContextOps, DeviceCollectionRef, DeviceId, DeviceType, Error, Ops,
Result, Stream, StreamParams, StreamParamsRef,
capi_new, ffi, Context, ContextOps, DeviceCollectionRef, DeviceId, DeviceType, Error,
InputProcessingParams, Ops, Result, Stream, StreamParams, StreamParamsRef,
};
use std::ffi::{CStr, CString};
use std::os::raw::c_void;
Expand Down Expand Up @@ -239,6 +239,14 @@ impl ContextOps for ClientContext {
send_recv!(self.rpc(), ContextGetPreferredSampleRate => ContextPreferredSampleRate())
}

fn supported_input_processing_params(&mut self) -> Result<InputProcessingParams> {
assert_not_in_callback();
send_recv!(self.rpc(),
ContextGetSupportedInputProcessingParams =>
ContextSupportedInputProcessingParams())
.map(InputProcessingParams::from_bits_truncate)
}

fn enumerate_devices(
&mut self,
devtype: DeviceType,
Expand Down
14 changes: 13 additions & 1 deletion client/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use audioipc::messages::StreamCreateParams;
use audioipc::messages::{self, CallbackReq, CallbackResp, ClientMessage, ServerMessage};
use audioipc::shm::SharedMem;
use audioipc::{rpccore, sys};
use cubeb_backend::{ffi, DeviceRef, Error, Result, Stream, StreamOps};
use cubeb_backend::{ffi, DeviceRef, Error, InputProcessingParams, Result, Stream, StreamOps};
use std::ffi::{CStr, CString};
use std::os::raw::c_void;
use std::ptr;
Expand Down Expand Up @@ -302,6 +302,18 @@ impl StreamOps for ClientStream<'_> {
}
}

fn set_input_mute(&mut self, mute: bool) -> Result<()> {
assert_not_in_callback();
let rpc = self.context.rpc();
send_recv!(rpc, StreamSetInputMute(self.token, mute) => StreamInputMuteSet)
}

fn set_input_processing_params(&mut self, params: InputProcessingParams) -> Result<()> {
assert_not_in_callback();
let rpc = self.context.rpc();
send_recv!(rpc, StreamSetInputProcessingParams(self.token, params.bits()) => StreamInputProcessingParamsSet)
}

fn device_destroy(&mut self, device: &DeviceRef) -> Result<()> {
assert_not_in_callback();
if device.as_ptr().is_null() {
Expand Down
4 changes: 2 additions & 2 deletions ipctest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ipctest"
version = "0.5.0"
version = "0.6.0"
authors = ["Dan Glastonbury <[email protected]>"]
license = "ISC"
edition = "2018"
Expand All @@ -9,7 +9,7 @@ edition = "2018"
audioipc = { package = "audioipc2", path = "../audioipc" }
audioipc-client = { package = "audioipc2-client", path = "../client" }
audioipc-server = { package = "audioipc2-server", path = "../server" }
cubeb = "0.10.0"
cubeb = "0.12.0"
env_logger = "0.9"
error-chain = "0.12.0"
log = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "audioipc2-server"
version = "0.5.0"
version = "0.6.0"
authors = [
"Matthew Gregan <[email protected]>",
"Dan Glastonbury <[email protected]>",
Expand All @@ -11,7 +11,7 @@ edition = "2018"

[dependencies]
audioipc = { package = "audioipc2", path = "../audioipc" }
cubeb-core = "0.10.0"
cubeb-core = "0.12.0"
once_cell = "1.2.0"
log = "0.4"
slab = "0.4"
Expand Down
18 changes: 18 additions & 0 deletions server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use audioipc::messages::{
};
use audioipc::shm::SharedMem;
use audioipc::{ipccore, rpccore, sys, PlatformHandle};
use cubeb::InputProcessingParams;
use cubeb_core as cubeb;
use cubeb_core::ffi;
use std::convert::{From, TryInto};
Expand Down Expand Up @@ -509,6 +510,11 @@ impl CubebServer {
.map(ClientMessage::ContextPreferredSampleRate)
.unwrap_or_else(error),

ServerMessage::ContextGetSupportedInputProcessingParams => context
.supported_input_processing_params()
.map(|params| ClientMessage::ContextSupportedInputProcessingParams(params.bits()))
.unwrap_or_else(error),

ServerMessage::ContextGetDeviceEnumeration(device_type) => context
.enumerate_devices(cubeb::DeviceType::from_bits_truncate(device_type))
.map(|devices| {
Expand Down Expand Up @@ -585,6 +591,18 @@ impl CubebServer {
.map(|device| ClientMessage::StreamCurrentDevice(Device::from(device)))
.unwrap_or_else(error),

ServerMessage::StreamSetInputMute(stm_tok, mute) => try_stream!(self, stm_tok)
.set_input_mute(mute)
.map(|_| ClientMessage::StreamInputMuteSet)
.unwrap_or_else(error),

ServerMessage::StreamSetInputProcessingParams(stm_tok, params) => {
try_stream!(self, stm_tok)
.set_input_processing_params(InputProcessingParams::from_bits_truncate(params))
.map(|_| ClientMessage::StreamInputProcessingParamsSet)
.unwrap_or_else(error)
}

ServerMessage::StreamRegisterDeviceChangeCallback(stm_tok, enable) => {
try_stream!(self, stm_tok)
.register_device_changed_callback(if enable {
Expand Down

0 comments on commit 8d99194

Please sign in to comment.