Skip to content

Commit

Permalink
ndk: Add missing brackets to links to functions in doc-comments in nd…
Browse files Browse the repository at this point in the history
…k::midi
  • Loading branch information
paxbun committed Aug 17, 2023
1 parent 802ab4a commit 300118e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions ndk/src/midi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl MidiDevice {

/// Opens the input port so that the client can send data to it. Note that the returned
/// [`MidiInputPort`] is intentionally `!Send` and `!Sync`; please use
/// [`safe::SafeMidiDevice::open_safe_input_port`] if you need the thread-safe version.
/// [`safe::SafeMidiDevice::open_safe_input_port()`] if you need the thread-safe version.
pub fn open_input_port(&self, port_number: i32) -> Result<MidiInputPort<'_>> {
unsafe {
let input_port =
Expand All @@ -169,7 +169,7 @@ impl MidiDevice {

/// Opens the output port so that the client can receive data from it. Note that the returned
/// [`MidiOutputPort`] is intentionally `!Send` and `!Sync`; please use
/// [`safe::SafeMidiDevice::open_safe_output_port`] if you need the thread-safe version.
/// [`safe::SafeMidiDevice::open_safe_output_port()`] if you need the thread-safe version.
pub fn open_output_port(&self, port_number: i32) -> Result<MidiOutputPort<'_>> {
unsafe {
let output_port =
Expand All @@ -189,7 +189,7 @@ impl Drop for MidiDevice {
}

/// A wrapper over [`ffi::AMidiInputPort`]. Note that [`MidiInputPort`] is intentionally `!Send` and
/// `!Sync`; please use [`safe::SafeMidiDevice::open_safe_input_port`] if you need the thread-safe
/// `!Sync`; please use [`safe::SafeMidiDevice::open_safe_input_port()`] if you need the thread-safe
/// version.
pub struct MidiInputPort<'a> {
ptr: NonNull<ffi::AMidiInputPort>,
Expand Down Expand Up @@ -280,7 +280,7 @@ impl<'a> Drop for MidiInputPort<'a> {
}

/// A wrapper over [`ffi::AMidiOutputPort`]. Note that [`MidiOutputPort`] is intentionally `!Send`
/// and `!Sync`; please use [`safe::SafeMidiDevice::open_safe_output_port`] if you need the
/// and `!Sync`; please use [`safe::SafeMidiDevice::open_safe_output_port()`] if you need the
/// thread-safe version.
pub struct MidiOutputPort<'a> {
ptr: NonNull<ffi::AMidiOutputPort>,
Expand Down
18 changes: 9 additions & 9 deletions ndk/src/midi/safe.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! Safe bindings for [`AMidiDevice`], [`AMidiInputPort`], and [`AMidiOutputPort`]
//!
//! Provides implementation of `SafeMidiDeviceBox` that ensures the current thread is attached to
//! the Java VM when being dropped, which is required by [`AMidiDevice_release`]. All other types
//! of this module holds an [`Arc`] of `SafeMidiDeviceBox`.
//! the Java VM when being dropped, which is required by [`ffi::AMidiDevice_release()`]. All other
//! types of this module holds an [`Arc`] of `SafeMidiDeviceBox`.
//!
//! Note that all other functions except for [`AMidiDevice_fromJava`] and [`AMidiDevice_release`]
//! are safe to be called in any thread without the calling thread attached to the Java VM.
//! Note that all other functions except for [`ffi::AMidiDevice_fromJava()`] and
//! [`ffi::AMidiDevice_release()`] are safe to be called in any thread without the calling thread
//! attached to the Java VM.
//!
//! [`AMidiDevice`]: https://developer.android.com/ndk/reference/group/midi#amididevice
//! [`AMidiDevice_release`]: https://developer.android.com/ndk/reference/group/midi#amididevice_release
//! [`AMidiInputPort`]: https://developer.android.com/ndk/reference/group/midi#amidiinputport
//! [`AMidiOutputPort`]: https://developer.android.com/ndk/reference/group/midi#amidioutputport

Expand All @@ -27,16 +27,16 @@ use super::*;
/// [`MidiDevice`] is not dropped while the safe wrappers are alive.
///
/// [`SafeMidiDeviceBox`] also holds a pointer to the current Java VM to attach the calling thread
/// of [`Drop::drop`] to the VM, which is required by [`ffi::AMidiDevice_release`].
/// of [`SafeMidiDeviceBox::drop()`] to the VM, which is required by [`ffi::AMidiDevice_release()`].
struct SafeMidiDeviceBox {
midi_device: ManuallyDrop<MidiDevice>,
java_vm: NonNull<jni_sys::JavaVM>,
}

// SAFETY: [`SafeMidiDeviceBox::drop`] attaches the calling thread to the Java VM if required.
// SAFETY: [`SafeMidiDeviceBox::drop()`] attaches the calling thread to the Java VM if required.
unsafe impl Send for SafeMidiDeviceBox {}

// SAFETY: [`SafeMidiDeviceBox::drop`] attaches the calling thread to the Java VM if required.
// SAFETY: [`SafeMidiDeviceBox::drop()`] attaches the calling thread to the Java VM if required.
unsafe impl Sync for SafeMidiDeviceBox {}

impl Drop for SafeMidiDeviceBox {
Expand Down Expand Up @@ -239,6 +239,6 @@ impl Deref for SafeMidiOutputPort {
unsafe impl Send for SafeMidiOutputPort {}

// SAFETY: AMidiOutputPort is guarded by a atomic state ([`AMIDI_Port::state`]), which enables
// [`ffi::AMidiOutputPort_receive`] to detect accesses from multiple threads and return error.
// [`ffi::AMidiOutputPort_receive()`] to detect accesses from multiple threads and return error.
// https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/media/native/midi/amidi.cpp?q=symbol%3A%5CbMidiReceiver%3A%3Areceive%5Cb%20case%3Ayes
unsafe impl Sync for SafeMidiOutputPort {}

0 comments on commit 300118e

Please sign in to comment.