ladybird/Userland/Utilities
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
..
abench.cpp LibAudio+Userland: Use new audio queue in client-server communication 2022-04-21 13:55:00 +02:00
adjtime.cpp adjtime: Port to LibMain 2022-01-21 01:52:22 +01:00
allocate.cpp
aplay.cpp LibAudio+Userland: Use new audio queue in client-server communication 2022-04-21 13:55:00 +02:00
arp.cpp arp: Add hostname resolution 2022-04-21 13:17:29 +02:00
asctl.cpp LibAudio+Userland: Use new audio queue in client-server communication 2022-04-21 13:55:00 +02:00
base64.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
basename.cpp
beep.cpp
blockdev.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
bt.cpp
cal.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
cat.cpp
checksum.cpp Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
chgrp.cpp Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
chmod.cpp
chown.cpp Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
chres.cpp Userland: Always construct Application with try_create() 2022-04-18 12:57:34 +02:00
cksum.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
clear.cpp Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
CMakeLists.txt js: Convert non-UTF-8 encoded files to UTF-8 before parsing 2022-04-05 00:14:29 +01:00
cmp.cpp cmp: Implement cmp(1) 2022-03-19 11:01:49 -07:00
comm.cpp Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
config.cpp
copy.cpp Userland: Always construct Application with try_create() 2022-04-18 12:57:34 +02:00
cp.cpp
cpp-lexer.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
cpp-parser.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
cpp-preprocessor.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
cut.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
date.cpp Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
dd.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
ddate.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
df.cpp
diff.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
dirname.cpp
disasm.cpp LibX86+disasm: Use an output format closer to objdump 2022-04-07 16:50:34 +02:00
disk_benchmark.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
dmesg.cpp
du.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
echo.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
env.cpp env: Use Core::System::exec() 2022-04-11 21:09:42 +02:00
errno.cpp
expr.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
false.cpp
fdtdump.cpp
fgrep.cpp
file.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
find.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
flock.cpp
fortune.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
functrace.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
gml-format.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
grep.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
gron.cpp
groupadd.cpp groupadd: Port to LibMain and use the new Core::Group abstraction :^) 2022-01-16 11:19:07 +01:00
groupdel.cpp groupdel: Port to LibMain 2022-02-28 14:05:04 +01:00
groups.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
gunzip.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
gzip.cpp
head.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
hexdump.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
host.cpp host: Use AK/IPv4Address to determine if argument is host/ip 2022-04-16 22:16:29 -07:00
hostname.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
id.cpp
ifconfig.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
ini.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
install.cpp LibCore+Userland: Remove File::ensure_parent_directories 2022-04-11 00:08:48 +02:00
jp.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
js.cpp js: Print the accumulator instead of the returned value in BC mode 2022-04-05 11:46:48 +02:00
kcov-example.cpp kcov-example: Port to LibMain 2022-03-29 21:28:29 -07:00
keymap.cpp LibCore+Everywhere: Return ErrorOr from ConfigFile::sync() 2022-02-16 19:49:41 -05:00
kill.cpp kill: Parse CLI arguments using Arguments.strings 2022-02-12 10:53:07 -05:00
killall.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
less.cpp Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
ln.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
logout.cpp
ls.cpp ls: Use Core::System::pledge(..) instead of LibC API 2022-04-03 17:13:51 -07:00
lscpu.cpp lscpu: Show hypervisor_vendor_id if present 2022-04-03 23:20:33 +02:00
lsirq.cpp lsirq: Port to LibMain 2022-01-31 15:25:07 +01:00
lsof.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
lspci.cpp Userland: Change static const variables to static constexpr 2022-03-18 19:58:57 +01:00
lsusb.cpp
man.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
markdown-check.cpp markdown-check: Use Core::ArgsParser 2022-03-29 21:28:29 -07:00
matroska.cpp matroska: Port to LibMain 2022-03-22 11:39:20 +01:00
md.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
mkdir.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
mkfifo.cpp mkfifo: Add support for setting permissions with -m 2022-04-20 18:35:08 +02:00
mknod.cpp mknod: Port to LibMain 2022-01-24 14:01:58 +03:30
mktemp.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
mount.cpp Mount: Implement wxallowed mount option 2022-03-22 12:20:19 +01:00
mv.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
nc.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
netstat.cpp netstat: Add the wide flag option 2022-04-21 13:17:29 +02:00
nl.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
notify.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
nproc.cpp
ntpquery.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
open.cpp open: Use more StringView instead of const char* 2022-01-31 15:25:07 +01:00
pape.cpp Userland: Always construct Application with try_create() 2022-04-18 12:57:34 +02:00
passwd.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
paste.cpp Userland: Always construct Application with try_create() 2022-04-18 12:57:34 +02:00
pathchk.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
pgrep.cpp pgrep: Port to LibMain 2022-02-10 14:10:58 +00:00
pidof.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
ping.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
pls.cpp pls: Use Core::System::exec() 2022-04-11 21:09:42 +02:00
pmap.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
pmemdump.cpp
printf.cpp AK: Differ between long and long long formats 2022-04-14 03:12:56 +04:30
pro.cpp pro: Only attempt to parse a proxy url if it is provided 2022-04-09 14:36:28 +02:00
profile.cpp Utilities/profile: Call split_view() using StringView for command parts 2022-04-18 14:17:01 +02:00
ps.cpp Userland: Fix crash when inputting non-tty device into ps 2022-04-02 21:49:16 +02:00
purge.cpp purge: Port to LibMain 2022-03-22 11:39:20 +01:00
pwd.cpp pwd: Add missing rpath pledge 2022-01-21 22:10:23 +01:00
readelf.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
readlink.cpp readlink: Use StringView instead of const char* 2022-03-24 11:57:51 +01:00
realpath.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
reboot.cpp reboot: Port to LibMain 2022-03-03 15:42:44 -08:00
rev.cpp rev: Port to LibMain 2022-01-24 05:38:30 +00:00
rm.cpp rm: Port to LibMain 2022-01-25 02:50:10 +00:00
rmdir.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
run-tests.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
seq.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
shot.cpp Userland: Always construct Application with try_create() 2022-04-18 12:57:34 +02:00
shuf.cpp shuf: Port to LibMain 2022-01-24 05:38:30 +00:00
shutdown.cpp shutdown: Port to LibMain 2022-02-01 04:58:24 +00:00
sleep.cpp Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
sort.cpp sort: Port to LibMain 2022-01-24 05:38:30 +00:00
sql.cpp sql: Re-prompt user for input after unrecognized command 2022-03-24 07:25:04 -04:00
stat.cpp Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
strace.cpp strace: Use Core::System::exec() 2022-04-11 21:09:42 +02:00
stty.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
su.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
sync.cpp sync: Port to LibMain 2022-02-01 04:58:24 +00:00
syscall.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
sysctl.cpp sysctl: Port to LibMain 2022-02-01 04:58:24 +00:00
tac.cpp
tail.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
tar.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
tee.cpp tee: Port to LibMain and move to SerenityOS code patterns 2022-03-26 18:39:58 +00:00
telws.cpp telws: Port to LibMain 2022-03-29 21:28:29 -07:00
test-bindtodevice.cpp test-bindtodevice: Port to LibMain 2022-03-29 21:28:29 -07:00
test-fuzz.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
test-imap.cpp
test-pthread.cpp test-pthread: Port to LibMain and let local functions return ErrorOr<T> 2022-03-29 21:28:29 -07:00
test-unveil.cpp test-unveil: Port to LibMain 2022-03-29 21:28:29 -07:00
test.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
test_env.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
timezone.cpp Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2022-01-31 18:23:22 +00:00
top.cpp top: Add support for quitting top by pressing q 2022-04-02 23:48:17 +01:00
touch.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
tr.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
traceroute.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
tree.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
true.cpp true: Port to LibMain 2022-03-22 11:39:20 +01:00
truncate.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
tt.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
tty.cpp tty: Port to LibMain 2022-03-29 21:28:29 -07:00
umount.cpp umount: Port to LibMain 2022-01-22 13:31:52 +02:00
uname.cpp
uniq.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
unzip.cpp Utilities/unzip: Use Core::Directory to create output directory 2022-04-13 16:00:17 +02:00
update-cpp-test-results.cpp Everywhere: Move cpp-tests under /home/anon/Tests 2022-03-20 22:20:59 +01:00
uptime.cpp
useradd.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
userdel.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
usermod.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
utmpupdate.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
w.cpp Revert "Userland: Invoke tzset in apps that care about time zones" 2022-01-28 15:13:35 +00:00
wasm.cpp
watch.cpp Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
wc.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
which.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
whoami.cpp
wsctl.cpp Userland: Always construct Application with try_create() 2022-04-18 12:57:34 +02:00
xargs.cpp Utilities: Read positional arguments as Strings not char*s 2022-04-11 21:09:42 +02:00
xml.cpp LibXML: Add a fairly basic XML parser 2022-03-28 23:11:48 +02:00
yes.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
zip.cpp Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00