mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibAudio: Rename ConnectionFromClient to ConnectionToServer
The automatic nomenclature change for IPC sockets got this one wrong.
This commit is contained in:
parent
70846d701c
commit
3f59356c79
|
@ -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}
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <LibAudio/ConnectionFromClient.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
@ -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<AudioWidget> 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::ConnectionFromClient> audio_client, Array<VolumeBitmapPair, 5> volume_level_bitmaps)
|
||||
AudioWidget(NonnullRefPtr<Audio::ConnectionToServer> audio_client, Array<VolumeBitmapPair, 5> 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<Audio::ConnectionFromClient> m_audio_client;
|
||||
NonnullRefPtr<Audio::ConnectionToServer> m_audio_client;
|
||||
Array<VolumeBitmapPair, 5> m_volume_level_bitmaps;
|
||||
bool m_show_percent { false };
|
||||
bool m_audio_muted { false };
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "TrackManager.h"
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <LibAudio/ConnectionFromClient.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibAudio/Resampler.h>
|
||||
#include <LibAudio/Sample.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
|
@ -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)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Music.h"
|
||||
#include <LibAudio/ConnectionFromClient.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibAudio/Resampler.h>
|
||||
#include <LibAudio/Sample.h>
|
||||
#include <LibAudio/WavWriter.h>
|
||||
|
@ -35,7 +35,7 @@ private:
|
|||
TrackManager& m_track_manager;
|
||||
Array<Sample, sample_count> m_buffer;
|
||||
Optional<Audio::ResampleHelper<Sample>> m_resampler;
|
||||
RefPtr<Audio::ConnectionFromClient> m_audio_client;
|
||||
RefPtr<Audio::ConnectionToServer> m_audio_client;
|
||||
|
||||
bool m_should_play_audio = true;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "MainWidget.h"
|
||||
#include "TrackManager.h"
|
||||
#include <AK/Queue.h>
|
||||
#include <LibAudio/ConnectionFromClient.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibAudio/WavWriter.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/System.h>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "PlaybackManager.h"
|
||||
|
||||
PlaybackManager::PlaybackManager(NonnullRefPtr<Audio::ConnectionFromClient> connection)
|
||||
PlaybackManager::PlaybackManager(NonnullRefPtr<Audio::ConnectionToServer> connection)
|
||||
: m_connection(connection)
|
||||
{
|
||||
// FIXME: The buffer enqueuing should happen on a wholly independent second thread.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <AK/FixedArray.h>
|
||||
#include <AK/Queue.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibAudio/ConnectionFromClient.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibAudio/Loader.h>
|
||||
#include <LibAudio/Resampler.h>
|
||||
#include <LibAudio/Sample.h>
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
class PlaybackManager final {
|
||||
public:
|
||||
PlaybackManager(NonnullRefPtr<Audio::ConnectionFromClient>);
|
||||
PlaybackManager(NonnullRefPtr<Audio::ConnectionToServer>);
|
||||
~PlaybackManager() = default;
|
||||
|
||||
void play();
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
float total_length() const { return m_total_length; }
|
||||
FixedArray<Audio::Sample> const& current_buffer() const { return m_current_buffer; }
|
||||
|
||||
NonnullRefPtr<Audio::ConnectionFromClient> connection() const { return m_connection; }
|
||||
NonnullRefPtr<Audio::ConnectionToServer> connection() const { return m_connection; }
|
||||
|
||||
Function<void()> on_update;
|
||||
Function<void()> 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<Audio::Loader> m_loader { nullptr };
|
||||
NonnullRefPtr<Audio::ConnectionFromClient> m_connection;
|
||||
NonnullRefPtr<Audio::ConnectionToServer> m_connection;
|
||||
FixedArray<Audio::Sample> m_current_buffer;
|
||||
Optional<Audio::ResampleHelper<Audio::Sample>> m_resampler;
|
||||
RefPtr<Core::Timer> m_timer;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <LibGUI/Window.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
|
||||
SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window, Audio::ConnectionFromClient& connection)
|
||||
SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window, Audio::ConnectionToServer& connection)
|
||||
: Player(connection)
|
||||
, m_window(window)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "VisualizationWidget.h"
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibAudio/ConnectionFromClient.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibGUI/Splitter.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "Player.h"
|
||||
#include "SampleWidget.h"
|
||||
#include "SoundPlayerWidgetAdvancedView.h"
|
||||
#include <LibAudio/ConnectionFromClient.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
|
@ -28,7 +28,7 @@ ErrorOr<int> 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"));
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
set(SOURCES
|
||||
SampleFormats.cpp
|
||||
ConnectionFromClient.cpp
|
||||
ConnectionToServer.cpp
|
||||
Loader.cpp
|
||||
WavLoader.cpp
|
||||
FlacLoader.cpp
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Time.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibAudio/ConnectionFromClient.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibAudio/UserSampleQueue.h>
|
||||
#include <LibCore/Event.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
namespace Audio {
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
||||
ConnectionToServer::ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
|
||||
: IPC::ConnectionToServer<AudioClientEndpoint, AudioServerEndpoint>(*this, move(socket))
|
||||
, m_buffer(make<AudioQueue>(MUST(AudioQueue::try_create())))
|
||||
, m_user_queue(make<UserSampleQueue>())
|
||||
|
@ -37,12 +37,12 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSock
|
|||
set_buffer(*m_buffer);
|
||||
}
|
||||
|
||||
ConnectionFromClient::~ConnectionFromClient()
|
||||
ConnectionToServer::~ConnectionToServer()
|
||||
{
|
||||
die();
|
||||
}
|
||||
|
||||
void ConnectionFromClient::die()
|
||||
void ConnectionToServer::die()
|
||||
{
|
||||
// We're sometimes getting here after the other thread has already exited and its event loop does no longer exist.
|
||||
m_enqueuer_loop_destruction.lock();
|
||||
|
@ -54,7 +54,7 @@ void ConnectionFromClient::die()
|
|||
(void)m_background_audio_enqueuer->join();
|
||||
}
|
||||
|
||||
ErrorOr<void> ConnectionFromClient::async_enqueue(FixedArray<Sample>&& samples)
|
||||
ErrorOr<void> ConnectionToServer::async_enqueue(FixedArray<Sample>&& samples)
|
||||
{
|
||||
update_good_sleep_time();
|
||||
m_user_queue->append(move(samples));
|
||||
|
@ -66,12 +66,12 @@ ErrorOr<void> ConnectionFromClient::async_enqueue(FixedArray<Sample>&& 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<double>(get_sample_rate());
|
||||
auto buffer_play_time_ns = 1'000'000'000.0 / (sample_rate / static_cast<double>(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<Sample, AUDIO_BUFFER_SIZE> next_chunk;
|
||||
while (true) {
|
||||
|
@ -107,39 +107,39 @@ void ConnectionFromClient::custom_event(Core::CustomEvent&)
|
|||
m_audio_enqueuer_active.store(false);
|
||||
}
|
||||
|
||||
ErrorOr<void, AudioQueue::QueueStatus> ConnectionFromClient::realtime_enqueue(Array<Sample, AUDIO_BUFFER_SIZE> samples)
|
||||
ErrorOr<void, AudioQueue::QueueStatus> ConnectionToServer::realtime_enqueue(Array<Sample, AUDIO_BUFFER_SIZE> 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<unsigned>(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);
|
|
@ -23,12 +23,12 @@
|
|||
|
||||
namespace Audio {
|
||||
|
||||
class ConnectionFromClient final
|
||||
class ConnectionToServer final
|
||||
: public IPC::ConnectionToServer<AudioClientEndpoint, AudioServerEndpoint>
|
||||
, 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<void(double volume)> on_client_volume_change;
|
||||
|
||||
private:
|
||||
ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSocket>);
|
||||
ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket>);
|
||||
|
||||
virtual void main_mix_muted_state_changed(bool) override;
|
||||
virtual void main_mix_volume_changed(double) override;
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <LibAudio/ConnectionFromClient.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibAudio/Loader.h>
|
||||
#include <LibAudio/Resampler.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
|
@ -40,7 +40,7 @@ ErrorOr<int> 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);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibAudio/ConnectionFromClient.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
|
@ -28,7 +28,7 @@ enum AudioVariable : u32 {
|
|||
ErrorOr<int> 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();
|
||||
|
|
Loading…
Reference in a new issue