impl play and pause for ALSA
snd_pcm_pause could have been used but not all hardware implement it, so I propose not to use it. In this implementation: there are two kind of scheduling: wait for resume signal and wait for pcm to be available if the stream is paused then it return notready and wait for resume the event loop is different as it manages descriptors corresponding to voices according to the nature of the scheduling. there is still a FIXME: in voice.play the is signal is send even if the event loop wasn't waiting for resume. It doesn't seem to create any issue. But it happens when you write voice.pause();voice.play();
This commit is contained in:
parent
f68509982a
commit
f822631bc4
2 changed files with 142 additions and 41 deletions
|
|
@ -7,6 +7,8 @@ use futures::task::Executor;
|
|||
use futures::task::Run;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
struct MyExecutor;
|
||||
|
||||
|
|
@ -57,5 +59,14 @@ fn main() {
|
|||
Ok(())
|
||||
})).execute(executor);
|
||||
|
||||
thread::spawn(move || {
|
||||
loop {
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
voice.pause();
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
voice.play();
|
||||
}
|
||||
});
|
||||
|
||||
event_loop.run();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue