drtio: aux_transact handles async playback status

pull/225/head
mwojcik 2023-03-27 15:15:02 +08:00
parent ca51cf7729
commit 4fa063d53d
1 changed files with 18 additions and 18 deletions

View File

@ -66,7 +66,16 @@ pub mod drtio {
}
let _lock = aux_mutex.async_lock().await;
drtioaux_async::send(linkno, request).await.unwrap();
recv_aux_timeout(linkno, 200, timer).await
loop {
let reply = recv_aux_timeout(linkno, 200, timer).await;
match reply {
Ok(Packet::DmaPlaybackStatus { id, destination, error, channel, timestamp }) => {
remote_dma::playback_done(id, destination, error, channel, timestamp).await;
},
Ok(packet) => return Ok(packet),
Err(e) => return Err(e)
}
}
}
async fn drain_buffer(linkno: u8, draining_time: Milliseconds, timer: GlobalTimer) {
@ -458,25 +467,16 @@ pub mod drtio {
timestamp: u64
) -> Result<(), &'static str> {
let linkno = routing_table.0[destination as usize][0] - 1;
let _lock = aux_mutex.async_lock().await;
drtioaux_async::send(linkno, &Packet::DmaPlaybackRequest{
id: id, destination: destination, timestamp: timestamp }).await.unwrap();
loop {
let reply = recv_aux_timeout(linkno, 200, timer).await;
match reply {
Ok(Packet::DmaPlaybackReply { succeeded: true }) => { return Ok(()) },
Ok(Packet::DmaPlaybackReply { succeeded: false }) => {
return Err("error on DMA playback request") },
// in case we received status from another destination
// but we want to get DmaPlaybackReply anyway, thus the loop
Ok(Packet::DmaPlaybackStatus { id, destination, error, channel, timestamp }) => {
remote_dma::playback_done(id, destination, error, channel, timestamp).await;
},
Ok(_) => { return Err("received unexpected aux packet while DMA playback") },
Err(_) => { return Err("aux error on DMA playback") }
}
let reply = aux_transact(aux_mutex, linkno, &Packet::DmaPlaybackRequest{
id: id, destination: destination, timestamp: timestamp }, timer).await;
match reply {
Ok(Packet::DmaPlaybackReply { succeeded: true }) => Ok(()),
Ok(Packet::DmaPlaybackReply { succeeded: false }) => Err("error on DMA playback request"),
Ok(_) => Err("received unexpected aux packet while DMA playback"),
Err(_) => Err("aux error on DMA playback")
}
}
}
fn read_device_map(cfg: &Config) -> BTreeMap<u32, String> {