async fn pump_notifications(peer: Arc<RwLock<RemotePeer>>) {
    // events we support when speaking to a peer that supports the target profile.
    const SUPPORTED_NOTIFICATIONS: [NotificationEventId; 4] = [
        NotificationEventId::EventPlaybackStatusChanged,
        NotificationEventId::EventTrackChanged,
        NotificationEventId::EventPlaybackPosChanged,
        NotificationEventId::EventVolumeChanged,
    ];

    let supported_notifications: Vec<NotificationEventId> =
        SUPPORTED_NOTIFICATIONS.iter().cloned().collect();

    // look up what notifications we support on this peer first. Consider updating this from
    // time to time.
    let remote_supported_notifications = match get_supported_events_internal(peer.clone()).await {
        Ok(x) => x,
        Err(_) => return,
    };

    let supported_notifications: Vec<NotificationEventId> = remote_supported_notifications
        .into_iter()
        .filter(|k| supported_notifications.contains(k))
        .collect();

    let mut notification_streams = SelectAll::new();

    for notif in supported_notifications {
        fx_vlog!(tag: "avrcp", 2, "creating notification stream for {:#?}", notif);
        let stream =
            NotificationStream::new(peer.clone(), notif, 1).map_ok(move |data| (notif, data));
        notification_streams.push(stream);
    }

    pin_mut!(notification_streams);
    loop {
        if futures::select! {
            event_result = notification_streams.select_next_some() => {
                match event_result {
                    Ok((notif, data)) => {
                        handle_notification(&notif, &peer, &data[..])
                            .unwrap_or_else(|e| { fx_log_err!("Error decoding packet from peer {:?}", e); true} )
                    },
                    Err(Error::CommandNotSupported) => false,
                    Err(_) => true,
                    _=> true,
                }
            }
            complete => { true }
        } {
            break;
        }
    }
    fx_vlog!(tag: "avrcp", 2, "stopping notifications for {:#?}", peer.read().peer_id);
}
/// Checks for supported notification on the peer and registers for notifications.
/// This is started on a remote peer when we have a connection and target profile descriptor.
Checks for supported notification on the peer and registers for notifications.
This is started on a remote peer when we have a connection and target profile descriptor.
Checks for supported notification on the peer and registers for notifications . This is started on a remote peer when we have a connection and target profile descriptor .
async fn pump_notifications(peer: Arc<RwLock<RemotePeer>>) {
    // events we support when speaking to a peer that supports the target profile.
    const SUPPORTED_NOTIFICATIONS: [NotificationEventId; 4] = [
        NotificationEventId::EventPlaybackStatusChanged,
        NotificationEventId::EventTrackChanged,
        NotificationEventId::EventPlaybackPosChanged,
        NotificationEventId::EventVolumeChanged,
    ];
    let supported_notifications: Vec<NotificationEventId> =
        SUPPORTED_NOTIFICATIONS.iter().cloned().collect();
    // look up what notifications we support on this peer first. Consider updating this from
    // time to time.
    let remote_supported_notifications = match get_supported_events_internal(peer.clone()).await {
        Ok(x) => x,
        Err(_) => return,
    };
    let supported_notifications: Vec<NotificationEventId> = remote_supported_notifications
        .into_iter()
        .filter(|k| supported_notifications.contains(k))
        .collect();
    let mut notification_streams = SelectAll::new();
    for notif in supported_notifications {
        fx_vlog!(tag: "avrcp", 2, "creating notification stream for {:#?}", notif);
        let stream =
            NotificationStream::new(peer.clone(), notif, 1).map_ok(move |data| (notif, data));
        notification_streams.push(stream);
    }
    pin_mut!(notification_streams);
    loop {
        if futures::select! {
            event_result = notification_streams.select_next_some() => {
                match event_result {
                    Ok((notif, data)) => {
                        handle_notification(&notif, &peer, &data[..])
                            .unwrap_or_else(|e| { fx_log_err!("Error decoding packet from peer {:?}", e); true} )
                    },
                    Err(Error::CommandNotSupported) => false,
                    Err(_) => true,
                    _=> true,
                }
            }
            complete => { true }
        } {
            break;
        }
    }
    fx_vlog!(tag: "avrcp", 2, "stopping notifications for {:#?}", peer.read().peer_id);
}
async fn pump_notifications ( peer : Arc < RwLock < RemotePeer > > ) { // events we support when speaking to a peer that supports the target profile. const SUPPORTED_NOTIFICATIONS : [ NotificationEventId ; 4 ] = [ NotificationEventId :: EventPlaybackStatusChanged , NotificationEventId :: EventTrackChanged , NotificationEventId :: EventPlaybackPosChanged , NotificationEventId :: EventVolumeChanged , ] ; let supported_notifications : Vec < NotificationEventId > = SUPPORTED_NOTIFICATIONS . iter ( ) . cloned ( ) . collect ( ) ; // look up what notifications we support on this peer first. Consider updating this from // time to time. let remote_supported_notifications = match get_supported_events_internal ( peer . clone ( ) ) . await { Ok ( x ) => x , Err ( _ ) => return , } ; let supported_notifications : Vec < NotificationEventId > = remote_supported_notifications . into_iter ( ) . filter ( | k | supported_notifications . contains ( k ) ) . collect ( ) ; let mut notification_streams = SelectAll :: new ( ) ; for notif in supported_notifications { fx_vlog ! ( tag " " 2 " " notif ) ; let stream = NotificationStream :: new ( peer . clone ( ) , notif , 1 ) . map_ok ( move | data | ( notif , data ) ) ; notification_streams . push ( stream ) ; } pin_mut ! ( notification_streams ) ; loop { if futures :: select ! { event_result notification_streams select_next_some ( ) { match event_result { Ok ( ( notif data ) ) { handle_notification ( notif peer data [ ] ) unwrap_or_else ( e { fx_log_err ( " " e ) true } ) } Err ( Error CommandNotSupported ) false Err ( ) true true } } complete { true } } { break ; } } fx_vlog ! ( tag " " 2 " " peer read ( ) peer_id ) ; }
Checks for supported notification on the peer and registers for notifications.
Checks for supported notification on the peer and registers for notifications .
peer
Arc<RwLock<RemotePeer>>
peer
Arc<RwLock<RemotePeer>>