Skip to main content

Plugin

Struct Plugin 

Source
#[repr(C)]
pub struct Plugin { pub name: *const c_char, pub open: unsafe extern "C" fn(params: *const Params) -> *mut ID, pub play: Option<unsafe extern "C" fn(id: *mut ID, track: Track) -> c_int>, pub stop: Option<unsafe extern "C" fn(id: *mut ID) -> c_int>, pub close: Option<unsafe extern "C" fn(id: *mut ID) -> c_int>, pub set_volume: Option<unsafe extern "C" fn(id: *mut ID, volume: c_int) -> c_int>, pub set_loglevel: unsafe extern "C" fn(level: c_int), pub get_playcmd: unsafe extern "C" fn() -> *const c_char, pub begin: Option<unsafe extern "C" fn(id: *mut ID, track: Track) -> c_int>, pub feed_sync: Option<unsafe extern "C" fn(id: *mut ID, track: Track) -> c_int>, pub feed_sync_overlap: Option<unsafe extern "C" fn(id: *mut ID, track: Track) -> c_int>, pub end: Option<unsafe extern "C" fn(id: *mut ID) -> c_int>, }
Expand description

These callbacks are called from a single thread, except stop which can be called from another thread open is called first, which returns an ID, which is later passed to to all the other callbacks, so plugins can extend the ID structure as they see fit to include their own data.

If feed_sync_overlap is available, begin is called first to set the format, then several calls to feed_sync_overlap are made to feed audio progressively with overlapping to avoid any underruns. Eventually, end is called.

If feed_sync_overlap is not available, begin is called first to set the format, then several calls to feed_sync are made to feed audio progressively, but we don’t overlap so we may have underruns. Eventually, end is again called.

If neither feed_sync_overlap nor feed_sync are available, play is called with the whole piece. This doesn’t allow pipelining, thus risking underruns.

When stop is called, the playback currently happening should be stopped as soon as possible.

Fields§

§name: *const c_char§open: unsafe extern "C" fn(params: *const Params) -> *mut ID§play: Option<unsafe extern "C" fn(id: *mut ID, track: Track) -> c_int>

Play audio track synchonously

§stop: Option<unsafe extern "C" fn(id: *mut ID) -> c_int>

Stop audio track immediately

§close: Option<unsafe extern "C" fn(id: *mut ID) -> c_int>

Called before plugin terminates

§set_volume: Option<unsafe extern "C" fn(id: *mut ID, volume: c_int) -> c_int>§set_loglevel: unsafe extern "C" fn(level: c_int)§get_playcmd: unsafe extern "C" fn() -> *const c_char

Return the CLI command that sd_generic modules can use to play sound

§begin: Option<unsafe extern "C" fn(id: *mut ID, track: Track) -> c_int>

Configure audio for playing this track

Only bits, num_channels, and sample_rate should be read.

§feed_sync: Option<unsafe extern "C" fn(id: *mut ID, track: Track) -> c_int>

Feed track to audio and wait for playback completion

bits, num_channels, and sample_rate will be unchanged from the begin call.

§feed_sync_overlap: Option<unsafe extern "C" fn(id: *mut ID, track: Track) -> c_int>

Feed track to audio and wait for almost complete playback completion

There should be enough playback left in audio buffers for the caller to have the time to report a mark and submit the subsequent audio pieces, without risking an underrun.

bits, num_channels, and sample_rate will be unchanged from the begin call.

§end: Option<unsafe extern "C" fn(id: *mut ID) -> c_int>

Clean up audio after playback

Needs to drain the audio if this wasn’t done already.

Trait Implementations§

Source§

impl Debug for Plugin

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.