summaryrefslogtreecommitdiff
path: root/Kernel/Devices/Audio/SB16.cpp
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2021-11-24 12:20:20 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-24 19:08:13 +0100
commitf97c9a5968f35f2e365c1878991299e001fe3166 (patch)
tree0a6168e3e78e7973bc201a8ac6243f72d5886dce /Kernel/Devices/Audio/SB16.cpp
parentc349634967db2751e8ff40b2e6f07bef8b59179b (diff)
downloadserenity-f97c9a5968f35f2e365c1878991299e001fe3166.zip
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.
Diffstat (limited to 'Kernel/Devices/Audio/SB16.cpp')
-rw-r--r--Kernel/Devices/Audio/SB16.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Kernel/Devices/Audio/SB16.cpp b/Kernel/Devices/Audio/SB16.cpp
index e5bfef119d..ce2cdc8d63 100644
--- a/Kernel/Devices/Audio/SB16.cpp
+++ b/Kernel/Devices/Audio/SB16.cpp
@@ -123,9 +123,10 @@ ErrorOr<void> SB16::ioctl(OpenFileDescription&, unsigned request, Userspace<void
return copy_to_user(output, &m_sample_rate);
}
case SOUNDCARD_IOCTL_SET_SAMPLE_RATE: {
- auto sample_rate_value = static_cast<u16>(arg.ptr());
- if (sample_rate_value == 0)
- return EINVAL;
+ auto sample_rate_input = static_cast<u32>(arg.ptr());
+ if (sample_rate_input == 0 || sample_rate_input > 44100)
+ return ENOTSUP;
+ auto sample_rate_value = static_cast<u16>(sample_rate_input);
if (m_sample_rate != sample_rate_value)
set_sample_rate(sample_rate_value);
return {};