Voice Rework -- Events, Track Queues (#806)
This implements a proof-of-concept for an improved audio frontend. The largest change is the introduction of events and event handling: both by time elapsed and by track events, such as ending or looping. Following on from this, the library now includes a basic, event-driven track queue system (which people seem to ask for unusually often). A new sample, `examples/13_voice_events`, demonstrates both the `TrackQueue` system and some basic events via the `~queue` and `~play_fade` commands. Locks are removed from around the control of `Audio` objects, which should allow the backend to be moved to a more granular futures-based backend solution in a cleaner way.
This commit is contained in:
28
src/events/untimed.rs
Normal file
28
src/events/untimed.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
/// Track and voice core events.
|
||||
///
|
||||
/// Untimed events persist while the `action` in [`EventData`]
|
||||
/// returns `None`.
|
||||
///
|
||||
/// [`EventData`]: struct.EventData.html
|
||||
pub enum UntimedEvent {
|
||||
/// Untimed events belonging to a track, such as state changes, end, or loops.
|
||||
Track(TrackEvent),
|
||||
/// Untimed events belonging to the global context, such as finished tracks,
|
||||
/// client speaking updates, or RT(C)P voice and telemetry data.
|
||||
Core(CoreEvent),
|
||||
}
|
||||
|
||||
impl From<TrackEvent> for UntimedEvent {
|
||||
fn from(evt: TrackEvent) -> Self {
|
||||
UntimedEvent::Track(evt)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CoreEvent> for UntimedEvent {
|
||||
fn from(evt: CoreEvent) -> Self {
|
||||
UntimedEvent::Core(evt)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user