mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:17:45 +00:00
LibAudio: Add a Serenity implementation of PlaybackStream
This implementation is very naive compared to the PulseAudio one. Instead of using a callback implemented by the audio server connection to push audio to the buffer, we have to poll on a timer to check when we need to push the audio buffers. Implementing cross-process condition variables into the audio queue class could allow us to avoid polling, which may prove beneficial to CPU usage. Audio timestamps will be accurate to the number of samples available, but will count in increments of about 100ms and run ahead of the actual audio being pushed to the device by the server. Buffer underruns are completely ignored for now as well, since the `AudioServer` has no way to know how many samples are actually written in a single audio buffer.
This commit is contained in:
parent
2caf68fd03
commit
bb156f8133
7 changed files with 185 additions and 3 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <AK/MemoryStream.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibAudio/PlaybackStream.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibTest/TestSuite.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -15,10 +16,23 @@
|
|||
# include <LibAudio/PulseAudioWrappers.h>
|
||||
#endif
|
||||
|
||||
TEST_CASE(create_and_destroy_playback_stream)
|
||||
// FIXME: CI doesn't run an AudioServer currently. Creating one in /etc/SystemServer.ini does not
|
||||
// allow this test to pass since CI runs in a Shell that will setsid() if it finds that the
|
||||
// current session ID is 0, and AudioServer's socket address depends on the current sid.
|
||||
// If we can fix that, this test can run on CI.
|
||||
// https://github.com/SerenityOS/serenity/issues/20538
|
||||
#if defined(AK_OS_SERENITY)
|
||||
# define STREAM_TEST BENCHMARK_CASE
|
||||
#else
|
||||
# define STREAM_TEST TEST_CASE
|
||||
#endif
|
||||
|
||||
STREAM_TEST(create_and_destroy_playback_stream)
|
||||
{
|
||||
Core::EventLoop event_loop;
|
||||
|
||||
bool has_implementation = false;
|
||||
#if defined(HAVE_PULSEAUDIO)
|
||||
#if defined(AK_OS_SERENITY) || defined(HAVE_PULSEAUDIO)
|
||||
has_implementation = true;
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue