Class SystemAudioSourceBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sources
- Assembly
- VisioForge.Core.dll
System audio source block for native audio capture device access across platforms. Provides unified audio recording from microphones, line-in devices, and system audio using platform-specific APIs (WASAPI, CoreAudio, ALSA, PulseAudio) for voice recording, audio streaming, and real-time audio processing applications. Implements the VisioForge.Core.MediaBlocks.Sources.SourceMediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.
public class SystemAudioSourceBlock : SourceMediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IAudioVolumeMuteInheritance
Implements
Inherited Members
Extension Methods
Constructors
SystemAudioSourceBlock()
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sources.SystemAudioSourceBlock class with the default audio capture device. Automatically selects the first available audio capture device on the system.
public SystemAudioSourceBlock()SystemAudioSourceBlock(IAudioCaptureDeviceSourceSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sources.SystemAudioSourceBlock class with custom capture settings. Configures the system audio source for microphone or line-in capture with specified parameters.
public SystemAudioSourceBlock(IAudioCaptureDeviceSourceSettings settings)Parameters
settingsIAudioCaptureDeviceSourceSettings-
The audio capture settings controlling device selection, sample rate, and format parameters.
Properties
Input
Gets the primary input pad (none for source blocks that capture from devices).
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets all input pads available on this block (none for source blocks).
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the primary audio output pad for the captured audio stream.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all output pads available on this block (single audio output for microphone).
public override MediaBlockPad[] Outputs { get; }Property Value
Settings
Gets or sets the audio capture device configuration settings that control device selection and audio parameters.
public IAudioCaptureDeviceSourceSettings Settings { get; set; }Property Value
Type
Gets the media block type identifier for system audio source operations.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds and initializes the system audio source within the pipeline context. Creates platform-specific audio capture source, configures device parameters, and prepares audio output for downstream processing.
public override bool Build()Returns
- bool
-
trueif the system audio source was successfully built and configured; otherwise,false.
CleanUp()
Cleans up all resources associated with the audio capture operations, including device handles and audio buffers.
public void CleanUp()Dispose(bool)
Releases unmanaged and managed resources used by the system audio source. Properly closes audio device handles and disposes of GStreamer elements and capture resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetCore()
Gets the core GStreamer element wrapper for advanced configuration and monitoring.
public BaseElement GetCore()Returns
- BaseElement
-
Always null for composite source blocks with multiple internal elements.
GetDevicesAsync(AudioCaptureDeviceAPI?)
Gets the list of available audio capture devices asynchronously. Enumerates all connected microphones, line-in devices, and system audio sources on the current system.
public static Task<AudioCaptureDeviceInfo[]> GetDevicesAsync(AudioCaptureDeviceAPI? api = null)Parameters
apiAudioCaptureDeviceAPI?-
Optional specific audio API to query; if null, queries all available APIs.
Returns
- Task<AudioCaptureDeviceInfo[]>
-
A task that represents the asynchronous operation returning an array of AudioCaptureDeviceInfo containing device names, IDs, and capabilities.
GetElement()
Gets the native GStreamer element for direct GStreamer pipeline integration.
public Element GetElement()Returns
- Element
-
The system audio source GStreamer element.
GetMute()
Gets the current mute state of the audio capture device.
public bool GetMute()Returns
- bool
-
trueif the audio capture is muted;falseif unmuted.
GetVolume()
Gets the current capture volume level of the audio device.
public double GetVolume()Returns
- double
-
The volume level as a double in the range 0.0 (silence) to 1.0 (maximum volume).
IsAvailable(AudioCaptureDeviceAPI)
Determines whether audio capture support is available for the specified API on the current system. Requires platform-specific audio capture APIs and drivers to be available and functional.
public static bool IsAvailable(AudioCaptureDeviceAPI api)Parameters
apiAudioCaptureDeviceAPI-
The audio capture API to check (WASAPI, CoreAudio, ALSA, PulseAudio, etc.).
Returns
- bool
-
trueif audio capture support is available for the specified API; otherwise,false.
IsSupported()
Determines whether volume and mute control is supported by the current audio capture device.
public bool IsSupported()Returns
- bool
-
trueif volume/mute control is supported; otherwise,false.
SetInterface(IAudioVolumeMute)
Sets the audio volume/mute interface for internal use by the framework.
public void SetInterface(IAudioVolumeMute intf)Parameters
intfIAudioVolumeMute-
The IAudioVolumeMute interface implementation.
SetMute(bool)
Sets the mute state of the audio capture device.
public void SetMute(bool mute)Parameters
mutebool-
If set to
true, mutes the audio capture; otherwise, unmutes it.
SetVolume(double)
Sets the capture volume level for the audio device.
public void SetVolume(double volume)Parameters
volumedouble-
The volume level in the range 0.0 (silence) to 1.0 (maximum volume).
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the pipeline context for this system audio source, providing access to the parent pipeline and logging context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The parent MediaBlocks pipeline containing this system audio source.