pub fn wait_for_speakers_ready(&self) -> Result<()> {
        let find_speaker = || -> Result<()> {
            let cras_client = CrasClient::new().map_err(Error::CrasClientFailed)?;
            let _node = cras_client
                .output_nodes()
                .find(|node| node.node_type == CrasNodeType::CRAS_NODE_TYPE_INTERNAL_SPEAKER)
                .ok_or(Error::InternalSpeakerNotFound)?;
            Ok(())
        };
        // TODO(b/155007305): Implement cras_client.wait_node_change and use it here.
        const RETRY: usize = 3;
        const RETRY_INTERVAL: Duration = Duration::from_millis(500);
        for _ in 0..RETRY {
            match find_speaker() {
                Ok(_) => return Ok(()),
                Err(e) => error!("retry on finding speaker: {}", e),
            };
            thread::sleep(RETRY_INTERVAL);
        }
        Err(Error::InternalSpeakerNotFound)
    }
/// Blocks until the internal speakers are ready.
///
/// # Errors
///
/// * Failed to wait the internal speakers to be ready.
Blocks until the internal speakers are ready.
Blocks until the internal speakers are ready .
pub fn wait_for_speakers_ready(&self) -> Result<()> {
        let find_speaker = || -> Result<()> {
            let cras_client = CrasClient::new().map_err(Error::CrasClientFailed)?;
            let _node = cras_client
                .output_nodes()
                .find(|node| node.node_type == CrasNodeType::CRAS_NODE_TYPE_INTERNAL_SPEAKER)
                .ok_or(Error::InternalSpeakerNotFound)?;
            Ok(())
        };
        // TODO(b/155007305): Implement cras_client.wait_node_change and use it here.
        const RETRY: usize = 3;
        const RETRY_INTERVAL: Duration = Duration::from_millis(500);
        for _ in 0..RETRY {
            match find_speaker() {
                Ok(_) => return Ok(()),
                Err(e) => error!("retry on finding speaker: {}", e),
            };
            thread::sleep(RETRY_INTERVAL);
        }
        Err(Error::InternalSpeakerNotFound)
    }
pub fn wait_for_speakers_ready ( & self ) -> Result < ( ) > { let find_speaker = | | -> Result < ( ) > { let cras_client = CrasClient :: new ( ) . map_err ( Error :: CrasClientFailed ) ? ; let _node = cras_client . output_nodes ( ) . find ( | node | node . node_type == CrasNodeType :: CRAS_NODE_TYPE_INTERNAL_SPEAKER ) . ok_or ( Error :: InternalSpeakerNotFound ) ? ; Ok ( ( ) ) } ; // TODO(b/155007305): Implement cras_client.wait_node_change and use it here. const RETRY : usize = 3 ; const RETRY_INTERVAL : Duration = Duration :: from_millis ( 500 ) ; for _ in 0 .. RETRY { match find_speaker ( ) { Ok ( _ ) => return Ok ( ( ) ) , Err ( e ) => error ! ( " " e ) , } ; thread :: sleep ( RETRY_INTERVAL ) ; } Err ( Error :: InternalSpeakerNotFound ) }
Blocks until the internal speakers are ready.
Blocks until the internal speakers are ready .
&self
&self
errors
Failed to wait the internal speakers to be ready.
Failed to wait the internal speakers to be ready .