11use std:: convert:: TryInto ;
22use std:: time:: Duration ;
33
4- extern crate oboe ;
4+ extern crate ndk ;
55
66use crate :: {
77 BackendSpecificError , BuildStreamError , PauseStreamError , PlayStreamError , StreamError ,
@@ -15,22 +15,21 @@ pub fn to_stream_instant(duration: Duration) -> StreamInstant {
1515 )
1616}
1717
18- pub fn stream_instant < T : oboe:: AudioStreamSafe + ?Sized > ( stream : & mut T ) -> StreamInstant {
19- const CLOCK_MONOTONIC : i32 = 1 ;
18+ pub fn stream_instant ( stream : & ndk:: audio:: AudioStream ) -> StreamInstant {
2019 let ts = stream
21- . get_timestamp ( CLOCK_MONOTONIC )
22- . unwrap_or ( oboe :: FrameTimestamp {
23- position : 0 ,
24- timestamp : 0 ,
20+ . timestamp ( ndk :: audio :: Clockid :: Monotonic )
21+ . unwrap_or ( ndk :: audio :: Timestamp {
22+ frame_position : 0 ,
23+ time_nanoseconds : 0 ,
2524 } ) ;
26- to_stream_instant ( Duration :: from_nanos ( ts. timestamp as u64 ) )
25+ to_stream_instant ( Duration :: from_nanos ( ts. time_nanoseconds as u64 ) )
2726}
2827
29- impl From < oboe :: Error > for StreamError {
30- fn from ( error : oboe :: Error ) -> Self {
31- use self :: oboe :: Error :: * ;
28+ impl From < ndk :: audio :: AudioError > for StreamError {
29+ fn from ( error : ndk :: audio :: AudioError ) -> Self {
30+ use self :: ndk :: audio :: AudioError :: * ;
3231 match error {
33- Disconnected | Unavailable | Closed => Self :: DeviceNotAvailable ,
32+ Disconnected | Unavailable => Self :: DeviceNotAvailable ,
3433 e => ( BackendSpecificError {
3534 description : e. to_string ( ) ,
3635 } )
@@ -39,11 +38,11 @@ impl From<oboe::Error> for StreamError {
3938 }
4039}
4140
42- impl From < oboe :: Error > for PlayStreamError {
43- fn from ( error : oboe :: Error ) -> Self {
44- use self :: oboe :: Error :: * ;
41+ impl From < ndk :: audio :: AudioError > for PlayStreamError {
42+ fn from ( error : ndk :: audio :: AudioError ) -> Self {
43+ use self :: ndk :: audio :: AudioError :: * ;
4544 match error {
46- Disconnected | Unavailable | Closed => Self :: DeviceNotAvailable ,
45+ Disconnected | Unavailable => Self :: DeviceNotAvailable ,
4746 e => ( BackendSpecificError {
4847 description : e. to_string ( ) ,
4948 } )
@@ -52,11 +51,11 @@ impl From<oboe::Error> for PlayStreamError {
5251 }
5352}
5453
55- impl From < oboe :: Error > for PauseStreamError {
56- fn from ( error : oboe :: Error ) -> Self {
57- use self :: oboe :: Error :: * ;
54+ impl From < ndk :: audio :: AudioError > for PauseStreamError {
55+ fn from ( error : ndk :: audio :: AudioError ) -> Self {
56+ use self :: ndk :: audio :: AudioError :: * ;
5857 match error {
59- Disconnected | Unavailable | Closed => Self :: DeviceNotAvailable ,
58+ Disconnected | Unavailable => Self :: DeviceNotAvailable ,
6059 e => ( BackendSpecificError {
6160 description : e. to_string ( ) ,
6261 } )
@@ -65,11 +64,11 @@ impl From<oboe::Error> for PauseStreamError {
6564 }
6665}
6766
68- impl From < oboe :: Error > for BuildStreamError {
69- fn from ( error : oboe :: Error ) -> Self {
70- use self :: oboe :: Error :: * ;
67+ impl From < ndk :: audio :: AudioError > for BuildStreamError {
68+ fn from ( error : ndk :: audio :: AudioError ) -> Self {
69+ use self :: ndk :: audio :: AudioError :: * ;
7170 match error {
72- Disconnected | Unavailable | Closed => Self :: DeviceNotAvailable ,
71+ Disconnected | Unavailable => Self :: DeviceNotAvailable ,
7372 NoFreeHandles => Self :: StreamIdOverflow ,
7473 InvalidFormat | InvalidRate => Self :: StreamConfigNotSupported ,
7574 IllegalArgument => Self :: InvalidArgument ,
0 commit comments