1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-07 08:07:35 +00:00
Commit graph

1176 commits

Author SHA1 Message Date
kleines Filmröllchen
49b087f3cd LibAudio+Userland: Use new audio queue in client-server communication
Previously, we were sending Buffers to the server whenever we had new
audio data for it. This meant that for every audio enqueue action, we
needed to create a new shared memory anonymous buffer, send that
buffer's file descriptor over IPC (+recfd on the other side) and then
map the buffer into the audio server's memory to be able to play it.
This was fine for sending large chunks of audio data, like when playing
existing audio files. However, in the future we want to move to
real-time audio in some applications like Piano. This means that the
size of buffers that are sent need to be very small, as just the size of
a buffer itself is part of the audio latency. If we were to try
real-time audio with the existing system, we would run into problems
really quickly. Dealing with a continuous stream of new anonymous files
like the current audio system is rather expensive, as we need Kernel
help in multiple places. Additionally, every enqueue incurs an IPC call,
which are not optimized for >1000 calls/second (which would be needed
for real-time audio with buffer sizes of ~40 samples). So a fundamental
change in how we handle audio sending in userspace is necessary.

This commit moves the audio sending system onto a shared single producer
circular queue (SSPCQ) (introduced with one of the previous commits).
This queue is intended to live in shared memory and be accessed by
multiple processes at the same time. It was specifically written to
support the audio sending case, so e.g. it only supports a single
producer (the audio client). Now, audio sending follows these general
steps:
- The audio client connects to the audio server.
- The audio client creates a SSPCQ in shared memory.
- The audio client sends the SSPCQ's file descriptor to the audio server
  with the set_buffer() IPC call.
- The audio server receives the SSPCQ and maps it.
- The audio client signals start of playback with start_playback().
- At the same time:
  - The audio client writes its audio data into the shared-memory queue.
  - The audio server reads audio data from the shared-memory queue(s).
  Both sides have additional before-queue/after-queue buffers, depending
  on the exact application.
- Pausing playback is just an IPC call, nothing happens to the buffer
  except that the server stops reading from it until playback is
  resumed.
- Muting has nothing to do with whether audio data is read or not.
- When the connection closes, the queues are unmapped on both sides.

This should already improve audio playback performance in a bunch of
places.

Implementation & commit notes:
- Audio loaders don't create LegacyBuffers anymore. LegacyBuffer is kept
  for WavLoader, see previous commit message.
- Most intra-process audio data passing is done with FixedArray<Sample>
  or Vector<Sample>.
- Improvements to most audio-enqueuing applications. (If necessary I can
  try to extract some of the aplay improvements.)
- New APIs on LibAudio/ClientConnection which allows non-realtime
  applications to enqueue audio in big chunks like before.
- Removal of status APIs from the audio server connection for
  information that can be directly obtained from the shared queue.
- Split the pause playback API into two APIs with more intuitive names.

I know this is a large commit, and you can kinda tell from the commit
message. It's basically impossible to break this up without hacks, so
please forgive me. These are some of the best changes to the audio
subsystem and I hope that that makes up for this :yaktangle: commit.

:yakring:
2022-04-21 13:55:00 +02:00
brapru
a7bb3fe7a8 netstat: Add the wide flag option
Previously netstat would print the whole line of an ip address or
resolved hostname. If the hostname was longer than the address column
length, it would push following columns into disaligned output.

This sets the default behavior to truncate any IP address or symbolic
hostname that is larger than the maximum address column size to provide
cleaner output. In the event the user wishes to see the whole address
name, they can then pass the wide option that will output as wide as
necessary to print the whole name.
2022-04-21 13:17:29 +02:00
brapru
07c2c86314 netstat: Add hostname resolution 2022-04-21 13:17:29 +02:00
brapru
a4d84a76e1 arp: Add hostname resolution 2022-04-21 13:17:29 +02:00
Eli Youngs
3afce86e83 mkfifo: Add support for setting permissions with -m 2022-04-20 18:35:08 +02:00
Karol Kosek
35cb5ea47c Utilities/profile: Call split_view() using StringView for command parts
This fixes the always appearing 'No such file' error when using the -c
flag, as the String was deconstructed right after running this line.
2022-04-18 14:17:01 +02:00
Sam Atkins
73552c1856 Userland: Always construct Application with try_create() 2022-04-18 12:57:34 +02:00
brapru
8b370f988b host: Use AK/IPv4Address to determine if argument is host/ip
It's a bit cleaner to just rely on AK/IPv4Address' ability to determine
the validity of the given input. If a valid IP address is not returned,
then input will be processed as a hostname.
2022-04-16 22:16:29 -07:00
Tim Schumacher
d6ccee4089 AK: Differ between long and long long formats 2022-04-14 03:12:56 +04:30
Sam Atkins
f92312e778 Utilities/unzip: Use Core::Directory to create output directory 2022-04-13 16:00:17 +02:00
Sam Atkins
f64ff945b2 env: Use Core::System::exec() 2022-04-11 21:09:42 +02:00
Sam Atkins
f0aba519c3 Utilities: Read positional arguments as Strings not char*s
This is a pretty trivial change so they're all batched together.
2022-04-11 21:09:42 +02:00
Sam Atkins
1ac6c4df72 strace: Use Core::System::exec() 2022-04-11 21:09:42 +02:00
Sam Atkins
b81a3a6f0e profile: Use Core::System::exec() 2022-04-11 21:09:42 +02:00
Sam Atkins
d2b32924d6 pls: Use Core::System::exec() 2022-04-11 21:09:42 +02:00
Sam Atkins
5a47b74227 paste: Use Core::System::{exec,setenv} 2022-04-11 21:09:42 +02:00
kleines Filmröllchen
5319e3a03f LibCore+Userland: Remove File::ensure_parent_directories
We have a much safer and more powerful alternative now, so let's move
the few users over.
2022-04-11 00:08:48 +02:00
Ali Mohammad Pur
b16918ccb9 pro: Only attempt to parse a proxy url if it is provided
Otherwise we'd end up trying to parse an empty string as a proxy url
which is certainly not one.
2022-04-09 14:36:28 +02:00
Ali Mohammad Pur
f9fc28931f pro: Accept an optional proxy to tunnel the download through
For now, this only accepts the format `socks5://ip:port` (i.e. the
hostname has to be an ipv4, and the port must be present).
2022-04-09 12:21:43 +02:00
Hendiadyoin1
f602bbf135 LibX86+disasm: Use an output format closer to objdump
This mainly does two things,
1. Removes spaces after commas
2. Elides "0x" and leading zeros in most contexts

Remaining differences are:
1. objdump always has memory size annotations
   We lack these and probably have some annotations wrong
2. Boolean check names
   We use jump-zero, while objdump uses jump-equal for example
3. We sometimes add "00 00" symbols, which objdump elides
4. We always demangle (This is a good thing)
5. We always resolve relocations (This is a good thing)
6. We seem to detect some symbols differently/incorrectly
2022-04-07 16:50:34 +02:00
Hendiadyoin1
5ee85aaa5d disasm: Print instruction bytes
This prints 7 instruction bytes per line, which is enough for most
x86-64 instructions (rex+opcode+mod/rm+imm32) and is also what
objdump uses.

Co-authored-by: Simon Wanner <skyrising@pvpctutorials.de>
2022-04-07 16:50:34 +02:00
brapru
3dbb4bc3a6 Utilities: Update arp to use newer APIs
Updates the arp command to use Core::System for the socket and
ioctl calls.

Updates command line arguments to StringView.
2022-04-05 12:43:18 +02:00
brapru
26b8155530 Utilities: Pledge inet in arp command
Previously the arp command would crash when trying to set/delete from
the table.
2022-04-05 12:43:18 +02:00
Ali Mohammad Pur
431776ebb7 js: Print the accumulator instead of the returned value in BC mode
The REPL is supposed to show the last value (and not the _returned_
value), so use the accumulator register as the 'value'.
2022-04-05 11:46:48 +02:00
Timothy Flynn
b36c3a68d8 js: Convert non-UTF-8 encoded files to UTF-8 before parsing 2022-04-05 00:14:29 +01:00
Brian Gianforcaro
7eaf1cfdc2 ls: Use Core::System::pledge(..) instead of LibC API 2022-04-03 17:13:51 -07:00
Brian Gianforcaro
af3751e4dd Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
Linus Groh
4f35c206e4 lscpu: Show hypervisor_vendor_id if present 2022-04-03 23:20:33 +02:00
Linus Groh
0f27432ec6 Kernel+SystemMonitor+lscpu: Rename 'CPUID' -> 'Vendor ID'
This is what the Intel manual, as well as Linux's cpuinfo calls it.
2022-04-03 23:20:33 +02:00
Brendan Coles
fd6d87df82 netstat: Resolve ports to service names 2022-04-03 12:08:41 +02:00
James Mintram
cd2f67c4ea top: Add support for quitting top by pressing q 2022-04-02 23:48:17 +01:00
Thomas Symalla
77add584fa Userland: Fix crash when inputting non-tty device into ps
This PR aims to fix #13299 by avoiding assertion failure
while trying to determine the pseudo tty when inputting
any non-tty device device into ps.
2022-04-02 21:49:16 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Kenneth Myhra
6581cf47ab test: Port to LibMain 2022-03-30 09:53:11 +01:00
safarp
704e1d13f4 AK: Allow printing wide characters using %ls modifier 2022-03-30 11:30:43 +04:30
Kenneth Myhra
c843f2e3a5 seq: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra
1ee93e0fe7 tty: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra
cf154ec0d9 tt: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra
ab9a78a305 tr: Utilize TRY more
This converts the local functions to return ErrorOr<T> and utilizes TRY
more.
2022-03-29 21:28:29 -07:00
Kenneth Myhra
e548b2cff2 tr: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra
8bd7c5b3d5 test_env: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra
3df8c9e9de test-unveil: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra
f4aef35e6e test-pthread: Port to LibMain and let local functions return ErrorOr<T>
This ports 'test-pthread' to LibMain and converts the local functions of
the program to return ErrorOr<T>.
2022-03-29 21:28:29 -07:00
Kenneth Myhra
d69f3aa958 test-fuzz: Allow listing fuzzing targets without specifying input file 2022-03-29 21:28:29 -07:00
Kenneth Myhra
4994718d8d test-fuzz: Port to LibMain
Also use StringView in place of raw C strings and String.
2022-03-29 21:28:29 -07:00
Kenneth Myhra
b47a9ab4dc test-bindtodevice: Port to LibMain
This ports 'test-bindtodevice' to LibMain and convert the local 'test'
function to return ErrorOr<T>.
2022-03-29 21:28:29 -07:00
Kenneth Myhra
e302fac34b kcov-example: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra
234025ee53 telws: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra
bb4994d67b run-tests: Port to LibMain 2022-03-29 21:28:29 -07:00
Kenneth Myhra
7d87f0d56d markdown-check: Use Core::ArgsParser 2022-03-29 21:28:29 -07:00