diff options
author | Moonchild <moonchild@palemoon.org> | 2021-04-30 21:22:08 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-04-30 21:22:08 +0000 |
commit | 0dd3424f774954627d6f53df9fb47379d9b5c871 (patch) | |
tree | d8c303bac59a5bbbbc6c6f5e541a01dec1a5ae49 /dom/media | |
parent | 5e705bd5059da5b7a39e3a096b7c7f59cb466730 (diff) | |
download | uxp-0dd3424f774954627d6f53df9fb47379d9b5c871.tar.gz |
Issue #1751 -- Remove XP_MACOSX conditionals from /dom
Diffstat (limited to 'dom/media')
-rw-r--r-- | dom/media/GraphDriver.cpp | 82 | ||||
-rw-r--r-- | dom/media/GraphDriver.h | 5 | ||||
-rw-r--r-- | dom/media/eme/MediaKeySystemAccessManager.cpp | 3 | ||||
-rw-r--r-- | dom/media/gmp/GMPChild.cpp | 6 | ||||
-rw-r--r-- | dom/media/gmp/rlz/GMPDeviceBinding.cpp | 48 | ||||
-rw-r--r-- | dom/media/systemservices/LoadMonitor.cpp | 27 | ||||
-rwxr-xr-x | dom/media/webaudio/AudioContext.cpp | 2 | ||||
-rw-r--r-- | dom/media/webrtc/MediaEngineCameraVideoSource.cpp | 7 |
8 files changed, 2 insertions, 178 deletions
diff --git a/dom/media/GraphDriver.cpp b/dom/media/GraphDriver.cpp index e8b71a2318..90680d8c69 100644 --- a/dom/media/GraphDriver.cpp +++ b/dom/media/GraphDriver.cpp @@ -14,10 +14,6 @@ #include "webrtc/MediaEngineWebRTC.h" #endif -#ifdef XP_MACOSX -#include <sys/sysctl.h> -#endif - extern mozilla::LazyLogModule gMediaStreamGraphLog; #define STREAM_LOG(type, msg) MOZ_LOG(gMediaStreamGraphLog, type, msg) @@ -586,32 +582,6 @@ AudioCallbackDriver::~AudioCallbackDriver() MOZ_ASSERT(mPromisesForOperation.IsEmpty()); } -bool IsMacbookOrMacbookAir() -{ -#ifdef XP_MACOSX - size_t len = 0; - sysctlbyname("hw.model", NULL, &len, NULL, 0); - if (len) { - UniquePtr<char[]> model(new char[len]); - // This string can be - // MacBook%d,%d for a normal MacBook - // MacBookPro%d,%d for a MacBook Pro - // MacBookAir%d,%d for a Macbook Air - sysctlbyname("hw.model", model.get(), &len, NULL, 0); - char* substring = strstr(model.get(), "MacBook"); - if (substring) { - const size_t offset = strlen("MacBook"); - if (strncmp(model.get() + offset, "Air", len - offset) || - isdigit(model[offset + 1])) { - return true; - } - } - return false; - } -#endif - return false; -} - void AudioCallbackDriver::Init() { @@ -648,13 +618,6 @@ AudioCallbackDriver::Init() } } - // Macbook and MacBook air don't have enough CPU to run very low latency - // MediaStreamGraphs, cap the minimal latency to 512 frames int this case. - if (IsMacbookOrMacbookAir()) { - latency_frames = std::max((uint32_t) 512, latency_frames); - } - - input = output; input.channels = mInputChannels; // change to support optional stereo capture @@ -1068,44 +1031,6 @@ AudioCallbackDriver::MixerCallback(AudioDataValue* aMixedBuffer, NS_WARNING_ASSERTION(written == aFrames - toWrite, "Dropping frames."); }; -void AudioCallbackDriver::PanOutputIfNeeded(bool aMicrophoneActive) -{ -#ifdef XP_MACOSX - cubeb_device* out; - int rv; - char name[128]; - size_t length = sizeof(name); - - rv = sysctlbyname("hw.model", name, &length, NULL, 0); - if (rv) { - return; - } - - if (!strncmp(name, "MacBookPro", 10)) { - if (cubeb_stream_get_current_device(mAudioStream, &out) == CUBEB_OK) { - // Check if we are currently outputing sound on external speakers. - if (!strcmp(out->output_name, "ispk")) { - // Pan everything to the right speaker. - if (aMicrophoneActive) { - if (cubeb_stream_set_panning(mAudioStream, 1.0) != CUBEB_OK) { - NS_WARNING("Could not pan audio output to the right."); - } - } else { - if (cubeb_stream_set_panning(mAudioStream, 0.0) != CUBEB_OK) { - NS_WARNING("Could not pan audio output to the center."); - } - } - } else { - if (cubeb_stream_set_panning(mAudioStream, 0.0) != CUBEB_OK) { - NS_WARNING("Could not pan audio output to the center."); - } - } - cubeb_stream_device_destroy(mAudioStream, out); - } - } -#endif -} - void AudioCallbackDriver::DeviceChangedCallback() { // Tell the audio engine the device has changed, it might want to reset some @@ -1114,9 +1039,6 @@ AudioCallbackDriver::DeviceChangedCallback() { if (mAudioInput) { mAudioInput->DeviceChanged(); } -#ifdef XP_MACOSX - PanOutputIfNeeded(mMicrophoneActive); -#endif } void @@ -1125,10 +1047,6 @@ AudioCallbackDriver::SetMicrophoneActive(bool aActive) MonitorAutoLock mon(mGraphImpl->GetMonitor()); mMicrophoneActive = aActive; - -#ifdef XP_MACOSX - PanOutputIfNeeded(mMicrophoneActive); -#endif } uint32_t diff --git a/dom/media/GraphDriver.h b/dom/media/GraphDriver.h index bb4f2689b8..f2a514b328 100644 --- a/dom/media/GraphDriver.h +++ b/dom/media/GraphDriver.h @@ -457,11 +457,6 @@ public: void CompleteAudioContextOperations(AsyncCubebOperation aOperation); private: /** - * On certain MacBookPro, the microphone is located near the left speaker. - * We need to pan the sound output to the right speaker if we are using the - * mic and the built-in speaker, or we will have terrible echo. */ - void PanOutputIfNeeded(bool aMicrophoneActive); - /** * This is called when the output device used by the cubeb stream changes. */ void DeviceChangedCallback(); /* Start the cubeb stream */ diff --git a/dom/media/eme/MediaKeySystemAccessManager.cpp b/dom/media/eme/MediaKeySystemAccessManager.cpp index ed31059e22..a1e1254ad4 100644 --- a/dom/media/eme/MediaKeySystemAccessManager.cpp +++ b/dom/media/eme/MediaKeySystemAccessManager.cpp @@ -14,9 +14,6 @@ #ifdef XP_WIN #include "mozilla/WindowsVersion.h" #endif -#ifdef XP_MACOSX -#include "nsCocoaFeatures.h" -#endif #include "nsPrintfCString.h" namespace mozilla { diff --git a/dom/media/gmp/GMPChild.cpp b/dom/media/gmp/GMPChild.cpp index fa6f2f4c83..eb18037364 100644 --- a/dom/media/gmp/GMPChild.cpp +++ b/dom/media/gmp/GMPChild.cpp @@ -112,14 +112,12 @@ GetPluginFile(const nsAString& aPluginPath, nsAutoString baseName; GetFileBase(aPluginPath, aLibDirectory, aLibFile, baseName); -#if defined(XP_MACOSX) - nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".dylib"); -#elif defined(OS_POSIX) +#if defined(OS_POSIX) nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".so"); #elif defined(XP_WIN) nsAutoString binaryName = baseName + NS_LITERAL_STRING(".dll"); #else -#error not defined +#error Unsupported O.S. #endif aLibFile->AppendRelativePath(binaryName); return true; diff --git a/dom/media/gmp/rlz/GMPDeviceBinding.cpp b/dom/media/gmp/rlz/GMPDeviceBinding.cpp index 04def8e8e0..0871d2e4ee 100644 --- a/dom/media/gmp/rlz/GMPDeviceBinding.cpp +++ b/dom/media/gmp/rlz/GMPDeviceBinding.cpp @@ -32,14 +32,6 @@ #include "windows.h" #endif -#ifdef XP_MACOSX -#include <assert.h> -#ifdef HASH_NODE_ID_WITH_DEVICE_ID -#include <unistd.h> -#include <mach/mach.h> -#include <mach/mach_vm.h> -#endif -#endif #endif // HASH_NODE_ID_WITH_DEVICE_ID @@ -83,46 +75,6 @@ GetStackAfterCurrentFrame(uint8_t** aOutTop, uint8_t** aOutBottom) } #endif -#if defined(XP_MACOSX) && defined(HASH_NODE_ID_WITH_DEVICE_ID) -static mach_vm_address_t -RegionContainingAddress(mach_vm_address_t aAddress) -{ - mach_port_t task; - kern_return_t kr = task_for_pid(mach_task_self(), getpid(), &task); - if (kr != KERN_SUCCESS) { - return 0; - } - - mach_vm_address_t address = aAddress; - mach_vm_size_t size; - vm_region_basic_info_data_64_t info; - mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64; - mach_port_t object_name; - kr = mach_vm_region(task, &address, &size, VM_REGION_BASIC_INFO_64, - reinterpret_cast<vm_region_info_t>(&info), &count, - &object_name); - if (kr != KERN_SUCCESS || size == 0 - || address > aAddress || address + size <= aAddress) { - // mach_vm_region failed, or couldn't find region at given address. - return 0; - } - - return address; -} - -MOZ_NEVER_INLINE -static bool -GetStackAfterCurrentFrame(uint8_t** aOutTop, uint8_t** aOutBottom) -{ - mach_vm_address_t stackFrame = - reinterpret_cast<mach_vm_address_t>(__builtin_frame_address(0)); - *aOutTop = reinterpret_cast<uint8_t*>(stackFrame); - // Kernel code shows that stack is always a single region. - *aOutBottom = reinterpret_cast<uint8_t*>(RegionContainingAddress(stackFrame)); - return *aOutBottom && (*aOutBottom < *aOutTop); -} -#endif - #ifdef HASH_NODE_ID_WITH_DEVICE_ID static void SecureMemset(void* start, uint8_t value, size_t size) { diff --git a/dom/media/systemservices/LoadMonitor.cpp b/dom/media/systemservices/LoadMonitor.cpp index 7a64c4fb0b..ef8d1a0cc7 100644 --- a/dom/media/systemservices/LoadMonitor.cpp +++ b/dom/media/systemservices/LoadMonitor.cpp @@ -31,12 +31,6 @@ #include <unistd.h> #endif -#ifdef XP_MACOSX -#include <mach/mach_host.h> -#include <mach/mach_init.h> -#include <mach/host_info.h> -#endif - #if defined(__DragonFly__) || defined(__FreeBSD__) \ || defined(__NetBSD__) || defined(__OpenBSD__) #include <sys/sysctl.h> @@ -415,27 +409,6 @@ nsresult RTCLoadInfo::UpdateSystemLoad() cpu_times, &mSystemLoad); return NS_OK; -#elif defined(XP_MACOSX) - mach_msg_type_number_t info_cnt = HOST_CPU_LOAD_INFO_COUNT; - host_cpu_load_info_data_t load_info; - kern_return_t rv = host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, - (host_info_t)(&load_info), &info_cnt); - - if (rv != KERN_SUCCESS || info_cnt != HOST_CPU_LOAD_INFO_COUNT) { - LOG(("Error from mach/host_statistics call")); - return NS_ERROR_FAILURE; - } - - const uint64_t cpu_times = load_info.cpu_ticks[CPU_STATE_NICE] - + load_info.cpu_ticks[CPU_STATE_SYSTEM] - + load_info.cpu_ticks[CPU_STATE_USER]; - const uint64_t total_times = cpu_times + load_info.cpu_ticks[CPU_STATE_IDLE]; - - UpdateCpuLoad(mTicksPerInterval, - total_times, - cpu_times, - &mSystemLoad); - return NS_OK; #elif defined(__DragonFly__) || defined(__FreeBSD__) \ || defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__NetBSD__) diff --git a/dom/media/webaudio/AudioContext.cpp b/dom/media/webaudio/AudioContext.cpp index 75f57a630b..3c7958349b 100755 --- a/dom/media/webaudio/AudioContext.cpp +++ b/dom/media/webaudio/AudioContext.cpp @@ -873,7 +873,6 @@ AudioContext::OnStateChanged(void* aPromise, AudioContextState aNewState) } #ifndef WIN32 // Bug 1170547 -#ifndef XP_MACOSX #ifdef DEBUG if (!((mAudioContextState == AudioContextState::Suspended && @@ -892,7 +891,6 @@ AudioContext::OnStateChanged(void* aPromise, AudioContextState aNewState) } #endif // DEBUG -#endif // XP_MACOSX #endif // WIN32 MOZ_ASSERT( diff --git a/dom/media/webrtc/MediaEngineCameraVideoSource.cpp b/dom/media/webrtc/MediaEngineCameraVideoSource.cpp index e1e572724f..e63a9afded 100644 --- a/dom/media/webrtc/MediaEngineCameraVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineCameraVideoSource.cpp @@ -339,13 +339,6 @@ MediaEngineCameraVideoSource::SetName(nsString aName) facingMode = VideoFacingModeEnum::User; } #endif // ANDROID -#ifdef XP_MACOSX - // Kludge to test user-facing cameras on OSX. - if (aName.Find(NS_LITERAL_STRING("Face")) != -1) { - hasFacingMode = true; - facingMode = VideoFacingModeEnum::User; - } -#endif #ifdef XP_WIN // The cameras' name of Surface book are "Microsoft Camera Front" and // "Microsoft Camera Rear" respectively. |