AudioServer: Give the AudioClient a way to keep track of the main mix volume
This commit is contained in:
parent
e634fe6072
commit
60a7187db2
Notes:
sideshowbarker
2024-07-19 04:41:36 +09:00
Author: https://github.com/benit8 Commit: https://github.com/SerenityOS/serenity/commit/60a7187db27 Pull-request: https://github.com/SerenityOS/serenity/pull/2845 Reviewed-by: https://github.com/awesomekling
7 changed files with 24 additions and 1 deletions
|
@ -116,4 +116,10 @@ void ClientConnection::handle(const Messages::AudioClient::MutedStateChanged& me
|
|||
on_muted_state_change(message.muted());
|
||||
}
|
||||
|
||||
void ClientConnection::handle(const Messages::AudioClient::MainMixVolumeChanged& message)
|
||||
{
|
||||
if (on_main_mix_volume_change)
|
||||
on_main_mix_volume_change(message.volume());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,10 +59,12 @@ public:
|
|||
|
||||
Function<void(i32 buffer_id)> on_finish_playing_buffer;
|
||||
Function<void(bool muted)> on_muted_state_change;
|
||||
Function<void(int volume)> on_main_mix_volume_change;
|
||||
|
||||
private:
|
||||
virtual void handle(const Messages::AudioClient::FinishedPlayingBuffer&) override;
|
||||
virtual void handle(const Messages::AudioClient::MutedStateChanged&) override;
|
||||
virtual void handle(const Messages::AudioClient::MainMixVolumeChanged&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -2,4 +2,5 @@ endpoint AudioClient = 82
|
|||
{
|
||||
FinishedPlayingBuffer(i32 buffer_id) =|
|
||||
MutedStateChanged(bool muted) =|
|
||||
MainMixVolumeChanged(i32 volume) =|
|
||||
}
|
||||
|
|
|
@ -76,6 +76,11 @@ void ClientConnection::did_change_muted_state(Badge<Mixer>, bool muted)
|
|||
post_message(Messages::AudioClient::MutedStateChanged(muted));
|
||||
}
|
||||
|
||||
void ClientConnection::did_change_main_mix_volume(Badge<Mixer>, int volume)
|
||||
{
|
||||
post_message(Messages::AudioClient::MainMixVolumeChanged(volume));
|
||||
}
|
||||
|
||||
OwnPtr<Messages::AudioServer::GreetResponse> ClientConnection::handle(const Messages::AudioServer::Greet&)
|
||||
{
|
||||
return make<Messages::AudioServer::GreetResponse>(client_id());
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
|
||||
void did_finish_playing_buffer(Badge<BufferQueue>, int buffer_id);
|
||||
void did_change_muted_state(Badge<Mixer>, bool muted);
|
||||
void did_change_main_mix_volume(Badge<Mixer>, int volume);
|
||||
|
||||
virtual void die() override;
|
||||
|
||||
|
|
|
@ -132,6 +132,14 @@ void Mixer::mix()
|
|||
}
|
||||
}
|
||||
|
||||
void Mixer::set_main_volume(int volume)
|
||||
{
|
||||
m_main_volume = volume;
|
||||
ClientConnection::for_each([volume](ClientConnection& client) {
|
||||
client.did_change_main_mix_volume({}, volume);
|
||||
});
|
||||
}
|
||||
|
||||
void Mixer::set_muted(bool muted)
|
||||
{
|
||||
if (m_muted == muted)
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
NonnullRefPtr<BufferQueue> create_queue(ClientConnection&);
|
||||
|
||||
int main_volume() const { return m_main_volume; }
|
||||
void set_main_volume(int volume) { m_main_volume = volume; }
|
||||
void set_main_volume(int volume);
|
||||
|
||||
bool is_muted() const { return m_muted; }
|
||||
void set_muted(bool);
|
||||
|
|
Loading…
Add table
Reference in a new issue