Merge pull request #491 from creator-rs/master
Add Android APK build CI and Release version 0.13.0
This commit is contained in:
commit
2220f58491
8 changed files with 85 additions and 30 deletions
|
|
@ -15,7 +15,7 @@ pub fn to_stream_instant(duration: Duration) -> StreamInstant {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn stream_instant<T: oboe::AudioStream + ?Sized>(stream: &mut T) -> StreamInstant {
|
||||
pub fn stream_instant<T: oboe::AudioStreamSafe + ?Sized>(stream: &mut T) -> StreamInstant {
|
||||
const CLOCK_MONOTONIC: i32 = 1;
|
||||
let ts = stream
|
||||
.get_timestamp(CLOCK_MONOTONIC)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl<I, C> CpalInputCallback<I, C> {
|
|||
|
||||
fn make_callback_info(
|
||||
&self,
|
||||
audio_stream: &mut dyn oboe::AudioInputStream,
|
||||
audio_stream: &mut dyn oboe::AudioInputStreamSafe,
|
||||
) -> InputCallbackInfo {
|
||||
InputCallbackInfo {
|
||||
timestamp: InputStreamTimestamp {
|
||||
|
|
@ -50,7 +50,7 @@ where
|
|||
|
||||
fn on_audio_ready(
|
||||
&mut self,
|
||||
audio_stream: &mut dyn oboe::AudioInputStream,
|
||||
audio_stream: &mut dyn oboe::AudioInputStreamSafe,
|
||||
audio_data: &[<<Self as oboe::AudioInputCallback>::FrameType as oboe::IsFrameType>::Type],
|
||||
) -> oboe::DataCallbackResult {
|
||||
let cb_info = self.make_callback_info(audio_stream);
|
||||
|
|
@ -74,7 +74,7 @@ where
|
|||
|
||||
fn on_error_before_close(
|
||||
&mut self,
|
||||
_audio_stream: &mut dyn oboe::AudioInputStream,
|
||||
_audio_stream: &mut dyn oboe::AudioInputStreamSafe,
|
||||
error: oboe::Error,
|
||||
) {
|
||||
(self.error_cb)(StreamError::from(error))
|
||||
|
|
@ -82,7 +82,7 @@ where
|
|||
|
||||
fn on_error_after_close(
|
||||
&mut self,
|
||||
_audio_stream: &mut dyn oboe::AudioInputStream,
|
||||
_audio_stream: &mut dyn oboe::AudioInputStreamSafe,
|
||||
error: oboe::Error,
|
||||
) {
|
||||
(self.error_cb)(StreamError::from(error))
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ mod output_callback;
|
|||
|
||||
use self::android_media::{get_audio_record_min_buffer_size, get_audio_track_min_buffer_size};
|
||||
use self::input_callback::CpalInputCallback;
|
||||
use self::oboe::{AudioInputStream, AudioOutputStream};
|
||||
use self::output_callback::CpalOutputCallback;
|
||||
|
||||
// Android Java API supports up to 8 channels, but oboe API
|
||||
|
|
@ -36,7 +37,10 @@ const SAMPLE_RATES: [i32; 13] = [
|
|||
|
||||
pub struct Host;
|
||||
pub struct Device(Option<oboe::AudioDeviceInfo>);
|
||||
pub struct Stream(Box<RefCell<dyn oboe::AudioStream>>);
|
||||
pub enum Stream {
|
||||
Input(Box<RefCell<dyn AudioInputStream>>),
|
||||
Output(Box<RefCell<dyn AudioOutputStream>>),
|
||||
}
|
||||
pub type SupportedInputConfigs = VecIntoIter<SupportedStreamConfigRange>;
|
||||
pub type SupportedOutputConfigs = VecIntoIter<SupportedStreamConfigRange>;
|
||||
pub type Devices = VecIntoIter<Device>;
|
||||
|
|
@ -242,7 +246,7 @@ where
|
|||
error_callback,
|
||||
))
|
||||
.open_stream()?;
|
||||
Ok(Stream(Box::new(RefCell::new(stream))))
|
||||
Ok(Stream::Input(Box::new(RefCell::new(stream))))
|
||||
}
|
||||
|
||||
fn build_output_stream<D, E, C, T>(
|
||||
|
|
@ -266,7 +270,7 @@ where
|
|||
error_callback,
|
||||
))
|
||||
.open_stream()?;
|
||||
Ok(Stream(Box::new(RefCell::new(stream))))
|
||||
Ok(Stream::Output(Box::new(RefCell::new(stream))))
|
||||
}
|
||||
|
||||
impl DeviceTrait for Device {
|
||||
|
|
@ -472,16 +476,28 @@ impl DeviceTrait for Device {
|
|||
|
||||
impl StreamTrait for Stream {
|
||||
fn play(&self) -> Result<(), PlayStreamError> {
|
||||
self.0
|
||||
.borrow_mut()
|
||||
.request_start()
|
||||
.map_err(PlayStreamError::from)
|
||||
match self {
|
||||
Self::Input(stream) => stream
|
||||
.borrow_mut()
|
||||
.request_start()
|
||||
.map_err(PlayStreamError::from),
|
||||
Self::Output(stream) => stream
|
||||
.borrow_mut()
|
||||
.request_start()
|
||||
.map_err(PlayStreamError::from),
|
||||
}
|
||||
}
|
||||
|
||||
fn pause(&self) -> Result<(), PauseStreamError> {
|
||||
self.0
|
||||
.borrow_mut()
|
||||
.request_pause()
|
||||
.map_err(PauseStreamError::from)
|
||||
match self {
|
||||
Self::Input(_) => Err(BackendSpecificError {
|
||||
description: "Pause called on the input stream.".to_owned(),
|
||||
}
|
||||
.into()),
|
||||
Self::Output(stream) => stream
|
||||
.borrow_mut()
|
||||
.request_pause()
|
||||
.map_err(PauseStreamError::from),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl<I, C> CpalOutputCallback<I, C> {
|
|||
|
||||
fn make_callback_info(
|
||||
&self,
|
||||
audio_stream: &mut dyn oboe::AudioOutputStream,
|
||||
audio_stream: &mut dyn oboe::AudioOutputStreamSafe,
|
||||
) -> OutputCallbackInfo {
|
||||
OutputCallbackInfo {
|
||||
timestamp: OutputStreamTimestamp {
|
||||
|
|
@ -50,7 +50,7 @@ where
|
|||
|
||||
fn on_audio_ready(
|
||||
&mut self,
|
||||
audio_stream: &mut dyn oboe::AudioOutputStream,
|
||||
audio_stream: &mut dyn oboe::AudioOutputStreamSafe,
|
||||
audio_data: &mut [<<Self as oboe::AudioOutputCallback>::FrameType as oboe::IsFrameType>::Type],
|
||||
) -> oboe::DataCallbackResult {
|
||||
let cb_info = self.make_callback_info(audio_stream);
|
||||
|
|
@ -74,7 +74,7 @@ where
|
|||
|
||||
fn on_error_before_close(
|
||||
&mut self,
|
||||
_audio_stream: &mut dyn oboe::AudioOutputStream,
|
||||
_audio_stream: &mut dyn oboe::AudioOutputStreamSafe,
|
||||
error: oboe::Error,
|
||||
) {
|
||||
(self.error_cb)(StreamError::from(error))
|
||||
|
|
@ -82,7 +82,7 @@ where
|
|||
|
||||
fn on_error_after_close(
|
||||
&mut self,
|
||||
_audio_stream: &mut dyn oboe::AudioOutputStream,
|
||||
_audio_stream: &mut dyn oboe::AudioOutputStreamSafe,
|
||||
error: oboe::Error,
|
||||
) {
|
||||
(self.error_cb)(StreamError::from(error))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue