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:
32
src/driver/tasks/message/mixer.rs
Normal file
32
src/driver/tasks/message/mixer.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use super::{Interconnect, UdpRxMessage, UdpTxMessage, WsMessage};
|
||||
|
||||
use crate::{tracks::Track, Bitrate};
|
||||
use flume::Sender;
|
||||
use xsalsa20poly1305::XSalsa20Poly1305 as Cipher;
|
||||
|
||||
pub(crate) struct MixerConnection {
|
||||
pub cipher: Cipher,
|
||||
pub udp_rx: Sender<UdpRxMessage>,
|
||||
pub udp_tx: Sender<UdpTxMessage>,
|
||||
}
|
||||
|
||||
impl Drop for MixerConnection {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.udp_rx.send(UdpRxMessage::Poison);
|
||||
let _ = self.udp_tx.send(UdpTxMessage::Poison);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum MixerMessage {
|
||||
AddTrack(Track),
|
||||
SetTrack(Option<Track>),
|
||||
SetBitrate(Bitrate),
|
||||
SetMute(bool),
|
||||
SetConn(MixerConnection, u32),
|
||||
DropConn,
|
||||
ReplaceInterconnect(Interconnect),
|
||||
RebuildEncoder,
|
||||
|
||||
Ws(Option<Sender<WsMessage>>),
|
||||
Poison,
|
||||
}
|
||||
Reference in New Issue
Block a user