summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibAudio/ClientConnection.cpp6
-rw-r--r--Userland/Libraries/LibAudio/ClientConnection.h2
-rw-r--r--Userland/Services/AudioServer/AudioClient.ipc1
-rw-r--r--Userland/Services/AudioServer/AudioServer.ipc2
-rw-r--r--Userland/Services/AudioServer/ClientConnection.cpp16
-rw-r--r--Userland/Services/AudioServer/ClientConnection.h5
-rw-r--r--Userland/Services/AudioServer/Mixer.cpp2
7 files changed, 33 insertions, 1 deletions
diff --git a/Userland/Libraries/LibAudio/ClientConnection.cpp b/Userland/Libraries/LibAudio/ClientConnection.cpp
index 949683e42a..07d4312d5c 100644
--- a/Userland/Libraries/LibAudio/ClientConnection.cpp
+++ b/Userland/Libraries/LibAudio/ClientConnection.cpp
@@ -54,4 +54,10 @@ void ClientConnection::main_mix_volume_changed(double volume)
on_main_mix_volume_change(volume);
}
+void ClientConnection::client_volume_changed(double volume)
+{
+ if (on_client_volume_change)
+ on_client_volume_change(volume);
+}
+
}
diff --git a/Userland/Libraries/LibAudio/ClientConnection.h b/Userland/Libraries/LibAudio/ClientConnection.h
index 226b65215f..ef0f8084d8 100644
--- a/Userland/Libraries/LibAudio/ClientConnection.h
+++ b/Userland/Libraries/LibAudio/ClientConnection.h
@@ -28,11 +28,13 @@ public:
Function<void(i32 buffer_id)> on_finish_playing_buffer;
Function<void(bool muted)> on_muted_state_change;
Function<void(double volume)> on_main_mix_volume_change;
+ Function<void(double volume)> on_client_volume_change;
private:
virtual void finished_playing_buffer(i32) override;
virtual void muted_state_changed(bool) override;
virtual void main_mix_volume_changed(double) override;
+ virtual void client_volume_changed(double) override;
};
}
diff --git a/Userland/Services/AudioServer/AudioClient.ipc b/Userland/Services/AudioServer/AudioClient.ipc
index ee8922f944..92195413ad 100644
--- a/Userland/Services/AudioServer/AudioClient.ipc
+++ b/Userland/Services/AudioServer/AudioClient.ipc
@@ -5,4 +5,5 @@ endpoint AudioClient
finished_playing_buffer(i32 buffer_id) =|
muted_state_changed(bool muted) =|
main_mix_volume_changed(double volume) =|
+ client_volume_changed(double volume) =|
}
diff --git a/Userland/Services/AudioServer/AudioServer.ipc b/Userland/Services/AudioServer/AudioServer.ipc
index 9b4973130b..f34a84532b 100644
--- a/Userland/Services/AudioServer/AudioServer.ipc
+++ b/Userland/Services/AudioServer/AudioServer.ipc
@@ -7,6 +7,8 @@ endpoint AudioServer
get_muted() => (bool muted)
get_main_mix_volume() => (double volume)
set_main_mix_volume(double volume) => ()
+ get_self_volume() => (double volume)
+ set_self_volume(double volume) => ()
// Audio device
set_sample_rate(u16 sample_rate) => ()
diff --git a/Userland/Services/AudioServer/ClientConnection.cpp b/Userland/Services/AudioServer/ClientConnection.cpp
index e22009ba73..be04b960b5 100644
--- a/Userland/Services/AudioServer/ClientConnection.cpp
+++ b/Userland/Services/AudioServer/ClientConnection.cpp
@@ -53,6 +53,11 @@ void ClientConnection::did_change_main_mix_volume(Badge<Mixer>, double volume)
async_main_mix_volume_changed(volume);
}
+void ClientConnection::did_change_client_volume(Badge<ClientAudioStream>, double volume)
+{
+ async_client_volume_changed(volume);
+}
+
Messages::AudioServer::GetMainMixVolumeResponse ClientConnection::get_main_mix_volume()
{
return m_mixer.main_volume();
@@ -73,6 +78,17 @@ void ClientConnection::set_sample_rate(u16 sample_rate)
m_mixer.audiodevice_set_sample_rate(sample_rate);
}
+Messages::AudioServer::GetSelfVolumeResponse ClientConnection::get_self_volume()
+{
+ return m_queue->volume().target();
+}
+
+void ClientConnection::set_self_volume(double volume)
+{
+ if (m_queue)
+ m_queue->set_volume(volume);
+}
+
Messages::AudioServer::EnqueueBufferResponse ClientConnection::enqueue_buffer(Core::AnonymousBuffer const& buffer, i32 buffer_id, int sample_count)
{
if (!m_queue)
diff --git a/Userland/Services/AudioServer/ClientConnection.h b/Userland/Services/AudioServer/ClientConnection.h
index 00b0a9076c..9a2004448e 100644
--- a/Userland/Services/AudioServer/ClientConnection.h
+++ b/Userland/Services/AudioServer/ClientConnection.h
@@ -26,7 +26,8 @@ public:
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id, Mixer& mixer);
~ClientConnection() override;
- void did_finish_playing_buffer(Badge<BufferQueue>, int buffer_id);
+ void did_finish_playing_buffer(Badge<ClientAudioStream>, int buffer_id);
+ void did_change_client_volume(Badge<ClientAudioStream>, double volume);
void did_change_muted_state(Badge<Mixer>, bool muted);
void did_change_main_mix_volume(Badge<Mixer>, double volume);
@@ -37,6 +38,8 @@ public:
private:
virtual Messages::AudioServer::GetMainMixVolumeResponse get_main_mix_volume() override;
virtual void set_main_mix_volume(double) override;
+ virtual Messages::AudioServer::GetSelfVolumeResponse get_self_volume() override;
+ virtual void set_self_volume(double) override;
virtual Messages::AudioServer::EnqueueBufferResponse enqueue_buffer(Core::AnonymousBuffer const&, i32, int) override;
virtual Messages::AudioServer::GetRemainingSamplesResponse get_remaining_samples() override;
virtual Messages::AudioServer::GetPlayedSamplesResponse get_played_samples() override;
diff --git a/Userland/Services/AudioServer/Mixer.cpp b/Userland/Services/AudioServer/Mixer.cpp
index e694cc2bb0..519780b996 100644
--- a/Userland/Services/AudioServer/Mixer.cpp
+++ b/Userland/Services/AudioServer/Mixer.cpp
@@ -88,6 +88,7 @@ void Mixer::mix()
continue;
}
++active_queues;
+ queue->volume().advance_time();
for (int i = 0; i < mixed_buffer_length; ++i) {
auto& mixed_sample = mixed_buffer[i];
@@ -95,6 +96,7 @@ void Mixer::mix()
if (!queue->get_next_sample(sample))
break;
sample.log_multiply(SAMPLE_HEADROOM);
+ sample.log_multiply(queue->volume());
mixed_sample += sample;
}
}