diff options
author | Jeremy Andrews <athenian200@outlook.com> | 2022-07-05 22:11:34 -0500 |
---|---|---|
committer | Jeremy Andrews <athenian200@outlook.com> | 2022-07-05 22:19:08 -0500 |
commit | de383de310088eff07d91c567cddd5b7c3d6c571 (patch) | |
tree | 120779b43ba4c5d668329f32aa45377228580e17 | |
parent | c29f3e8dbab5176c2afe733a602d065c521f0543 (diff) | |
download | uxp-de383de310088eff07d91c567cddd5b7c3d6c571.tar.gz |
Issue #1956 - Follow-up: Fix weird linker issue on 32-bit MSVC2022.
I moved Range<bool>::Merge and Range<bool>::FinalizeMerge from MediaTrackConstraints.cpp, into MediaTrackConstraints.h. The header file previously contained only a forward declaration of functions implemented in the .cpp, which can be a problem if other parts of the program are including this header expecting to find the function.
-rw-r--r-- | dom/media/webrtc/MediaTrackConstraints.cpp | 43 | ||||
-rw-r--r-- | dom/media/webrtc/MediaTrackConstraints.h | 46 |
2 files changed, 44 insertions, 45 deletions
diff --git a/dom/media/webrtc/MediaTrackConstraints.cpp b/dom/media/webrtc/MediaTrackConstraints.cpp index 42582e3c29..08bb513955 100644 --- a/dom/media/webrtc/MediaTrackConstraints.cpp +++ b/dom/media/webrtc/MediaTrackConstraints.cpp @@ -34,49 +34,6 @@ NormalizedConstraintSet::Range<ValueType>::SetFrom(const ConstrainRange& aOther) } } -// The Range code works surprisingly well for bool, except when averaging ideals. -template<> -bool -NormalizedConstraintSet::Range<bool>::Merge(const Range& aOther) { - if (!Intersects(aOther)) { - return false; - } - Intersect(aOther); - - // To avoid "unsafe use of type 'bool'", we keep counter in mMergeDenominator - uint32_t counter = mMergeDenominator >> 16; - uint32_t denominator = mMergeDenominator & 0xffff; - - if (aOther.mIdeal.isSome()) { - if (mIdeal.isNothing()) { - mIdeal.emplace(aOther.Get(false)); - counter = aOther.Get(false); - denominator = 1; - } else { - if (!denominator) { - counter = Get(false); - denominator = 1; - } - counter += aOther.Get(false); - denominator++; - } - } - mMergeDenominator = ((counter & 0xffff) << 16) + (denominator & 0xffff); - return true; -} - -template<> -void -NormalizedConstraintSet::Range<bool>::FinalizeMerge() -{ - if (mMergeDenominator) { - uint32_t counter = mMergeDenominator >> 16; - uint32_t denominator = mMergeDenominator & 0xffff; - - *mIdeal = !!(counter / denominator); - mMergeDenominator = 0; - } -} NormalizedConstraintSet::LongRange::LongRange( LongPtrType aMemberPtr, diff --git a/dom/media/webrtc/MediaTrackConstraints.h b/dom/media/webrtc/MediaTrackConstraints.h index 842fea0d2d..693c905d5f 100644 --- a/dom/media/webrtc/MediaTrackConstraints.h +++ b/dom/media/webrtc/MediaTrackConstraints.h @@ -261,8 +261,50 @@ public: aOther.mMozAutoGainControl, advanced, aList) {} }; -template<> bool NormalizedConstraintSet::Range<bool>::Merge(const Range& aOther); -template<> void NormalizedConstraintSet::Range<bool>::FinalizeMerge(); +// The Range code works surprisingly well for bool, except when averaging ideals. +template<> +bool +NormalizedConstraintSet::Range<bool>::Merge(const Range& aOther) { + if (!Intersects(aOther)) { + return false; + } + Intersect(aOther); + + // To avoid "unsafe use of type 'bool'", we keep counter in mMergeDenominator + uint32_t counter = mMergeDenominator >> 16; + uint32_t denominator = mMergeDenominator & 0xffff; + + if (aOther.mIdeal.isSome()) { + if (mIdeal.isNothing()) { + mIdeal.emplace(aOther.Get(false)); + counter = aOther.Get(false); + denominator = 1; + } else { + if (!denominator) { + counter = Get(false); + denominator = 1; + } + counter += aOther.Get(false); + denominator++; + } + } + mMergeDenominator = ((counter & 0xffff) << 16) + (denominator & 0xffff); + return true; +} + +template<> +void +NormalizedConstraintSet::Range<bool>::FinalizeMerge() +{ + if (mMergeDenominator) { + uint32_t counter = mMergeDenominator >> 16; + uint32_t denominator = mMergeDenominator & 0xffff; + + *mIdeal = !!(counter / denominator); + mMergeDenominator = 0; + } +} + // Used instead of MediaTrackConstraints in lower-level code. struct NormalizedConstraints : public NormalizedConstraintSet |