Return back missed play/pause implementation

This commit is contained in:
Viktor Lazarev 2019-08-29 08:51:10 +02:00 committed by mitchmindtree
parent a218dc90e6
commit 10dc779943
1 changed files with 22 additions and 0 deletions

View File

@ -19,6 +19,7 @@ use std::sync::atomic::AtomicUsize;
use std::{sync::{Arc}, use std::{sync::{Arc},
thread::{self, JoinHandle}}; thread::{self, JoinHandle}};
use crate::traits::StreamTrait;
use BackendSpecificError; use BackendSpecificError;
use BuildStreamError; use BuildStreamError;
@ -109,6 +110,16 @@ impl Stream {
pending_scheduled_event, pending_scheduled_event,
} }
} }
#[inline]
fn push_command(&self, command: Command) {
// Safe to unwrap: sender outlives receiver.
self.commands.send(command).unwrap();
unsafe {
let result = synchapi::SetEvent(self.pending_scheduled_event);
assert!(result != 0);
}
}
} }
impl Drop for Stream { impl Drop for Stream {
@ -125,6 +136,17 @@ impl Drop for Stream {
} }
} }
impl StreamTrait for Stream {
fn play(&self) -> Result<(), PlayStreamError> {
self.push_command(Command::PlayStream);
Ok(())
}
fn pause(&self)-> Result<(), PauseStreamError> {
self.push_command(Command::PauseStream);
Ok(())
}
}
impl Drop for AudioClientFlow { impl Drop for AudioClientFlow {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {