Skip to content

Commit

Permalink
Rename HostAudioThreadHandle to HostAudioProcessorHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
prokopyl committed May 10, 2024
1 parent 7c7dd34 commit eb5ef98
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl DefaultPluginFactory for MyGainPlugin {
pub struct MyGainPluginAudioProcessor;

impl<'a> PluginAudioProcessor<'a, (), ()> for MyGainPluginAudioProcessor {
fn activate(_host: HostAudioThreadHandle<'a>, _main_thread: &mut (), _shared: &'a (), _audio_config: PluginAudioConfiguration) -> Result<Self, PluginError> {
fn activate(_host: HostAudioProcessorHandle<'a>, _main_thread: &mut (), _shared: &'a (), _audio_config: PluginAudioConfiguration) -> Result<Self, PluginError> {
Ok(Self)
}

Expand Down
4 changes: 2 additions & 2 deletions common/src/extensions/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ use std::ptr::NonNull;
/// `use_extension()` method on one of the handle types:
///
/// * For plugin-side extensions (from the `clack-host` crate): `PluginSharedHandle`,
/// `PluginMainThreadHandle`, or `PluginAudioThreadHandle`;
/// `PluginMainThreadHandle`, or `PluginAudioProcessorHandle`;
/// * For host-side extensions (from the `clack-plugin` crate): `HostSharedHandle`,
/// `HostMainThreadHandle`, or `HostAudioThreadHandle`.
/// `HostMainThreadHandle`, or `HostAudioProcessorHandle`.
///
/// This pointer type is only useful for *consuming* extension pointers. For producing extension
/// pointers from an extension implementation, use the [`RawExtensionImplementation`] type instead.
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/__doc_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod diva_stub {
for DivaPluginStubAudioProcessor<'a>
{
fn activate(
_host: HostAudioThreadHandle<'a>,
_host: HostAudioProcessorHandle<'a>,
_main_thread: &mut DivaPluginStubMainThread,
shared: &'a DivaPluginStubShared<'a>,
_audio_config: PluginAudioConfiguration,
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ mod plugin {
impl HostTail {
/// Informs the host that the plugin's tail length has changed and needs to be updated.
#[inline]
pub fn changed(&self, host: &mut HostAudioThreadHandle) {
pub fn changed(&self, host: &mut HostAudioProcessorHandle) {
if let Some(changed) = host.use_extension(&self.0).changed {
// SAFETY: This type ensures the function pointer is valid.
unsafe { changed(host.as_raw()) }
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/thread_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mod plugin {
/// This method will return [`ThreadPoolRequestError`] if the host denied the request.
pub fn request_exec(
&self,
host: &mut HostAudioThreadHandle,
host: &mut HostAudioProcessorHandle,
task_count: u32,
) -> Result<(), ThreadPoolRequestError> {
let request_exec = host
Expand Down
2 changes: 1 addition & 1 deletion host/src/bundle/diva_stub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'a> PluginAudioProcessor<'a, DivaPluginStubShared<'a>, ()>
for DivaPluginStubAudioProcessor<'a>
{
fn activate(
_host: HostAudioThreadHandle<'a>,
_host: HostAudioProcessorHandle<'a>,
_main_thread: &mut (),
shared: &'a DivaPluginStubShared<'a>,
_audio_config: PluginAudioConfiguration,
Expand Down
2 changes: 1 addition & 1 deletion host/tests/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl DefaultPluginFactory for DivaPluginStub {

impl<'a> PluginAudioProcessor<'a, (), DivaPluginStubMainThread> for DivaPluginStubAudioProcessor {
fn activate(
_host: HostAudioThreadHandle<'a>,
_host: HostAudioProcessorHandle<'a>,
main_thread: &mut DivaPluginStubMainThread,
_shared: &'a (),
_audio_config: PluginAudioConfiguration,
Expand Down
2 changes: 1 addition & 1 deletion host/tests/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl DefaultPluginFactory for DivaPluginStub {

impl<'a> PluginAudioProcessor<'a, (), DivaPluginStubMainThread> for DivaPluginStubAudioProcessor {
fn activate(
_host: HostAudioThreadHandle<'a>,
_host: HostAudioProcessorHandle<'a>,
_main_thread: &mut DivaPluginStubMainThread,
_shared: &'a (),
_audio_config: PluginAudioConfiguration,
Expand Down
2 changes: 1 addition & 1 deletion host/tests/shared-state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl DefaultPluginFactory for DivaPluginStub {

impl<'a> PluginAudioProcessor<'a, (), DivaPluginStubMainThread> for DivaPluginStubAudioProcessor {
fn activate(
_host: HostAudioThreadHandle<'a>,
_host: HostAudioProcessorHandle<'a>,
_main_thread: &mut DivaPluginStubMainThread,
_shared: &'a (),
_audio_config: PluginAudioConfiguration,
Expand Down
8 changes: 5 additions & 3 deletions plugin/examples/gain/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# clack-plugin-gain

A tiny, simple volume attenuator example CLAP plugin, based on the `clack-plugin` crate.

### Features

This project is an example for the `clack-plugin` and `clack-extensions` crates, and shows
off the various parts of the Clack API by implementing the following features:
off the various parts of the Clack API by implementing the following features:

* **General Clack plugin structure:** Usage and implementation of the `Plugin` trait, and of the
`PluginMainThread`, `PluginAudioThread` and `PluginShared` sub-traits.
`PluginMainThread`, `PluginAudioProcessor` and `PluginShared` sub-traits.
* **Audio input/output declaration and generation:** Using the `audio-ports` CLAP extension to declare
audio ports, and accessing the various audio buffers in the `process` call.
* **Parameter declaration, management and usage:** Using the `params` CLAP extension
Expand All @@ -25,7 +27,7 @@ cargo build -p clack-plugin-gain --release
```

This will create a `clack_plugin_gain` library file (suffix may vary depending on
your Operating System) in the `target/release` directory.
your Operating System) in the `target/release` directory.

You can then copy (or link) that file to your CLAP plugin directory, and renaming it
with a `.clap` extension (e.g. `clack_plugin_gain.clap`). This will enable it to
Expand Down
2 changes: 1 addition & 1 deletion plugin/examples/gain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a> PluginAudioProcessor<'a, GainPluginShared, GainPluginMainThread<'a>>
for GainPluginAudioProcessor<'a>
{
fn activate(
_host: HostAudioThreadHandle<'a>,
_host: HostAudioProcessorHandle<'a>,
_main_thread: &mut GainPluginMainThread,
shared: &'a GainPluginShared,
_audio_config: PluginAudioConfiguration,
Expand Down
8 changes: 5 additions & 3 deletions plugin/examples/polysynth/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# clack-plugin-polysynth

A small, polyphonic square wave synthesizer CLAP plugin, based on the `clack-plugin` crate.

### Features

This project is an example for the `clack-plugin` and `clack-extensions` crates, and shows
off the various parts of the Clack API by implementing the following features:
off the various parts of the Clack API by implementing the following features:

* **General Clack plugin structure:** Usage and implementation of the `Plugin` trait, and of the
`PluginMainThread`, `PluginAudioThread` and `PluginShared` sub-traits.
`PluginMainThread`, `PluginAudioProcessor` and `PluginShared` sub-traits.
* **Audio output declaration and generation:** Using the `audio-ports` CLAP extension to declare
audio ports, and accessing the various audio buffers in the `process` call.
* **Note input declaration and usage:** Using the `note-ports` CLAP extension to declare
Expand All @@ -29,7 +31,7 @@ cargo build -p clack-plugin-polysynth --release
```

This will create a `clack_plugin_polysynth` library file (suffix may vary depending on
your Operating System) in the `target/release` directory.
your Operating System) in the `target/release` directory.

You can then copy (or link) that file to your CLAP plugin directory, and renaming it
with a `.clap` extension (e.g. `clack_plugin_polysynth.clap`). This will enable it to
Expand Down
2 changes: 1 addition & 1 deletion plugin/examples/polysynth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<'a> PluginAudioProcessor<'a, PolySynthPluginShared, PolySynthPluginMainThre
for PolySynthAudioProcessor<'a>
{
fn activate(
_host: HostAudioThreadHandle<'a>,
_host: HostAudioProcessorHandle<'a>,
_main_thread: &mut PolySynthPluginMainThread,
shared: &'a PolySynthPluginShared,
audio_config: PluginAudioConfiguration,
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub mod prelude {
Extension, ExtensionImplementation, HostExtensionSide, PluginExtensionSide,
RawExtension, RawExtensionImplementation,
},
host::{HostAudioThreadHandle, HostMainThreadHandle, HostSharedHandle},
host::{HostAudioProcessorHandle, HostMainThreadHandle, HostSharedHandle},
plugin::{Plugin, PluginError},
utils::ClapId,
};
Expand Down
16 changes: 8 additions & 8 deletions plugin/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ impl<'a> HostSharedHandle<'a> {
///
/// Callers *MUST* ensure this is only called on the audio thread, and that they have exclusive (&mut) access.
#[inline]
pub unsafe fn as_audio_thread_unchecked(&self) -> HostAudioThreadHandle<'a> {
HostAudioThreadHandle {
pub unsafe fn as_audio_thread_unchecked(&self) -> HostAudioProcessorHandle<'a> {
HostAudioProcessorHandle {
raw: self.raw,
_lifetime: PhantomData,
}
Expand Down Expand Up @@ -267,15 +267,15 @@ impl<'a> Deref for HostMainThreadHandle<'a> {
}

#[repr(transparent)]
pub struct HostAudioThreadHandle<'a> {
pub struct HostAudioProcessorHandle<'a> {
raw: NonNull<clap_host>,
_lifetime: PhantomData<&'a clap_host>,
}

// SAFETY: this type only exposes the audio-thread-safe (Send) operation of clap_host
unsafe impl<'a> Send for HostAudioThreadHandle<'a> {}
unsafe impl<'a> Send for HostAudioProcessorHandle<'a> {}

impl<'a> HostAudioThreadHandle<'a> {
impl<'a> HostAudioProcessorHandle<'a> {
#[inline]
pub fn shared(&self) -> HostSharedHandle<'a> {
HostSharedHandle {
Expand All @@ -297,14 +297,14 @@ impl<'a> HostAudioThreadHandle<'a> {
}
}

impl<'a> From<HostAudioThreadHandle<'a>> for HostSharedHandle<'a> {
impl<'a> From<HostAudioProcessorHandle<'a>> for HostSharedHandle<'a> {
#[inline]
fn from(h: HostAudioThreadHandle<'a>) -> Self {
fn from(h: HostAudioProcessorHandle<'a>) -> Self {
h.shared()
}
}

impl<'a> Deref for HostAudioThreadHandle<'a> {
impl<'a> Deref for HostAudioProcessorHandle<'a> {
type Target = HostSharedHandle<'a>;

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub mod prelude {
Event, EventHeader, Pckn, UnknownEvent,
},
extensions::PluginExtensions,
host::{HostAudioThreadHandle, HostMainThreadHandle, HostSharedHandle},
host::{HostAudioProcessorHandle, HostMainThreadHandle, HostSharedHandle},
plugin::{
Plugin, PluginAudioProcessor, PluginDescriptor, PluginError, PluginMainThread,
PluginShared,
Expand Down
6 changes: 3 additions & 3 deletions plugin/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
//! threads that are neither the main thread nor the audio thread.

use crate::extensions::PluginExtensions;
use crate::host::HostAudioThreadHandle;
use crate::host::HostAudioProcessorHandle;
use crate::process::{Audio, Events, PluginAudioConfiguration, Process, ProcessStatus};

mod descriptor;
Expand Down Expand Up @@ -165,7 +165,7 @@ pub trait PluginAudioProcessor<'a, S: PluginShared<'a>, M: PluginMainThread<'a,
/// This method is not realtime-safe: it may perform memory allocations of audio buffers, or any
/// other initialization the plugin may deem necessary.
fn activate(
host: HostAudioThreadHandle<'a>,
host: HostAudioProcessorHandle<'a>,
main_thread: &mut M,
shared: &'a S,
audio_config: PluginAudioConfiguration,
Expand Down Expand Up @@ -212,7 +212,7 @@ pub trait PluginAudioProcessor<'a, S: PluginShared<'a>, M: PluginMainThread<'a,
impl<'a, M: PluginMainThread<'a, S>, S: PluginShared<'a>> PluginAudioProcessor<'a, S, M> for () {
#[inline]
fn activate(
_host: HostAudioThreadHandle<'a>,
_host: HostAudioProcessorHandle<'a>,
_main_thread: &mut M,
_shared: &'a S,
_audio_config: PluginAudioConfiguration,
Expand Down

0 comments on commit eb5ef98

Please sign in to comment.