Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/Spice86.Audio/Backend/Audio/CrossPlatform/AudioCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Spice86.Audio.Backend.Audio.CrossPlatform;
/// Callback delegate invoked by the audio backend when it needs audio data.
/// Reference: SDL_AudioCallback from SDL_audio.h
/// </summary>
/// <param name="buffer">Buffer to fill with audio samples (interleaved float stereo).</param>
/// <param name="buffer">Buffer to fill with interleaved float samples in the obtained channel layout.</param>
/// <remarks>
/// This callback is called from the audio thread. Implementations must be thread-safe
/// and should not block. Fill the buffer with silence (zeros) if no audio is available.
Expand All @@ -21,9 +21,12 @@ namespace Spice86.Audio.Backend.Audio.CrossPlatform;
public delegate void AudioPostmixCallback(Span<float> buffer);

/// <summary>
/// Audio format specification matching SDL_AudioSpec.
/// Audio format specification matching the managed subset of SDL_AudioSpec.
/// The callback-facing mix format is always interleaved float samples even when
/// a backend negotiates a different native device representation internally.
/// </summary>
public sealed class AudioSpec {
public sealed class AudioSpec
{
/// <summary>
/// Sample rate in Hz (e.g., 48000).
/// </summary>
Expand Down Expand Up @@ -61,15 +64,16 @@ public sealed class AudioSpec {
public int BufferSamples => BufferFrames * Channels;

/// <summary>
/// Gets the buffer size in bytes (for float samples).
/// Gets the buffer size in bytes for the managed float callback representation.
/// </summary>
public int BufferBytes => BufferSamples * sizeof(float);
}

/// <summary>
/// Audio device state.
/// </summary>
public enum AudioDeviceState {
public enum AudioDeviceState
{
/// <summary>
/// Device is stopped/paused.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ namespace Spice86.Audio.Backend.Audio.CrossPlatform.Sdl;
/// Reference: SDL_AudioDriverImpl from SDL_sysaudio.h
/// Each platform (WASAPI, ALSA, CoreAudio) implements this interface.
/// </summary>
internal interface ISdlAudioDriver {
internal interface ISdlAudioDriver
{
/// <summary>
/// Gets a value indicating whether the backend owns the callback thread.
/// Drivers such as CoreAudio run their own callback loop and should not use
/// the shared SDL-style playback thread in <see cref="SdlAudioDevice"/>.
/// </summary>
bool ProvidesOwnCallbackThread { get; }

/// <summary>
/// Opens the audio device with the desired spec.
/// Reference: SDL_AudioDriverImpl.OpenDevice
Expand Down
Loading
Loading