TrackQueues: Convenience methods and extension (#7)
* Adds a uuid field to tracks and handles to make it easier to identify and match event sources after the fact. * Adds optional feature "builtin-queue" to expose a queue on every driver, as a convenience for users who can guarantee they'll need a queue for every driver/call. * Adds methods to queues to allow access to the currently running track handle, remove a specified queue entry, as well as to mutate the underlying queue from a closure.
This commit is contained in:
@@ -5,6 +5,7 @@ use tokio::sync::{
|
||||
mpsc::{error::SendError, UnboundedSender},
|
||||
oneshot,
|
||||
};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
/// Handle for safe control of a [`Track`] track from other threads, outside
|
||||
@@ -18,6 +19,7 @@ use tokio::sync::{
|
||||
pub struct TrackHandle {
|
||||
command_channel: UnboundedSender<TrackCommand>,
|
||||
seekable: bool,
|
||||
uuid: Uuid,
|
||||
}
|
||||
|
||||
impl TrackHandle {
|
||||
@@ -25,10 +27,11 @@ impl TrackHandle {
|
||||
/// the underlying [`Input`] supports seek operations.
|
||||
///
|
||||
/// [`Input`]: ../input/struct.Input.html
|
||||
pub fn new(command_channel: UnboundedSender<TrackCommand>, seekable: bool) -> Self {
|
||||
pub fn new(command_channel: UnboundedSender<TrackCommand>, seekable: bool, uuid: Uuid) -> Self {
|
||||
Self {
|
||||
command_channel,
|
||||
seekable,
|
||||
uuid,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +152,11 @@ impl TrackHandle {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns this handle's (and track's) unique identifier.
|
||||
pub fn uuid(&self) -> Uuid {
|
||||
self.uuid
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Send a raw command to the [`Track`] object.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user