Input: Make restartable sources fully async. (#15)

Redresses a previous holdover from an attempt to get Restartable sources to work more neatly inside the synchronous mixer thread. This prevents `Restartable::*` from blocking without warning.

The initial fix at the time was to perform the restart work on a task provided by the tokio runtime as `executor::block_on` needs to be run from within a valid async runtime. Naturally, this completely missed the point that these closures should/could be async, without any need to fudge async functions into a sync wrapper.

Also removes the `From` for normal closures, as this will probably act as a footgun for folks on a single-threaded executor.
This commit is contained in:
Kyle Simpson
2020-11-18 20:48:34 +00:00
committed by GitHub
parent cb7d8cc618
commit 2da5901930
2 changed files with 65 additions and 59 deletions

View File

@@ -184,7 +184,7 @@ async fn play(msg: Message, state: State) -> Result<(), Box<dyn Error + Send + S
let guild_id = msg.guild_id.unwrap();
if let Ok(song) = Restartable::ytdl(msg.content.clone()) {
if let Ok(song) = Restartable::ytdl(msg.content.clone()).await {
let input = Input::from(song);
let content = format!(