Skip to content

Add empty [workspace] to Cargo.toml. #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ pulse-ffi = { path = "pulse-ffi" }
pulse = { path = "pulse-rs" }
semver = "1.0"
ringbuf = "0.2"

# Workaround for https://github.com/rust-lang/cargo/issues/6745 to allow this
# Cargo.toml file to appear under a subdirectory of a workspace without being in
# that workspace (e.g. in cubeb-rs).
[workspace]
71 changes: 38 additions & 33 deletions pulse-rs/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ use *;
// mem::forget(object);
// result

// For all clippy-ignored warnings in this file, see
// https://github.com/mozilla/cubeb-pulse-rs/issues/95 for the effort to fix.

// Aid in returning Operation from callbacks
macro_rules! op_or_err {
($self_:ident, $e:expr) => {{
Expand Down Expand Up @@ -78,6 +81,7 @@ impl Context {
}

#[doc(hidden)]
#[allow(clippy::mut_from_ref)]
pub fn raw_mut(&self) -> &mut ffi::pa_context {
unsafe { &mut *self.0 }
}
Expand All @@ -94,6 +98,7 @@ impl Context {
}
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn set_state_callback<CB>(&self, _: CB, userdata: *mut c_void)
where
CB: Fn(&Context, *mut c_void),
Expand All @@ -107,10 +112,9 @@ impl Context {
{
let ctx = context::from_raw_ptr(c);
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, userdata);
(*cb.as_ptr())(&ctx, userdata);
#[allow(clippy::forget_non_drop)]
forget(ctx);

result
}

unsafe {
Expand All @@ -127,6 +131,7 @@ impl Context {
.expect("pa_context_get_state returned invalid ContextState")
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn connect<'a, OPT>(
&self,
server: OPT,
Expand All @@ -153,6 +158,7 @@ impl Context {
}
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn drain<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
where
CB: Fn(&Context, *mut c_void),
Expand All @@ -166,10 +172,9 @@ impl Context {
{
let ctx = context::from_raw_ptr(c);
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, userdata);
(*cb.as_ptr())(&ctx, userdata);
#[allow(clippy::forget_non_drop)]
forget(ctx);

result
}

op_or_err!(
Expand All @@ -178,6 +183,7 @@ impl Context {
)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn rttime_new<CB>(
&self,
usec: USec,
Expand All @@ -201,15 +207,15 @@ impl Context {
let api = mainloop_api::from_raw_ptr(a);
let timeval = &*tv;
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&api, e, timeval, userdata);
(*cb.as_ptr())(&api, e, timeval, userdata);
#[allow(clippy::forget_non_drop)]
forget(api);

result
}

unsafe { ffi::pa_context_rttime_new(self.raw_mut(), usec, Some(wrapped::<CB>), userdata) }
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn get_server_info<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
where
CB: Fn(&Context, Option<&ServerInfo>, *mut c_void),
Expand All @@ -227,10 +233,9 @@ impl Context {
let info = if i.is_null() { None } else { Some(&*i) };
let ctx = context::from_raw_ptr(c);
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, info, userdata);
(*cb.as_ptr())(&ctx, info, userdata);
#[allow(clippy::forget_non_drop)]
forget(ctx);

result
}

op_or_err!(
Expand All @@ -239,6 +244,7 @@ impl Context {
)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn get_sink_info_by_name<'str, CS, CB>(
&self,
name: CS,
Expand All @@ -262,10 +268,9 @@ impl Context {
{
let ctx = context::from_raw_ptr(c);
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, info, eol, userdata);
(*cb.as_ptr())(&ctx, info, eol, userdata);
#[allow(clippy::forget_non_drop)]
forget(ctx);

result
}

op_or_err!(
Expand All @@ -279,6 +284,7 @@ impl Context {
)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn get_sink_info_list<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
where
CB: Fn(&Context, *const SinkInfo, i32, *mut c_void),
Expand All @@ -296,10 +302,9 @@ impl Context {
{
let ctx = context::from_raw_ptr(c);
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, info, eol, userdata);
(*cb.as_ptr())(&ctx, info, eol, userdata);
#[allow(clippy::forget_non_drop)]
forget(ctx);

result
}

op_or_err!(
Expand All @@ -308,6 +313,7 @@ impl Context {
)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn get_sink_input_info<CB>(
&self,
idx: u32,
Expand All @@ -330,10 +336,9 @@ impl Context {
{
let ctx = context::from_raw_ptr(c);
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, info, eol, userdata);
(*cb.as_ptr())(&ctx, info, eol, userdata);
#[allow(clippy::forget_non_drop)]
forget(ctx);

result
}

op_or_err!(
Expand All @@ -342,6 +347,7 @@ impl Context {
)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn get_source_info_list<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
where
CB: Fn(&Context, *const SourceInfo, i32, *mut c_void),
Expand All @@ -359,10 +365,9 @@ impl Context {
{
let ctx = context::from_raw_ptr(c);
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, info, eol, userdata);
(*cb.as_ptr())(&ctx, info, eol, userdata);
#[allow(clippy::forget_non_drop)]
forget(ctx);

result
}

op_or_err!(
Expand All @@ -371,6 +376,7 @@ impl Context {
)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn set_sink_input_volume<CB>(
&self,
idx: u32,
Expand All @@ -393,10 +399,9 @@ impl Context {
{
let ctx = context::from_raw_ptr(c);
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, success, userdata);
(*cb.as_ptr())(&ctx, success, userdata);
#[allow(clippy::forget_non_drop)]
forget(ctx);

result
}

op_or_err!(
Expand All @@ -411,6 +416,7 @@ impl Context {
)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn subscribe<CB>(
&self,
m: SubscriptionMask,
Expand All @@ -432,10 +438,9 @@ impl Context {
{
let ctx = context::from_raw_ptr(c);
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, success, userdata);
(*cb.as_ptr())(&ctx, success, userdata);
#[allow(clippy::forget_non_drop)]
forget(ctx);

result
}

op_or_err!(
Expand All @@ -450,6 +455,7 @@ impl Context {
}
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn set_subscribe_callback<CB>(&self, _: CB, userdata: *mut c_void)
where
CB: Fn(&Context, SubscriptionEvent, u32, *mut c_void),
Expand All @@ -469,10 +475,9 @@ impl Context {
let event = SubscriptionEvent::try_from(t)
.expect("pa_context_subscribe_cb_t passed invalid pa_subscription_event_type_t");
let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, event, idx, userdata);
(*cb.as_ptr())(&ctx, event, idx, userdata);
#[allow(clippy::forget_non_drop)]
forget(ctx);

result
}

unsafe {
Expand Down
2 changes: 1 addition & 1 deletion pulse-rs/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl ErrorCode {

pub fn from_error_code(err: ffi::pa_error_code_t) -> Self {
debug_assert!(err > 0);
ErrorCode { err: err }
ErrorCode { err }
}

fn desc(&self) -> &'static str {
Expand Down
Loading
Loading