Input: Allow Restartable sources to be lazy
This change is made with queue users in mind. Since sources of this kind *know* how to (re)create themselves, they can avoid being created at all until needed. This also adds machinery to preload tracks *before* they are needed, for gapless playback on queues and so on. Queues make use of the event system to do this.
This commit is contained in:
@@ -307,6 +307,7 @@ impl Track {
|
||||
TrackStateChange::Loops(self.loops, true),
|
||||
));
|
||||
},
|
||||
MakePlayable => self.make_playable(),
|
||||
}
|
||||
},
|
||||
Err(TryRecvError::Closed) => {
|
||||
@@ -320,6 +321,16 @@ impl Track {
|
||||
}
|
||||
}
|
||||
|
||||
/// Ready a track for playing if it is lazily initialised.
|
||||
///
|
||||
/// Currently, only [`Restartable`] sources support lazy setup.
|
||||
/// This call is a no-op for all others.
|
||||
///
|
||||
/// [`Restartable`]: crate::input::restartable::Restartable
|
||||
pub fn make_playable(&mut self) {
|
||||
self.source.reader.make_playable();
|
||||
}
|
||||
|
||||
/// Creates a read-only copy of the audio track's state.
|
||||
///
|
||||
/// The primary use-case of this is sending information across
|
||||
|
||||
Reference in New Issue
Block a user