mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
LibWeb: Output audio in stereo regardless of the encoded channel count
Audio loaders currently always output two channels, even if they were encoded as mono. Therefore, we have to hardcode the channel count in our audio plugin to avoid crashing until we can handle mono or multi- channel audio better. Fixes #21898
This commit is contained in:
parent
f4a847894f
commit
d64ffb1b9b
1 changed files with 3 additions and 1 deletions
|
@ -37,8 +37,10 @@ ErrorOr<NonnullOwnPtr<AudioCodecPluginAgnostic>> AudioCodecPluginAgnostic::creat
|
|||
auto plugin = TRY(adopt_nonnull_own_or_enomem(new (nothrow) AudioCodecPluginAgnostic(loader, duration, move(update_timer))));
|
||||
|
||||
constexpr u32 latency_ms = 100;
|
||||
// FIXME: Audio loaders are hard-coded to output stereo audio. Once that changes, the channel count provided
|
||||
// below should be retrieved from the audio loader instead of being hard-coded to 2.
|
||||
RefPtr<Audio::PlaybackStream> output = TRY(Audio::PlaybackStream::create(
|
||||
Audio::OutputState::Suspended, loader->sample_rate(), loader->num_channels(), latency_ms,
|
||||
Audio::OutputState::Suspended, loader->sample_rate(), /* channels = */ 2, latency_ms,
|
||||
[&plugin = *plugin, loader](Bytes buffer, Audio::PcmSampleFormat format, size_t sample_count) -> ReadonlyBytes {
|
||||
VERIFY(format == Audio::PcmSampleFormat::Float32);
|
||||
auto samples = loader->get_more_samples(sample_count).release_value_but_fixme_should_propagate_errors();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue