pub fn start(&mut self, min_playback_time: Duration) -> Result<()> {
        if self.running() {
            return Err(Error::ZeroPlayerIsRunning);
        }
        self.thread_info = Some(PlayZeroWorkerInfo::new(min_playback_time));
        if let Some(thread_info) = &mut self.thread_info {
            // Block until playback of zeros has started for min_playback_time or timeout.
            let (lock, cvar) = &*(thread_info.ready);
            let result = cvar.wait_timeout_while(
                lock.lock()?,
                min_playback_time + ZeroPlayer::TIMEOUT,
                |&mut is_ready| !is_ready,
            )?;
            if result.1.timed_out() {
                return Err(Error::StartPlaybackTimeout);
            }
        }
        Ok(())
    }
/// Starts to play zeros for at most `max_playback_time`.
/// This function blocks and returns until playback has started for `min_playback_time`.
/// This function must be called when self.running() returns false.
///
/// # Arguments
///
/// * `min_playback_time` - It blocks and returns until playback has started for
///                         `min_playback_time`.
///
/// # Errors
///
/// * If it's called when the `ZeroPlayer` is already running.
/// * Failed to find internal speakers.
/// * Failed to start the background thread.
Starts to play zeros for at most `max_playback_time`.
This function blocks and returns until playback has started for `min_playback_time`.
This function must be called when self.running() returns false.
Starts to play zeros for at most ` max_playback_time ` . This function blocks and returns until playback has started for ` min_playback_time ` . This function must be called when self . running () returns false .
pub fn start(&mut self, min_playback_time: Duration) -> Result<()> {
        if self.running() {
            return Err(Error::ZeroPlayerIsRunning);
        }
        self.thread_info = Some(PlayZeroWorkerInfo::new(min_playback_time));
        if let Some(thread_info) = &mut self.thread_info {
            // Block until playback of zeros has started for min_playback_time or timeout.
            let (lock, cvar) = &*(thread_info.ready);
            let result = cvar.wait_timeout_while(
                lock.lock()?,
                min_playback_time + ZeroPlayer::TIMEOUT,
                |&mut is_ready| !is_ready,
            )?;
            if result.1.timed_out() {
                return Err(Error::StartPlaybackTimeout);
            }
        }
        Ok(())
    }
pub fn start ( & mut self , min_playback_time : Duration ) -> Result < ( ) > { if self . running ( ) { return Err ( Error :: ZeroPlayerIsRunning ) ; } self . thread_info = Some ( PlayZeroWorkerInfo :: new ( min_playback_time ) ) ; if let Some ( thread_info ) = & mut self . thread_info { // Block until playback of zeros has started for min_playback_time or timeout. let ( lock , cvar ) = & * ( thread_info . ready ) ; let result = cvar . wait_timeout_while ( lock . lock ( ) ? , min_playback_time + ZeroPlayer :: TIMEOUT , | & mut is_ready | ! is_ready , ) ? ; if result . 1 . timed_out ( ) { return Err ( Error :: StartPlaybackTimeout ) ; } } Ok ( ( ) ) }
Starts to play zeros for at most `max_playback_time`.
Starts to play zeros for at most ` max_playback_time ` .
&mut self
min_playback_time
Duration
&mut self
min_playback_time
Duration
errors
If it's called when the `ZeroPlayer` is already running.
Failed to find internal speakers.
Failed to start the background thread.
If it ' s called when the ` ZeroPlayer ` is already running . Failed to find internal speakers . Failed to start the background thread .