impl default output format for emscripten (#234)

This commit is contained in:
thiolliere 2018-07-10 15:04:00 +02:00 committed by Pierre Krieger
parent 568d4097e7
commit 77a4ee6145
2 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,7 @@
# Unreleased # Unreleased
- Implement `default_output_format` for emscripten backend.
# Version 0.8.1 (2018-03-18) # Version 0.8.1 (2018-03-18)
- Fix the handling of non-default sample rates for coreaudio input streams. - Fix the handling of non-default sample rates for coreaudio input streams.

View File

@ -68,7 +68,6 @@ impl EventLoop {
stream: &stream, stream: &stream,
}; };
let id = StreamId(stream_id);
let buffer = UnknownTypeOutputBuffer::F32(::OutputBuffer { target: Some(buffer) }); let buffer = UnknownTypeOutputBuffer::F32(::OutputBuffer { target: Some(buffer) });
let data = StreamData::Output { buffer: buffer }; let data = StreamData::Output { buffer: buffer };
user_cb(StreamId(stream_id), data); user_cb(StreamId(stream_id), data);
@ -204,6 +203,8 @@ impl Device {
// TODO: right now cpal's API doesn't allow flexibility here // TODO: right now cpal's API doesn't allow flexibility here
// "44100" and "2" (channels) have also been hard-coded in the rest of the code ; if // "44100" and "2" (channels) have also been hard-coded in the rest of the code ; if
// this ever becomes more flexible, don't forget to change that // this ever becomes more flexible, don't forget to change that
// According to https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/createBuffer
// browsers must support 1 to 32 channels at leats and 8,000 Hz to 96,000 Hz.
Ok( Ok(
vec![ vec![
SupportedFormat { SupportedFormat {
@ -221,7 +222,14 @@ impl Device {
} }
pub fn default_output_format(&self) -> Result<Format, DefaultFormatError> { pub fn default_output_format(&self) -> Result<Format, DefaultFormatError> {
unimplemented!(); // TODO: because it is hard coded, see supported_output_formats.
Ok(
Format {
channels: 2,
sample_rate: ::SampleRate(44100),
data_type: ::SampleFormat::F32,
},
)
} }
} }