From 3f59356c79a044e7f2c49a7e456f8309d47508fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Sun, 17 Jul 2022 11:31:01 +0200 Subject: [PATCH] LibAudio: Rename ConnectionFromClient to ConnectionToServer The automatic nomenclature change for IPC sockets got this one wrong. --- Meta/Lagom/CMakeLists.txt | 2 +- Userland/Applets/Audio/main.cpp | 8 ++--- .../Applications/Piano/AudioPlayerLoop.cpp | 4 +-- Userland/Applications/Piano/AudioPlayerLoop.h | 4 +-- Userland/Applications/Piano/main.cpp | 2 +- .../SoundPlayer/PlaybackManager.cpp | 2 +- .../SoundPlayer/PlaybackManager.h | 8 ++--- Userland/Applications/SoundPlayer/Player.cpp | 2 +- Userland/Applications/SoundPlayer/Player.h | 4 +-- .../SoundPlayerWidgetAdvancedView.cpp | 2 +- .../SoundPlayerWidgetAdvancedView.h | 4 +-- Userland/Applications/SoundPlayer/main.cpp | 4 +-- Userland/Libraries/LibAudio/CMakeLists.txt | 2 +- ...nFromClient.cpp => ConnectionToServer.cpp} | 30 +++++++++---------- ...ctionFromClient.h => ConnectionToServer.h} | 8 ++--- Userland/Utilities/aplay.cpp | 4 +-- Userland/Utilities/asctl.cpp | 4 +-- 17 files changed, 47 insertions(+), 47 deletions(-) rename Userland/Libraries/LibAudio/{ConnectionFromClient.cpp => ConnectionToServer.cpp} (79%) rename Userland/Libraries/LibAudio/{ConnectionFromClient.h => ConnectionToServer.h} (94%) diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index 8a65912a11..e183889883 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -318,7 +318,7 @@ if (BUILD_LAGOM) # Audio file(GLOB LIBAUDIO_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibAudio/*.cpp") - list(REMOVE_ITEM LIBAUDIO_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../Userland/Libraries/LibAudio/ConnectionFromClient.cpp") + list(REMOVE_ITEM LIBAUDIO_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../Userland/Libraries/LibAudio/ConnectionToServer.cpp") lagom_lib(Audio audio SOURCES ${LIBAUDIO_SOURCES} ) diff --git a/Userland/Applets/Audio/main.cpp b/Userland/Applets/Audio/main.cpp index 58c01aa156..211b66a3e0 100644 --- a/Userland/Applets/Audio/main.cpp +++ b/Userland/Applets/Audio/main.cpp @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include @@ -43,14 +43,14 @@ public: { 0, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-zero.png"sv)) }, { 0, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-muted.png"sv)) } } }; - auto audio_client = TRY(Audio::ConnectionFromClient::try_create()); + auto audio_client = TRY(Audio::ConnectionToServer::try_create()); NonnullRefPtr audio_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) AudioWidget(move(audio_client), move(volume_level_bitmaps)))); TRY(audio_widget->try_initialize_graphical_elements()); return audio_widget; } private: - AudioWidget(NonnullRefPtr audio_client, Array volume_level_bitmaps) + AudioWidget(NonnullRefPtr audio_client, Array volume_level_bitmaps) : m_audio_client(move(audio_client)) , m_volume_level_bitmaps(move(volume_level_bitmaps)) , m_show_percent(Config::read_bool("AudioApplet"sv, "Applet"sv, "ShowPercent"sv, false)) @@ -222,7 +222,7 @@ private: height); } - NonnullRefPtr m_audio_client; + NonnullRefPtr m_audio_client; Array m_volume_level_bitmaps; bool m_show_percent { false }; bool m_audio_muted { false }; diff --git a/Userland/Applications/Piano/AudioPlayerLoop.cpp b/Userland/Applications/Piano/AudioPlayerLoop.cpp index 1bbaaf01ad..c6f36f5a4c 100644 --- a/Userland/Applications/Piano/AudioPlayerLoop.cpp +++ b/Userland/Applications/Piano/AudioPlayerLoop.cpp @@ -10,7 +10,7 @@ #include "TrackManager.h" #include #include -#include +#include #include #include #include @@ -29,7 +29,7 @@ AudioPlayerLoop::AudioPlayerLoop(TrackManager& track_manager, bool& need_to_writ , m_need_to_write_wav(need_to_write_wav) , m_wav_writer(wav_writer) { - m_audio_client = Audio::ConnectionFromClient::try_create().release_value_but_fixme_should_propagate_errors(); + m_audio_client = Audio::ConnectionToServer::try_create().release_value_but_fixme_should_propagate_errors(); auto target_sample_rate = m_audio_client->get_sample_rate(); if (target_sample_rate == 0) diff --git a/Userland/Applications/Piano/AudioPlayerLoop.h b/Userland/Applications/Piano/AudioPlayerLoop.h index ecba88036a..90e3d0d9e8 100644 --- a/Userland/Applications/Piano/AudioPlayerLoop.h +++ b/Userland/Applications/Piano/AudioPlayerLoop.h @@ -8,7 +8,7 @@ #pragma once #include "Music.h" -#include +#include #include #include #include @@ -35,7 +35,7 @@ private: TrackManager& m_track_manager; Array m_buffer; Optional> m_resampler; - RefPtr m_audio_client; + RefPtr m_audio_client; bool m_should_play_audio = true; diff --git a/Userland/Applications/Piano/main.cpp b/Userland/Applications/Piano/main.cpp index ab1f33319e..f64502c853 100644 --- a/Userland/Applications/Piano/main.cpp +++ b/Userland/Applications/Piano/main.cpp @@ -11,7 +11,7 @@ #include "MainWidget.h" #include "TrackManager.h" #include -#include +#include #include #include #include diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.cpp b/Userland/Applications/SoundPlayer/PlaybackManager.cpp index 5442d13697..aa1830e2d3 100644 --- a/Userland/Applications/SoundPlayer/PlaybackManager.cpp +++ b/Userland/Applications/SoundPlayer/PlaybackManager.cpp @@ -7,7 +7,7 @@ #include "PlaybackManager.h" -PlaybackManager::PlaybackManager(NonnullRefPtr connection) +PlaybackManager::PlaybackManager(NonnullRefPtr connection) : m_connection(connection) { // FIXME: The buffer enqueuing should happen on a wholly independent second thread. diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.h b/Userland/Applications/SoundPlayer/PlaybackManager.h index 9dcca04191..d73f87d577 100644 --- a/Userland/Applications/SoundPlayer/PlaybackManager.h +++ b/Userland/Applications/SoundPlayer/PlaybackManager.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -18,7 +18,7 @@ class PlaybackManager final { public: - PlaybackManager(NonnullRefPtr); + PlaybackManager(NonnullRefPtr); ~PlaybackManager() = default; void play(); @@ -36,7 +36,7 @@ public: float total_length() const { return m_total_length; } FixedArray const& current_buffer() const { return m_current_buffer; } - NonnullRefPtr connection() const { return m_connection; } + NonnullRefPtr connection() const { return m_connection; } Function on_update; Function on_finished_playing; @@ -56,7 +56,7 @@ private: size_t m_device_samples_per_buffer { 0 }; size_t m_samples_to_load_per_buffer { 0 }; RefPtr m_loader { nullptr }; - NonnullRefPtr m_connection; + NonnullRefPtr m_connection; FixedArray m_current_buffer; Optional> m_resampler; RefPtr m_timer; diff --git a/Userland/Applications/SoundPlayer/Player.cpp b/Userland/Applications/SoundPlayer/Player.cpp index 384626ac5b..5238fbb2b0 100644 --- a/Userland/Applications/SoundPlayer/Player.cpp +++ b/Userland/Applications/SoundPlayer/Player.cpp @@ -7,7 +7,7 @@ #include "Player.h" -Player::Player(Audio::ConnectionFromClient& audio_client_connection) +Player::Player(Audio::ConnectionToServer& audio_client_connection) : m_audio_client_connection(audio_client_connection) , m_playback_manager(audio_client_connection) { diff --git a/Userland/Applications/SoundPlayer/Player.h b/Userland/Applications/SoundPlayer/Player.h index 564aba82f5..cd8872c590 100644 --- a/Userland/Applications/SoundPlayer/Player.h +++ b/Userland/Applications/SoundPlayer/Player.h @@ -31,7 +31,7 @@ public: Shuffling, }; - explicit Player(Audio::ConnectionFromClient& audio_client_connection); + explicit Player(Audio::ConnectionToServer& audio_client_connection); virtual ~Player() = default; void play_file_path(String const& path); @@ -91,7 +91,7 @@ private: LoopMode m_loop_mode { LoopMode::None }; ShuffleMode m_shuffle_mode { ShuffleMode::None }; - Audio::ConnectionFromClient& m_audio_client_connection; + Audio::ConnectionToServer& m_audio_client_connection; PlaybackManager m_playback_manager; String m_loaded_filename; diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp index 1bd46f0366..d7e1441129 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp @@ -24,7 +24,7 @@ #include #include -SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window, Audio::ConnectionFromClient& connection) +SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window, Audio::ConnectionToServer& connection) : Player(connection) , m_window(window) { diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h index d87ed4de15..8164b534e0 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h @@ -13,7 +13,7 @@ #include "VisualizationWidget.h" #include #include -#include +#include #include #include @@ -53,7 +53,7 @@ protected: void keydown_event(GUI::KeyEvent&) override; private: - SoundPlayerWidgetAdvancedView(GUI::Window&, Audio::ConnectionFromClient&); + SoundPlayerWidgetAdvancedView(GUI::Window&, Audio::ConnectionToServer&); void sync_previous_next_actions(); diff --git a/Userland/Applications/SoundPlayer/main.cpp b/Userland/Applications/SoundPlayer/main.cpp index 42918d8584..fde41f3f95 100644 --- a/Userland/Applications/SoundPlayer/main.cpp +++ b/Userland/Applications/SoundPlayer/main.cpp @@ -10,7 +10,7 @@ #include "Player.h" #include "SampleWidget.h" #include "SoundPlayerWidgetAdvancedView.h" -#include +#include #include #include #include @@ -28,7 +28,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd rpath thread unix")); auto app = TRY(GUI::Application::try_create(arguments)); - auto audio_client = TRY(Audio::ConnectionFromClient::try_create()); + auto audio_client = TRY(Audio::ConnectionToServer::try_create()); TRY(Core::System::pledge("stdio recvfd sendfd rpath thread")); diff --git a/Userland/Libraries/LibAudio/CMakeLists.txt b/Userland/Libraries/LibAudio/CMakeLists.txt index 06c3dad5ac..ea3534d8af 100644 --- a/Userland/Libraries/LibAudio/CMakeLists.txt +++ b/Userland/Libraries/LibAudio/CMakeLists.txt @@ -1,6 +1,6 @@ set(SOURCES SampleFormats.cpp - ConnectionFromClient.cpp + ConnectionToServer.cpp Loader.cpp WavLoader.cpp FlacLoader.cpp diff --git a/Userland/Libraries/LibAudio/ConnectionFromClient.cpp b/Userland/Libraries/LibAudio/ConnectionToServer.cpp similarity index 79% rename from Userland/Libraries/LibAudio/ConnectionFromClient.cpp rename to Userland/Libraries/LibAudio/ConnectionToServer.cpp index fe3e4e9ae2..44d2ab2766 100644 --- a/Userland/Libraries/LibAudio/ConnectionFromClient.cpp +++ b/Userland/Libraries/LibAudio/ConnectionToServer.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -18,7 +18,7 @@ namespace Audio { -ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr socket) +ConnectionToServer::ConnectionToServer(NonnullOwnPtr socket) : IPC::ConnectionToServer(*this, move(socket)) , m_buffer(make(MUST(AudioQueue::try_create()))) , m_user_queue(make()) @@ -37,12 +37,12 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtrjoin(); } -ErrorOr ConnectionFromClient::async_enqueue(FixedArray&& samples) +ErrorOr ConnectionToServer::async_enqueue(FixedArray&& samples) { update_good_sleep_time(); m_user_queue->append(move(samples)); @@ -66,12 +66,12 @@ ErrorOr ConnectionFromClient::async_enqueue(FixedArray&& samples) return {}; } -void ConnectionFromClient::clear_client_buffer() +void ConnectionToServer::clear_client_buffer() { m_user_queue->clear(); } -void ConnectionFromClient::update_good_sleep_time() +void ConnectionToServer::update_good_sleep_time() { auto sample_rate = static_cast(get_sample_rate()); auto buffer_play_time_ns = 1'000'000'000.0 / (sample_rate / static_cast(AUDIO_BUFFER_SIZE)); @@ -80,7 +80,7 @@ void ConnectionFromClient::update_good_sleep_time() } // Non-realtime audio writing loop -void ConnectionFromClient::custom_event(Core::CustomEvent&) +void ConnectionToServer::custom_event(Core::CustomEvent&) { Array next_chunk; while (true) { @@ -107,39 +107,39 @@ void ConnectionFromClient::custom_event(Core::CustomEvent&) m_audio_enqueuer_active.store(false); } -ErrorOr ConnectionFromClient::realtime_enqueue(Array samples) +ErrorOr ConnectionToServer::realtime_enqueue(Array samples) { return m_buffer->try_enqueue(samples); } -unsigned ConnectionFromClient::total_played_samples() const +unsigned ConnectionToServer::total_played_samples() const { return m_buffer->weak_tail() * AUDIO_BUFFER_SIZE; } -unsigned ConnectionFromClient::remaining_samples() +unsigned ConnectionToServer::remaining_samples() { return static_cast(m_user_queue->remaining_samples()); } -size_t ConnectionFromClient::remaining_buffers() const +size_t ConnectionToServer::remaining_buffers() const { return m_buffer->size() - m_buffer->weak_remaining_capacity(); } -void ConnectionFromClient::main_mix_muted_state_changed(bool muted) +void ConnectionToServer::main_mix_muted_state_changed(bool muted) { if (on_main_mix_muted_state_change) on_main_mix_muted_state_change(muted); } -void ConnectionFromClient::main_mix_volume_changed(double volume) +void ConnectionToServer::main_mix_volume_changed(double volume) { if (on_main_mix_volume_change) on_main_mix_volume_change(volume); } -void ConnectionFromClient::client_volume_changed(double volume) +void ConnectionToServer::client_volume_changed(double volume) { if (on_client_volume_change) on_client_volume_change(volume); diff --git a/Userland/Libraries/LibAudio/ConnectionFromClient.h b/Userland/Libraries/LibAudio/ConnectionToServer.h similarity index 94% rename from Userland/Libraries/LibAudio/ConnectionFromClient.h rename to Userland/Libraries/LibAudio/ConnectionToServer.h index b74e553bc8..154d7bb5b5 100644 --- a/Userland/Libraries/LibAudio/ConnectionFromClient.h +++ b/Userland/Libraries/LibAudio/ConnectionToServer.h @@ -23,12 +23,12 @@ namespace Audio { -class ConnectionFromClient final +class ConnectionToServer final : public IPC::ConnectionToServer , public AudioClientEndpoint { - IPC_CLIENT_CONNECTION(ConnectionFromClient, "/tmp/portal/audio") + IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/portal/audio") public: - virtual ~ConnectionFromClient() override; + virtual ~ConnectionToServer() override; // Both of these APIs are for convenience and when you don't care about real-time behavior. // They will not work properly in conjunction with realtime_enqueue. @@ -61,7 +61,7 @@ public: Function on_client_volume_change; private: - ConnectionFromClient(NonnullOwnPtr); + ConnectionToServer(NonnullOwnPtr); virtual void main_mix_muted_state_changed(bool) override; virtual void main_mix_volume_changed(double) override; diff --git a/Userland/Utilities/aplay.cpp b/Userland/Utilities/aplay.cpp index b3b0d489fc..cbf97462cc 100644 --- a/Userland/Utilities/aplay.cpp +++ b/Userland/Utilities/aplay.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include @@ -40,7 +40,7 @@ ErrorOr serenity_main(Main::Arguments arguments) Core::EventLoop loop; - auto audio_client = TRY(Audio::ConnectionFromClient::try_create()); + auto audio_client = TRY(Audio::ConnectionToServer::try_create()); auto maybe_loader = Audio::Loader::create(path); if (maybe_loader.is_error()) { warnln("Failed to load audio file: {}", maybe_loader.error().description); diff --git a/Userland/Utilities/asctl.cpp b/Userland/Utilities/asctl.cpp index 089568388e..9ed3393581 100644 --- a/Userland/Utilities/asctl.cpp +++ b/Userland/Utilities/asctl.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include @@ -28,7 +28,7 @@ enum AudioVariable : u32 { ErrorOr serenity_main(Main::Arguments arguments) { Core::EventLoop loop; - auto audio_client = TRY(Audio::ConnectionFromClient::try_create()); + auto audio_client = TRY(Audio::ConnectionToServer::try_create()); audio_client->async_pause_playback(); String command = String::empty();