#[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_charReturn 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.