Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SDL3 Audio backend #6002

Draft
wants to merge 142 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
1c2b24f
More abstract audio components
hwsmm Oct 30, 2023
525e22c
Add SDL2 audio components
hwsmm Oct 30, 2023
8aba5b9
Add FFmpeg audio decoding capability in VideoDecoder
hwsmm Oct 30, 2023
4700117
Add needed dependencies for SDL2 Audio
hwsmm Oct 30, 2023
e711830
Init SDL2 Audio in SDL_Init
hwsmm Oct 30, 2023
949ba72
Make SDL2 audio support through framework.ini
hwsmm Oct 30, 2023
b4a6c58
Fix broken BASS tests
hwsmm Oct 30, 2023
87d2cd6
Merge branch 'master' into sdl-audio
hwsmm Oct 31, 2023
23af051
Cleanup AudioDecoder
hwsmm Oct 31, 2023
ff3b081
Merge branch 'master' into sdl-audio
hwsmm Nov 10, 2023
69c65a3
Separate BASS and FFmpeg AudioDecoder
hwsmm Nov 10, 2023
67b3ecf
Edit Waveform to use AudioDecoder
hwsmm Nov 10, 2023
d4fbc8e
Reduce allocations in VideoDecoder
hwsmm Nov 10, 2023
9ade55a
Fix a possible race condition in TrackSDL2
hwsmm Nov 10, 2023
89a67ae
Use the sample rate const in SDL2AudioMixer
hwsmm Nov 11, 2023
1a3c8c7
Add an option to dispose stream automatically in AudioDecoder
hwsmm Nov 11, 2023
24dfb68
Reset videoStream position in VideoDecoder
hwsmm Nov 11, 2023
455af66
Create MemoryStream in VideoDecoder if audio
hwsmm Nov 11, 2023
380618d
Merge branch 'master' into sdl-audio
hwsmm Nov 11, 2023
a7f9bee
Let AudioDecoder dispose the stream
hwsmm Nov 15, 2023
3ee5aec
Flush when seeking in TrackSDL2Player
hwsmm Nov 15, 2023
03a6787
Let TempoSDL2Player use offset
hwsmm Nov 15, 2023
aff6271
Merge branch 'master' into sdl-audio
hwsmm Dec 16, 2023
9ec8d46
Revert "Let TempoSDL2Player use offset"
hwsmm Dec 18, 2023
41b65fa
Remove unused using
hwsmm Dec 18, 2023
2535ec4
Fix wrong audio byteLength assumption
hwsmm Dec 18, 2023
028c0ff
Use float for Balance and improve thread safety
hwsmm Dec 19, 2023
bd7c7c9
Reduce allocation when passing decoded audio
hwsmm Dec 19, 2023
9f2eff4
Refactor AudioDecoder
hwsmm Dec 21, 2023
089fc0f
Use BASS in SDL2AudioManager
hwsmm Dec 21, 2023
47669ea
Undo an unneeded change
hwsmm Dec 23, 2023
4f341d2
Fix SampleSDL2Factory Length and use private for decodedAudio
hwsmm Dec 23, 2023
89ab405
Let TrackSDL2Player use ArrayPool
hwsmm Dec 24, 2023
57d367f
Merge master
hwsmm Dec 25, 2023
20e066e
Use a constant to init BASS No Sound in SDL2AudioManager
hwsmm Dec 25, 2023
e823423
Swap stereo channel in TrackSDL2Player ReversePlayback
hwsmm Dec 25, 2023
9a5d364
Use Log2 instead in Waveform
hwsmm Dec 25, 2023
e3689d2
Add a basic implementation of CurrentAmplitude in TrackSDL2
hwsmm Dec 25, 2023
cc9f19c
Use a better method name for passing audio data in TrackSDL2
hwsmm Dec 26, 2023
fbac4ca
Fix TrackSDL2 CurrentAmplitude not updating after looping
hwsmm Dec 26, 2023
0fcb821
Add ComputeMagnitude extension for NAudio Complex
hwsmm Dec 26, 2023
d4acdcb
Remove unused usings
hwsmm Dec 26, 2023
63652b2
Remove a reference to AudioDecoder once the player has finished recei…
hwsmm Dec 26, 2023
64caee9
Use Array.Copy instead of Buffer.MemoryCopy
hwsmm Dec 27, 2023
fc4ebd8
Better message in SDL2AudioManager
hwsmm Dec 27, 2023
9d4f4f2
Merge master
hwsmm Dec 27, 2023
c96d1e9
Abstract a bit more in SampleFactory
hwsmm Dec 28, 2023
8472acb
Use Math.Min instead in SDL2 AudioPlayers
hwsmm Dec 28, 2023
2f53ffa
Better TrackSDL2Player Peek
hwsmm Dec 28, 2023
9dcecd8
Satisfy InspectCode
hwsmm Dec 28, 2023
d31fbd7
Extra safety check in TrackSDL2Player
hwsmm Dec 28, 2023
06551a9
Use BASSMix to resample instead of SDL2
hwsmm Dec 28, 2023
626a641
No longer make use of bits in BassAudioDecoder
hwsmm Dec 29, 2023
dbef466
Remove SDL2AudioStream accordingly
hwsmm Dec 29, 2023
7dc9e98
Wait until sample gets loaded in SampleSDL2
hwsmm Dec 29, 2023
9c26587
Dispose SampleFactory properly
hwsmm Dec 29, 2023
83b641d
Revert "No longer make use of bits in BassAudioDecoder"
hwsmm Dec 29, 2023
d26a330
Simplify BassAudioDecoder
hwsmm Dec 30, 2023
50e32b3
Implement SDL2AudioCallback properly
hwsmm Dec 30, 2023
cad1fa2
Remove sync at end in BassAudioDecoder in code
hwsmm Dec 31, 2023
c65479b
Fix SampleFactory docs summary
hwsmm Dec 31, 2023
e8f1cba
No lock in TrackSDL2 Peek
hwsmm Dec 31, 2023
3fc1b0b
Clear syncHandle in BassAudioDecoder
hwsmm Dec 31, 2023
a2681a5
Properly clamp TrackSDL2Player Peek position
hwsmm Jan 2, 2024
5e73ed8
Use Clear instead of Flush in TrackSDL2Players
hwsmm Jan 2, 2024
e030098
Use while instead
hwsmm Jan 2, 2024
6afa85a
Add the dispose logic in SDL2AudioMixer
hwsmm Jan 12, 2024
b330078
Handle SDL2 Audio device event
hwsmm Jan 12, 2024
fa715c2
Prepare to invoke audio events in SDL2AudioManager
hwsmm Jan 12, 2024
b95e11c
Merge master
hwsmm Jan 12, 2024
679c4fe
Move syncAudioDevices to Bass entirely and let SDL2AudioManager recei…
hwsmm Jan 12, 2024
6da5254
Fix BASS device changing thread safety issue
hwsmm Jan 12, 2024
b47f745
Remove unneeded log in SDL2AudioManager
hwsmm Jan 24, 2024
32d8c56
Merge branch 'master' into sdl-audio
hwsmm Jan 28, 2024
0850312
Implement basic sample concurrency in SDL2 Audio backend
hwsmm Jan 28, 2024
5745cf7
Move sample concurrency to factory
hwsmm Jan 28, 2024
8842761
Remove sample concurrency for now
hwsmm Jan 28, 2024
153b1ee
Start decoding thread in Manager constructor
hwsmm Jan 30, 2024
4240bbc
Merge branch 'master' into sdl-audio
hwsmm Jan 30, 2024
7dc3c99
Merge master
hwsmm Feb 6, 2024
61af01e
Dispose Stream in generic Waveform
hwsmm Feb 6, 2024
aef3aab
Fix code quality issues
hwsmm Feb 6, 2024
5be11f3
Fix typo
hwsmm Feb 6, 2024
28b9938
Merge master
hwsmm Mar 22, 2024
ff9fa11
Make channel volume as tuple
hwsmm Mar 22, 2024
744f665
Let mixing no longer create a new array on every callback
hwsmm Mar 22, 2024
71f0b2f
Revert unneeded changes in SampleBassFactory
hwsmm Mar 31, 2024
3cbd9df
No longer uses ArrayPool for tracks
hwsmm Mar 31, 2024
9e90995
Merge master
hwsmm Apr 7, 2024
e5deb77
Merge master (incomplete due to SDL3)
hwsmm Apr 9, 2024
be8c1b0
SDL3 Audio migration (first pass)
hwsmm Apr 9, 2024
32ad8fc
Ignore SDL audio devices with empty name
hwsmm Apr 12, 2024
685db63
No longer uses ArrayPool and pointers in SDL audio callback
hwsmm Apr 12, 2024
3ea2a72
Satisfy InspectCode
hwsmm Apr 12, 2024
e9dfbe9
Remove unneeded lines in SDL3AudioManager
hwsmm Apr 13, 2024
4f28d5f
Merge master
hwsmm May 1, 2024
97203f0
Merge master
hwsmm May 10, 2024
4c867b6
Fix channel balance in SDL3 audio
hwsmm May 10, 2024
2569628
Merge master
hwsmm Jun 18, 2024
8deadc6
intermediate
hwsmm Jun 18, 2024
21a01ec
Cleanup and adapt to master
hwsmm Jun 18, 2024
ca971bb
Cleanup BiQuad filter application
hwsmm Jun 21, 2024
60437dd
Clamp volume
hwsmm Jun 22, 2024
50fc3f7
Merge branch 'sdl3-bindings-update' into sdl-audio
hwsmm Jul 20, 2024
f82d46c
Apply SDL3 audio upstream changes
hwsmm Jul 20, 2024
76e9fab
Clamp later in SDL3 mixer
hwsmm Jul 20, 2024
3eccbf7
Merge branch 'sdl3-bindings-update' into sdl-audio
hwsmm Aug 3, 2024
142d3be
Merge branch 'sdl3-bindings-update' into sdl-audio
hwsmm Aug 5, 2024
8ed0a59
Merge decoders into one file and use decoder thread for samples
hwsmm Aug 6, 2024
b18934d
Merge branch 'sdl3-bindings-update' into sdl-audio
hwsmm Aug 6, 2024
d43b68c
Polish SDL3AudioDecoder a bit
hwsmm Aug 6, 2024
3889ec9
SDL3 Audio visual test fixes
hwsmm Aug 6, 2024
7cb6160
Update TrackSDL3 CurrentAmplitude less frequently
hwsmm Aug 7, 2024
ed044d0
Merge master
hwsmm Aug 7, 2024
d29123b
Don't divide by 2 when doing FFT in TrackSDL3/Waveform
hwsmm Aug 7, 2024
d36e569
Satisfy InspectCode
hwsmm Aug 7, 2024
3f7a7db
Init Bass in SDL3AudioDecoder
hwsmm Aug 8, 2024
bf24b0f
Make Sample/Track/Mixer tests compatible with SDL3 Audio
hwsmm Aug 8, 2024
4f8fb15
Use interface to receive audio data in SDL3 Audio
hwsmm Aug 8, 2024
fbcbd5f
SDL3 Audio text fixes
hwsmm Aug 8, 2024
509b075
Satisfy InspectCode
hwsmm Aug 8, 2024
68c31bf
Revert test class name changes to reduce diff
hwsmm Aug 8, 2024
b11b249
Init baseManager first in SDL3AudioManager
hwsmm Aug 8, 2024
96003b3
Different workaround for an SDL3 Audio test
hwsmm Aug 9, 2024
32d675d
Process 10ms more in advance in TempoSDL3AudioPlayer
hwsmm Aug 9, 2024
462560e
Fix incorrect volume at start in SDL audio single thread mode
hwsmm Aug 16, 2024
47408ab
Merge branch 'master' into sdl-audio
hwsmm Aug 16, 2024
5b7e293
Remove a node later in SDL3AudioDecoder
hwsmm Aug 16, 2024
2c67b93
Merge branch 'master' into sdl-audio
hwsmm Aug 20, 2024
4f5cd48
Fix test function name
hwsmm Aug 20, 2024
7ea5f36
Make ffmpeg null after finishing audio decoding
hwsmm Aug 20, 2024
b492982
Init SDL Audio later
hwsmm Aug 22, 2024
d2cdee0
Merge master
hwsmm Sep 6, 2024
e844ea1
Separate AmplitudeProcessor from TrackSDL3
hwsmm Sep 6, 2024
f704557
Satisfy InspectCode
hwsmm Sep 6, 2024
fe29690
Potential fix for a flaky test
hwsmm Sep 6, 2024
28a59b0
Merge master
hwsmm Sep 14, 2024
be14528
Satisfy CodeFactor and simplify mixing
hwsmm Sep 14, 2024
d30029c
Merge master
hwsmm Sep 16, 2024
642b625
Use simple logic in SDL3 mixing and adjust parameter
hwsmm Sep 16, 2024
a3263af
Apply a change for SDL3-CS update
hwsmm Sep 16, 2024
15df042
Potential fix for TestRestartFromRestartPoint failure
hwsmm Sep 18, 2024
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
2 changes: 1 addition & 1 deletion osu.Framework.Tests/Audio/AudioManagerWithDeviceLoss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace osu.Framework.Tests.Audio
/// <see cref="AudioManager"/> that can simulate the loss of a device.
/// This will NOT work without a physical audio device!
/// </summary>
internal class AudioManagerWithDeviceLoss : AudioManager
internal class AudioManagerWithDeviceLoss : BassAudioManager
{
public AudioManagerWithDeviceLoss(AudioThread audioThread, ResourceStore<byte[]> trackStore, ResourceStore<byte[]> sampleStore)
: base(audioThread, trackStore, sampleStore)
Expand Down
91 changes: 91 additions & 0 deletions osu.Framework.Tests/Audio/AudioTestComponents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.Audio;
using System.IO;
using osu.Framework.IO.Stores;

namespace osu.Framework.Tests.Audio
{
public abstract class AudioTestComponents : IDisposable
{
public enum Type
{
BASS,
SDL3
}

internal readonly AudioMixer Mixer;
public readonly DllResourceStore Resources;
internal readonly TrackStore TrackStore;
internal readonly SampleStore SampleStore;

protected readonly AudioCollectionManager<AudioComponent> AllComponents = new AudioCollectionManager<AudioComponent>();
protected readonly AudioCollectionManager<AudioComponent> MixerComponents = new AudioCollectionManager<AudioComponent>();

protected AudioTestComponents(bool init)
{
Prepare();

if (init)
Init();

AllComponents.AddItem(MixerComponents);

Mixer = CreateMixer();
Resources = new DllResourceStore(typeof(TrackBassTest).Assembly);
TrackStore = new TrackStore(Resources, Mixer, CreateTrack);
SampleStore = new SampleStore(Resources, Mixer, CreateSampleFactory);

Add(TrackStore, SampleStore);
}

protected virtual void Prepare()
{
}

internal abstract Track CreateTrack(Stream data, string name);

internal abstract SampleFactory CreateSampleFactory(Stream stream, string name, AudioMixer mixer, int playbackConcurrency);

public abstract void Init();

public virtual void Add(params AudioComponent[] component)
{
foreach (var c in component)
AllComponents.AddItem(c);
}

public abstract AudioMixer CreateMixer();

public virtual void Update()
{
RunOnAudioThread(AllComponents.Update);
}

/// <summary>
/// Runs an <paramref name="action"/> on a newly created audio thread, and blocks until it has been run to completion.
/// </summary>
/// <param name="action">The action to run on the audio thread.</param>
public virtual void RunOnAudioThread(Action action) => AudioTestHelper.RunOnAudioThread(action);

internal Track GetTrack() => TrackStore.Get("Resources.Tracks.sample-track.mp3");
internal Sample GetSample() => SampleStore.Get("Resources.Tracks.sample-track.mp3");

public void Dispose() => RunOnAudioThread(() =>
{
AllComponents.Dispose();
AllComponents.Update(); // Actually runs the disposal.
DisposeInternal();
});

public virtual void DisposeInternal()
{
}
}
}
Loading
Loading