mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
fix: add error handling to BaseAudioContext::new_inherited (#33023)
* fix: add error handling to BaseAudioContext::new_inherited Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> * Update servo-media Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> * Update test expectations Signed-off-by: Taym <haddadi.taym@gmail.com> * Update servo-media Signed-off-by: Taym <haddadi.taym@gmail.com> --------- Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> Signed-off-by: Taym <haddadi.taym@gmail.com>
This commit is contained in:
parent
1ef3e107bd
commit
a24e92778a
5 changed files with 37 additions and 32 deletions
|
@ -48,12 +48,15 @@ pub struct AudioContext {
|
|||
impl AudioContext {
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
// https://webaudio.github.io/web-audio-api/#AudioContext-constructors
|
||||
fn new_inherited(options: &AudioContextOptions, pipeline_id: PipelineId) -> AudioContext {
|
||||
fn new_inherited(
|
||||
options: &AudioContextOptions,
|
||||
pipeline_id: PipelineId,
|
||||
) -> Fallible<AudioContext> {
|
||||
// Steps 1-3.
|
||||
let context = BaseAudioContext::new_inherited(
|
||||
BaseAudioContextOptions::AudioContext(options.into()),
|
||||
pipeline_id,
|
||||
);
|
||||
)?;
|
||||
|
||||
// Step 4.1.
|
||||
let latency_hint = match options.latencyHint {
|
||||
|
@ -70,12 +73,12 @@ impl AudioContext {
|
|||
// Steps 5 and 6 of the construction algorithm will happen in `resume`,
|
||||
// after reflecting dom object.
|
||||
|
||||
AudioContext {
|
||||
Ok(AudioContext {
|
||||
context,
|
||||
latency_hint,
|
||||
base_latency: 0., // TODO
|
||||
output_latency: 0., // TODO
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
|
@ -83,12 +86,12 @@ impl AudioContext {
|
|||
window: &Window,
|
||||
proto: Option<HandleObject>,
|
||||
options: &AudioContextOptions,
|
||||
) -> DomRoot<AudioContext> {
|
||||
) -> Fallible<DomRoot<AudioContext>> {
|
||||
let pipeline_id = window.pipeline_id();
|
||||
let context = AudioContext::new_inherited(options, pipeline_id);
|
||||
let context = AudioContext::new_inherited(options, pipeline_id)?;
|
||||
let context = reflect_dom_object_with_proto(Box::new(context), window, proto);
|
||||
context.resume();
|
||||
context
|
||||
Ok(context)
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#AudioContext-constructors
|
||||
|
@ -98,7 +101,7 @@ impl AudioContext {
|
|||
proto: Option<HandleObject>,
|
||||
options: &AudioContextOptions,
|
||||
) -> Fallible<DomRoot<AudioContext>> {
|
||||
Ok(AudioContext::new(window, proto, options))
|
||||
AudioContext::new(window, proto, options)
|
||||
}
|
||||
|
||||
fn resume(&self) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue