fn check_and_bind_volume_controls(
    service_connected: Arc<RwLock<bool>>,
    service_context_handle: Arc<RwLock<ServiceContext>>,
    stream_volume_controls: &mut HashMap<AudioStreamType, StreamVolumeControl>,
) -> Result<(), Error> {
    let mut service_connected_lock = service_connected.write();
    if *service_connected_lock {
        return Ok(());
    }

    let service_result =
        service_context_handle.read().connect::<fidl_fuchsia_media::AudioCoreMarker>();

    let audio_service = match service_result {
        Ok(service) => {
            *service_connected_lock = true;
            service
        }
        Err(err) => {
            fx_log_err!("failed to connect to audio core, {}", err);
            return Err(err);
        }
    };

    for stream in default_audio_info().streams.iter() {
        stream_volume_controls.insert(
            stream.stream_type.clone(),
            StreamVolumeControl::create(&audio_service, stream.clone()),
        );
    }
    Ok(())
}
// Checks to see if |service_connected| contains true. If it is not, then
// connect to the audio core service. If the service connects successfully,
// set |service_connected| to true and create a StreamVolumeControl for each
// stream type.
Checks to see if |service_connected| contains true. If it is not, then
connect to the audio core service. If the service connects successfully,
set |service_connected| to true and create a StreamVolumeControl for each
stream type.
Checks to see if |service_connected| contains true . If it is not then connect to the audio core service . If the service connects successfully set |service_connected| to true and create a StreamVolumeControl for each stream type .
fn check_and_bind_volume_controls(
    service_connected: Arc<RwLock<bool>>,
    service_context_handle: Arc<RwLock<ServiceContext>>,
    stream_volume_controls: &mut HashMap<AudioStreamType, StreamVolumeControl>,
) -> Result<(), Error> {
    let mut service_connected_lock = service_connected.write();
    if *service_connected_lock {
        return Ok(());
    }
    let service_result =
        service_context_handle.read().connect::<fidl_fuchsia_media::AudioCoreMarker>();
    let audio_service = match service_result {
        Ok(service) => {
            *service_connected_lock = true;
            service
        }
        Err(err) => {
            fx_log_err!("failed to connect to audio core, {}", err);
            return Err(err);
        }
    };
    for stream in default_audio_info().streams.iter() {
        stream_volume_controls.insert(
            stream.stream_type.clone(),
            StreamVolumeControl::create(&audio_service, stream.clone()),
        );
    }
    Ok(())
}
fn check_and_bind_volume_controls ( service_connected : Arc < RwLock < bool > > , service_context_handle : Arc < RwLock < ServiceContext > > , stream_volume_controls : & mut HashMap < AudioStreamType , StreamVolumeControl > , ) -> Result < ( ) , Error > { let mut service_connected_lock = service_connected . write ( ) ; if * service_connected_lock { return Ok ( ( ) ) ; } let service_result = service_context_handle . read ( ) . connect :: < fidl_fuchsia_media :: AudioCoreMarker > ( ) ; let audio_service = match service_result { Ok ( service ) => { * service_connected_lock = true ; service } Err ( err ) => { fx_log_err ! ( " " err ) ; return Err ( err ) ; } } ; for stream in default_audio_info ( ) . streams . iter ( ) { stream_volume_controls . insert ( stream . stream_type . clone ( ) , StreamVolumeControl :: create ( & audio_service , stream . clone ( ) ) , ) ; } Ok ( ( ) ) }
Checks to see if |service_connected| contains true.
Checks to see if |service_connected| contains true .
service_connected
Arc<RwLock<bool>>
service_context_handle
Arc<RwLock<ServiceContext>>
stream_volume_controls
&mut HashMap<AudioStreamType, StreamVolumeControl>