1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:58:11 +00:00

Kernel: Set audio sample rate to 44.1 KHz by default

Ideally, we would want the audio controller to run a channel at a
device's initial sample rate instead of hardcoding 44.1 KHz. However,
most audio is provided at 44.1 KHz and as long as `Audio::Resampler`
introduces significant audio artifacts, let's set a sensible sample
rate that offers a better experience for most users.

This can be removed after someone implements a higher quality
`Audio::Resampler`.
This commit is contained in:
Jelle Raaijmakers 2023-06-19 21:13:39 +02:00 committed by Andreas Kling
parent 2133bae1a4
commit 4a86861a9d
2 changed files with 11 additions and 3 deletions

View file

@ -15,7 +15,15 @@ namespace Kernel {
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<AudioChannel>> AudioChannel::create(AudioController const& controller, size_t channel_index)
{
return *TRY(DeviceManagement::try_create_device<AudioChannel>(controller, channel_index));
auto channel = TRY(DeviceManagement::try_create_device<AudioChannel>(controller, channel_index));
// FIXME: Ideally, we would want the audio controller to run a channel at a device's initial sample
// rate instead of hardcoding 44.1 KHz here. However, most audio is provided at 44.1 KHz and as
// long as Audio::Resampler introduces significant audio artifacts, let's set a sensible sample
// rate here. Remove this after implementing a higher quality Audio::Resampler.
TRY(const_cast<AudioController&>(controller).set_pcm_output_sample_rate(channel_index, 44100));
return *channel;
}
AudioChannel::AudioChannel(AudioController const& controller, size_t channel_index)