Skip to content

Truly independent web browser

AudioServer+LibWebView+LibWeb: Mute tabs in the AudioServer

Luke Wilde67dbe3a0c2ae
diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
index 632bfc1a3d5..7fb83633e29 100644
--- a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
@@ -810,19 +810,12 @@ void HTMLMediaElement::volume_or_muted_attribute_changed()
update_audio_play_state();
}
-void HTMLMediaElement::page_mute_state_changed(Badge<Page>)
-{
- update_volume();
- update_audio_play_state();
-}
-
// https://html.spec.whatwg.org/multipage/media.html#effective-media-volume
double HTMLMediaElement::effective_media_volume() const
{
// 1. If the user has indicated that the user agent is to override the volume of the element, then return the
// volume desired by the user.
- if (document().page().page_mute_state() == MuteState::Muted)
- return 0.0;
+ // NB: The user mutes a tab in the AudioServer, which a compromised renderer can't bypass.
// 2. If the element's audio output is muted, then return zero.
if (m_muted)
diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Libraries/LibWeb/HTML/HTMLMediaElement.h
index ab0ae7a4bc8..e6006229897 100644
--- a/Libraries/LibWeb/HTML/HTMLMediaElement.h
+++ b/Libraries/LibWeb/HTML/HTMLMediaElement.h
@@ -152,8 +152,6 @@ public:
void toggle_fullscreen();
- void page_mute_state_changed(Badge<Page>);
-
double effective_media_volume() const;
bool is_playing_audio() const { return m_is_playing_audio; }
diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cpp
index 6d210206ebc..69f825360c1 100644
--- a/Libraries/LibWeb/Internals/Internals.cpp
+++ b/Libraries/LibWeb/Internals/Internals.cpp
@@ -2145,11 +2145,6 @@ void Internals::disconnect_media_server()
client.value()->shutdown();
}
-void Internals::set_page_muted(bool muted)
-{
- window().associated_document().page().set_page_mute_state(muted ? HTML::MuteState::Muted : HTML::MuteState::Unmuted);
-}
-
DOM::Document::StyleInvalidationCounters const& Internals::style_invalidation_counters() const
{
return window().associated_document().style_invalidation_counters();
diff --git a/Libraries/LibWeb/Internals/Internals.h b/Libraries/LibWeb/Internals/Internals.h
index 73ec3e899d1..a451d6babce 100644
--- a/Libraries/LibWeb/Internals/Internals.h
+++ b/Libraries/LibWeb/Internals/Internals.h
@@ -324,7 +324,6 @@ public:
void set_media_element_paused(HTML::HTMLMediaElement&, bool paused);
void set_media_element_seeking(HTML::HTMLMediaElement&, bool seeking);
void disconnect_media_server();
- void set_page_muted(bool muted);
String viewport_overflow_x();
GC::Ref<Streams::ReadableStream> create_stream_pulling_from_bytes(String const& bytes, WebIDL::UnsignedLong pull_size);
diff --git a/Libraries/LibWeb/Internals/Internals.idl b/Libraries/LibWeb/Internals/Internals.idl
index cb9450b55d2..e36e1ecbdb2 100644
--- a/Libraries/LibWeb/Internals/Internals.idl
+++ b/Libraries/LibWeb/Internals/Internals.idl
@@ -399,7 +399,6 @@ interface Internals {
undefined setMediaElementSeeking(HTMLMediaElement element, boolean seeking);
// Closes this process's connection to its media server, which is what a media server crash looks like from here.
undefined disconnectMediaServer();
- undefined setPageMuted(boolean muted);
DOMString viewportOverflowX();
diff --git a/Libraries/LibWeb/Page/Page.cpp b/Libraries/LibWeb/Page/Page.cpp
index a6f4ecddd39..5e7a841168e 100644
--- a/Libraries/LibWeb/Page/Page.cpp
+++ b/Libraries/LibWeb/Page/Page.cpp
@@ -1831,18 +1831,6 @@ void Page::set_picture_in_picture_window_controls_in_use(bool in_use)
});
}
-void Page::set_page_mute_state(HTML::MuteState mute_state)
-{
- if (m_mute_state == mute_state)
- return;
-
- m_mute_state = mute_state;
-
- for_each_media_element([&](auto& media_element) {
- media_element.page_mute_state_changed({});
- });
-}
-
GC::Ptr<HTML::HTMLMediaElement> Page::media_context_menu_element()
{
if (!m_media_context_menu_element_id.has_value())
diff --git a/Libraries/LibWeb/Page/Page.h b/Libraries/LibWeb/Page/Page.h
index 1df5ad9aa42..439b04a21b7 100644
--- a/Libraries/LibWeb/Page/Page.h
+++ b/Libraries/LibWeb/Page/Page.h
@@ -420,9 +420,6 @@ public:
void toggle_media_controls_state();
void set_picture_in_picture_window_controls_in_use(bool);
- HTML::MuteState page_mute_state() const { return m_mute_state; }
- void set_page_mute_state(HTML::MuteState);
-
Optional<Utf16String> const& user_style() const { return m_user_style_sheet_source; }
void set_user_style(Utf16String source);
void invalidate_user_style();
@@ -597,8 +594,6 @@ private:
Vector<GC::Ref<HTML::OffscreenCanvas>> m_offscreen_canvases_pending_placeholder_commit;
Optional<UniqueNodeID> m_media_context_menu_element_id;
- Web::HTML::MuteState m_mute_state { Web::HTML::MuteState::Unmuted };
-
Optional<ContextMenuRequest> m_context_menu_request;
InputTraceRecorder m_input_trace;
Optional<Editing::ContextMenuMisspelling> m_context_menu_misspelling;
diff --git a/Libraries/LibWebView/ViewImplementation.cpp b/Libraries/LibWebView/ViewImplementation.cpp
index 869f17cf06f..5d93e1d3f1b 100644
--- a/Libraries/LibWebView/ViewImplementation.cpp
+++ b/Libraries/LibWebView/ViewImplementation.cpp
@@ -2628,7 +2628,9 @@ void ViewImplementation::insert_clipboard_item(Web::Clipboard::SystemClipboardIt
void ViewImplementation::toggle_page_mute_state()
{
m_mute_state = Web::HTML::invert_mute_state(m_mute_state);
- page().async_set_page_mute_state(m_mute_state);
+ traversable().for_each_hosting_page([&](WebContentPage& page) {
+ page.client().set_audio_playback_mute_state(page.id(), m_mute_state);
+ });
}
void ViewImplementation::did_change_audio_play_state(Badge<WebContentPage>, Web::HTML::AudioPlayState play_state)
@@ -3206,8 +3208,8 @@ void ViewImplementation::prepare_page_for_navigable(WebContentPage& page)
page.async_set_document_cookie_version_buffer(m_document_cookie_version_buffer);
if (m_debugger_is_attached)
page.async_attach_debugger();
- page.async_set_page_mute_state(m_mute_state);
- // The page's sound plays while it hosts the tab's documents.
+ // The page's sound plays while it hosts the tab's documents, unless the tab is muted.
+ page.client().set_audio_playback_mute_state(page.id(), m_mute_state);
page.client().authorize_audio_playback(page.id());
if (Application::browser_options().webdriver_browser_endpoint.has_value())
Application::the().push_webdriver_session_config(page);
diff --git a/Libraries/LibWebView/WebContentClient.cpp b/Libraries/LibWebView/WebContentClient.cpp
index eb69fa06b13..feba9c71807 100644
--- a/Libraries/LibWebView/WebContentClient.cpp
+++ b/Libraries/LibWebView/WebContentClient.cpp
@@ -917,6 +917,9 @@ ErrorOr<void> WebContentClient::initialize_audio_server_controller()
};
if (m_audio_capture_permitted)
TRY(tell_audio_server_of_capture_permission());
+ // A muted group is never heard: the mutes land before the authorizations.
+ for (auto group : m_muted_audio_playback_groups)
+ m_audio_server_client->async_mute_playback_group(m_audio_tab_id, group);
for (auto group : m_authorized_audio_playback_groups)
TRY(tell_audio_server_of_playback_authorization(group));
return {};
@@ -1006,6 +1009,31 @@ void WebContentClient::revoke_audio_playback(Web::PageId page_id)
m_audio_server_client->async_revoke_playback_group(m_audio_tab_id, group);
}
+void WebContentClient::set_audio_playback_mute_state(Web::PageId page_id, Web::HTML::MuteState mute_state)
+{
+ auto group = audio_playback_group(page_id);
+ switch (mute_state) {
+ case Web::HTML::MuteState::Muted:
+ if (m_muted_audio_playback_groups.set(group) != HashSetResult::InsertedNewEntry)
+ return;
+ if (m_audio_server_client && m_audio_server_client->is_open())
+ m_audio_server_client->async_mute_playback_group(m_audio_tab_id, group);
+ break;
+ case Web::HTML::MuteState::Unmuted:
+ if (!m_muted_audio_playback_groups.remove(group))
+ return;
+ if (m_audio_server_client && m_audio_server_client->is_open())
+ m_audio_server_client->async_unmute_playback_group(m_audio_tab_id, group);
+ break;
+ }
+}
+
+void WebContentClient::forget_audio_playback(Web::PageId page_id)
+{
+ revoke_audio_playback(page_id);
+ set_audio_playback_mute_state(page_id, Web::HTML::MuteState::Unmuted);
+}
+
ErrorOr<void> WebContentClient::tell_audio_server_of_playback_authorization(Audio::PlaybackGroupId group)
{
auto response = m_audio_server_client->send_sync_but_allow_failure<Messages::AudioServerControl::AuthorizePlaybackGroup>(m_audio_tab_id, group);
diff --git a/Libraries/LibWebView/WebContentClient.h b/Libraries/LibWebView/WebContentClient.h
index fc837ee17bd..d8601f7a7d1 100644
--- a/Libraries/LibWebView/WebContentClient.h
+++ b/Libraries/LibWebView/WebContentClient.h
@@ -36,6 +36,7 @@
#include <LibWebCommon/Gamepad/GamepadSnapshot.h>
#include <LibWebCommon/HTML/ActivateTab.h>
#include <LibWebCommon/HTML/ApplyHistoryStep.h>
+#include <LibWebCommon/HTML/AudioPlayState.h>
#include <LibWebCommon/HTML/CrossProcessId.h>
#include <LibWebCommon/HTML/FileFilter.h>
#include <LibWebCommon/HTML/HistoryHandlingBehavior.h>
@@ -164,6 +165,9 @@ public:
// before this returns, so a document the page goes on to run is heard from its start.
void authorize_audio_playback(Web::PageId);
void revoke_audio_playback(Web::PageId);
+ // Muting the page leaves its sound out whether or not it is authorized, and authorizes nothing.
+ void set_audio_playback_mute_state(Web::PageId, Web::HTML::MuteState);
+ void forget_audio_playback(Web::PageId);
void replay_compositor_view_state_after_reconnect(Badge<Application>);
void notify_compositor_process_reconnected(Badge<Application>);
Web::CompositorContextId compositor_context_id_for_page(WebContentPage const&);
@@ -266,8 +270,9 @@ private:
// again whenever it relaunches, and rules on nothing itself.
HashTable<String> m_audio_capture_grants;
bool m_audio_capture_permitted { false };
- // Likewise, the AudioServer is told again of the groups it may play.
+ // Likewise, the AudioServer is told again of the groups it may play, and of those the user has muted.
HashTable<Audio::PlaybackGroupId> m_authorized_audio_playback_groups;
+ HashTable<Audio::PlaybackGroupId> m_muted_audio_playback_groups;
RefPtr<Core::Timer> m_detached_page_close_timer;
static HashTable<WebContentClient*>& clients();
diff --git a/Libraries/LibWebView/WebContentPage.cpp b/Libraries/LibWebView/WebContentPage.cpp
index aa243eeeb38..92299cd90f7 100644
--- a/Libraries/LibWebView/WebContentPage.cpp
+++ b/Libraries/LibWebView/WebContentPage.cpp
@@ -647,7 +647,7 @@ void WebContentPage::close()
m_client->update_audio_capture_permission();
if (auto* bidi = WebDriverBiDi::the())
bidi->push_session_state_for_client(*m_client);
- m_client->revoke_audio_playback(m_id);
+ m_client->forget_audio_playback(m_id);
}
m_web_ui = nullptr;
auto owed_replies = move(m_owed_replies);
diff --git a/Services/AudioServer/AudioServerControl.ipc b/Services/AudioServer/AudioServerControl.ipc
index daae2cb7d69..d423aac14bd 100644
--- a/Services/AudioServer/AudioServerControl.ipc
+++ b/Services/AudioServer/AudioServerControl.ipc
@@ -19,4 +19,8 @@ endpoint AudioServerControl
// Authorizing is synchronous, so a group may play before a document of its page runs.
authorize_playback_group(u64 tab_id, Audio::PlaybackGroupId group) => ()
revoke_playback_group(u64 tab_id, Audio::PlaybackGroupId group) =|
+
+ // The playback groups the user has muted: their streams play into nothing, whether or not they are authorized.
+ mute_playback_group(u64 tab_id, Audio::PlaybackGroupId group) =|
+ unmute_playback_group(u64 tab_id, Audio::PlaybackGroupId group) =|
}
diff --git a/Services/AudioServer/ControlConnection.cpp b/Services/AudioServer/ControlConnection.cpp
index 68b22a5f327..f129d5bdd24 100644
--- a/Services/AudioServer/ControlConnection.cpp
+++ b/Services/AudioServer/ControlConnection.cpp
@@ -52,4 +52,14 @@ void ControlConnection::revoke_playback_group(u64 tab_id, Audio::PlaybackGroupId
Tabs::the().set_playback_group_authorization(tab_id, group, Audio::PlaybackGroupAuthorization::Unauthorized);
}
+void ControlConnection::mute_playback_group(u64 tab_id, Audio::PlaybackGroupId group)
+{
+ Tabs::the().set_playback_group_mute_state(tab_id, group, Audio::PlaybackGroupMuteState::Muted);
+}
+
+void ControlConnection::unmute_playback_group(u64 tab_id, Audio::PlaybackGroupId group)
+{
+ Tabs::the().set_playback_group_mute_state(tab_id, group, Audio::PlaybackGroupMuteState::Unmuted);
+}
+
}
diff --git a/Services/AudioServer/ControlConnection.h b/Services/AudioServer/ControlConnection.h
index afadccecb61..10853289972 100644
--- a/Services/AudioServer/ControlConnection.h
+++ b/Services/AudioServer/ControlConnection.h
@@ -31,6 +31,8 @@ private:
virtual void capture_decided(u64 request_id, bool allowed) override;
virtual void authorize_playback_group(u64 tab_id, Audio::PlaybackGroupId group) override;
virtual void revoke_playback_group(u64 tab_id, Audio::PlaybackGroupId group) override;
+ virtual void mute_playback_group(u64 tab_id, Audio::PlaybackGroupId group) override;
+ virtual void unmute_playback_group(u64 tab_id, Audio::PlaybackGroupId group) override;
};
}
diff --git a/Services/AudioServer/PlaybackStreamMixer.cpp b/Services/AudioServer/PlaybackStreamMixer.cpp
index a0cc2cdd8a1..7935343186d 100644
--- a/Services/AudioServer/PlaybackStreamMixer.cpp
+++ b/Services/AudioServer/PlaybackStreamMixer.cpp
@@ -107,6 +107,19 @@ void PlaybackStreamMixer::set_group_authorization(PlaybackGroupId group, Playbac
}
}
+void PlaybackStreamMixer::set_group_mute_state(PlaybackGroupId group, PlaybackGroupMuteState mute_state)
+{
+ MutexLocker locker(m_state->m_mutex);
+ switch (mute_state) {
+ case PlaybackGroupMuteState::Muted:
+ m_state->m_muted_groups.set(group);
+ break;
+ case PlaybackGroupMuteState::Unmuted:
+ m_state->m_muted_groups.remove(group);
+ break;
+ }
+}
+
void PlaybackStreamMixer::remove_client(MixerClientId id)
{
bool was_active = false;
@@ -271,8 +284,8 @@ ReadonlySpan<float> PlaybackStreamMixer::MixState::mix_into(Span<float> buffer,
for (auto& [id, client] : m_clients) {
if (client.state == ClientState::Suspended || client.state == ClientState::Drained)
continue;
- auto is_authorized = client.group.has_value() && m_authorized_groups.contains(*client.group);
- auto consumed_frames = is_authorized
+ auto is_heard = client.group.has_value() && m_authorized_groups.contains(*client.group) && !m_muted_groups.contains(*client.group);
+ auto consumed_frames = is_heard
? client.ring.pop_mixing_into(buffer, client.gain)
: client.ring.discard(buffer.size() / client.ring.channel_count());
if (consumed_frames > 0)
diff --git a/Services/AudioServer/PlaybackStreamMixer.h b/Services/AudioServer/PlaybackStreamMixer.h
index 0439d4fec34..8b34c4c0d6d 100644
--- a/Services/AudioServer/PlaybackStreamMixer.h
+++ b/Services/AudioServer/PlaybackStreamMixer.h
@@ -28,6 +28,11 @@ enum class PlaybackGroupAuthorization : u8 {
Authorized,
};
+enum class PlaybackGroupMuteState : u8 {
+ Unmuted,
+ Muted,
+};
+
// Mixes the shared rings of one tab's client streams into one output device stream, which plays only while some
// client is playing or draining.
class PlaybackStreamMixer : public AtomicRefCounted<PlaybackStreamMixer> {
@@ -44,11 +49,12 @@ public:
Optional<SampleSpecification> const& device_sample_specification() const { return m_device_sample_specification; }
u32 device_target_latency_ms() const { return m_device_target_latency_ms; }
- // Control thread. Rings must be in the device format. A client is mixed only while its group is authorized; until
- // then, and while it has no group, its frames are consumed into nothing.
+ // Control thread. Rings must be in the device format. A client is mixed only while its group is authorized and
+ // unmuted; otherwise, and while it has no group, its frames are consumed into nothing.
void add_client(MixerClientId, SharedAudioFrameRing, float gain, Optional<PlaybackGroupId>);
void set_client_group(MixerClientId, Optional<PlaybackGroupId>);
void set_group_authorization(PlaybackGroupId, PlaybackGroupAuthorization);
+ void set_group_mute_state(PlaybackGroupId, PlaybackGroupMuteState);
void remove_client(MixerClientId);
void resume_client(MixerClientId);
// on_drained runs on the control thread once the ring has played out, or at once if the drain is made moot.
@@ -95,6 +101,7 @@ private:
Mutex m_mutex;
HashMap<MixerClientId, Client> m_clients;
HashTable<PlaybackGroupId> m_authorized_groups;
+ HashTable<PlaybackGroupId> m_muted_groups;
};
PlaybackStreamMixer(NonnullRefPtr<MixState>, u32 device_target_latency_ms);
diff --git a/Services/AudioServer/Tabs.cpp b/Services/AudioServer/Tabs.cpp
index 68f5cb1bb81..f015ee679ec 100644
--- a/Services/AudioServer/Tabs.cpp
+++ b/Services/AudioServer/Tabs.cpp
@@ -79,6 +79,10 @@ Tabs::Tab& Tabs::tab_for(u64 tab_id)
for (auto group : *authorized_groups)
mixer->set_group_authorization(group, Audio::PlaybackGroupAuthorization::Authorized);
}
+ if (auto muted_groups = m_muted_playback_groups.get(tab_id); muted_groups.has_value()) {
+ for (auto group : *muted_groups)
+ mixer->set_group_mute_state(group, Audio::PlaybackGroupMuteState::Muted);
+ }
return Tab { .mixer = move(mixer), .connections = {} };
});
}
@@ -129,6 +133,16 @@ void Tabs::set_capture_permission(u64 tab_id, bool granted)
connection->set_capture_permitted(granted);
}
+static void remove_group(HashMap<u64, HashTable<Audio::PlaybackGroupId>>& groups_by_tab, u64 tab_id, Audio::PlaybackGroupId group)
+{
+ auto groups = groups_by_tab.get(tab_id);
+ if (!groups.has_value())
+ return;
+ groups->remove(group);
+ if (groups->is_empty())
+ groups_by_tab.remove(tab_id);
+}
+
void Tabs::set_playback_group_authorization(u64 tab_id, Audio::PlaybackGroupId group, Audio::PlaybackGroupAuthorization authorization)
{
switch (authorization) {
@@ -136,17 +150,27 @@ void Tabs::set_playback_group_authorization(u64 tab_id, Audio::PlaybackGroupId g
m_authorized_playback_groups.ensure(tab_id).set(group);
break;
case Audio::PlaybackGroupAuthorization::Unauthorized:
- if (auto authorized_groups = m_authorized_playback_groups.get(tab_id); authorized_groups.has_value()) {
- authorized_groups->remove(group);
- if (authorized_groups->is_empty())
- m_authorized_playback_groups.remove(tab_id);
- }
+ remove_group(m_authorized_playback_groups, tab_id, group);
break;
}
if (auto tab = m_tabs.get(tab_id); tab.has_value())
tab->mixer->set_group_authorization(group, authorization);
}
+void Tabs::set_playback_group_mute_state(u64 tab_id, Audio::PlaybackGroupId group, Audio::PlaybackGroupMuteState mute_state)
+{
+ switch (mute_state) {
+ case Audio::PlaybackGroupMuteState::Muted:
+ m_muted_playback_groups.ensure(tab_id).set(group);
+ break;
+ case Audio::PlaybackGroupMuteState::Unmuted:
+ remove_group(m_muted_playback_groups, tab_id, group);
+ break;
+ }
+ if (auto tab = m_tabs.get(tab_id); tab.has_value())
+ tab->mixer->set_group_mute_state(group, mute_state);
+}
+
void Tabs::request_capture_permission(u64 tab_id, ByteString const& device_id, Function<void(bool)> on_decided)
{
auto control_connection = m_control_connection.strong_ref();
diff --git a/Services/AudioServer/Tabs.h b/Services/AudioServer/Tabs.h
index ad8fb94c734..d84cb55afb0 100644
--- a/Services/AudioServer/Tabs.h
+++ b/Services/AudioServer/Tabs.h
@@ -25,7 +25,7 @@ namespace AudioServer {
class ControlConnection;
// The tabs with connected client processes: each has a mixer, and the Browser's word on whether its pages hold the
-// microphone permission and on which playback groups may play.
+// microphone permission, on which playback groups may play, and on which the user has muted.
class Tabs {
public:
static Tabs& the();
@@ -41,9 +41,10 @@ public:
// it, and the capture streams they have are closed without it.
void set_capture_permission(u64 tab_id, bool granted);
void capture_decided(u64 request_id, bool allowed);
- // Whether the tab's streams of the group may play. It holds for the tab's clients, present and future, since a
- // client can reconnect while the Browser's word stands.
+ // Whether the tab's streams of the group may play, and whether the user has muted them. Both hold for the tab's
+ // clients, present and future, since a client can reconnect while the Browser's word stands.
void set_playback_group_authorization(u64 tab_id, Audio::PlaybackGroupId, Audio::PlaybackGroupAuthorization);
+ void set_playback_group_mute_state(u64 tab_id, Audio::PlaybackGroupId, Audio::PlaybackGroupMuteState);
private:
struct Tab {
@@ -59,6 +60,7 @@ private:
HashMap<u64, Tab> m_tabs;
HashTable<u64> m_tabs_with_capture_permission;
HashMap<u64, HashTable<Audio::PlaybackGroupId>> m_authorized_playback_groups;
+ HashMap<u64, HashTable<Audio::PlaybackGroupId>> m_muted_playback_groups;
RefPtr<Audio::CaptureDevices> m_capture_devices;
int m_next_client_id { 1 };
Audio::AudioOutput m_audio_output { Audio::AudioOutput::Platform };
diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp
index 28942f95a12..166908438d5 100644
--- a/Services/WebContent/ConnectionFromClient.cpp
+++ b/Services/WebContent/ConnectionFromClient.cpp
@@ -3512,12 +3512,6 @@ void ConnectionFromClient::toggle_media_controls_state(Web::PageId page_id)
page->page().toggle_media_controls_state();
}
-void ConnectionFromClient::set_page_mute_state(Web::PageId page_id, Web::HTML::MuteState mute_state)
-{
- if (auto page = this->page(page_id); page.has_value())
- page->page().set_page_mute_state(mute_state);
-}
-
void ConnectionFromClient::system_time_zone_changed()
{
JS::clear_system_time_zone_cache();
diff --git a/Services/WebContent/ConnectionFromClient.h b/Services/WebContent/ConnectionFromClient.h
index e7e653d33c7..3666f54bb4c 100644
--- a/Services/WebContent/ConnectionFromClient.h
+++ b/Services/WebContent/ConnectionFromClient.h
@@ -300,8 +300,6 @@ private:
virtual void toggle_media_picture_in_picture_state(Web::PageId page_id) override;
virtual void toggle_media_controls_state(Web::PageId page_id) override;
- virtual void set_page_mute_state(Web::PageId page_id, Web::HTML::MuteState mute_state) override;
-
virtual void take_document_screenshot(Web::PageId page_id) override;
virtual void take_dom_node_screenshot(Web::PageId page_id, Web::UniqueNodeID node_id) override;
diff --git a/Services/WebContent/WebContentServer.ipc b/Services/WebContent/WebContentServer.ipc
index 567ab05616c..9889339c7ae 100644
--- a/Services/WebContent/WebContentServer.ipc
+++ b/Services/WebContent/WebContentServer.ipc
@@ -18,7 +18,6 @@
#include <LibWebCommon/Gamepad/GamepadSnapshot.h>
#include <LibWebCommon/Gamepad/GamepadStateBuffer.h>
#include <LibWebCommon/HTML/ApplyHistoryStep.h>
-#include <LibWebCommon/HTML/AudioPlayState.h>
#include <LibWebCommon/HTML/AutoplayPolicy.h>
#include <LibWebCommon/HTML/BroadcastChannelMessage.h>
#include <LibWebCommon/HTML/ColorPickerUpdateState.h>
@@ -305,8 +304,6 @@ endpoint WebContentServer routed by Web::PageId page_id
toggle_media_picture_in_picture_state(Web::PageId page_id) =|
toggle_media_controls_state(Web::PageId page_id) =|
- set_page_mute_state(Web::PageId page_id, Web::HTML::MuteState mute_state) =|
-
system_time_zone_changed() =|
set_system_font_family(String family) =|
diff --git a/Tests/AudioServer/TestPlaybackStreamMixer.cpp b/Tests/AudioServer/TestPlaybackStreamMixer.cpp
index 4d21ab37709..94c81deb35c 100644
--- a/Tests/AudioServer/TestPlaybackStreamMixer.cpp
+++ b/Tests/AudioServer/TestPlaybackStreamMixer.cpp
@@ -147,6 +147,41 @@ TEST_CASE(a_client_moved_to_another_group_is_heard_as_part_of_it)
fixture.expect_render_of(32, 0.0f);
}
+TEST_CASE(a_muted_group_is_consumed_into_silence_until_it_is_unmuted)
+{
+ MixerFixture fixture;
+ auto client = fixture.add_client(1);
+ EXPECT_EQ(client.try_push(constant_frames(64, 1.0f)), 64u);
+ fixture.mixer->resume_client(1);
+
+ fixture.mixer->set_group_mute_state(AUTHORIZED_GROUP, Audio::PlaybackGroupMuteState::Muted);
+ fixture.expect_render_of(32, 0.0f);
+ EXPECT_EQ(client.frames_free(), 1024u - 32u);
+ fixture.mixer->set_group_mute_state(AUTHORIZED_GROUP, Audio::PlaybackGroupMuteState::Unmuted);
+ fixture.expect_render_of(32, 1.0f);
+}
+
+TEST_CASE(muting_and_authorizing_a_group_are_independent)
+{
+ MixerFixture fixture;
+ auto client = fixture.add_client(1, 1.0f, OTHER_GROUP);
+ EXPECT_EQ(client.try_push(constant_frames(128, 1.0f)), 128u);
+ fixture.mixer->resume_client(1);
+
+ // Authorizing a muted group leaves it muted.
+ fixture.mixer->set_group_mute_state(OTHER_GROUP, Audio::PlaybackGroupMuteState::Muted);
+ fixture.mixer->set_group_authorization(OTHER_GROUP, Audio::PlaybackGroupAuthorization::Authorized);
+ fixture.expect_render_of(32, 0.0f);
+ fixture.mixer->set_group_mute_state(OTHER_GROUP, Audio::PlaybackGroupMuteState::Unmuted);
+ fixture.expect_render_of(32, 1.0f);
+
+ // Unmuting a revoked group leaves it unauthorized.
+ fixture.mixer->set_group_authorization(OTHER_GROUP, Audio::PlaybackGroupAuthorization::Unauthorized);
+ fixture.mixer->set_group_mute_state(OTHER_GROUP, Audio::PlaybackGroupMuteState::Muted);
+ fixture.mixer->set_group_mute_state(OTHER_GROUP, Audio::PlaybackGroupMuteState::Unmuted);
+ fixture.expect_render_of(32, 0.0f);
+}
+
TEST_CASE(suspended_clients_are_not_consumed)
{
MixerFixture fixture;
diff --git a/Tests/LibWeb/Text/expected/HTML/HTMLMediaElement-audio-play-state.txt b/Tests/LibWeb/Text/expected/HTML/HTMLMediaElement-audio-play-state.txt
index 325cebc9812..74d351927e5 100644
--- a/Tests/LibWeb/Text/expected/HTML/HTMLMediaElement-audio-play-state.txt
+++ b/Tests/LibWeb/Text/expected/HTML/HTMLMediaElement-audio-play-state.txt
@@ -2,8 +2,6 @@ muted playback reported as playing audio: false
unmuted playback reported as playing audio: true
zero-volume playback reported as playing audio: false
nonzero-volume playback reported as playing audio: true
-playback in a muted page reported as playing audio: false
-playback in an unmuted page reported as playing audio: true
playback without an enabled audio track reported as playing audio: false
playback with an enabled audio track reported as playing audio: true
playback after adoption reported as playing audio: true
diff --git a/Tests/LibWeb/Text/input/HTML/HTMLMediaElement-audio-play-state.html b/Tests/LibWeb/Text/input/HTML/HTMLMediaElement-audio-play-state.html
index 62202b75a2a..c8073d31543 100644
--- a/Tests/LibWeb/Text/input/HTML/HTMLMediaElement-audio-play-state.html
+++ b/Tests/LibWeb/Text/input/HTML/HTMLMediaElement-audio-play-state.html
@@ -19,12 +19,6 @@
video.volume = 0.5;
println(`nonzero-volume playback reported as playing audio: ${internals.mediaElementIsPlayingAudio(video)}`);
- internals.setPageMuted(true);
- println(`playback in a muted page reported as playing audio: ${internals.mediaElementIsPlayingAudio(video)}`);
-
- internals.setPageMuted(false);
- println(`playback in an unmuted page reported as playing audio: ${internals.mediaElementIsPlayingAudio(video)}`);
-
video.audioTracks[0].enabled = false;
println(`playback without an enabled audio track reported as playing audio: ${internals.mediaElementIsPlayingAudio(video)}`);