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

Kernel+Userland: Add option for duration of /dev/beep producing sound

This commit is contained in:
Liav A 2023-08-25 20:26:18 +03:00 committed by Tim Schumacher
parent 1b00618fd9
commit 26f96d2a42
6 changed files with 13 additions and 5 deletions

View file

@ -48,9 +48,11 @@ ErrorOr<size_t> PCSpeakerDevice::write(OpenFileDescription&, u64, UserOrKernelBu
TRY(buffer.read(&instruction, sizeof(BeepInstruction)));
if (instruction.tone < 20 || instruction.tone > 20000)
return Error::from_errno(EINVAL);
if (instruction.milliseconds_duration == 0)
return Error::from_errno(EINVAL);
#if ARCH(X86_64)
PCSpeaker::tone_on(instruction.tone);
auto result = Thread::current()->sleep(Duration::from_nanoseconds(200'000'000));
auto result = Thread::current()->sleep(Duration::from_milliseconds(instruction.milliseconds_duration));
PCSpeaker::tone_off();
if (result.was_interrupted())
return Error::from_errno(EINTR);