mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibMedia: Remove preprocessor chain when initializing audio streams
Instead of having to duplicate the audio stream backend conditions, just define PlaybackStream::create in each audio backend implementation file. We provide a weak definition in PlaybackStream.cpp as the fallback.
This commit is contained in:
parent
4d866f22a4
commit
dfa727a4d4
Notes:
github-actions[bot]
2024-12-25 11:01:55 +00:00
Author: https://github.com/trflynn89
Commit: dfa727a4d4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3027
4 changed files with 18 additions and 24 deletions
|
@ -6,32 +6,11 @@
|
|||
|
||||
#include "PlaybackStream.h"
|
||||
|
||||
#include <AK/Platform.h>
|
||||
|
||||
#if defined(HAVE_PULSEAUDIO)
|
||||
# include "PlaybackStreamPulseAudio.h"
|
||||
#elif defined(AK_OS_MACOS)
|
||||
# include "PlaybackStreamAudioUnit.h"
|
||||
#elif defined(AK_OS_ANDROID)
|
||||
# include "PlaybackStreamOboe.h"
|
||||
#endif
|
||||
|
||||
namespace Audio {
|
||||
|
||||
ErrorOr<NonnullRefPtr<PlaybackStream>> PlaybackStream::create(OutputState initial_output_state, u32 sample_rate, u8 channels, u32 target_latency_ms, AudioDataRequestCallback&& data_request_callback)
|
||||
ErrorOr<NonnullRefPtr<PlaybackStream>> __attribute__((weak)) PlaybackStream::create(OutputState, u32, u8, u32, AudioDataRequestCallback&&)
|
||||
{
|
||||
VERIFY(data_request_callback);
|
||||
// Create the platform-specific implementation for this stream.
|
||||
#if defined(HAVE_PULSEAUDIO)
|
||||
return PlaybackStreamPulseAudio::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback));
|
||||
#elif defined(AK_OS_MACOS)
|
||||
return PlaybackStreamAudioUnit::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback));
|
||||
#elif defined(AK_OS_ANDROID)
|
||||
return PlaybackStreamOboe::create(initial_output_state, sample_rate, channels, target_latency_ms, move(data_request_callback));
|
||||
#else
|
||||
(void)initial_output_state, (void)sample_rate, (void)channels, (void)target_latency_ms;
|
||||
return Error::from_string_literal("Audio output is not available for this platform");
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue