pub struct TestAudioSource { /* private fields */ }Expand description
Generates a synthetic sine-wave tone — GStreamer’s audiotestsrc
equivalent. No real capture device involved: TestAudioSource::run
fabricates however many samples wall-clock time now owes on a
drift-free absolute schedule (expected = elapsed * sample_rate,
needed = expected - samples_emitted — the same shape
WasapiCaptureSource::fill_silence_gap/AudioMixer::mix_tick both
use, not a fixed
per-tick sample count, which would drift the same way a fixed-duration
thread::sleep-only schedule would), stamps it with an increasing
pts (one sample per tick of TestAudioSource::time_base’s units),
and pushes it straight downstream — useful for exercising
AudioMixer/an encoder/a muxer without a real microphone.
Always emits Sample::F32(Packed) — the same fixed internal format
AudioMixer mixes in, so this can feed a MixerHandle input directly
with nothing to resample (though MixerInputSink resamples regardless
if fed something else instead, so this isn’t load-bearing).
Runs until Stop — never reaches Eos on its own, same as every other
live source in this crate (no sample-count limit is exposed,
deliberately, mirroring a live capture source more than a file).
Implementations§
Trait Implementations§
Source§impl Element for TestAudioSource
impl Element for TestAudioSource
Source§fn name(&self) -> Arc<str> ⓘ
fn name(&self) -> Arc<str> ⓘ
crate::bus::BusEvent stores names as
Arc<str> for exactly this reason: a hot path like
crate::queue::Queue posting BusEvent::Dropped once per
overflowed buffer shouldn’t pay for a fresh heap allocation every
time it wants to report which element it is.Source§fn element_type(&self) -> ElementType
fn element_type(&self) -> ElementType
ElementType.Source§fn pp_log(&self) -> &PpLog
fn pp_log(&self) -> &PpLog
crate::bus::Bus::post — same
id/name as Element::name, just already wrapped as the
crate::pp_log::PpLog its pp_info!/pp_warn!/pp_error! macros need. A
stored private field, not built fresh per call, for the same reason
name() returns a cheap Arc<str> clone instead of a fresh String
— see its own docs.Source§fn pp_log_mut(&mut self) -> &mut PpLog
fn pp_log_mut(&mut self) -> &mut PpLog
Element::pp_log reads — used by
crate::pipeline::ChainBuilder to stamp the owning
crate::pipeline::Pipeline’s id onto every element that
passes through it, via element_pp_log. Not meant to be called
from anywhere else.impl Send for TestAudioSource
Source§impl SourceElement for TestAudioSource
impl SourceElement for TestAudioSource
Source§fn run(&mut self, control: &ControlReceiver, bus: &Bus) -> Result<()>
fn run(&mut self, control: &ControlReceiver, bus: &Bus) -> Result<()>
Eos (normal completion),
crate::pipeline::Pipeline::finish, or Stop (see
ControlMsg::Stop) — call crate::control::drain_control
once per loop iteration to make control responsive between
blocking reads. Read moreSource§fn seek(&mut self, _target: Duration) -> Result<Duration>
fn seek(&mut self, _target: Duration) -> Result<Duration>
target, an absolute position from the
start of the media (e.g. av_seek_frame for
crate::elements::FileDemuxer). Called by
crate::control::drain_control as part of handling
ControlMsg::Seek, before that message is forwarded to the
source’s own pads — so whatever’s read next comes from the new
position by the time downstream elements are told to flush for it. Read more