From f97c9a5968f35f2e365c1878991299e001fe3166 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Wed, 24 Nov 2021 12:20:20 +0100 Subject: Kernel: Allow higher audio sample rates than 65kHZ (`u16`) Executing `asctl set r 96000` no longer results in weird sample rates being set on the audio devices. SB16 checks for a sample rate between 1 and 44100 Hz, while AC97 implements double-rate support which allows sample rates between 8kHz and 96kHZ. --- Userland/Services/AudioServer/AudioServer.ipc | 4 ++-- Userland/Services/AudioServer/ClientConnection.cpp | 2 +- Userland/Services/AudioServer/ClientConnection.h | 2 +- Userland/Services/AudioServer/Mixer.cpp | 6 +++--- Userland/Services/AudioServer/Mixer.h | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'Userland/Services') diff --git a/Userland/Services/AudioServer/AudioServer.ipc b/Userland/Services/AudioServer/AudioServer.ipc index f34a84532b..d0396bad7e 100644 --- a/Userland/Services/AudioServer/AudioServer.ipc +++ b/Userland/Services/AudioServer/AudioServer.ipc @@ -11,8 +11,8 @@ endpoint AudioServer set_self_volume(double volume) => () // Audio device - set_sample_rate(u16 sample_rate) => () - get_sample_rate() => (u16 sample_rate) + set_sample_rate(u32 sample_rate) => () + get_sample_rate() => (u32 sample_rate) // Buffer playback enqueue_buffer(Core::AnonymousBuffer buffer, i32 buffer_id, int sample_count) => (bool success) diff --git a/Userland/Services/AudioServer/ClientConnection.cpp b/Userland/Services/AudioServer/ClientConnection.cpp index be04b960b5..ee84a59536 100644 --- a/Userland/Services/AudioServer/ClientConnection.cpp +++ b/Userland/Services/AudioServer/ClientConnection.cpp @@ -73,7 +73,7 @@ Messages::AudioServer::GetSampleRateResponse ClientConnection::get_sample_rate() return { m_mixer.audiodevice_get_sample_rate() }; } -void ClientConnection::set_sample_rate(u16 sample_rate) +void ClientConnection::set_sample_rate(u32 sample_rate) { m_mixer.audiodevice_set_sample_rate(sample_rate); } diff --git a/Userland/Services/AudioServer/ClientConnection.h b/Userland/Services/AudioServer/ClientConnection.h index a4d2d6a177..be5458d4e1 100644 --- a/Userland/Services/AudioServer/ClientConnection.h +++ b/Userland/Services/AudioServer/ClientConnection.h @@ -49,7 +49,7 @@ private: virtual Messages::AudioServer::GetPlayingBufferResponse get_playing_buffer() override; virtual Messages::AudioServer::GetMutedResponse get_muted() override; virtual void set_muted(bool) override; - virtual void set_sample_rate(u16 sample_rate) override; + virtual void set_sample_rate(u32 sample_rate) override; virtual Messages::AudioServer::GetSampleRateResponse get_sample_rate() override; Mixer& m_mixer; diff --git a/Userland/Services/AudioServer/Mixer.cpp b/Userland/Services/AudioServer/Mixer.cpp index 04b95c138e..27b6daf1bf 100644 --- a/Userland/Services/AudioServer/Mixer.cpp +++ b/Userland/Services/AudioServer/Mixer.cpp @@ -165,7 +165,7 @@ void Mixer::set_muted(bool muted) }); } -int Mixer::audiodevice_set_sample_rate(u16 sample_rate) +int Mixer::audiodevice_set_sample_rate(u32 sample_rate) { int code = ioctl(m_device->fd(), SOUNDCARD_IOCTL_SET_SAMPLE_RATE, sample_rate); if (code != 0) @@ -173,9 +173,9 @@ int Mixer::audiodevice_set_sample_rate(u16 sample_rate) return code; } -u16 Mixer::audiodevice_get_sample_rate() const +u32 Mixer::audiodevice_get_sample_rate() const { - u16 sample_rate = 0; + u32 sample_rate = 0; int code = ioctl(m_device->fd(), SOUNDCARD_IOCTL_GET_SAMPLE_RATE, &sample_rate); if (code != 0) dbgln("Error while getting sample rate: ioctl error: {}", strerror(errno)); diff --git a/Userland/Services/AudioServer/Mixer.h b/Userland/Services/AudioServer/Mixer.h index 0cd48c8500..9c64ab0eec 100644 --- a/Userland/Services/AudioServer/Mixer.h +++ b/Userland/Services/AudioServer/Mixer.h @@ -119,8 +119,8 @@ public: bool is_muted() const { return m_muted; } void set_muted(bool); - int audiodevice_set_sample_rate(u16 sample_rate); - u16 audiodevice_get_sample_rate() const; + int audiodevice_set_sample_rate(u32 sample_rate); + u32 audiodevice_get_sample_rate() const; private: Mixer(NonnullRefPtr config); -- cgit v1.2.3