mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +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:
parent
2133bae1a4
commit
4a86861a9d
Notes:
sideshowbarker
2024-07-17 03:03:15 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/4a86861a9d Pull-request: https://github.com/SerenityOS/serenity/pull/19493
|
@ -86,8 +86,6 @@ UNMAP_AFTER_INIT ErrorOr<void> AC97::initialize(Badge<AudioManagement>)
|
|||
dbgln_if(AC97_DEBUG, "AC97 @ {}: mixer base: {:#04x}", device_identifier().address(), m_mixer_io_window);
|
||||
dbgln_if(AC97_DEBUG, "AC97 @ {}: bus base: {:#04x}", device_identifier().address(), m_bus_io_window);
|
||||
|
||||
m_audio_channel = TRY(AudioChannel::create(*this, 0));
|
||||
|
||||
// Read out AC'97 codec revision and vendor
|
||||
auto extended_audio_id = m_mixer_io_window->read16(NativeAudioMixerRegister::ExtendedAudioID);
|
||||
m_codec_revision = static_cast<AC97Revision>(((extended_audio_id & ExtendedAudioMask::Revision) >> 10) & 0b11);
|
||||
|
@ -133,6 +131,8 @@ UNMAP_AFTER_INIT ErrorOr<void> AC97::initialize(Badge<AudioManagement>)
|
|||
|
||||
m_pcm_out_channel->reset();
|
||||
enable_irq();
|
||||
|
||||
m_audio_channel = TRY(AudioChannel::create(*this, 0));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue