Struct script::dom::baseaudiocontext::BaseAudioContext
source · #[repr(C)]pub struct BaseAudioContext {
eventtarget: EventTarget,
audio_context_impl: Arc<Mutex<AudioContext>>,
destination: MutNullableDom<AudioDestinationNode>,
listener: MutNullableDom<AudioListener>,
in_flight_resume_promises_queue: DomRefCell<VecDeque<(Box<[Rc<Promise>]>, Result<(), Error>)>>,
pending_resume_promises: DomRefCell<Vec<Rc<Promise>>>,
decode_resolvers: DomRefCell<HashMap<String, DecodeResolver>>,
sample_rate: f32,
state: Cell<AudioContextState>,
channel_count: u32,
}
Fields§
§eventtarget: EventTarget
§audio_context_impl: Arc<Mutex<AudioContext>>
§destination: MutNullableDom<AudioDestinationNode>
§listener: MutNullableDom<AudioListener>
§in_flight_resume_promises_queue: DomRefCell<VecDeque<(Box<[Rc<Promise>]>, Result<(), Error>)>>
Resume promises which are soon to be fulfilled by a queued task.
pending_resume_promises: DomRefCell<Vec<Rc<Promise>>>
§decode_resolvers: DomRefCell<HashMap<String, DecodeResolver>>
§sample_rate: f32
§state: Cell<AudioContextState>
https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-state Although servo-media already keeps track of the control thread state, we keep a state flag here as well. This is so that we can synchronously throw when trying to do things on the context when the context has just been “closed()”.
channel_count: u32
Implementations§
source§impl BaseAudioContext
impl BaseAudioContext
pub fn new_inherited( options: BaseAudioContextOptions, pipeline_id: PipelineId, ) -> Result<BaseAudioContext, Error>
sourcepub fn is_offline(&self) -> bool
pub fn is_offline(&self) -> bool
Tells whether this is an OfflineAudioContext or not.
pub fn audio_context_impl(&self) -> Arc<Mutex<AudioContext>>
pub fn destination_node(&self) -> NodeId
pub fn listener(&self) -> NodeId
pub fn is_allowed_to_start(&self) -> bool
fn push_pending_resume_promise(&self, promise: &Rc<Promise>)
sourcefn take_pending_resume_promises(&self, result: Result<(), Error>)
fn take_pending_resume_promises(&self, result: Result<(), Error>)
Takes the pending resume promises.
The result with which these promises will be fulfilled is passed here
and this method returns nothing because we actually just move the
current list of pending resume promises to the
in_flight_resume_promises_queue
field.
Each call to this method must be followed by a call to
fulfill_in_flight_resume_promises
, to actually fulfill the promises
which were taken and moved to the in-flight queue.
sourcefn fulfill_in_flight_resume_promises<F>(&self, f: F)where
F: FnOnce(),
fn fulfill_in_flight_resume_promises<F>(&self, f: F)where
F: FnOnce(),
Fulfills the next in-flight resume promises queue after running a closure.
See the comment on take_pending_resume_promises
for why this method
does not take a list of promises to fulfill. Callers cannot just pop
the front list off of in_flight_resume_promises_queue
and later fulfill
the promises because that would mean putting
#[allow(crown::unrooted_must_root)]
on even more functions, potentially
hiding actual safety bugs.
sourcepub fn control_thread_state(&self) -> ProcessingState
pub fn control_thread_state(&self) -> ProcessingState
Control thread processing state
sourcepub fn set_state_attribute(&self, state: AudioContextState)
pub fn set_state_attribute(&self, state: AudioContextState)
Set audio context state
pub fn resume(&self)
pub fn channel_count(&self) -> u32
source§impl BaseAudioContext
impl BaseAudioContext
fn __assert_parent_type(&self)
Trait Implementations§
source§impl BaseAudioContextMethods for BaseAudioContext
impl BaseAudioContextMethods for BaseAudioContext
source§fn SampleRate(&self) -> Finite<f32>
fn SampleRate(&self) -> Finite<f32>
source§fn CurrentTime(&self) -> Finite<f64>
fn CurrentTime(&self) -> Finite<f64>
source§fn State(&self) -> AudioContextState
fn State(&self) -> AudioContextState
source§fn Destination(&self) -> Root<Dom<AudioDestinationNode>>
fn Destination(&self) -> Root<Dom<AudioDestinationNode>>
source§fn CreateOscillator(
&self,
can_gc: CanGc,
) -> Result<Root<Dom<OscillatorNode>>, Error>
fn CreateOscillator( &self, can_gc: CanGc, ) -> Result<Root<Dom<OscillatorNode>>, Error>
source§fn CreatePanner(&self, can_gc: CanGc) -> Result<Root<Dom<PannerNode>>, Error>
fn CreatePanner(&self, can_gc: CanGc) -> Result<Root<Dom<PannerNode>>, Error>
source§fn CreateAnalyser(
&self,
can_gc: CanGc,
) -> Result<Root<Dom<AnalyserNode>>, Error>
fn CreateAnalyser( &self, can_gc: CanGc, ) -> Result<Root<Dom<AnalyserNode>>, Error>
source§fn CreateBiquadFilter(
&self,
can_gc: CanGc,
) -> Result<Root<Dom<BiquadFilterNode>>, Error>
fn CreateBiquadFilter( &self, can_gc: CanGc, ) -> Result<Root<Dom<BiquadFilterNode>>, Error>
source§fn CreateStereoPanner(
&self,
can_gc: CanGc,
) -> Result<Root<Dom<StereoPannerNode>>, Error>
fn CreateStereoPanner( &self, can_gc: CanGc, ) -> Result<Root<Dom<StereoPannerNode>>, Error>
source§fn CreateConstantSource(
&self,
can_gc: CanGc,
) -> Result<Root<Dom<ConstantSourceNode>>, Error>
fn CreateConstantSource( &self, can_gc: CanGc, ) -> Result<Root<Dom<ConstantSourceNode>>, Error>
source§fn CreateChannelMerger(
&self,
count: u32,
can_gc: CanGc,
) -> Result<Root<Dom<ChannelMergerNode>>, Error>
fn CreateChannelMerger( &self, count: u32, can_gc: CanGc, ) -> Result<Root<Dom<ChannelMergerNode>>, Error>
source§fn CreateChannelSplitter(
&self,
count: u32,
can_gc: CanGc,
) -> Result<Root<Dom<ChannelSplitterNode>>, Error>
fn CreateChannelSplitter( &self, count: u32, can_gc: CanGc, ) -> Result<Root<Dom<ChannelSplitterNode>>, Error>
source§fn CreateBuffer(
&self,
number_of_channels: u32,
length: u32,
sample_rate: Finite<f32>,
can_gc: CanGc,
) -> Result<Root<Dom<AudioBuffer>>, Error>
fn CreateBuffer( &self, number_of_channels: u32, length: u32, sample_rate: Finite<f32>, can_gc: CanGc, ) -> Result<Root<Dom<AudioBuffer>>, Error>
source§fn CreateIIRFilter(
&self,
feedforward: Vec<Finite<f64>>,
feedback: Vec<Finite<f64>>,
can_gc: CanGc,
) -> Result<Root<Dom<IIRFilterNode>>, Error>
fn CreateIIRFilter( &self, feedforward: Vec<Finite<f64>>, feedback: Vec<Finite<f64>>, can_gc: CanGc, ) -> Result<Root<Dom<IIRFilterNode>>, Error>
fn GetOnstatechange(&self) -> Option<Rc<EventHandlerNonNull>>
fn SetOnstatechange(&self, listener: Option<Rc<EventHandlerNonNull>>)
fn CreateBufferSource( &self, can_gc: CanGc, ) -> Result<Root<Dom<AudioBufferSourceNode>>, Error>
fn DecodeAudioData( &self, audio_data: CustomAutoRooterGuard<'_, ArrayBuffer>, decode_success_callback: Option<Rc<DecodeSuccessCallback>>, decode_error_callback: Option<Rc<DecodeErrorCallback>>, comp: InRealm<'_>, can_gc: CanGc, ) -> Rc<Promise>
source§impl Castable for BaseAudioContext
impl Castable for BaseAudioContext
source§impl DomObject for BaseAudioContext
impl DomObject for BaseAudioContext
source§impl DomObjectWrap for BaseAudioContext
impl DomObjectWrap for BaseAudioContext
source§const WRAP: unsafe fn(_: SafeJSContext, _: &GlobalScope, _: Option<HandleObject<'_>>, _: Box<Self>, _: CanGc) -> Root<Dom<Self>> = {dom::bindings::codegen::Bindings::BaseAudioContextBinding::BaseAudioContext_Binding::Wrap as for<'a, 'b> unsafe fn(script_runtime::JSContext, &'a dom::globalscope::GlobalScope, std::option::Option<js::rust::Handle<'b, *mut js::jsapi::JSObject>>, std::boxed::Box<dom::baseaudiocontext::BaseAudioContext>, script_runtime::CanGc) -> dom::bindings::root::Root<dom::bindings::root::Dom<dom::baseaudiocontext::BaseAudioContext>>}
const WRAP: unsafe fn(_: SafeJSContext, _: &GlobalScope, _: Option<HandleObject<'_>>, _: Box<Self>, _: CanGc) -> Root<Dom<Self>> = {dom::bindings::codegen::Bindings::BaseAudioContextBinding::BaseAudioContext_Binding::Wrap as for<'a, 'b> unsafe fn(script_runtime::JSContext, &'a dom::globalscope::GlobalScope, std::option::Option<js::rust::Handle<'b, *mut js::jsapi::JSObject>>, std::boxed::Box<dom::baseaudiocontext::BaseAudioContext>, script_runtime::CanGc) -> dom::bindings::root::Root<dom::bindings::root::Dom<dom::baseaudiocontext::BaseAudioContext>>}
source§impl HasParent for BaseAudioContext
impl HasParent for BaseAudioContext
source§fn as_parent(&self) -> &EventTarget
fn as_parent(&self) -> &EventTarget
This is used in a type assertion to ensure that the source and webidls agree as to what the parent type is
type Parent = EventTarget
source§impl IDLInterface for BaseAudioContext
impl IDLInterface for BaseAudioContext
source§impl MallocSizeOf for BaseAudioContext
impl MallocSizeOf for BaseAudioContext
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl MutDomObject for BaseAudioContext
impl MutDomObject for BaseAudioContext
source§impl PartialEq for BaseAudioContext
impl PartialEq for BaseAudioContext
source§impl Traceable for BaseAudioContext
impl Traceable for BaseAudioContext
impl DerivedFrom<BaseAudioContext> for AudioContext
impl DerivedFrom<BaseAudioContext> for BaseAudioContext
impl DerivedFrom<BaseAudioContext> for OfflineAudioContext
impl DerivedFrom<EventTarget> for BaseAudioContext
impl Eq for BaseAudioContext
Auto Trait Implementations§
impl !Freeze for BaseAudioContext
impl !RefUnwindSafe for BaseAudioContext
impl !Send for BaseAudioContext
impl !Sync for BaseAudioContext
impl Unpin for BaseAudioContext
impl !UnwindSafe for BaseAudioContext
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more