mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
AudioServer: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through ClassName::construct(), to avoid handling ref-counted objects with refcount zero. Fixing the visibility means that misuses like this are more difficult. This commit is separate from the other Servives changes because it required additional adaption of the code. Note that the old code did precisely what these changes try to prevent: Create and handle a ref-counted object with a refcount of zero.
This commit is contained in:
parent
4e55d649d7
commit
25032a02aa
3 changed files with 6 additions and 4 deletions
|
@ -23,7 +23,6 @@ class Mixer;
|
||||||
class ClientConnection final : public IPC::ClientConnection<AudioClientEndpoint, AudioServerEndpoint> {
|
class ClientConnection final : public IPC::ClientConnection<AudioClientEndpoint, AudioServerEndpoint> {
|
||||||
C_OBJECT(ClientConnection)
|
C_OBJECT(ClientConnection)
|
||||||
public:
|
public:
|
||||||
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id, Mixer& mixer);
|
|
||||||
~ClientConnection() override;
|
~ClientConnection() override;
|
||||||
|
|
||||||
void did_finish_playing_buffer(Badge<ClientAudioStream>, int buffer_id);
|
void did_finish_playing_buffer(Badge<ClientAudioStream>, int buffer_id);
|
||||||
|
@ -36,6 +35,8 @@ public:
|
||||||
static void for_each(Function<void(ClientConnection&)>);
|
static void for_each(Function<void(ClientConnection&)>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id, Mixer& mixer);
|
||||||
|
|
||||||
virtual Messages::AudioServer::GetMainMixVolumeResponse get_main_mix_volume() override;
|
virtual Messages::AudioServer::GetMainMixVolumeResponse get_main_mix_volume() override;
|
||||||
virtual void set_main_mix_volume(double) override;
|
virtual void set_main_mix_volume(double) override;
|
||||||
virtual Messages::AudioServer::GetSelfVolumeResponse get_self_volume() override;
|
virtual Messages::AudioServer::GetSelfVolumeResponse get_self_volume() override;
|
||||||
|
|
|
@ -108,7 +108,6 @@ private:
|
||||||
class Mixer : public Core::Object {
|
class Mixer : public Core::Object {
|
||||||
C_OBJECT(Mixer)
|
C_OBJECT(Mixer)
|
||||||
public:
|
public:
|
||||||
Mixer(NonnullRefPtr<Core::ConfigFile> config);
|
|
||||||
virtual ~Mixer() override;
|
virtual ~Mixer() override;
|
||||||
|
|
||||||
NonnullRefPtr<ClientAudioStream> create_queue(ClientConnection&);
|
NonnullRefPtr<ClientAudioStream> create_queue(ClientConnection&);
|
||||||
|
@ -124,6 +123,8 @@ public:
|
||||||
u16 audiodevice_get_sample_rate() const;
|
u16 audiodevice_get_sample_rate() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Mixer(NonnullRefPtr<Core::ConfigFile> config);
|
||||||
|
|
||||||
void request_setting_sync();
|
void request_setting_sync();
|
||||||
|
|
||||||
Vector<NonnullRefPtr<ClientAudioStream>> m_pending_mixing;
|
Vector<NonnullRefPtr<ClientAudioStream>> m_pending_mixing;
|
||||||
|
|
|
@ -29,7 +29,7 @@ int main(int, char**)
|
||||||
unveil(nullptr, nullptr);
|
unveil(nullptr, nullptr);
|
||||||
|
|
||||||
Core::EventLoop event_loop;
|
Core::EventLoop event_loop;
|
||||||
AudioServer::Mixer mixer { config };
|
auto mixer = AudioServer::Mixer::construct(config);
|
||||||
|
|
||||||
auto server = Core::LocalServer::construct();
|
auto server = Core::LocalServer::construct();
|
||||||
bool ok = server->take_over_from_system_server();
|
bool ok = server->take_over_from_system_server();
|
||||||
|
@ -42,7 +42,7 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
static int s_next_client_id = 0;
|
static int s_next_client_id = 0;
|
||||||
int client_id = ++s_next_client_id;
|
int client_id = ++s_next_client_id;
|
||||||
IPC::new_client_connection<AudioServer::ClientConnection>(client_socket.release_nonnull(), client_id, mixer);
|
IPC::new_client_connection<AudioServer::ClientConnection>(client_socket.release_nonnull(), client_id, *mixer);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pledge("stdio recvfd thread accept cpath rpath wpath", nullptr) < 0) {
|
if (pledge("stdio recvfd thread accept cpath rpath wpath", nullptr) < 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue