diff --git a/Cargo.lock b/Cargo.lock index 9ee8049ee456..f2641e3b015d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2020,7 +2020,6 @@ dependencies = [ "log", "mapped_hyph", "mdns_service", - "midir", "midir_impl", "mozurl", "mp4parse_capi", diff --git a/dom/midi/MIDIPlatformService.cpp b/dom/midi/MIDIPlatformService.cpp index 8a9090d30d53..32d6de6927cc 100644 --- a/dom/midi/MIDIPlatformService.cpp +++ b/dom/midi/MIDIPlatformService.cpp @@ -7,9 +7,9 @@ #include "MIDIPlatformService.h" #include "MIDIMessageQueue.h" #include "TestMIDIPlatformService.h" -#ifndef MOZ_WIDGET_ANDROID +#ifdef MOZ_WEBMIDI_MIDIR_IMPL # include "midirMIDIPlatformService.h" -#endif // MOZ_WIDGET_ANDROID +#endif // MOZ_WEBMIDI_MIDIR_IMPL #include "mozilla/ErrorResult.h" #include "mozilla/StaticPrefs_midi.h" #include "mozilla/StaticPtr.h" @@ -185,11 +185,11 @@ MIDIPlatformService* MIDIPlatformService::Get() { if (StaticPrefs::midi_testing()) { gMIDIPlatformService = new TestMIDIPlatformService(); } -#ifndef MOZ_WIDGET_ANDROID +#ifdef MOZ_WEBMIDI_MIDIR_IMPL else { gMIDIPlatformService = new midirMIDIPlatformService(); } -#endif // MOZ_WIDGET_ANDROID +#endif // MOZ_WEBMIDI_MIDIR_IMPL gMIDIPlatformService->Init(); } return gMIDIPlatformService; diff --git a/dom/midi/moz.build b/dom/midi/moz.build index 8a3ad035f1fd..50468070697b 100644 --- a/dom/midi/moz.build +++ b/dom/midi/moz.build @@ -4,9 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -if CONFIG["OS_TARGET"] != "Android": - DIRS += ["midir_impl"] - IPDL_SOURCES += [ "MIDITypes.ipdlh", "PMIDIManager.ipdl", @@ -58,16 +55,17 @@ UNIFIED_SOURCES += [ include("/ipc/chromium/chromium-config.mozbuild") -if CONFIG["OS_TARGET"] == "Linux": - OS_LIBS += ["asound"] # Required by midir - UNIFIED_SOURCES += ["AlsaCompatibility.cpp"] - - -if CONFIG["OS_TARGET"] != "Android": +if CONFIG["MOZ_WEBMIDI_MIDIR_IMPL"]: + DEFINES["MOZ_WEBMIDI_MIDIR_IMPL"] = True + DIRS += ["midir_impl"] UNIFIED_SOURCES += [ "midirMIDIPlatformService.cpp", ] + if CONFIG["OS_TARGET"] == "Linux": + OS_LIBS += ["asound"] # Required by midir + UNIFIED_SOURCES += ["AlsaCompatibility.cpp"] + FINAL_LIBRARY = "xul" LOCAL_INCLUDES += [ "/dom/base", diff --git a/toolkit/library/gtest/rust/Cargo.toml b/toolkit/library/gtest/rust/Cargo.toml index a5680b51e0eb..31faa1f22c1e 100644 --- a/toolkit/library/gtest/rust/Cargo.toml +++ b/toolkit/library/gtest/rust/Cargo.toml @@ -31,6 +31,7 @@ glean_with_gecko = ["gkrust-shared/glean_with_gecko"] with_dbus = ["gkrust-shared/with_dbus"] thread_sanitizer = ["gkrust-shared/thread_sanitizer"] oxidized_breakpad = ["gkrust-shared/oxidized_breakpad"] +webmidi_midir_impl = ["gkrust-shared/webmidi_midir_impl"] [dependencies] bench-collections-gtest = { path = "../../../../xpcom/rust/gtest/bench-collections" } diff --git a/toolkit/library/rust/Cargo.toml b/toolkit/library/rust/Cargo.toml index fa7afecc0c4e..54e015ab2387 100644 --- a/toolkit/library/rust/Cargo.toml +++ b/toolkit/library/rust/Cargo.toml @@ -31,6 +31,7 @@ glean_with_gecko = ["gkrust-shared/glean_with_gecko"] with_dbus = ["gkrust-shared/with_dbus"] thread_sanitizer = ["gkrust-shared/thread_sanitizer"] oxidized_breakpad = ["gkrust-shared/oxidized_breakpad"] +webmidi_midir_impl = ["gkrust-shared/webmidi_midir_impl"] [dependencies] gkrust-shared = { path = "shared" } diff --git a/toolkit/library/rust/gkrust-features.mozbuild b/toolkit/library/rust/gkrust-features.mozbuild index bd78deab1a0f..ed8b40817e16 100644 --- a/toolkit/library/rust/gkrust-features.mozbuild +++ b/toolkit/library/rust/gkrust-features.mozbuild @@ -81,3 +81,6 @@ if CONFIG['MOZ_ENABLE_DBUS']: if CONFIG["MOZ_CRASHREPORTER"] and CONFIG['MOZ_OXIDIZED_BREAKPAD']: gkrust_features += ['oxidized_breakpad'] + +if CONFIG["MOZ_WEBMIDI_MIDIR_IMPL"]: + gkrust_features += ['webmidi_midir_impl'] diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml index 33423f3f2ac3..59c5776542af 100644 --- a/toolkit/library/rust/shared/Cargo.toml +++ b/toolkit/library/rust/shared/Cargo.toml @@ -52,6 +52,7 @@ fluent-langneg = { version = "0.13", features = ["cldr"] } fluent-langneg-ffi = { path = "../../../../intl/locale/rust/fluent-langneg-ffi" } rust_minidump_writer_linux = { path = "../../../crashreporter/rust_minidump_writer_linux", optional = true } gecko-profiler = { path = "../../../../tools/profiler/rust-api"} +midir_impl = { path = "../../../../dom/midi/midir_impl", optional = true } # Note: `modern_sqlite` means rusqlite's bindings file be for a sqlite with # version less than or equal to what we link to. This isn't a problem because we @@ -72,8 +73,6 @@ qcms = { path = "../../../../gfx/qcms", features = ["c_bindings", "neon"], defau [target.'cfg(not(target_os = "android"))'.dependencies] viaduct = { git = "https://github.com/mozilla/application-services", rev = "c51b63595a27a6ef45161012323e0261475c10c9"} webext_storage_bridge = { path = "../../../components/extensions/storage/webext_storage_bridge" } -midir = { git = "https://github.com/mozilla/midir.git", rev = "dc87afbd4361ae5ec192e1fab0a6409dd13d4011" } -midir_impl = { path = "../../../../dom/midi/midir_impl" } # https://github.com/mozilla/audioipc-2/commits/master [target.'cfg(not(target_os = "macos"))'.dependencies] @@ -110,6 +109,7 @@ glean_with_gecko = ["fog_control/with_gecko"] oxidized_breakpad = ["rust_minidump_writer_linux"] with_dbus = ["audio_thread_priority/with_dbus"] thread_sanitizer = ["xpcom/thread_sanitizer"] +webmidi_midir_impl = ["midir_impl"] [lib] path = "lib.rs" diff --git a/toolkit/library/rust/shared/lib.rs b/toolkit/library/rust/shared/lib.rs index bd30d79be3b0..a8c24af863d2 100644 --- a/toolkit/library/rust/shared/lib.rs +++ b/toolkit/library/rust/shared/lib.rs @@ -79,17 +79,14 @@ extern crate localization_ffi; #[cfg(not(target_os = "android"))] extern crate viaduct; -#[cfg(not(target_os = "android"))] -extern crate midir; - -#[cfg(not(target_os = "android"))] -extern crate midir_impl; - extern crate gecko_logger; #[cfg(feature = "oxidized_breakpad")] extern crate rust_minidump_writer_linux; +#[cfg(feature = "webmidi_midir_impl")] +extern crate midir_impl; + extern crate log; use log::info; diff --git a/toolkit/moz.configure b/toolkit/moz.configure index 47aecc2da8f2..736ccdfb8923 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -169,22 +169,32 @@ imply_option("--enable-profiling", dmd) imply_option("--enable-jemalloc", dmd, when=compile_environment) imply_option("--enable-replace-malloc", dmd, when=compile_environment) -# ALSA cubeb backend +# midir-based Web MIDI support # ============================================================== @depends(target) -def alsa_default_check(target): +def midir_linux_support(target): return target.kernel == "Linux" and target.os != "Android" +@depends(target, midir_linux_support) +def midir_support(target, midir_linux_support): + if target.os in ("WINNT", "OSX") or midir_linux_support: + return True + + +set_config("MOZ_WEBMIDI_MIDIR_IMPL", midir_support) + +# ALSA cubeb backend +# ============================================================== option("--enable-alsa", env="MOZ_ALSA", help="Enable ALSA audio backend.") -@depends("--enable-alsa", alsa_default_check) -def enable_alsa_or_alsa_default_check(alsa_enabled, alsa_default_check): - return alsa_enabled or alsa_default_check +@depends("--enable-alsa", midir_linux_support) +def enable_alsa_or_midir_linux_support(alsa_enabled, midir_linux_support): + return alsa_enabled or midir_linux_support -pkg_check_modules("MOZ_ALSA", "alsa", when=enable_alsa_or_alsa_default_check) +pkg_check_modules("MOZ_ALSA", "alsa", when=enable_alsa_or_midir_linux_support) set_config("MOZ_ALSA", True, when="--enable-alsa") set_define("MOZ_ALSA", True, when="--enable-alsa")