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:
parent
1b00618fd9
commit
26f96d2a42
6 changed files with 13 additions and 5 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue