use std::future::Future;
use std::io::{self, Error};
use std::marker::PhantomData;
use std::pin::Pin;
use std::task::{Context, Poll};
use web_sys::{AudioWorkletNode, AudioWorkletNodeOptions, BaseAudioContext};
use super::super::Thread;
use crate::web::audio_worklet::{AudioWorkletNodeError, ExtendAudioWorkletProcessor};
pub(in super::super) fn register_thread<F>(
_: BaseAudioContext,
_: Option<usize>,
_: F,
) -> RegisterThreadFuture {
unreachable!("reached `register_thread()` without atomics target feature")
}
#[cfg(feature = "message")]
pub(in super::super) fn register_thread_with_message<F, M>(
_: BaseAudioContext,
_: Option<usize>,
_: F,
_: M,
) -> RegisterThreadFuture {
unreachable!("reached `register_thread()` without atomics target feature")
}
#[derive(Debug)]
pub(in super::super) struct RegisterThreadFuture {
error: Option<Error>,
_marker: PhantomData<*const ()>,
}
impl Future for RegisterThreadFuture {
type Output = io::Result<AudioWorkletHandle>;
fn poll(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Ready(Err(self.error.take().expect("polled after completion")))
}
}
impl RegisterThreadFuture {
pub(in super::super) const fn error(error: Error) -> Self {
Self {
error: Some(error),
_marker: PhantomData,
}
}
}
#[derive(Debug)]
pub(in super::super) struct AudioWorkletHandle;
impl AudioWorkletHandle {
#[allow(clippy::unused_self)]
pub(crate) const fn thread(&self) -> &Thread {
unreachable!()
}
#[allow(clippy::unused_self)]
pub(crate) unsafe fn release(self) -> Result<(), Self> {
unreachable!("reached `register_thread()` without atomics target feature")
}
}
#[allow(clippy::missing_const_for_fn)]
pub(in super::super) fn is_main_thread() -> bool {
true
}
#[allow(clippy::extra_unused_type_parameters)]
pub(in super::super) fn register_processor<P>(_: &str) -> Result<(), Error> {
unreachable!("reached `register_processor()` on the main thread")
}
#[allow(clippy::missing_const_for_fn)]
pub(in super::super) fn is_registered(_: &BaseAudioContext) -> bool {
false
}
pub(in super::super) fn audio_worklet_node<P: ExtendAudioWorkletProcessor>(
_: &BaseAudioContext,
_: &str,
_: P::Data,
_: Option<&AudioWorkletNodeOptions>,
) -> Result<AudioWorkletNode, AudioWorkletNodeError<P>> {
unreachable!("reached despite not being able to register a thread")
}