1
1
use std:: convert:: TryInto ;
2
2
use std:: time:: Duration ;
3
3
4
- extern crate oboe ;
4
+ extern crate ndk ;
5
5
6
6
use crate :: {
7
7
BackendSpecificError , BuildStreamError , PauseStreamError , PlayStreamError , StreamError ,
@@ -15,22 +15,21 @@ pub fn to_stream_instant(duration: Duration) -> StreamInstant {
15
15
)
16
16
}
17
17
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 {
20
19
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 ,
25
24
} ) ;
26
- to_stream_instant ( Duration :: from_nanos ( ts. timestamp as u64 ) )
25
+ to_stream_instant ( Duration :: from_nanos ( ts. time_nanoseconds as u64 ) )
27
26
}
28
27
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 :: * ;
32
31
match error {
33
- Disconnected | Unavailable | Closed => Self :: DeviceNotAvailable ,
32
+ Disconnected | Unavailable => Self :: DeviceNotAvailable ,
34
33
e => ( BackendSpecificError {
35
34
description : e. to_string ( ) ,
36
35
} )
@@ -39,11 +38,11 @@ impl From<oboe::Error> for StreamError {
39
38
}
40
39
}
41
40
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 :: * ;
45
44
match error {
46
- Disconnected | Unavailable | Closed => Self :: DeviceNotAvailable ,
45
+ Disconnected | Unavailable => Self :: DeviceNotAvailable ,
47
46
e => ( BackendSpecificError {
48
47
description : e. to_string ( ) ,
49
48
} )
@@ -52,11 +51,11 @@ impl From<oboe::Error> for PlayStreamError {
52
51
}
53
52
}
54
53
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 :: * ;
58
57
match error {
59
- Disconnected | Unavailable | Closed => Self :: DeviceNotAvailable ,
58
+ Disconnected | Unavailable => Self :: DeviceNotAvailable ,
60
59
e => ( BackendSpecificError {
61
60
description : e. to_string ( ) ,
62
61
} )
@@ -65,11 +64,11 @@ impl From<oboe::Error> for PauseStreamError {
65
64
}
66
65
}
67
66
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 :: * ;
71
70
match error {
72
- Disconnected | Unavailable | Closed => Self :: DeviceNotAvailable ,
71
+ Disconnected | Unavailable => Self :: DeviceNotAvailable ,
73
72
NoFreeHandles => Self :: StreamIdOverflow ,
74
73
InvalidFormat | InvalidRate => Self :: StreamConfigNotSupported ,
75
74
IllegalArgument => Self :: InvalidArgument ,
0 commit comments