diff --git a/Base/etc/SystemServer.ini b/Base/etc/SystemServer.ini index 7cf6d0f4a01..f736c313a51 100644 --- a/Base/etc/SystemServer.ini +++ b/Base/etc/SystemServer.ini @@ -25,14 +25,6 @@ SocketPermissions=600 Priority=low User=anon -[AudioServer] -# TODO: It would be nice to make this lazy, but Audio.Applet connects to it immediately on startup anyway. -Socket=/tmp/portal/audio -Priority=high -KeepAlive=true -User=anon -SystemModes=text,graphical - [Shell@tty0] Executable=/bin/Shell StdIO=/dev/tty0 diff --git a/Base/home/anon/.config/SystemServer.ini b/Base/home/anon/.config/SystemServer.ini index 58ecb001434..e1ed44be1a7 100644 --- a/Base/home/anon/.config/SystemServer.ini +++ b/Base/home/anon/.config/SystemServer.ini @@ -57,6 +57,12 @@ Socket=/tmp/user/%uid/portal/inspector,/tmp/user/%uid/portal/inspectables SocketPermissions=600,666 KeepAlive=true +[AudioServer] +Socket=/tmp/user/%uid/portal/audio +Priority=high +KeepAlive=true +SystemModes=text,graphical + [LaunchServer] Socket=/tmp/user/%uid/portal/launch SocketPermissions=600 diff --git a/Base/usr/share/man/man7/Audio-subsystem.md b/Base/usr/share/man/man7/Audio-subsystem.md index 0a4650c0499..1ef91749193 100644 --- a/Base/usr/share/man/man7/Audio-subsystem.md +++ b/Base/usr/share/man/man7/Audio-subsystem.md @@ -14,11 +14,22 @@ There are two primary sample formats used in SerenityOS. The `Sample` class in L ### AudioServer -AudioServer is responsible for handling userland audio clients and talking to the hardware. For this reason, no userland application should ever need to write to a device in `/dev/audio` directly, except for special cases in which AudioServer is not present. +AudioServer is responsible for handling userland audio clients and talking to the hardware. For this reason, no userland +application should ever need to write to a device in `/dev/audio` directly, except for special cases in which +AudioServer is not present. -As with all system servers, AudioServer provides an IPC interface on `/tmp/portal/audio`. For specifics on how to talk to AudioServer, the IPC interface specifications are the best source of information. For controlling mixer functionality, clients have the ability to obtain and change their own volume, or the main volume and mute state. +As with all system servers, AudioServer provides an IPC interface on `/tmp/user/%uid/portal/audio`, with `%uid` being +the uid +of the current user. For specifics on how to talk to AudioServer, the IPC interface specifications are the best source +of information. For controlling mixer functionality, clients have the ability to obtain and change their own volume, or +the main volume and mute state. -Userland audio transmission happens via the AudioQueue. This is a shared memory circular queue which supports concurrent lock-free writing and reading. The queue is created by the audio client and its shared memory file descriptor sent to the audio server. In order to use this queue, an audio application needs to split up its audio data into atomic chunks that can then be provided to the queue. The application might need to wait around until the queue is empty in order to write to it. For these reasons, there's a utility API in LibAudio's audio server IPC connection which allows audio applications to send off a large chunk of samples which get progressively sent in the background. +Userland audio transmission happens via the AudioQueue. This is a shared memory circular queue which supports concurrent +lock-free writing and reading. The queue is created by the audio client and its shared memory file descriptor sent to +the audio server. In order to use this queue, an audio application needs to split up its audio data into atomic chunks +that can then be provided to the queue. The application might need to wait around until the queue is empty in order to +write to it. For these reasons, there's a utility API in LibAudio's audio server IPC connection which allows audio +applications to send off a large chunk of samples which get progressively sent in the background. On the server -> client side, AudioServer has "event" calls that the client receives. These are various mixer state changes (main volume, main mute, client volume). @@ -68,7 +79,7 @@ Although the sample rate can change at any time, it is considered a rarely-chang * [/dev/audio](help://man/4/audio) * AudioApplet and AudioServer have settings which are managed by ConfigServer. -* `/tmp/portal/audio`: AudioServer's IPC socket +* `/tmp/user/%uid/portal/audio`: AudioServer's IPC socket ## See also diff --git a/Userland/Applets/Audio/main.cpp b/Userland/Applets/Audio/main.cpp index 211b66a3e0d..10a7b674f1b 100644 --- a/Userland/Applets/Audio/main.cpp +++ b/Userland/Applets/Audio/main.cpp @@ -241,7 +241,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); Config::pledge_domain("AudioApplet"); - TRY(Core::System::unveil("/tmp/portal/audio", "rw")); + TRY(Core::System::unveil("/tmp/user/%uid/portal/audio", "rw")); TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); diff --git a/Userland/Libraries/LibAudio/ConnectionToServer.h b/Userland/Libraries/LibAudio/ConnectionToServer.h index 687eae652e4..5ed42450fa1 100644 --- a/Userland/Libraries/LibAudio/ConnectionToServer.h +++ b/Userland/Libraries/LibAudio/ConnectionToServer.h @@ -26,7 +26,7 @@ namespace Audio { class ConnectionToServer final : public IPC::ConnectionToServer , public AudioClientEndpoint { - IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/portal/audio"sv) + IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/user/%uid/portal/audio"sv) public: virtual ~ConnectionToServer() override; diff --git a/Userland/Utilities/aplay.cpp b/Userland/Utilities/aplay.cpp index cbf97462cc2..b8e1a9f5370 100644 --- a/Userland/Utilities/aplay.cpp +++ b/Userland/Utilities/aplay.cpp @@ -35,7 +35,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); TRY(Core::System::unveil(Core::File::absolute_path(path), "r"sv)); - TRY(Core::System::unveil("/tmp/portal/audio", "rw")); + TRY(Core::System::unveil("/tmp/user/%uid/portal/audio", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); Core::EventLoop loop;