Bug 1656438 - Make integer types explicit and unsigned in AudioDriftCorrection and friends. r=padenot
authorAndreas Pehrson <apehrson@mozilla.com>
Thu, 17 Sep 2020 06:13:40 +0000
changeset 549114 5d2a5063ef6f5ae38a508468869e9ed78b81eb8c
parent 549113 2f3a801569ab51f6af12087f1edc9b181f8c0688
child 549115 e054117630cb2429ad45a42e62935ee10e2a1061
push id37792
push usermalexandru@mozilla.com
push dateFri, 18 Sep 2020 09:45:00 +0000
treeherdermozilla-central@8084c8793a55 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1656438
milestone82.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1656438 - Make integer types explicit and unsigned in AudioDriftCorrection and friends. r=padenot In particular, this patch gets rid of signed integers where negative values don't make sense anyway. Differential Revision: https://phabricator.services.mozilla.com/D89777
dom/media/AudioDriftCorrection.h
dom/media/AudioRingBuffer.cpp
dom/media/AudioRingBuffer.h
dom/media/DynamicResampler.cpp
dom/media/DynamicResampler.h
dom/media/gtest/MockCubeb.h
dom/media/gtest/TestAudioDriftCorrection.cpp
dom/media/gtest/TestAudioRingBuffer.cpp
dom/media/gtest/TestDynamicResampler.cpp
--- a/dom/media/AudioDriftCorrection.h
+++ b/dom/media/AudioDriftCorrection.h
@@ -33,18 +33,18 @@ extern LazyLogModule gMediaTrackGraphLog
  * internal buffering. Right now it is at 50ms. But it can be increased if there
  * are audio quality problems.
  */
 class ClockDrift final {
  public:
   /**
    * Provide the nominal source and the target sample rate.
    */
-  ClockDrift(int32_t aSourceRate, int32_t aTargetRate,
-             int32_t aDesiredBuffering)
+  ClockDrift(uint32_t aSourceRate, uint32_t aTargetRate,
+             uint32_t aDesiredBuffering)
       : mSourceRate(aSourceRate),
         mTargetRate(aTargetRate),
         mDesiredBuffering(aDesiredBuffering) {}
 
   /**
    * The correction in the form of a ratio. A correction of 0.98 means that the
    * target is 2% slower compared to the source or 1.03 which means that the
    * target is 3% faster than the source.
@@ -55,18 +55,18 @@ class ClockDrift final {
    * Update the available source frames, target frames, and the current
    * buffer, in every iteration. If the conditions are met a new correction is
    * calculated. A new correction is calculated in the following cases:
    *   1. Every mAdjustmentIntervalMs milliseconds (1000ms).
    *   2. Every time we run low on buffered frames (less than 20ms).
    * In addition to that, the correction is clamped to 10% to avoid sound
    * distortion so the result will be in [0.9, 1.1].
    */
-  void UpdateClock(int aSourceFrames, int aTargetFrames, int aBufferedFrames,
-                   int aRemainingFrames) {
+  void UpdateClock(uint32_t aSourceFrames, uint32_t aTargetFrames,
+                   uint32_t aBufferedFrames, uint32_t aRemainingFrames) {
     if (mSourceClock >= mSourceRate / 10 || mTargetClock >= mTargetRate / 10) {
       // Only update the correction if 100ms has passed since last update.
       if (aBufferedFrames < mDesiredBuffering * 4 / 10 /*40%*/ ||
           aRemainingFrames < mDesiredBuffering * 4 / 10 /*40%*/) {
         // We are getting close to the lower or upper bound of the internal
         // buffer. Steer clear.
         CalculateCorrection(0.9, aBufferedFrames, aRemainingFrames);
       } else if ((mTargetClock * 1000 / mTargetRate) >= mAdjustmentIntervalMs ||
@@ -81,29 +81,29 @@ class ClockDrift final {
 
  private:
   /**
    * aCalculationWeight is a percentage [0, 1] with which the calculated
    * correction will be weighted. The existing correction will be weighted with
    * 1 - aCalculationWeight. This gives some inertia to the speed at which the
    * correction changes, for smoother changes.
    */
-  void CalculateCorrection(float aCalculationWeight, int aBufferedFrames,
-                           int aRemainingFrames) {
+  void CalculateCorrection(float aCalculationWeight, uint32_t aBufferedFrames,
+                           uint32_t aRemainingFrames) {
     // We want to maintain the desired buffer
-    int32_t bufferedFramesDiff = aBufferedFrames - mDesiredBuffering;
-    int32_t resampledSourceClock =
-        std::max(1, mSourceClock + bufferedFramesDiff);
+    uint32_t bufferedFramesDiff = aBufferedFrames - mDesiredBuffering;
+    uint32_t resampledSourceClock =
+        std::max(1u, mSourceClock + bufferedFramesDiff);
     if (mTargetRate != mSourceRate) {
       resampledSourceClock *= static_cast<float>(mTargetRate) / mSourceRate;
     }
 
     MOZ_LOG(gMediaTrackGraphLog, LogLevel::Verbose,
             ("ClockDrift %p Calculated correction %.3f (with weight: %.1f -> "
-             "%.3f) (buffer: %d, desired: %d, remaining: %d)",
+             "%.3f) (buffer: %u, desired: %u, remaining: %u)",
              this, static_cast<float>(mTargetClock) / resampledSourceClock,
              aCalculationWeight,
              (1 - aCalculationWeight) * mCorrection +
                  aCalculationWeight * mTargetClock / resampledSourceClock,
              aBufferedFrames, mDesiredBuffering, aRemainingFrames));
 
     mCorrection = (1 - aCalculationWeight) * mCorrection +
                   aCalculationWeight * mTargetClock / resampledSourceClock;
@@ -112,26 +112,26 @@ class ClockDrift final {
     mCorrection = std::min(std::max(mCorrection, 0.9f), 1.1f);
 
     // Reset the counters to prepare for the next period.
     mTargetClock = 0;
     mSourceClock = 0;
   }
 
  public:
-  const int32_t mSourceRate;
-  const int32_t mTargetRate;
-  const int32_t mAdjustmentIntervalMs = 1000;
-  const int32_t mDesiredBuffering;
+  const uint32_t mSourceRate;
+  const uint32_t mTargetRate;
+  const uint32_t mAdjustmentIntervalMs = 1000;
+  const uint32_t mDesiredBuffering;
 
  private:
   float mCorrection = 1.0;
 
-  int32_t mSourceClock = 0;
-  int32_t mTargetClock = 0;
+  uint32_t mSourceClock = 0;
+  uint32_t mTargetClock = 0;
 };
 
 /**
  * Correct the drift between two independent clocks, the source, and the target
  * clock. The target clock is the master clock so the correction syncs the drift
  * of the source clock to the target. The nominal sampling rates of source and
  * target must be provided. If the source and the target operate in different
  * sample rate the drift correction will be performed on the top of resampling
@@ -145,17 +145,17 @@ class ClockDrift final {
  *
  * The class is not thread-safe. The construction can happen in any thread but
  * the member method must be used in a single thread that can be different than
  * the construction thread. Appropriate for being used in the high priority
  * audio thread.
  */
 class AudioDriftCorrection final {
  public:
-  AudioDriftCorrection(int32_t aSourceRate, int32_t aTargetRate)
+  AudioDriftCorrection(uint32_t aSourceRate, uint32_t aTargetRate)
       : mDesiredBuffering(
             std::max(5, Preferences::GetInt("media.clockdrift.buffering", 50)) *
             aSourceRate / 1000),
         mTargetRate(aTargetRate),
         mClockDrift(aSourceRate, aTargetRate, mDesiredBuffering),
         mResampler(aSourceRate, aTargetRate, mDesiredBuffering) {}
 
   /**
@@ -163,17 +163,17 @@ class AudioDriftCorrection final {
    * be provided. The duration of the source and the output is considered as the
    * source clock and the target clock. The input is buffered internally so some
    * latency exists. The returned AudioSegment must be cleaned up because the
    * internal buffer will be reused after 100ms. If the drift correction (and
    * possible resampling) is not possible due to lack of input data an empty
    * AudioSegment will be returned. Not thread-safe.
    */
   AudioSegment RequestFrames(const AudioSegment& aInput,
-                             int32_t aOutputFrames) {
+                             uint32_t aOutputFrames) {
     // Very important to go first since the Dynamic will get the sample format
     // from the chunk.
     if (aInput.GetDuration()) {
       // Always go through the resampler because the clock might shift later.
       mResampler.AppendInput(aInput);
     }
     mClockDrift.UpdateClock(aInput.GetDuration(), aOutputFrames,
                             mResampler.InputReadableFrames(),
@@ -188,18 +188,18 @@ class AudioDriftCorrection final {
       output.AppendNullData(aOutputFrames);
     }
     return output;
   }
 
   // Only accessible from the same thread that is driving RequestFrames().
   uint32_t CurrentBuffering() const { return mResampler.InputReadableFrames(); }
 
-  const int32_t mDesiredBuffering;
-  const int32_t mTargetRate;
+  const uint32_t mDesiredBuffering;
+  const uint32_t mTargetRate;
 
  private:
   ClockDrift mClockDrift;
   AudioResampler mResampler;
 };
 
 };     // namespace mozilla
 #endif /* MOZILLA_AUDIO_DRIFT_CORRECTION_H_ */
--- a/dom/media/AudioRingBuffer.cpp
+++ b/dom/media/AudioRingBuffer.cpp
@@ -30,45 +30,45 @@ class RingBuffer final {
         mMemoryBuffer(std::move(aMemoryBuffer)) {
     MOZ_ASSERT(std::is_trivial<T>::value);
     MOZ_ASSERT(!mStorage.IsEmpty());
   }
 
   /**
    * Write `aSamples` number of zeros in the buffer.
    */
-  int WriteSilence(int aSamples) {
+  uint32_t WriteSilence(uint32_t aSamples) {
     MOZ_ASSERT(aSamples);
     return Write(Span<T>(), aSamples);
   }
 
   /**
    * Copy `aBuffer` to the RingBuffer.
    */
-  int Write(const Span<const T>& aBuffer) {
+  uint32_t Write(const Span<const T>& aBuffer) {
     MOZ_ASSERT(!aBuffer.IsEmpty());
     return Write(aBuffer, aBuffer.Length());
   }
 
  private:
   /**
    * Copy `aSamples` number of elements from `aBuffer` to the RingBuffer. If
    * `aBuffer` is empty append `aSamples` of zeros.
    */
-  int Write(const Span<const T>& aBuffer, int aSamples) {
+  uint32_t Write(const Span<const T>& aBuffer, uint32_t aSamples) {
     MOZ_ASSERT(aSamples > 0 &&
                aBuffer.Length() <= static_cast<uint32_t>(aSamples));
 
     if (IsFull()) {
       return 0;
     }
 
-    int toWrite = std::min(AvailableWrite(), aSamples);
-    int part1 = std::min(Capacity() - mWriteIndex, toWrite);
-    int part2 = toWrite - part1;
+    uint32_t toWrite = std::min(AvailableWrite(), aSamples);
+    uint32_t part1 = std::min(Capacity() - mWriteIndex, toWrite);
+    uint32_t part2 = toWrite - part1;
 
     Span<T> part1Buffer = mStorage.Subspan(mWriteIndex, part1);
     Span<T> part2Buffer = mStorage.To(part2);
 
     if (!aBuffer.IsEmpty()) {
       Span<const T> fromPart1 = aBuffer.To(part1);
       Span<const T> fromPart2 = aBuffer.Subspan(part1, part2);
 
@@ -85,54 +85,55 @@ class RingBuffer final {
     return toWrite;
   }
 
  public:
   /**
    * Copy `aSamples` number of elements from `aBuffer` to the RingBuffer. The
    * `aBuffer` does not change.
    */
-  int Write(const RingBuffer& aBuffer, int aSamples) {
+  uint32_t Write(const RingBuffer& aBuffer, uint32_t aSamples) {
     MOZ_ASSERT(aSamples);
 
     if (IsFull()) {
       return 0;
     }
 
-    int toWriteThis = std::min(AvailableWrite(), aSamples);
-    int toReadThat = std::min(aBuffer.AvailableRead(), toWriteThis);
-    int part1 = std::min(aBuffer.Capacity() - aBuffer.mReadIndex, toReadThat);
-    int part2 = toReadThat - part1;
+    uint32_t toWriteThis = std::min(AvailableWrite(), aSamples);
+    uint32_t toReadThat = std::min(aBuffer.AvailableRead(), toWriteThis);
+    uint32_t part1 =
+        std::min(aBuffer.Capacity() - aBuffer.mReadIndex, toReadThat);
+    uint32_t part2 = toReadThat - part1;
 
     Span<T> part1Buffer = aBuffer.mStorage.Subspan(aBuffer.mReadIndex, part1);
-    DebugOnly<int> ret = Write(part1Buffer);
+    DebugOnly<uint32_t> ret = Write(part1Buffer);
     MOZ_ASSERT(ret == part1);
     if (part2) {
       Span<T> part2Buffer = aBuffer.mStorage.To(part2);
       ret = Write(part2Buffer);
       MOZ_ASSERT(ret == part2);
     }
 
     return toReadThat;
   }
 
   /**
    * Copy `aBuffer.Length()` number of elements from RingBuffer to `aBuffer`.
    */
-  int Read(const Span<T>& aBuffer) {
+  uint32_t Read(const Span<T>& aBuffer) {
     MOZ_ASSERT(!aBuffer.IsEmpty());
-    MOZ_ASSERT(aBuffer.size() <= std::numeric_limits<int>::max());
+    MOZ_ASSERT(aBuffer.size() <= std::numeric_limits<uint32_t>::max());
 
     if (IsEmpty()) {
       return 0;
     }
 
-    int toRead = std::min(AvailableRead(), static_cast<int>(aBuffer.Length()));
-    int part1 = std::min(Capacity() - mReadIndex, toRead);
-    int part2 = toRead - part1;
+    uint32_t toRead = std::min<uint32_t>(AvailableRead(), aBuffer.Length());
+    uint32_t part1 = std::min(Capacity() - mReadIndex, toRead);
+    uint32_t part2 = toRead - part1;
 
     Span<T> part1Buffer = mStorage.Subspan(mReadIndex, part1);
     Span<T> part2Buffer = mStorage.To(part2);
 
     Span<T> toPart1 = aBuffer.To(part1);
     Span<T> toPart2 = aBuffer.Subspan(part1, part2);
 
     CopySpan(toPart1, part1Buffer);
@@ -159,64 +160,65 @@ class RingBuffer final {
    *
    * In general, the problem with ring buffers is that they cannot provide one
    * linear chunk of memory so extra copies, to a linear buffer, are often
    * needed. This method bridge that gap by breaking the ring buffer's
    * internal read memory into linear pieces and making it available through
    * the `aCallable`. In the body of the `aCallable` those buffers can be used
    * directly without any copy or intermediate steps.
    */
-  int ReadNoCopy(std::function<int(const Span<const T>&)>&& aCallable) {
+  uint32_t ReadNoCopy(
+      std::function<uint32_t(const Span<const T>&)>&& aCallable) {
     if (IsEmpty()) {
       return 0;
     }
 
-    int part1 = std::min(Capacity() - mReadIndex, AvailableRead());
-    int part2 = AvailableRead() - part1;
+    uint32_t part1 = std::min(Capacity() - mReadIndex, AvailableRead());
+    uint32_t part2 = AvailableRead() - part1;
 
     Span<T> part1Buffer = mStorage.Subspan(mReadIndex, part1);
-    int toRead = aCallable(part1Buffer);
+    uint32_t toRead = aCallable(part1Buffer);
     MOZ_ASSERT(toRead <= part1);
 
     if (toRead == part1 && part2) {
       Span<T> part2Buffer = mStorage.To(part2);
       toRead += aCallable(part2Buffer);
       MOZ_ASSERT(toRead <= part1 + part2);
     }
 
     mReadIndex = NextIndex(mReadIndex, toRead);
 
     return toRead;
   }
 
   /**
    * Remove the next `aSamples` number of samples from the ring buffer.
    */
-  int Discard(int aSamples) {
+  uint32_t Discard(uint32_t aSamples) {
     MOZ_ASSERT(aSamples);
 
     if (IsEmpty()) {
       return 0;
     }
 
-    int toDiscard = std::min(AvailableRead(), aSamples);
+    uint32_t toDiscard = std::min(AvailableRead(), aSamples);
     mReadIndex = NextIndex(mReadIndex, toDiscard);
 
     return toDiscard;
   }
 
   /**
    * Empty the ring buffer.
    */
-  int Clear() {
+  uint32_t Clear() {
     if (IsEmpty()) {
       return 0;
     }
 
-    int toDiscard = AvailableRead();
+    uint32_t toDiscard = AvailableRead();
     mReadIndex = NextIndex(mReadIndex, toDiscard);
 
     return toDiscard;
   }
 
   /**
    * Returns true if the full capacity of the ring buffer is being used. When
    * full any attempt to write more samples to the ring buffer will fail.
@@ -227,60 +229,59 @@ class RingBuffer final {
    * Returns true if the ring buffer is empty. When empty any attempt to read
    * more samples from the ring buffer will fail.
    */
   bool IsEmpty() const { return mWriteIndex == mReadIndex; }
 
   /**
    * The number of samples available for writing.
    */
-  int AvailableWrite() const {
+  uint32_t AvailableWrite() const {
     /* We subtract one element here to always keep at least one sample
      * free in the buffer, to distinguish between full and empty array. */
-    int rv = mReadIndex - mWriteIndex - 1;
+    uint32_t rv = mReadIndex - mWriteIndex - 1;
     if (mWriteIndex >= mReadIndex) {
       rv += Capacity();
     }
     return rv;
   }
 
   /**
    * The number of samples available for reading.
    */
-  int AvailableRead() const {
+  uint32_t AvailableRead() const {
     if (mWriteIndex >= mReadIndex) {
       return mWriteIndex - mReadIndex;
     }
     return mWriteIndex + Capacity() - mReadIndex;
   }
 
  private:
-  int NextIndex(int aIndex, int aStep) const {
-    MOZ_ASSERT(aStep >= 0);
+  uint32_t NextIndex(uint32_t aIndex, uint32_t aStep) const {
     MOZ_ASSERT(aStep < Capacity());
     MOZ_ASSERT(aIndex < Capacity());
     return (aIndex + aStep) % Capacity();
   }
 
-  int32_t Capacity() const { return mStorage.Length(); }
+  uint32_t Capacity() const { return mStorage.Length(); }
 
   Span<T> ConvertToSpan(const AlignedByteBuffer& aOther) const {
     MOZ_ASSERT(aOther.Length() >= sizeof(T));
     return Span<T>(reinterpret_cast<T*>(aOther.Data()),
                    aOther.Length() / sizeof(T));
   }
 
   void CopySpan(Span<T>& aTo, const Span<const T>& aFrom) {
     MOZ_ASSERT(aTo.Length() == aFrom.Length());
     std::copy(aFrom.cbegin(), aFrom.cend(), aTo.begin());
   }
 
  private:
-  int mReadIndex = 0;
-  int mWriteIndex = 0;
+  uint32_t mReadIndex = 0;
+  uint32_t mWriteIndex = 0;
   /* Points to the mMemoryBuffer. */
   const Span<T> mStorage;
   /* The actual allocated memory set from outside. It is set in the ctor and it
    * is not used again. It is here to control the lifetime of the memory. The
    * memory is accessed through the mStorage. The idea is that the memory used
    * from the RingBuffer can be pre-allocated. */
   const AlignedByteBuffer mMemoryBuffer;
 };
@@ -291,20 +292,19 @@ class RingBuffer final {
 class AudioRingBuffer::AudioRingBufferPrivate {
  public:
   AudioSampleFormat mSampleFormat = AUDIO_FORMAT_SILENCE;
   Maybe<RingBuffer<float>> mFloatRingBuffer;
   Maybe<RingBuffer<int16_t>> mIntRingBuffer;
   Maybe<AlignedByteBuffer> mBackingBuffer;
 };
 
-AudioRingBuffer::AudioRingBuffer(int aSizeInBytes)
+AudioRingBuffer::AudioRingBuffer(uint32_t aSizeInBytes)
     : mPtr(MakeUnique<AudioRingBufferPrivate>()) {
   MOZ_ASSERT(aSizeInBytes > 0);
-  MOZ_ASSERT(aSizeInBytes < std::numeric_limits<int>::max());
   mPtr->mBackingBuffer.emplace(aSizeInBytes);
   MOZ_ASSERT(mPtr->mBackingBuffer);
 }
 
 AudioRingBuffer::~AudioRingBuffer() = default;
 
 void AudioRingBuffer::SetSampleFormat(AudioSampleFormat aFormat) {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_SILENCE);
@@ -318,99 +318,100 @@ void AudioRingBuffer::SetSampleFormat(Au
     mPtr->mIntRingBuffer.emplace(mPtr->mBackingBuffer.extract());
     MOZ_ASSERT(!mPtr->mBackingBuffer);
     return;
   }
   mPtr->mFloatRingBuffer.emplace(mPtr->mBackingBuffer.extract());
   MOZ_ASSERT(!mPtr->mBackingBuffer);
 }
 
-int AudioRingBuffer::Write(const Span<const float>& aBuffer) {
+uint32_t AudioRingBuffer::Write(const Span<const float>& aBuffer) {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_FLOAT32);
   MOZ_ASSERT(!mPtr->mIntRingBuffer);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   return mPtr->mFloatRingBuffer->Write(aBuffer);
 }
 
-int AudioRingBuffer::Write(const Span<const int16_t>& aBuffer) {
+uint32_t AudioRingBuffer::Write(const Span<const int16_t>& aBuffer) {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_S16);
   MOZ_ASSERT(!mPtr->mFloatRingBuffer);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   return mPtr->mIntRingBuffer->Write(aBuffer);
 }
 
-int AudioRingBuffer::Write(const AudioRingBuffer& aBuffer, int aSamples) {
+uint32_t AudioRingBuffer::Write(const AudioRingBuffer& aBuffer,
+                                uint32_t aSamples) {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_S16 ||
              mPtr->mSampleFormat == AUDIO_FORMAT_FLOAT32);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   if (mPtr->mSampleFormat == AUDIO_FORMAT_S16) {
     MOZ_ASSERT(!mPtr->mFloatRingBuffer);
     return mPtr->mIntRingBuffer->Write(aBuffer.mPtr->mIntRingBuffer.ref(),
                                        aSamples);
   }
   MOZ_ASSERT(!mPtr->mIntRingBuffer);
   return mPtr->mFloatRingBuffer->Write(aBuffer.mPtr->mFloatRingBuffer.ref(),
                                        aSamples);
 }
 
-int AudioRingBuffer::WriteSilence(int aSamples) {
+uint32_t AudioRingBuffer::WriteSilence(uint32_t aSamples) {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_S16 ||
              mPtr->mSampleFormat == AUDIO_FORMAT_FLOAT32);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   if (mPtr->mSampleFormat == AUDIO_FORMAT_S16) {
     MOZ_ASSERT(!mPtr->mFloatRingBuffer);
     return mPtr->mIntRingBuffer->WriteSilence(aSamples);
   }
   MOZ_ASSERT(!mPtr->mIntRingBuffer);
   return mPtr->mFloatRingBuffer->WriteSilence(aSamples);
 }
 
-int AudioRingBuffer::Read(const Span<float>& aBuffer) {
+uint32_t AudioRingBuffer::Read(const Span<float>& aBuffer) {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_FLOAT32);
   MOZ_ASSERT(!mPtr->mIntRingBuffer);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   return mPtr->mFloatRingBuffer->Read(aBuffer);
 }
 
-int AudioRingBuffer::Read(const Span<int16_t>& aBuffer) {
+uint32_t AudioRingBuffer::Read(const Span<int16_t>& aBuffer) {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_S16);
   MOZ_ASSERT(!mPtr->mFloatRingBuffer);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   return mPtr->mIntRingBuffer->Read(aBuffer);
 }
 
-int AudioRingBuffer::ReadNoCopy(
-    std::function<int(const Span<const float>&)>&& aCallable) {
+uint32_t AudioRingBuffer::ReadNoCopy(
+    std::function<uint32_t(const Span<const float>&)>&& aCallable) {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_FLOAT32);
   MOZ_ASSERT(!mPtr->mIntRingBuffer);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   return mPtr->mFloatRingBuffer->ReadNoCopy(std::move(aCallable));
 }
 
-int AudioRingBuffer::ReadNoCopy(
-    std::function<int(const Span<const int16_t>&)>&& aCallable) {
+uint32_t AudioRingBuffer::ReadNoCopy(
+    std::function<uint32_t(const Span<const int16_t>&)>&& aCallable) {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_S16);
   MOZ_ASSERT(!mPtr->mFloatRingBuffer);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   return mPtr->mIntRingBuffer->ReadNoCopy(std::move(aCallable));
 }
 
-int AudioRingBuffer::Discard(int aSamples) {
+uint32_t AudioRingBuffer::Discard(uint32_t aSamples) {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_S16 ||
              mPtr->mSampleFormat == AUDIO_FORMAT_FLOAT32);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   if (mPtr->mSampleFormat == AUDIO_FORMAT_S16) {
     MOZ_ASSERT(!mPtr->mFloatRingBuffer);
     return mPtr->mIntRingBuffer->Discard(aSamples);
   }
   MOZ_ASSERT(!mPtr->mIntRingBuffer);
   return mPtr->mFloatRingBuffer->Discard(aSamples);
 }
 
-int AudioRingBuffer::Clear() {
+uint32_t AudioRingBuffer::Clear() {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_S16 ||
              mPtr->mSampleFormat == AUDIO_FORMAT_FLOAT32);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   if (mPtr->mSampleFormat == AUDIO_FORMAT_S16) {
     MOZ_ASSERT(!mPtr->mFloatRingBuffer);
     MOZ_ASSERT(mPtr->mIntRingBuffer);
     return mPtr->mIntRingBuffer->Clear();
   }
@@ -438,29 +439,29 @@ bool AudioRingBuffer::IsEmpty() const {
   if (mPtr->mSampleFormat == AUDIO_FORMAT_S16) {
     MOZ_ASSERT(!mPtr->mFloatRingBuffer);
     return mPtr->mIntRingBuffer->IsEmpty();
   }
   MOZ_ASSERT(!mPtr->mIntRingBuffer);
   return mPtr->mFloatRingBuffer->IsEmpty();
 }
 
-int AudioRingBuffer::AvailableWrite() const {
+uint32_t AudioRingBuffer::AvailableWrite() const {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_S16 ||
              mPtr->mSampleFormat == AUDIO_FORMAT_FLOAT32);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   if (mPtr->mSampleFormat == AUDIO_FORMAT_S16) {
     MOZ_ASSERT(!mPtr->mFloatRingBuffer);
     return mPtr->mIntRingBuffer->AvailableWrite();
   }
   MOZ_ASSERT(!mPtr->mIntRingBuffer);
   return mPtr->mFloatRingBuffer->AvailableWrite();
 }
 
-int AudioRingBuffer::AvailableRead() const {
+uint32_t AudioRingBuffer::AvailableRead() const {
   MOZ_ASSERT(mPtr->mSampleFormat == AUDIO_FORMAT_S16 ||
              mPtr->mSampleFormat == AUDIO_FORMAT_FLOAT32);
   MOZ_ASSERT(!mPtr->mBackingBuffer);
   if (mPtr->mSampleFormat == AUDIO_FORMAT_S16) {
     MOZ_ASSERT(!mPtr->mFloatRingBuffer);
     return mPtr->mIntRingBuffer->AvailableRead();
   }
   MOZ_ASSERT(!mPtr->mIntRingBuffer);
--- a/dom/media/AudioRingBuffer.h
+++ b/dom/media/AudioRingBuffer.h
@@ -17,97 +17,99 @@ namespace mozilla {
  * AudioRingBuffer works with audio sample format float or short. The
  * implementation wrap around the RingBuffer thus it is not thread-safe. Reads
  * and writes must happen in the same thread which may be different than the
  * construction thread. The memory is pre-allocated in the constructor. The
  * sample format has to be specified in order to be used.
  */
 class AudioRingBuffer final {
  public:
-  explicit AudioRingBuffer(int aSizeInBytes);
+  explicit AudioRingBuffer(uint32_t aSizeInBytes);
   ~AudioRingBuffer();
 
   /**
    * Set the sample format to either short or float. The sample format must be
    * set before the using any other method.
    */
   void SetSampleFormat(AudioSampleFormat aFormat);
 
   /**
    * Write `aBuffer.Length()` number of samples when the format is float.
    */
-  int Write(const Span<const float>& aBuffer);
+  uint32_t Write(const Span<const float>& aBuffer);
 
   /**
    * Write `aBuffer.Length()` number of samples when the format is short.
    */
-  int Write(const Span<const int16_t>& aBuffer);
+  uint32_t Write(const Span<const int16_t>& aBuffer);
 
   /**
    * Write `aSamples` number of samples from `aBuffer`. Note the `aBuffer` does
    * not change.
    */
-  int Write(const AudioRingBuffer& aBuffer, int aSamples);
+  uint32_t Write(const AudioRingBuffer& aBuffer, uint32_t aSamples);
 
   /**
    * Write `aSamples` number of zeros.
    */
-  int WriteSilence(int aSamples);
+  uint32_t WriteSilence(uint32_t aSamples);
 
   /**
    * Read `aBuffer.Length()` number of samples when the format is float.
    */
-  int Read(const Span<float>& aBuffer);
+  uint32_t Read(const Span<float>& aBuffer);
 
   /**
    * Read `aBuffer.Length()` number of samples when the format is short.
    */
-  int Read(const Span<int16_t>& aBuffer);
+  uint32_t Read(const Span<int16_t>& aBuffer);
 
   /**
    * Read the internal buffer without extra copies when sample format is float.
    * Check also the RingBuffer::ReadNoCopy() for more details.
    */
-  int ReadNoCopy(std::function<int(const Span<const float>&)>&& aCallable);
+  uint32_t ReadNoCopy(
+      std::function<uint32_t(const Span<const float>&)>&& aCallable);
 
   /**
    * Read the internal buffer without extra copies when sample format is short.
    * Check also the RingBuffer::ReadNoCopy() for more details.
    */
-  int ReadNoCopy(std::function<int(const Span<const int16_t>&)>&& aCallable);
+  uint32_t ReadNoCopy(
+      std::function<uint32_t(const Span<const int16_t>&)>&& aCallable);
 
   /**
    * Remove `aSamples` number of samples.
    */
-  int Discard(int aSamples);
+  uint32_t Discard(uint32_t aSamples);
 
   /**
    * Remove all available samples.
    */
-  int Clear();
+  uint32_t Clear();
 
   /**
    * Return true if the buffer is full.
    */
   bool IsFull() const;
 
   /**
    * Return true if the buffer is empty.
    */
   bool IsEmpty() const;
 
   /**
    * Return the number of samples available for writing.
    */
-  int AvailableWrite() const;
+  uint32_t AvailableWrite() const;
 
   /**
    * Return the number of samples available for reading.
    */
-  int AvailableRead() const;
+  uint32_t AvailableRead() const;
 
  private:
   class AudioRingBufferPrivate;
   UniquePtr<AudioRingBufferPrivate> mPtr;
 };
 
 }  // namespace mozilla
 
--- a/dom/media/DynamicResampler.cpp
+++ b/dom/media/DynamicResampler.cpp
@@ -2,17 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #include "DynamicResampler.h"
 
 namespace mozilla {
 
-DynamicResampler::DynamicResampler(int aInRate, int aOutRate,
+DynamicResampler::DynamicResampler(uint32_t aInRate, uint32_t aOutRate,
                                    uint32_t aPreBufferFrames)
     : mInRate(aInRate), mPreBufferFrames(aPreBufferFrames), mOutRate(aOutRate) {
   MOZ_ASSERT(aInRate);
   MOZ_ASSERT(aOutRate);
   UpdateResampler(mOutRate, STEREO);
 }
 
 DynamicResampler::~DynamicResampler() {
@@ -30,83 +30,81 @@ void DynamicResampler::SetSampleFormat(A
     b.SetSampleFormat(mSampleFormat);
   }
   if (mPreBufferFrames) {
     AppendInputSilence(mPreBufferFrames);
   }
 }
 
 bool DynamicResampler::Resample(float* aOutBuffer, uint32_t* aOutFrames,
-                                int aChannelIndex) {
+                                uint32_t aChannelIndex) {
   MOZ_ASSERT(mSampleFormat == AUDIO_FORMAT_FLOAT32);
   return ResampleInternal(aOutBuffer, aOutFrames, aChannelIndex);
 }
 
 bool DynamicResampler::Resample(int16_t* aOutBuffer, uint32_t* aOutFrames,
-                                int aChannelIndex) {
+                                uint32_t aChannelIndex) {
   MOZ_ASSERT(mSampleFormat == AUDIO_FORMAT_S16);
   return ResampleInternal(aOutBuffer, aOutFrames, aChannelIndex);
 }
 
 void DynamicResampler::ResampleInternal(const float* aInBuffer,
                                         uint32_t* aInFrames, float* aOutBuffer,
                                         uint32_t* aOutFrames,
-                                        int aChannelIndex) {
+                                        uint32_t aChannelIndex) {
   MOZ_ASSERT(mResampler);
   MOZ_ASSERT(mChannels);
   MOZ_ASSERT(mInRate);
   MOZ_ASSERT(mOutRate);
 
   MOZ_ASSERT(aInBuffer);
   MOZ_ASSERT(aInFrames);
   MOZ_ASSERT(*aInFrames > 0);
   MOZ_ASSERT(aOutBuffer);
   MOZ_ASSERT(aOutFrames);
   MOZ_ASSERT(*aOutFrames > 0);
 
-  MOZ_ASSERT(aChannelIndex >= 0);
   MOZ_ASSERT(aChannelIndex <= mChannels);
 
 #ifdef DEBUG
   int rv =
 #endif
       speex_resampler_process_float(mResampler, aChannelIndex, aInBuffer,
                                     aInFrames, aOutBuffer, aOutFrames);
   MOZ_ASSERT(rv == RESAMPLER_ERR_SUCCESS);
 }
 
 void DynamicResampler::ResampleInternal(const int16_t* aInBuffer,
                                         uint32_t* aInFrames,
                                         int16_t* aOutBuffer,
                                         uint32_t* aOutFrames,
-                                        int aChannelIndex) {
+                                        uint32_t aChannelIndex) {
   MOZ_ASSERT(mResampler);
   MOZ_ASSERT(mChannels);
   MOZ_ASSERT(mInRate);
   MOZ_ASSERT(mOutRate);
 
   MOZ_ASSERT(aInBuffer);
   MOZ_ASSERT(aInFrames);
   MOZ_ASSERT(*aInFrames > 0);
   MOZ_ASSERT(aOutBuffer);
   MOZ_ASSERT(aOutFrames);
   MOZ_ASSERT(*aOutFrames > 0);
 
-  MOZ_ASSERT(aChannelIndex >= 0);
   MOZ_ASSERT(aChannelIndex <= mChannels);
 
 #ifdef DEBUG
   int rv =
 #endif
       speex_resampler_process_int(mResampler, aChannelIndex, aInBuffer,
                                   aInFrames, aOutBuffer, aOutFrames);
   MOZ_ASSERT(rv == RESAMPLER_ERR_SUCCESS);
 }
 
-void DynamicResampler::UpdateResampler(int aOutRate, int aChannels) {
+void DynamicResampler::UpdateResampler(uint32_t aOutRate, uint32_t aChannels) {
   MOZ_ASSERT(aOutRate);
   MOZ_ASSERT(aChannels);
 
   if (mChannels != aChannels) {
     mResampler = speex_resampler_init(aChannels, mInRate, aOutRate,
                                       SPEEX_RESAMPLER_QUALITY_MIN, nullptr);
     MOZ_ASSERT(mResampler);
     mChannels = aChannels;
@@ -116,35 +114,34 @@ void DynamicResampler::UpdateResampler(i
     if ((mChannels == STEREO || mChannels == 1) &&
         mInternalInBuffer.Length() == STEREO) {
       // Don't worry if format is not set it will write silence then.
       if ((mSampleFormat == AUDIO_FORMAT_S16 ||
            mSampleFormat == AUDIO_FORMAT_FLOAT32) &&
           mChannels == STEREO) {
         // The mono channel is always up to date. When we are going from mono
         // to stereo upmix the mono to stereo channel
-        int bufferedDuration = mInternalInBuffer[0].AvailableRead();
+        uint32_t bufferedDuration = mInternalInBuffer[0].AvailableRead();
         mInternalInBuffer[1].Clear();
         if (bufferedDuration) {
           mInternalInBuffer[1].Write(mInternalInBuffer[0], bufferedDuration);
         }
       }
       // Maintain stereo size
       mInputTail.SetLength(STEREO);
       WarmUpResampler(false);
       return;
     }
     // upmix or downmix, for now just clear but it has to be updated
     // because allocates and this is executed in audio thread.
     mInternalInBuffer.Clear();
-    for (int i = 0; i < mChannels; ++i) {
+    for (uint32_t i = 0; i < mChannels; ++i) {
       // Pre-allocate something big, twice the pre-buffer, or at least 100ms.
       AudioRingBuffer* b = mInternalInBuffer.AppendElement(
-          sizeof(float) *
-          std::max(2 * mPreBufferFrames, static_cast<uint32_t>(mInRate) / 10));
+          sizeof(float) * std::max(2 * mPreBufferFrames, mInRate / 10));
       if (mSampleFormat != AUDIO_FORMAT_SILENCE) {
         // In ctor this update is not needed
         b->SetSampleFormat(mSampleFormat);
       }
     }
     mInputTail.SetLength(mChannels);
     return;
   }
@@ -161,17 +158,17 @@ void DynamicResampler::UpdateResampler(i
         speex_resampler_set_rate(mResampler, mInRate, aOutRate);
     MOZ_ASSERT(rv == RESAMPLER_ERR_SUCCESS);
     mOutRate = aOutRate;
   }
 }
 
 void DynamicResampler::WarmUpResampler(bool aSkipLatency) {
   MOZ_ASSERT(mInputTail.Length());
-  for (int i = 0; i < mChannels; ++i) {
+  for (uint32_t i = 0; i < mChannels; ++i) {
     if (!mInputTail[i].Length()) {
       continue;
     }
     uint32_t inFrames = mInputTail[i].Length();
     uint32_t outFrames = 5 * TailBuffer::MAXSIZE;  // something big
     if (mSampleFormat == AUDIO_FORMAT_S16) {
       short outBuffer[5 * TailBuffer::MAXSIZE] = {};
       ResampleInternal(mInputTail[i].Buffer<short>(), &inFrames, outBuffer,
@@ -202,98 +199,96 @@ void DynamicResampler::AppendInput(const
 }
 void DynamicResampler::AppendInput(const nsTArray<const int16_t*>& aInBuffer,
                                    uint32_t aInFrames) {
   MOZ_ASSERT(mSampleFormat == AUDIO_FORMAT_S16);
   AppendInputInternal(aInBuffer, aInFrames);
 }
 
 bool DynamicResampler::EnoughInFrames(uint32_t aOutFrames,
-                                      int aChannelIndex) const {
+                                      uint32_t aChannelIndex) const {
   if (mInRate == mOutRate) {
     return InFramesBuffered(aChannelIndex) >= aOutFrames;
   }
   if (!(mOutRate % mInRate) && !(aOutFrames % mOutRate / mInRate)) {
     return InFramesBuffered(aChannelIndex) >= aOutFrames / (mOutRate / mInRate);
   }
   if (!(mInRate % mOutRate) && !(aOutFrames % mOutRate / mInRate)) {
     return InFramesBuffered(aChannelIndex) >= aOutFrames * mInRate / mOutRate;
   }
   return InFramesBuffered(aChannelIndex) > aOutFrames * mInRate / mOutRate;
 }
 
 bool DynamicResampler::CanResample(uint32_t aOutFrames) const {
-  for (int i = 0; i < mChannels; ++i) {
+  for (uint32_t i = 0; i < mChannels; ++i) {
     if (!EnoughInFrames(aOutFrames, i)) {
       return false;
     }
   }
   return true;
 }
 
 void DynamicResampler::AppendInputSilence(const uint32_t aInFrames) {
   MOZ_ASSERT(aInFrames);
   MOZ_ASSERT(mChannels);
   MOZ_ASSERT(mInternalInBuffer.Length() >= (uint32_t)mChannels);
-  for (int i = 0; i < mChannels; ++i) {
+  for (uint32_t i = 0; i < mChannels; ++i) {
     mInternalInBuffer[i].WriteSilence(aInFrames);
   }
 }
 
-uint32_t DynamicResampler::InFramesBuffered(int aChannelIndex) const {
+uint32_t DynamicResampler::InFramesBuffered(uint32_t aChannelIndex) const {
   MOZ_ASSERT(mChannels);
-  MOZ_ASSERT(aChannelIndex >= 0);
   MOZ_ASSERT(aChannelIndex <= mChannels);
-  MOZ_ASSERT((uint32_t)aChannelIndex <= mInternalInBuffer.Length());
+  MOZ_ASSERT(aChannelIndex <= mInternalInBuffer.Length());
   return mInternalInBuffer[aChannelIndex].AvailableRead();
 }
 
-uint32_t DynamicResampler::InFramesLeftToBuffer(int aChannelIndex) const {
+uint32_t DynamicResampler::InFramesLeftToBuffer(uint32_t aChannelIndex) const {
   MOZ_ASSERT(mChannels);
-  MOZ_ASSERT(aChannelIndex >= 0);
   MOZ_ASSERT(aChannelIndex <= mChannels);
-  MOZ_ASSERT((uint32_t)aChannelIndex <= mInternalInBuffer.Length());
+  MOZ_ASSERT(aChannelIndex <= mInternalInBuffer.Length());
   return mInternalInBuffer[aChannelIndex].AvailableWrite();
 }
 
-AudioChunkList::AudioChunkList(int aTotalDuration, int aChannels) {
-  int numOfChunks = aTotalDuration / mChunkCapacity;
+AudioChunkList::AudioChunkList(uint32_t aTotalDuration, uint32_t aChannels) {
+  uint32_t numOfChunks = aTotalDuration / mChunkCapacity;
   if (aTotalDuration % mChunkCapacity) {
     ++numOfChunks;
   }
   CreateChunks(numOfChunks, aChannels);
 }
 
-void AudioChunkList::CreateChunks(int aNumOfChunks, int aChannels) {
+void AudioChunkList::CreateChunks(uint32_t aNumOfChunks, uint32_t aChannels) {
   MOZ_ASSERT(!mChunks.Length());
   MOZ_ASSERT(aNumOfChunks);
   MOZ_ASSERT(aChannels);
   mChunks.AppendElements(aNumOfChunks);
 
   for (AudioChunk& chunk : mChunks) {
     AutoTArray<nsTArray<float>, STEREO> buffer;
     buffer.AppendElements(aChannels);
 
     AutoTArray<const float*, STEREO> bufferPtrs;
     bufferPtrs.AppendElements(aChannels);
 
-    for (int i = 0; i < aChannels; ++i) {
+    for (uint32_t i = 0; i < aChannels; ++i) {
       float* ptr = buffer[i].AppendElements(mChunkCapacity);
       bufferPtrs[i] = ptr;
     }
 
     chunk.mBuffer = new mozilla::SharedChannelArrayBuffer(std::move(buffer));
     chunk.mChannelData.AppendElements(aChannels);
-    for (int i = 0; i < aChannels; ++i) {
+    for (uint32_t i = 0; i < aChannels; ++i) {
       chunk.mChannelData[i] = bufferPtrs[i];
     }
   }
 }
 
-void AudioChunkList::UpdateToMonoOrStereo(int aChannels) {
+void AudioChunkList::UpdateToMonoOrStereo(uint32_t aChannels) {
   MOZ_ASSERT(mChunks.Length());
   MOZ_ASSERT(mSampleFormat == AUDIO_FORMAT_S16 ||
              mSampleFormat == AUDIO_FORMAT_FLOAT32);
   MOZ_ASSERT(aChannels == 1 || aChannels == 2);
 
   for (AudioChunk& chunk : mChunks) {
     MOZ_ASSERT(chunk.ChannelCount() != (uint32_t)aChannels);
     MOZ_ASSERT(chunk.ChannelCount() == 1 || chunk.ChannelCount() == 2);
@@ -339,34 +334,34 @@ AudioChunk& AudioChunkList::GetNext() {
   chunk.mDuration = 0;
   chunk.mVolume = 1.0f;
   chunk.mPrincipalHandle = PRINCIPAL_HANDLE_NONE;
   chunk.mBufferFormat = mSampleFormat;
   IncrementIndex();
   return chunk;
 }
 
-void AudioChunkList::Update(int aChannels) {
+void AudioChunkList::Update(uint32_t aChannels) {
   MOZ_ASSERT(mChunks.Length());
-  if (mChunks[0].ChannelCount() == (uint32_t)aChannels) {
+  if (mChunks[0].ChannelCount() == aChannels) {
     return;
   }
 
   // Special handling between mono and stereo to avoid reallocations.
   if (aChannels <= 2 && mChunks[0].ChannelCount() <= 2) {
     UpdateToMonoOrStereo(aChannels);
     return;
   }
 
-  int numOfChunks = static_cast<int>(mChunks.Length());
+  uint32_t numOfChunks = mChunks.Length();
   mChunks.ClearAndRetainStorage();
   CreateChunks(numOfChunks, aChannels);
 }
 
-AudioResampler::AudioResampler(int aInRate, int aOutRate,
+AudioResampler::AudioResampler(uint32_t aInRate, uint32_t aOutRate,
                                uint32_t aPreBufferFrames)
     : mResampler(aInRate, aOutRate, aPreBufferFrames),
       mOutputChunks(aOutRate / 10, STEREO) {}
 
 void AudioResampler::AppendInput(const AudioSegment& aInSegment) {
   MOZ_ASSERT(aInSegment.GetDuration());
   for (AudioSegment::ConstChunkIterator iter(aInSegment); !iter.IsEnded();
        iter.Next()) {
@@ -415,21 +410,21 @@ AudioSegment AudioResampler::Resample(ui
   // Not enough input frames abort. We check for the requested frames plus one.
   // This is to make sure that the individual resample iteration that will
   // follow up, will have enough frames even if one of them consume an extra
   // frame.
   if (!mResampler.CanResample(aOutFrames + 1)) {
     return segment;
   }
 
-  int totalFrames = aOutFrames;
+  uint32_t totalFrames = aOutFrames;
   while (totalFrames) {
     MOZ_ASSERT(totalFrames > 0);
     AudioChunk& chunk = mOutputChunks.GetNext();
-    int outFrames = std::min(totalFrames, mOutputChunks.ChunkCapacity());
+    uint32_t outFrames = std::min(totalFrames, mOutputChunks.ChunkCapacity());
     totalFrames -= outFrames;
 
     for (uint32_t i = 0; i < chunk.ChannelCount(); ++i) {
       uint32_t outFramesUsed = outFrames;
       if (chunk.mBufferFormat == AUDIO_FORMAT_FLOAT32) {
 #ifdef DEBUG
         bool rv =
 #endif
@@ -439,43 +434,41 @@ AudioSegment AudioResampler::Resample(ui
       } else {
 #ifdef DEBUG
         bool rv =
 #endif
             mResampler.Resample(chunk.ChannelDataForWrite<int16_t>(i),
                                 &outFramesUsed, i);
         MOZ_ASSERT(rv);
       }
-      MOZ_ASSERT(outFramesUsed == (uint32_t)outFrames);
+      MOZ_ASSERT(outFramesUsed == outFrames);
       chunk.mDuration = outFrames;
     }
 
     // Create a copy in order to consume that copy and not the pre-allocated
     // chunk
     AudioChunk tmp = chunk;
     segment.AppendAndConsumeChunk(&tmp);
   }
 
   return segment;
 }
 
-void AudioResampler::Update(int aOutRate, int aChannels) {
+void AudioResampler::Update(uint32_t aOutRate, uint32_t aChannels) {
   mResampler.UpdateResampler(aOutRate, aChannels);
   mOutputChunks.Update(aChannels);
 }
 
-int AudioResampler::InputReadableFrames() const {
+uint32_t AudioResampler::InputReadableFrames() const {
   if (!mIsSampleFormatSet) {
-    return (int)mResampler.mPreBufferFrames;
+    return mResampler.mPreBufferFrames;
   }
-  MOZ_ASSERT((int)mResampler.InFramesBuffered(0) >= 0);
-  return (int)mResampler.InFramesBuffered(0);
+  return mResampler.InFramesBuffered(0);
 }
 
-int AudioResampler::InputWritableFrames() const {
+uint32_t AudioResampler::InputWritableFrames() const {
   if (!mIsSampleFormatSet) {
-    return (int)mResampler.mPreBufferFrames;
+    return mResampler.mPreBufferFrames;
   }
-  MOZ_ASSERT((int)mResampler.InFramesLeftToBuffer(0) >= 0);
-  return (int)mResampler.InFramesLeftToBuffer(0);
+  return mResampler.InFramesLeftToBuffer(0);
 }
 
 }  // namespace mozilla
--- a/dom/media/DynamicResampler.h
+++ b/dom/media/DynamicResampler.h
@@ -8,17 +8,17 @@
 
 #include "AudioRingBuffer.h"
 #include "AudioSegment.h"
 
 #include <speex/speex_resampler.h>
 
 namespace mozilla {
 
-const int STEREO = 2;
+const uint32_t STEREO = 2;
 
 /**
  * DynamicResampler allows updating on the fly the output sample rate and the
  * number of channels. In addition to that, it maintains an internal buffer for
  * the input data and allows pre-buffering as well. The Resample() method
  * strives to provide the requested number of output frames by using the input
  * data including any pre-buffering. If this is not possible then it will not
  * attempt to resample and it will return failure.
@@ -38,101 +38,103 @@ const int STEREO = 2;
  */
 class DynamicResampler final {
  public:
   /**
    * Provide the initial input and output rate and the amount of pre-buffering.
    * The channel count will be set to stereo. Memory allocation will take
    * place. The input buffer is non-interleaved.
    */
-  DynamicResampler(int aInRate, int aOutRate, uint32_t aPreBufferFrames = 0);
+  DynamicResampler(uint32_t aInRate, uint32_t aOutRate,
+                   uint32_t aPreBufferFrames = 0);
   ~DynamicResampler();
 
   /**
    * Set the sample format type to float or short.
    */
   void SetSampleFormat(AudioSampleFormat aFormat);
-  int GetOutRate() const { return mOutRate; }
-  int GetChannels() const { return mChannels; }
+  uint32_t GetOutRate() const { return mOutRate; }
+  uint32_t GetChannels() const { return mChannels; }
 
   /**
    * Append `aInFrames` number of frames from `aInBuffer` to the internal input
    * buffer. Memory copy/move takes place.
    */
   void AppendInput(const nsTArray<const float*>& aInBuffer, uint32_t aInFrames);
   void AppendInput(const nsTArray<const int16_t*>& aInBuffer,
                    uint32_t aInFrames);
   /**
    * Append `aInFrames` number of frames of silence to the internal input
    * buffer. Memory copy/move takes place.
    */
   void AppendInputSilence(const uint32_t aInFrames);
   /**
    * Return the number of frames stored in the internal input buffer.
    */
-  uint32_t InFramesBuffered(int aChannelIndex) const;
+  uint32_t InFramesBuffered(uint32_t aChannelIndex) const;
   /**
    * Return the number of frames left to store in the internal input buffer.
    */
-  uint32_t InFramesLeftToBuffer(int aChannelIndex) const;
+  uint32_t InFramesLeftToBuffer(uint32_t aChannelIndex) const;
 
   /*
    * Resampler as much frame is needed from the internal input buffer to the
    * `aOutBuffer` in order to provide all `aOutFrames` and return true. If there
    * not enough input frames to provide the requested output frames no
    * resampling is attempted and false is returned.
    */
-  bool Resample(float* aOutBuffer, uint32_t* aOutFrames, int aChannelIndex);
-  bool Resample(int16_t* aOutBuffer, uint32_t* aOutFrames, int aChannelIndex);
+  bool Resample(float* aOutBuffer, uint32_t* aOutFrames,
+                uint32_t aChannelIndex);
+  bool Resample(int16_t* aOutBuffer, uint32_t* aOutFrames,
+                uint32_t aChannelIndex);
 
   /**
    * Update the output rate or/and the channel count. If a value is not updated
    * compared to the current one nothing happens. Changing the `aOutRate`
    * results in recalculation in the resampler. Changing `aChannels` results in
    * the reallocation of the internal input buffer with the exception of
    * changes between mono to stereo and vice versa where no reallocation takes
    * place. A stereo internal input buffer is always maintained even if the
    * sound is mono.
    */
-  void UpdateResampler(int aOutRate, int aChannels);
+  void UpdateResampler(uint32_t aOutRate, uint32_t aChannels);
 
   /**
    * Returns true if the resampler has enough input data to provide to the
    * output of the `Resample()` method `aOutFrames` number of frames. This is a
    * way to know in advance if the `Resampler` method will return true or false
    * given that nothing changes in between.
    */
   bool CanResample(uint32_t aOutFrames) const;
 
  private:
   template <typename T>
   void AppendInputInternal(const nsTArray<const T*>& aInBuffer,
                            uint32_t aInFrames) {
     MOZ_ASSERT(aInBuffer.Length() == (uint32_t)mChannels);
-    for (int i = 0; i < mChannels; ++i) {
+    for (uint32_t i = 0; i < mChannels; ++i) {
       PushInFrames(aInBuffer[i], aInFrames, i);
     }
   }
 
   void ResampleInternal(const float* aInBuffer, uint32_t* aInFrames,
                         float* aOutBuffer, uint32_t* aOutFrames,
-                        int aChannelIndex);
+                        uint32_t aChannelIndex);
   void ResampleInternal(const int16_t* aInBuffer, uint32_t* aInFrames,
                         int16_t* aOutBuffer, uint32_t* aOutFrames,
-                        int aChannelIndex);
+                        uint32_t aChannelIndex);
 
   template <typename T>
   bool ResampleInternal(T* aOutBuffer, uint32_t* aOutFrames,
-                        int aChannelIndex) {
+                        uint32_t aChannelIndex) {
     MOZ_ASSERT(mInRate);
     MOZ_ASSERT(mOutRate);
     MOZ_ASSERT(mChannels);
-    MOZ_ASSERT(aChannelIndex >= 0);
     MOZ_ASSERT(aChannelIndex <= mChannels);
-    MOZ_ASSERT((uint32_t)aChannelIndex <= mInternalInBuffer.Length());
+    MOZ_ASSERT(aChannelIndex <= mInternalInBuffer.Length());
     MOZ_ASSERT(aOutFrames);
     MOZ_ASSERT(*aOutFrames);
 
     // Not enough input, don't do anything
     if (!EnoughInFrames(*aOutFrames, aChannelIndex)) {
       *aOutFrames = 0;
       return false;
     }
@@ -146,17 +148,17 @@ class DynamicResampler final {
       mInputTail[aChannelIndex].StoreTail<T>(aOutBuffer, *aOutFrames);
       return true;
     }
 
     uint32_t totalOutFramesNeeded = *aOutFrames;
 
     mInternalInBuffer[aChannelIndex].ReadNoCopy(
         [this, &aOutBuffer, &totalOutFramesNeeded,
-         aChannelIndex](const Span<const T>& aInBuffer) -> int {
+         aChannelIndex](const Span<const T>& aInBuffer) -> uint32_t {
           if (!totalOutFramesNeeded) {
             return 0;
           }
           uint32_t outFramesResampled = totalOutFramesNeeded;
           uint32_t inFrames = aInBuffer.Length();
           ResampleInternal(aInBuffer.data(), &inFrames, aOutBuffer,
                            &outFramesResampled, aChannelIndex);
           aOutBuffer += outFramesResampled;
@@ -164,39 +166,38 @@ class DynamicResampler final {
           mInputTail[aChannelIndex].StoreTail<T>(aInBuffer);
           return inFrames;
         });
 
     MOZ_ASSERT(totalOutFramesNeeded == 0);
     return true;
   }
 
-  bool EnoughInFrames(uint32_t aOutFrames, int aChannelIndex) const;
+  bool EnoughInFrames(uint32_t aOutFrames, uint32_t aChannelIndex) const;
 
   template <typename T>
   void PushInFrames(const T* aInBuffer, const uint32_t aInFrames,
-                    int aChannelIndex) {
+                    uint32_t aChannelIndex) {
     MOZ_ASSERT(aInBuffer);
     MOZ_ASSERT(aInFrames);
     MOZ_ASSERT(mChannels);
-    MOZ_ASSERT(aChannelIndex >= 0);
     MOZ_ASSERT(aChannelIndex <= mChannels);
-    MOZ_ASSERT((uint32_t)aChannelIndex <= mInternalInBuffer.Length());
+    MOZ_ASSERT(aChannelIndex <= mInternalInBuffer.Length());
     mInternalInBuffer[aChannelIndex].Write(Span(aInBuffer, aInFrames));
   }
 
   void WarmUpResampler(bool aSkipLatency);
 
  public:
-  const int mInRate;
+  const uint32_t mInRate;
   const uint32_t mPreBufferFrames;
 
  private:
-  int mChannels = 0;
-  int mOutRate;
+  uint32_t mChannels = 0;
+  uint32_t mOutRate;
 
   AutoTArray<AudioRingBuffer, STEREO> mInternalInBuffer;
 
   SpeexResamplerState* mResampler = nullptr;
   AudioSampleFormat mSampleFormat = AUDIO_FORMAT_SILENCE;
 
   class TailBuffer {
    public:
@@ -211,25 +212,25 @@ class DynamicResampler final {
     }
     template <typename T>
     void StoreTail(const T* aInBuffer, uint32_t aInFrames) {
       if (aInFrames >= MAXSIZE) {
         PodCopy(Buffer<T>(), aInBuffer + aInFrames - MAXSIZE, MAXSIZE);
         mSize = MAXSIZE;
       } else {
         PodCopy(Buffer<T>(), aInBuffer, aInFrames);
-        mSize = static_cast<int>(aInFrames);
+        mSize = aInFrames;
       }
     }
-    int Length() { return mSize; }
-    static const int MAXSIZE = 20;
+    uint32_t Length() { return mSize; }
+    static const uint32_t MAXSIZE = 20;
 
    private:
     float mBuffer[MAXSIZE] = {};
-    int mSize = 0;
+    uint32_t mSize = 0;
   };
   AutoTArray<TailBuffer, STEREO> mInputTail;
 };
 
 /**
  * AudioChunkList provides a way to have preallocated audio buffers in
  * AudioSegment. The idea is that the amount of  AudioChunks is created in
  * advance. Each AudioChunk is able to hold a specific amount of audio
@@ -267,17 +268,17 @@ class DynamicResampler final {
  * always be used to query the total capacity.
  */
 class AudioChunkList {
  public:
   /**
    * Constructor, the final total duration might be different from the requested
    * `aTotalDuration`. Memory allocation takes place.
    */
-  AudioChunkList(int aTotalDuration, int aChannels);
+  AudioChunkList(uint32_t aTotalDuration, uint32_t aChannels);
   AudioChunkList(const AudioChunkList&) = delete;
   AudioChunkList(AudioChunkList&&) = delete;
   ~AudioChunkList() = default;
 
   /**
    * Set sample format. It must be done before any other method being used.
    */
   void SetSampleFormat(AudioSampleFormat aFormat);
@@ -295,48 +296,48 @@ class AudioChunkList {
    * ```
    * This way no memory allocation or copy, takes place.
    */
   AudioChunk& GetNext();
 
   /**
    * Get the capacity of each individual AudioChunk in the list.
    */
-  int ChunkCapacity() const {
+  uint32_t ChunkCapacity() const {
     MOZ_ASSERT(mSampleFormat == AUDIO_FORMAT_S16 ||
                mSampleFormat == AUDIO_FORMAT_FLOAT32);
     return mChunkCapacity;
   }
   /**
    * Get the total capacity of AudioChunkList.
    */
-  int TotalCapacity() const {
+  uint32_t TotalCapacity() const {
     MOZ_ASSERT(mSampleFormat == AUDIO_FORMAT_S16 ||
                mSampleFormat == AUDIO_FORMAT_FLOAT32);
-    return CheckedInt<int>(mChunkCapacity * mChunks.Length()).value();
+    return CheckedInt<uint32_t>(mChunkCapacity * mChunks.Length()).value();
   }
 
   /**
    * Update the channel count of the AudioChunkList. Memory allocation is
    * taking place.
    */
-  void Update(int aChannels);
+  void Update(uint32_t aChannels);
 
  private:
   void IncrementIndex() {
     ++mIndex;
-    mIndex = CheckedInt<int>(mIndex % mChunks.Length()).value();
+    mIndex = CheckedInt<uint32_t>(mIndex % mChunks.Length()).value();
   }
-  void CreateChunks(int aNumOfChunks, int aChannels);
-  void UpdateToMonoOrStereo(int aChannels);
+  void CreateChunks(uint32_t aNumOfChunks, uint32_t aChannels);
+  void UpdateToMonoOrStereo(uint32_t aChannels);
 
  private:
   nsTArray<AudioChunk> mChunks;
-  int mIndex = 0;
-  int mChunkCapacity = 128;
+  uint32_t mIndex = 0;
+  uint32_t mChunkCapacity = 128;
   AudioSampleFormat mSampleFormat = AUDIO_FORMAT_SILENCE;
 };
 
 /**
  * Audio Resampler is a resampler able to change the output rate and channels
  * count on the fly. The API is simple and it is based in AudioSegment in order
  * to be used MTG. All memory allocations, for input and output buffers, happen
  * in the constructor and when channel count changes. The memory is recycled in
@@ -350,54 +351,55 @@ class AudioChunkList {
  * resampler method must be cleaned up in order to be able for the `AudioChunk`s
  * that it consists of to be reused. For `MediaTrack::mSegment` this happens
  * every ~50ms (look at MediaTrack::AdvanceTimeVaryingValuesToCurrentTime). Thus
  * memory capacity of 100ms has been preallocated for internal input and output
  * buffering.
  */
 class AudioResampler final {
  public:
-  AudioResampler(int aInRate, int aOutRate, uint32_t aPreBufferFrames = 0);
+  AudioResampler(uint32_t aInRate, uint32_t aOutRate,
+                 uint32_t aPreBufferFrames = 0);
 
   /**
    * Append input data into the resampler internal buffer. Copy/move of the
    * memory is taking place. Also, the channel count will change according to
    * the channel count of the chunks.
    */
   void AppendInput(const AudioSegment& aInSegment);
   /**
    * Get the number of frames that can be read from the internal input buffer
    * before it becomes empty.
    */
-  int InputReadableFrames() const;
+  uint32_t InputReadableFrames() const;
   /**
    * Get the number of frames that can be written to the internal input buffer
    * before it becomes full.
    */
-  int InputWritableFrames() const;
+  uint32_t InputWritableFrames() const;
 
   /*
    * Reguest `aOutFrames` of audio in the output sample rate. The internal
    * buffered input is used. If there is no enough input for that amount of
    * output and empty AudioSegment is returned
    */
   AudioSegment Resample(uint32_t aOutFrames);
 
   /*
    * Updates the output rate that will be used by the resampler.
    */
-  void UpdateOutRate(int aOutRate) {
+  void UpdateOutRate(uint32_t aOutRate) {
     Update(aOutRate, mResampler.GetChannels());
   }
 
  private:
-  void UpdateChannels(int aChannels) {
+  void UpdateChannels(uint32_t aChannels) {
     Update(mResampler.GetOutRate(), aChannels);
   }
-  void Update(int aOutRate, int aChannels);
+  void Update(uint32_t aOutRate, uint32_t aChannels);
 
  private:
   DynamicResampler mResampler;
   AudioChunkList mOutputChunks;
   bool mIsSampleFormatSet = false;
 };
 
 }  // namespace mozilla
--- a/dom/media/gtest/MockCubeb.h
+++ b/dom/media/gtest/MockCubeb.h
@@ -186,17 +186,17 @@ class MockCubebStream {
     uint32_t rate = mHasOutput ? mOutputParams.rate : mInputParams.rate;
     const long nrFrames =
         static_cast<long>(static_cast<float>(rate * 10) * mDriftFactor) /
         PR_MSEC_PER_SEC;
     if (mInputParams.rate) {
       mAudioGenerator.GenerateInterleaved(mInputBuffer, nrFrames);
     }
     cubeb_stream* stream = reinterpret_cast<cubeb_stream*>(this);
-    long outframes =
+    const long outframes =
         mDataCallback(stream, mUserPtr, mHasInput ? mInputBuffer : nullptr,
                       mHasOutput ? mOutputBuffer : nullptr, nrFrames);
 
     mAudioVerifier.AppendDataInterleaved(mOutputBuffer, outframes,
                                          NUM_OF_CHANNELS);
 
     if (mAudioVerifier.PreSilenceEnded()) {
       mFramesProcessedEvent.Notify(outframes);
--- a/dom/media/gtest/TestAudioDriftCorrection.cpp
+++ b/dom/media/gtest/TestAudioDriftCorrection.cpp
@@ -9,38 +9,39 @@
 
 #include "gmock/gmock.h"
 #include "gtest/gtest-printers.h"
 #include "gtest/gtest.h"
 
 // Runs UpdateClock() and checks that the reported correction level doesn't
 // change for enough time to trigger a correction update on the first
 // following UpdateClock(). Returns the first reported correction level.
-static float RunUntilCorrectionUpdate(ClockDrift& aC, int aSource, int aTarget,
-                                      int aBuffering, int aSaturation,
-                                      int aSourceOffset = 0,
-                                      int aTargetOffset = 0) {
+static float RunUntilCorrectionUpdate(ClockDrift& aC, uint32_t aSource,
+                                      uint32_t aTarget, uint32_t aBuffering,
+                                      uint32_t aSaturation,
+                                      uint32_t aSourceOffset = 0,
+                                      uint32_t aTargetOffset = 0) {
   Maybe<float> correction;
-  for (int s = aSourceOffset, t = aTargetOffset;
+  for (uint32_t s = aSourceOffset, t = aTargetOffset;
        s < aC.mSourceRate && t < aC.mTargetRate; s += aSource, t += aTarget) {
     aC.UpdateClock(aSource, aTarget, aBuffering, aSaturation);
     if (correction) {
       EXPECT_FLOAT_EQ(aC.GetCorrection(), *correction)
           << "s=" << s << "; t=" << t;
     } else {
       correction = Some(aC.GetCorrection());
     }
   }
   return *correction;
 };
 
 TEST(TestClockDrift, Basic)
 {
   // Keep buffered frames to the wanted level in order to not affect that test.
-  const int buffered = 5 * 480;
+  const uint32_t buffered = 5 * 480;
 
   ClockDrift c(48000, 48000, buffered);
   EXPECT_EQ(c.GetCorrection(), 1.0);
 
   EXPECT_FLOAT_EQ(RunUntilCorrectionUpdate(c, 480, 480, buffered, buffered),
                   1.0);
   EXPECT_FLOAT_EQ(
       RunUntilCorrectionUpdate(c, 480, 480 + 48, buffered, buffered), 1.0);
@@ -51,17 +52,17 @@ TEST(TestClockDrift, Basic)
 
   c.UpdateClock(0, 0, 5 * 480, 5 * 480);
   EXPECT_FLOAT_EQ(c.GetCorrection(), 0.95505452);
 }
 
 TEST(TestClockDrift, BasicResampler)
 {
   // Keep buffered frames to the wanted level in order to not affect that test.
-  const int buffered = 5 * 240;
+  const uint32_t buffered = 5 * 240;
 
   ClockDrift c(24000, 48000, buffered);
 
   // Keep buffered frames to the wanted level in order to not affect that test.
   EXPECT_FLOAT_EQ(RunUntilCorrectionUpdate(c, 240, 480, buffered, buffered),
                   1.0);
 
   // +10%
@@ -142,17 +143,17 @@ TEST(TestClockDrift, BufferedInputWithRe
 
   c.UpdateClock(240, 480, 7 * 240, 3 * 240);
   EXPECT_FLOAT_EQ(c.GetCorrection(), 0.99322605);
 }
 
 TEST(TestClockDrift, Clamp)
 {
   // Keep buffered frames to the wanted level in order to not affect that test.
-  const int buffered = 5 * 480;
+  const uint32_t buffered = 5 * 480;
 
   ClockDrift c(48000, 48000, buffered);
 
   // +30%
   EXPECT_FLOAT_EQ(
       RunUntilCorrectionUpdate(c, 480, 480 + 3 * 48, buffered, buffered), 1.0);
 
   // -30%
@@ -161,17 +162,17 @@ TEST(TestClockDrift, Clamp)
 
   c.UpdateClock(0, 0, buffered, buffered);
   EXPECT_FLOAT_EQ(c.GetCorrection(), 0.9);
 }
 
 TEST(TestClockDrift, SmallDiff)
 {
   // Keep buffered frames to the wanted level in order to not affect that test.
-  const int buffered = 5 * 480;
+  const uint32_t buffered = 5 * 480;
 
   ClockDrift c(48000, 48000, buffered);
 
   EXPECT_FLOAT_EQ(RunUntilCorrectionUpdate(c, 480 + 4, 480, buffered, buffered),
                   1.0);
   EXPECT_FLOAT_EQ(RunUntilCorrectionUpdate(c, 480 + 5, 480, buffered, buffered),
                   0.99504131);
   EXPECT_FLOAT_EQ(RunUntilCorrectionUpdate(c, 480, 480, buffered, buffered),
@@ -182,17 +183,17 @@ TEST(TestClockDrift, SmallDiff)
   EXPECT_FLOAT_EQ(c.GetCorrection(), 1.003693);
 }
 
 TEST(TestClockDrift, SmallBufferedFrames)
 {
   ClockDrift c(48000, 48000, 5 * 480);
 
   EXPECT_FLOAT_EQ(c.GetCorrection(), 1.0);
-  for (int i = 0; i < 10; ++i) {
+  for (uint32_t i = 0; i < 10; ++i) {
     c.UpdateClock(480, 480, 5 * 480, 5 * 480);
   }
   EXPECT_FLOAT_EQ(c.GetCorrection(), 1.0);
   c.UpdateClock(480, 480, 0, 10 * 480);
   EXPECT_FLOAT_EQ(c.GetCorrection(), 1.1);
 
   EXPECT_FLOAT_EQ(
       RunUntilCorrectionUpdate(c, 480, 480, 5 * 480, 5 * 480, 24000, 24000),
@@ -201,28 +202,28 @@ TEST(TestClockDrift, SmallBufferedFrames
   EXPECT_FLOAT_EQ(c.GetCorrection(), 1.1);
 }
 
 // Print the mono channel of a segment.
 void printAudioSegment(const AudioSegment& segment) {
   for (AudioSegment::ConstChunkIterator iter(segment); !iter.IsEnded();
        iter.Next()) {
     const AudioChunk& c = *iter;
-    for (int i = 0; i < c.GetDuration(); ++i) {
+    for (uint32_t i = 0; i < c.GetDuration(); ++i) {
       if (c.mBufferFormat == AUDIO_FORMAT_FLOAT32) {
         printf("%f\n", c.ChannelData<float>()[0][i]);
       } else {
         printf("%d\n", c.ChannelData<int16_t>()[0][i]);
       }
     }
   }
 }
 
 template <class T>
-AudioChunk CreateAudioChunk(uint32_t aFrames, int aChannels,
+AudioChunk CreateAudioChunk(uint32_t aFrames, uint32_t aChannels,
                             AudioSampleFormat aSampleFormat);
 
 void testAudioCorrection(int32_t aSourceRate, int32_t aTargetRate) {
   const uint32_t channels = 1;
   const uint32_t sampleRateTransmitter = aSourceRate;
   const uint32_t sampleRateReceiver = aTargetRate;
   const uint32_t frequency = 100;
   AudioDriftCorrection ad(sampleRateTransmitter, sampleRateReceiver);
@@ -232,29 +233,29 @@ void testAudioCorrection(int32_t aSource
   AudioVerifier<AudioDataValue> inToneVerifier(sampleRateTransmitter,
                                                frequency);
   AudioVerifier<AudioDataValue> outToneVerifier(sampleRateReceiver, frequency);
 
   uint32_t sourceFrames;
   const uint32_t targetFrames = sampleRateReceiver / 100;
 
   // Run for some time: 3 * 1050 = 3150 iterations
-  for (int j = 0; j < 3; ++j) {
+  for (uint32_t j = 0; j < 3; ++j) {
     // apply some drift
     if (j % 2 == 0) {
       sourceFrames =
           sampleRateTransmitter * /*1.02*/ 102 / 100 / /*1s->10ms*/ 100;
     } else {
       sourceFrames =
           sampleRateTransmitter * /*0.98*/ 98 / 100 / /*1s->10ms*/ 100;
     }
 
     // 10.5 seconds, allows for at least 10 correction changes, to stabilize
     // around the desired buffer.
-    for (int n = 0; n < 1050; ++n) {
+    for (uint32_t n = 0; n < 1050; ++n) {
       // Create the input (sine tone)
       AudioSegment inSegment;
       tone.Generate(inSegment, sourceFrames);
       inToneVerifier.AppendData(inSegment);
       // Print the input for debugging
       // printAudioSegment(inSegment);
 
       // Get the output of the correction
@@ -287,41 +288,41 @@ TEST(TestAudioDriftCorrection, Basic)
   printf("Testing AudioCorrection 48 -> 44.1\n");
   testAudioCorrection(48000, 44100);
   printf("Testing AudioCorrection 44.1 -> 48\n");
   testAudioCorrection(44100, 48000);
   printf("Testing AudioCorrection 23458 -> 25113\n");
   testAudioCorrection(23458, 25113);
 }
 
-void testMonoToStereoInput(int aSourceRate, int aTargetRate) {
+void testMonoToStereoInput(uint32_t aSourceRate, uint32_t aTargetRate) {
   const uint32_t frequency = 100;
   const uint32_t sampleRateTransmitter = aSourceRate;
   const uint32_t sampleRateReceiver = aTargetRate;
   AudioDriftCorrection ad(sampleRateTransmitter, sampleRateReceiver);
 
   AudioGenerator<AudioDataValue> monoTone(1, sampleRateTransmitter, frequency);
   AudioGenerator<AudioDataValue> stereoTone(2, sampleRateTransmitter,
                                             frequency);
   AudioVerifier<AudioDataValue> inToneVerify(sampleRateTransmitter, frequency);
   AudioVerifier<AudioDataValue> outToneVerify(sampleRateReceiver, frequency);
 
   uint32_t sourceFrames;
   const uint32_t targetFrames = sampleRateReceiver / 100;
 
   // Run for some time: 6 * 250 = 1500 iterations
-  for (int j = 0; j < 6; ++j) {
+  for (uint32_t j = 0; j < 6; ++j) {
     // apply some drift
     if (j % 2 == 0) {
       sourceFrames = sampleRateTransmitter / 100 + 10;
     } else {
       sourceFrames = sampleRateTransmitter / 100 - 10;
     }
 
-    for (int n = 0; n < 250; ++n) {
+    for (uint32_t n = 0; n < 250; ++n) {
       // Create the input (sine tone) of two chunks.
       AudioSegment inSegment;
       monoTone.Generate(inSegment, sourceFrames / 2);
       stereoTone.SetOffset(monoTone.Offset());
       stereoTone.Generate(inSegment, sourceFrames / 2);
       monoTone.SetOffset(stereoTone.Offset());
       inToneVerify.AppendData(inSegment);
       // Print the input for debugging
@@ -358,17 +359,17 @@ TEST(TestAudioDriftCorrection, MonoToSte
 
 TEST(TestAudioDriftCorrection, NotEnoughFrames)
 {
   const uint32_t sampleRateTransmitter = 48000;
   const uint32_t sampleRateReceiver = 48000;
   AudioDriftCorrection ad(sampleRateTransmitter, sampleRateReceiver);
   const uint32_t targetFrames = sampleRateReceiver / 100;
 
-  for (int i = 0; i < 7; ++i) {
+  for (uint32_t i = 0; i < 7; ++i) {
     // Input is something small, 10 frames here, in order to dry out fast,
     // after 4 iterations
     AudioChunk chunk = CreateAudioChunk<float>(10, 1, AUDIO_FORMAT_FLOAT32);
     AudioSegment inSegment;
     inSegment.AppendAndConsumeChunk(&chunk);
 
     AudioSegment outSegment = ad.RequestFrames(inSegment, targetFrames);
     EXPECT_EQ(outSegment.GetDuration(), targetFrames);
@@ -384,17 +385,17 @@ TEST(TestAudioDriftCorrection, NotEnough
 
 TEST(TestAudioDriftCorrection, CrashInAudioResampler)
 {
   const uint32_t sampleRateTransmitter = 48000;
   const uint32_t sampleRateReceiver = 48000;
   AudioDriftCorrection ad(sampleRateTransmitter, sampleRateReceiver);
   const uint32_t targetFrames = sampleRateReceiver / 100;
 
-  for (int i = 0; i < 100; ++i) {
+  for (uint32_t i = 0; i < 100; ++i) {
     AudioChunk chunk = CreateAudioChunk<float>(sampleRateTransmitter / 1000, 1,
                                                AUDIO_FORMAT_FLOAT32);
     AudioSegment inSegment;
     inSegment.AppendAndConsumeChunk(&chunk);
 
     AudioSegment outSegment = ad.RequestFrames(inSegment, targetFrames);
     EXPECT_EQ(outSegment.GetDuration(), targetFrames);
   }
--- a/dom/media/gtest/TestAudioRingBuffer.cpp
+++ b/dom/media/gtest/TestAudioRingBuffer.cpp
@@ -9,418 +9,419 @@
 
 TEST(TestAudioRingBuffer, BasicFloat)
 {
   AudioRingBuffer ringBuffer(11 * sizeof(float));
   ringBuffer.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
 
-  int rv = ringBuffer.WriteSilence(4);
-  EXPECT_EQ(rv, 4);
+  uint32_t rv = ringBuffer.WriteSilence(4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 6);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 4);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 6u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 4u);
 
   float in[4] = {.1, .2, .3, .4};
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 2);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 8);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 2u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 8u);
 
   rv = ringBuffer.WriteSilence(4);
-  EXPECT_EQ(rv, 2);
+  EXPECT_EQ(rv, 2u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 0);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 10);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 0u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 10u);
 
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 0);
+  EXPECT_EQ(rv, 0u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 0);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 10);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 0u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 10u);
 
   float out[4] = {};
   rv = ringBuffer.Read(Span(out, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 4);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 6);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 4u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 6u);
   for (float f : out) {
     EXPECT_FLOAT_EQ(f, 0.0);
   }
 
   rv = ringBuffer.Read(Span(out, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 8);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 2);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 8u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 2u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_FLOAT_EQ(in[i], out[i]);
   }
 
   rv = ringBuffer.Read(Span(out, 4));
-  EXPECT_EQ(rv, 2);
+  EXPECT_EQ(rv, 2u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < 2; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < 2; ++i) {
     EXPECT_FLOAT_EQ(out[i], 0.0);
   }
 
   rv = ringBuffer.Clear();
-  EXPECT_EQ(rv, 0);
+  EXPECT_EQ(rv, 0u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
 }
 
 TEST(TestAudioRingBuffer, BasicShort)
 {
   AudioRingBuffer ringBuffer(11 * sizeof(short));
   ringBuffer.SetSampleFormat(AUDIO_FORMAT_S16);
 
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
 
-  int rv = ringBuffer.WriteSilence(4);
-  EXPECT_EQ(rv, 4);
+  uint32_t rv = ringBuffer.WriteSilence(4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 6);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 4);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 6u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 4u);
 
   short in[4] = {1, 2, 3, 4};
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 2);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 8);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 2u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 8u);
 
   rv = ringBuffer.WriteSilence(4);
-  EXPECT_EQ(rv, 2);
+  EXPECT_EQ(rv, 2u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 0);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 10);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 0u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 10u);
 
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 0);
+  EXPECT_EQ(rv, 0u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 0);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 10);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 0u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 10u);
 
   short out[4] = {};
   rv = ringBuffer.Read(Span(out, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 4);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 6);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 4u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 6u);
   for (float f : out) {
     EXPECT_EQ(f, 0);
   }
 
   rv = ringBuffer.Read(Span(out, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 8);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 2);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 8u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 2u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_EQ(in[i], out[i]);
   }
 
   rv = ringBuffer.Read(Span(out, 4));
-  EXPECT_EQ(rv, 2);
+  EXPECT_EQ(rv, 2u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < 2; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < 2; ++i) {
     EXPECT_EQ(out[i], 0);
   }
 
   rv = ringBuffer.Clear();
-  EXPECT_EQ(rv, 0);
+  EXPECT_EQ(rv, 0u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
 }
 
 TEST(TestAudioRingBuffer, BasicFloat2)
 {
   AudioRingBuffer ringBuffer(11 * sizeof(float));
   ringBuffer.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
 
   float in[4] = {.1, .2, .3, .4};
-  int rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  uint32_t rv = ringBuffer.Write(Span(in, 4));
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 6);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 4);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 6u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 4u);
 
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 2);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 8);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 2u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 8u);
 
   float out[4] = {};
   rv = ringBuffer.Read(Span(out, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 6);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 4);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 6u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 4u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_FLOAT_EQ(in[i], out[i]);
   }
 
   // WriteIndex = 12
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 2);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 8);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 2u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 8u);
 
   rv = ringBuffer.Read(Span(out, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 6);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 4);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 6u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 4u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_FLOAT_EQ(in[i], out[i]);
   }
 
   rv = ringBuffer.Read(Span(out, 8));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_FLOAT_EQ(in[i], out[i]);
   }
 
   rv = ringBuffer.Read(Span(out, 8));
-  EXPECT_EQ(rv, 0);
+  EXPECT_EQ(rv, 0u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_FLOAT_EQ(in[i], out[i]);
   }
 
   // WriteIndex = 16
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 6);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 4);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 6u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 4u);
 
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 2);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 8);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 2u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 8u);
 
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 2);
+  EXPECT_EQ(rv, 2u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 0);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 10);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 0u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 10u);
 
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 0);
+  EXPECT_EQ(rv, 0u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 0);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 10);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 0u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 10u);
 }
 
 TEST(TestAudioRingBuffer, BasicShort2)
 {
   AudioRingBuffer ringBuffer(11 * sizeof(int16_t));
   ringBuffer.SetSampleFormat(AUDIO_FORMAT_S16);
 
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
 
   int16_t in[4] = {1, 2, 3, 4};
-  int rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  uint32_t rv = ringBuffer.Write(Span(in, 4));
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 6);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 4);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 6u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 4u);
 
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 2);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 8);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 2u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 8u);
 
   int16_t out[4] = {};
   rv = ringBuffer.Read(Span(out, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 6);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 4);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 6u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 4u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_EQ(in[i], out[i]);
   }
 
   // WriteIndex = 12
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 2);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 8);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 2u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 8u);
 
   rv = ringBuffer.Read(Span(out, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 6);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 4);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 6u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 4u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_EQ(in[i], out[i]);
   }
 
   rv = ringBuffer.Read(Span(out, 8));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_EQ(in[i], out[i]);
   }
 
   rv = ringBuffer.Read(Span(out, 8));
-  EXPECT_EQ(rv, 0);
+  EXPECT_EQ(rv, 0u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_EQ(in[i], out[i]);
   }
 
   // WriteIndex = 16
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 6);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 4);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 6u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 4u);
 
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 2);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 8);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 2u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 8u);
 
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 2);
+  EXPECT_EQ(rv, 2u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 0);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 10);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 0u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 10u);
 
   rv = ringBuffer.Write(Span(in, 4));
-  EXPECT_EQ(rv, 0);
+  EXPECT_EQ(rv, 0u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 0);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 10);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 0u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 10u);
 }
 
 TEST(TestAudioRingBuffer, NoCopyFloat)
 {
   AudioRingBuffer ringBuffer(11 * sizeof(float));
   ringBuffer.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   float in[8] = {.0, .1, .2, .3, .4, .5, .6, .7};
   ringBuffer.Write(Span(in, 6));
   //  v ReadIndex
   // [x0: .0, x1: .1, x2: .2, x3: .3, x4: .4,
   //  x5: .5, x6: .0, x7: .0, x8: .0, x9: .0, x10: .0]
 
   float out[10] = {};
   float* out_ptr = out;
 
-  int rv = ringBuffer.ReadNoCopy([&out_ptr](const Span<const float> aInBuffer) {
-    PodMove(out_ptr, aInBuffer.data(), aInBuffer.Length());
-    out_ptr += aInBuffer.Length();
-    return aInBuffer.Length();
-  });
-  EXPECT_EQ(rv, 6);
+  uint32_t rv =
+      ringBuffer.ReadNoCopy([&out_ptr](const Span<const float> aInBuffer) {
+        PodMove(out_ptr, aInBuffer.data(), aInBuffer.Length());
+        out_ptr += aInBuffer.Length();
+        return aInBuffer.Length();
+      });
+  EXPECT_EQ(rv, 6u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_FLOAT_EQ(out[i], in[i]);
   }
 
   ringBuffer.Write(Span(in, 8));
   // Now the buffer contains:
   // [x0: .5, x1: .6, x2: .2, x3: .3, x4: .4,
   //  x5: .5, x6: .0, x7: .1, x8: .2, x9: .3, x10: .4
   //          ^ ReadIndex
   out_ptr = out;  // reset the pointer before lambdas reuse
   rv = ringBuffer.ReadNoCopy([&out_ptr](const Span<const float> aInBuffer) {
     PodMove(out_ptr, aInBuffer.data(), aInBuffer.Length());
     out_ptr += aInBuffer.Length();
     return aInBuffer.Length();
   });
-  EXPECT_EQ(rv, 8);
+  EXPECT_EQ(rv, 8u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_FLOAT_EQ(out[i], in[i]);
   }
 }
 
 TEST(TestAudioRingBuffer, NoCopyShort)
 {
   AudioRingBuffer ringBuffer(11 * sizeof(short));
   ringBuffer.SetSampleFormat(AUDIO_FORMAT_S16);
@@ -429,47 +430,48 @@ TEST(TestAudioRingBuffer, NoCopyShort)
   ringBuffer.Write(Span(in, 6));
   //  v ReadIndex
   // [x0: 0, x1: 1, x2: 2, x3: 3, x4: 4,
   //  x5: 5, x6: 0, x7: 0, x8: 0, x9: 0, x10: 0]
 
   short out[10] = {};
   short* out_ptr = out;
 
-  int rv = ringBuffer.ReadNoCopy([&out_ptr](const Span<const short> aInBuffer) {
-    PodMove(out_ptr, aInBuffer.data(), aInBuffer.Length());
-    out_ptr += aInBuffer.Length();
-    return aInBuffer.Length();
-  });
-  EXPECT_EQ(rv, 6);
+  uint32_t rv =
+      ringBuffer.ReadNoCopy([&out_ptr](const Span<const short> aInBuffer) {
+        PodMove(out_ptr, aInBuffer.data(), aInBuffer.Length());
+        out_ptr += aInBuffer.Length();
+        return aInBuffer.Length();
+      });
+  EXPECT_EQ(rv, 6u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_EQ(out[i], in[i]);
   }
 
   ringBuffer.Write(Span(in, 8));
   // Now the buffer contains:
   // [x0: 5, x1: 6, x2: 2, x3: 3, x4: 4,
   //  x5: 5, x6: 0, x7: 1, x8: 2, x9: 3, x10: 4
   //          ^ ReadIndex
   out_ptr = out;  // reset the pointer before lambdas reuse
   rv = ringBuffer.ReadNoCopy([&out_ptr](const Span<const short> aInBuffer) {
     PodMove(out_ptr, aInBuffer.data(), aInBuffer.Length());
     out_ptr += aInBuffer.Length();
     return aInBuffer.Length();
   });
-  EXPECT_EQ(rv, 8);
+  EXPECT_EQ(rv, 8u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_EQ(out[i], in[i]);
   }
 }
 
 TEST(TestAudioRingBuffer, NoCopyFloat2)
 {
   AudioRingBuffer ringBuffer(11 * sizeof(float));
   ringBuffer.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
@@ -477,131 +479,136 @@ TEST(TestAudioRingBuffer, NoCopyFloat2)
   float in[8] = {.0, .1, .2, .3, .4, .5, .6, .7};
   ringBuffer.Write(Span(in, 6));
   //  v ReadIndex
   // [x0: .0, x1: .1, x2: .2, x3: .3, x4: .4,
   //  x5: .5, x6: .0, x7: .0, x8: .0, x9: .0, x10: .0]
 
   float out[10] = {};
   float* out_ptr = out;
-  int total_frames = 3;
+  uint32_t total_frames = 3;
 
-  int rv = ringBuffer.ReadNoCopy(
+  uint32_t rv = ringBuffer.ReadNoCopy(
       [&out_ptr, &total_frames](const Span<const float>& aInBuffer) {
-        int inFramesUsed = std::min<int>(total_frames, aInBuffer.Length());
+        uint32_t inFramesUsed =
+            std::min<uint32_t>(total_frames, aInBuffer.Length());
         PodMove(out_ptr, aInBuffer.data(), inFramesUsed);
         out_ptr += inFramesUsed;
         total_frames -= inFramesUsed;
         return inFramesUsed;
       });
   //                          v ReadIndex
   // [x0: .0, x1: .1, x2: .2, x3: .3, x4: .4,
   //  x5: .5, x6: .0, x7: .0, x8: .0, x9: .0, x10: .0]
-  EXPECT_EQ(rv, 3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 7);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 3);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 7u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 3u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_FLOAT_EQ(out[i], in[i]);
   }
 
   total_frames = 3;
   rv = ringBuffer.ReadNoCopy(
       [&out_ptr, &total_frames](const Span<const float>& aInBuffer) {
-        int inFramesUsed = std::min<int>(total_frames, aInBuffer.Length());
+        uint32_t inFramesUsed =
+            std::min<uint32_t>(total_frames, aInBuffer.Length());
         PodMove(out_ptr, aInBuffer.data(), inFramesUsed);
         out_ptr += inFramesUsed;
         total_frames -= inFramesUsed;
         return inFramesUsed;
       });
   // [x0: .0, x1: .1, x2: .2, x3: .3, x4: .4,
   //  x5: .5, x6: .0, x7: .0, x8: .0, x9: .0, x10: .0]
   //          ^ ReadIndex
-  EXPECT_EQ(rv, 3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_FLOAT_EQ(out[i + 3], in[i + 3]);
   }
 
   ringBuffer.Write(Span(in, 8));
   // Now the buffer contains:
   // [x0: .5, x1: .6, x2: .7, x3: .3, x4: .4,
   //  x5: .5, x6: .0, x7: .1, x8: .2, x9: .3, x10: .4
   //          ^ ReadIndex
 
   // reset the pointer before lambdas reuse
   out_ptr = out;
   total_frames = 3;
   rv = ringBuffer.ReadNoCopy(
       [&out_ptr, &total_frames](const Span<const float>& aInBuffer) {
-        int inFramesUsed = std::min<int>(total_frames, aInBuffer.Length());
+        uint32_t inFramesUsed =
+            std::min<uint32_t>(total_frames, aInBuffer.Length());
         PodMove(out_ptr, aInBuffer.data(), inFramesUsed);
         out_ptr += inFramesUsed;
         total_frames -= inFramesUsed;
         return inFramesUsed;
       });
   // Now the buffer contains:
   // [x0: .5, x1: .6, x2: .2, x3: .3, x4: .4,
   //  x5: .5, x6: .0, x7: .1, x8: .2, x9: .3, x10: .4
   //                                  ^ ReadIndex
-  EXPECT_EQ(rv, 3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 5);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 5);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 5u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 5u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_FLOAT_EQ(out[i], in[i]);
   }
 
   total_frames = 3;
   rv = ringBuffer.ReadNoCopy(
       [&out_ptr, &total_frames](const Span<const float>& aInBuffer) {
-        int inFramesUsed = std::min<int>(total_frames, aInBuffer.Length());
+        uint32_t inFramesUsed =
+            std::min<uint32_t>(total_frames, aInBuffer.Length());
         PodMove(out_ptr, aInBuffer.data(), inFramesUsed);
         out_ptr += inFramesUsed;
         total_frames -= inFramesUsed;
         return inFramesUsed;
       });
   // Now the buffer contains:
   //          v ReadIndex
   // [x0: .5, x1: .6, x2: .7, x3: .3, x4: .4,
   //  x5: .5, x6: .0, x7: .1, x8: .2, x9: .3, x10: .4
-  EXPECT_EQ(rv, 3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 8);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 2);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 8u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 2u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_FLOAT_EQ(out[i + 3], in[i + 3]);
   }
 
   total_frames = 3;
   rv = ringBuffer.ReadNoCopy(
       [&out_ptr, &total_frames](const Span<const float>& aInBuffer) {
-        int inFramesUsed = std::min<int>(total_frames, aInBuffer.Length());
+        uint32_t inFramesUsed =
+            std::min<uint32_t>(total_frames, aInBuffer.Length());
         PodMove(out_ptr, aInBuffer.data(), inFramesUsed);
         out_ptr += inFramesUsed;
         total_frames -= inFramesUsed;
         return inFramesUsed;
       });
   // Now the buffer contains:
   //                          v ReadIndex
   // [x0: .5, x1: .6, x2: .7, x3: .3, x4: .4,
   //  x5: .5, x6: .0, x7: .1, x8: .2, x9: .3, x10: .4
-  EXPECT_EQ(rv, 2);
-  EXPECT_EQ(total_frames, 1);
+  EXPECT_EQ(rv, 2u);
+  EXPECT_EQ(total_frames, 1u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_FLOAT_EQ(out[i + 6], in[i + 6]);
   }
 }
 
 TEST(TestAudioRingBuffer, NoCopyShort2)
 {
   AudioRingBuffer ringBuffer(11 * sizeof(short));
   ringBuffer.SetSampleFormat(AUDIO_FORMAT_S16);
@@ -609,265 +616,270 @@ TEST(TestAudioRingBuffer, NoCopyShort2)
   short in[8] = {0, 1, 2, 3, 4, 5, 6, 7};
   ringBuffer.Write(Span(in, 6));
   //  v ReadIndex
   // [x0: 0, x1: 1, x2: 2, x3: 3, x4: 4,
   //  x5: 5, x6: 0, x7: 0, x8: 0, x9: 0, x10: 0]
 
   short out[10] = {};
   short* out_ptr = out;
-  int total_frames = 3;
+  uint32_t total_frames = 3;
 
-  int rv = ringBuffer.ReadNoCopy(
+  uint32_t rv = ringBuffer.ReadNoCopy(
       [&out_ptr, &total_frames](const Span<const short>& aInBuffer) {
-        int inFramesUsed = std::min<int>(total_frames, aInBuffer.Length());
+        uint32_t inFramesUsed =
+            std::min<uint32_t>(total_frames, aInBuffer.Length());
         PodMove(out_ptr, aInBuffer.data(), inFramesUsed);
         out_ptr += inFramesUsed;
         total_frames -= inFramesUsed;
         return inFramesUsed;
       });
   //                       v ReadIndex
   // [x0: 0, x1: 1, x2: 2, x3: 3, x4: 4,
   //  x5: 5, x6: 0, x7: 0, x8: 0, x9: 0, x10: 0]
-  EXPECT_EQ(rv, 3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 7);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 3);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 7u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 3u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_EQ(out[i], in[i]);
   }
 
   total_frames = 3;
   rv = ringBuffer.ReadNoCopy(
       [&out_ptr, &total_frames](const Span<const short>& aInBuffer) {
-        int inFramesUsed = std::min<int>(total_frames, aInBuffer.Length());
+        uint32_t inFramesUsed =
+            std::min<uint32_t>(total_frames, aInBuffer.Length());
         PodMove(out_ptr, aInBuffer.data(), inFramesUsed);
         out_ptr += inFramesUsed;
         total_frames -= inFramesUsed;
         return inFramesUsed;
       });
   // [x0: 0, x1: 1, x2: 2, x3: 3, x4: 4,
   //  x5: 5, x6: 0, x7: 0, x8: 0, x9: 0, x10: .0]
   //         ^ ReadIndex
-  EXPECT_EQ(rv, 3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_EQ(out[i + 3], in[i + 3]);
   }
 
   ringBuffer.Write(Span(in, 8));
   // Now the buffer contains:
   // [x0: 5, x1: 6, x2: 7, x3: 3, x4: 4,
   //  x5: 5, x6: 0, x7: 1, x8: 2, x9: 3, x10: 4
   //         ^ ReadIndex
 
   // reset the pointer before lambdas reuse
   out_ptr = out;
   total_frames = 3;
   rv = ringBuffer.ReadNoCopy(
       [&out_ptr, &total_frames](const Span<const short>& aInBuffer) {
-        int inFramesUsed = std::min<int>(total_frames, aInBuffer.Length());
+        uint32_t inFramesUsed =
+            std::min<uint32_t>(total_frames, aInBuffer.Length());
         PodMove(out_ptr, aInBuffer.data(), inFramesUsed);
         out_ptr += inFramesUsed;
         total_frames -= inFramesUsed;
         return inFramesUsed;
       });
   // Now the buffer contains:
   // [x0: 5, x1: 6, x2: 2, x3: 3, x4: 4,
   //  x5: 5, x6: 0, x7: 1, x8: 2, x9: 3, x10: 4
   //                              ^ ReadIndex
-  EXPECT_EQ(rv, 3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 5);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 5);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 5u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 5u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_EQ(out[i], in[i]);
   }
 
   total_frames = 3;
   rv = ringBuffer.ReadNoCopy(
       [&out_ptr, &total_frames](const Span<const short>& aInBuffer) {
-        int inFramesUsed = std::min<int>(total_frames, aInBuffer.Length());
+        uint32_t inFramesUsed =
+            std::min<uint32_t>(total_frames, aInBuffer.Length());
         PodMove(out_ptr, aInBuffer.data(), inFramesUsed);
         out_ptr += inFramesUsed;
         total_frames -= inFramesUsed;
         return inFramesUsed;
       });
   // Now the buffer contains:
   //         v ReadIndex
   // [x0: 5, x1: 6, x2: 7, x3: 3, x4: 4,
   //  x5: 5, x6: 0, x7: 1, x8: 2, x9: 3, x10: 4
-  EXPECT_EQ(rv, 3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 8);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 2);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 8u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 2u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_EQ(out[i + 3], in[i + 3]);
   }
 
   total_frames = 3;
   rv = ringBuffer.ReadNoCopy(
       [&out_ptr, &total_frames](const Span<const short>& aInBuffer) {
-        int inFramesUsed = std::min<int>(total_frames, aInBuffer.Length());
+        uint32_t inFramesUsed =
+            std::min<uint32_t>(total_frames, aInBuffer.Length());
         PodMove(out_ptr, aInBuffer.data(), inFramesUsed);
         out_ptr += inFramesUsed;
         total_frames -= inFramesUsed;
         return inFramesUsed;
       });
   // Now the buffer contains:
   //                       v ReadIndex
   // [x0: 5, x1: 6, x2: 7, x3: 3, x4: 4,
   //  x5: 5, x6: 0, x7: 1, x8: 2, x9: 3, x10: 4
-  EXPECT_EQ(rv, 2);
-  EXPECT_EQ(total_frames, 1);
+  EXPECT_EQ(rv, 2u);
+  EXPECT_EQ(total_frames, 1u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_EQ(out[i + 6], in[i + 6]);
   }
 }
 
 TEST(TestAudioRingBuffer, DiscardFloat)
 {
   AudioRingBuffer ringBuffer(11 * sizeof(float));
   ringBuffer.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   float in[8] = {.0, .1, .2, .3, .4, .5, .6, .7};
   ringBuffer.Write(Span(in, 8));
 
-  int rv = ringBuffer.Discard(3);
-  EXPECT_EQ(rv, 3);
+  uint32_t rv = ringBuffer.Discard(3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 5);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 5);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 5u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 5u);
 
   float out[8] = {};
   rv = ringBuffer.Read(Span(out, 3));
-  EXPECT_EQ(rv, 3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 8);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 2);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 8u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 2u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_FLOAT_EQ(out[i], in[i + 3]);
   }
 
   rv = ringBuffer.Discard(3);
-  EXPECT_EQ(rv, 2);
+  EXPECT_EQ(rv, 2u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
 
   ringBuffer.WriteSilence(4);
   rv = ringBuffer.Discard(6);
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
 }
 
 TEST(TestAudioRingBuffer, DiscardShort)
 {
   AudioRingBuffer ringBuffer(11 * sizeof(short));
   ringBuffer.SetSampleFormat(AUDIO_FORMAT_S16);
 
   short in[8] = {0, 1, 2, 3, 4, 5, 6, 7};
   ringBuffer.Write(Span(in, 8));
 
-  int rv = ringBuffer.Discard(3);
-  EXPECT_EQ(rv, 3);
+  uint32_t rv = ringBuffer.Discard(3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 5);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 5);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 5u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 5u);
 
   short out[8] = {};
   rv = ringBuffer.Read(Span(out, 3));
-  EXPECT_EQ(rv, 3);
+  EXPECT_EQ(rv, 3u);
   EXPECT_TRUE(!ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 8);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 2);
-  for (int i = 0; i < rv; ++i) {
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 8u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 2u);
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_EQ(out[i], in[i + 3]);
   }
 
   rv = ringBuffer.Discard(3);
-  EXPECT_EQ(rv, 2);
+  EXPECT_EQ(rv, 2u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
 
   ringBuffer.WriteSilence(4);
   rv = ringBuffer.Discard(6);
-  EXPECT_EQ(rv, 4);
+  EXPECT_EQ(rv, 4u);
   EXPECT_TRUE(ringBuffer.IsEmpty());
   EXPECT_TRUE(!ringBuffer.IsFull());
-  EXPECT_EQ(ringBuffer.AvailableWrite(), 10);
-  EXPECT_EQ(ringBuffer.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer.AvailableWrite(), 10u);
+  EXPECT_EQ(ringBuffer.AvailableRead(), 0u);
 }
 
 TEST(TestRingBuffer, WriteFromRing1)
 {
   AudioRingBuffer ringBuffer1(11 * sizeof(float));
   ringBuffer1.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
   AudioRingBuffer ringBuffer2(11 * sizeof(float));
   ringBuffer2.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   float in[4] = {.1, .2, .3, .4};
-  int rv = ringBuffer1.Write(Span<const float>(in, 4));
-  EXPECT_EQ(rv, 4);
+  uint32_t rv = ringBuffer1.Write(Span<const float>(in, 4));
+  EXPECT_EQ(rv, 4u);
 
-  EXPECT_EQ(ringBuffer2.AvailableRead(), 0);
+  EXPECT_EQ(ringBuffer2.AvailableRead(), 0u);
   rv = ringBuffer2.Write(ringBuffer1, 4);
-  EXPECT_EQ(rv, 4);
-  EXPECT_EQ(ringBuffer2.AvailableRead(), 4);
+  EXPECT_EQ(rv, 4u);
+  EXPECT_EQ(ringBuffer2.AvailableRead(), 4u);
 
   float out[4] = {};
   rv = ringBuffer2.Read(Span<float>(out, 4));
-  EXPECT_EQ(rv, 4);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(rv, 4u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_FLOAT_EQ(in[i], out[i]);
   }
 }
 
 TEST(TestRingBuffer, WriteFromRing2)
 {
   AudioRingBuffer ringBuffer1(11 * sizeof(float));
   ringBuffer1.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
   AudioRingBuffer ringBuffer2(11 * sizeof(float));
   ringBuffer2.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   // Advance the index
   ringBuffer2.WriteSilence(8);
   ringBuffer2.Clear();
 
   float in[4] = {.1, .2, .3, .4};
-  int rv = ringBuffer1.Write(Span<const float>(in, 4));
-  EXPECT_EQ(rv, 4);
+  uint32_t rv = ringBuffer1.Write(Span<const float>(in, 4));
+  EXPECT_EQ(rv, 4u);
   rv = ringBuffer2.Write(ringBuffer1, 4);
-  EXPECT_EQ(rv, 4);
-  EXPECT_EQ(ringBuffer2.AvailableRead(), 4);
+  EXPECT_EQ(rv, 4u);
+  EXPECT_EQ(ringBuffer2.AvailableRead(), 4u);
 
   float out[4] = {};
   rv = ringBuffer2.Read(Span<float>(out, 4));
-  EXPECT_EQ(rv, 4);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(rv, 4u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_FLOAT_EQ(in[i], out[i]);
   }
 }
 
 TEST(TestRingBuffer, WriteFromRing3)
 {
   AudioRingBuffer ringBuffer1(11 * sizeof(float));
   ringBuffer1.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
@@ -876,103 +888,103 @@ TEST(TestRingBuffer, WriteFromRing3)
 
   // Advance the index
   ringBuffer2.WriteSilence(8);
   ringBuffer2.Clear();
   ringBuffer2.WriteSilence(4);
   ringBuffer2.Clear();
 
   float in[4] = {.1, .2, .3, .4};
-  int rv = ringBuffer1.Write(Span<const float>(in, 4));
-  EXPECT_EQ(rv, 4);
+  uint32_t rv = ringBuffer1.Write(Span<const float>(in, 4));
+  EXPECT_EQ(rv, 4u);
   rv = ringBuffer2.Write(ringBuffer1, 4);
-  EXPECT_EQ(rv, 4);
-  EXPECT_EQ(ringBuffer2.AvailableRead(), 4);
+  EXPECT_EQ(rv, 4u);
+  EXPECT_EQ(ringBuffer2.AvailableRead(), 4u);
 
   float out[4] = {};
   rv = ringBuffer2.Read(Span<float>(out, 4));
-  EXPECT_EQ(rv, 4);
-  for (int i = 0; i < 4; ++i) {
+  EXPECT_EQ(rv, 4u);
+  for (uint32_t i = 0; i < 4; ++i) {
     EXPECT_FLOAT_EQ(in[i], out[i]);
   }
 }
 
 TEST(TestAudioRingBuffer, WriteFromRingShort)
 {
   AudioRingBuffer ringBuffer1(11 * sizeof(short));
   ringBuffer1.SetSampleFormat(AUDIO_FORMAT_S16);
 
   short in[8] = {0, 1, 2, 3, 4, 5, 6, 7};
-  int rv = ringBuffer1.Write(Span(in, 8));
-  EXPECT_EQ(rv, 8);
+  uint32_t rv = ringBuffer1.Write(Span(in, 8));
+  EXPECT_EQ(rv, 8u);
 
   AudioRingBuffer ringBuffer2(11 * sizeof(short));
   ringBuffer2.SetSampleFormat(AUDIO_FORMAT_S16);
 
   rv = ringBuffer2.Write(ringBuffer1, 4);
-  EXPECT_EQ(rv, 4);
-  EXPECT_EQ(ringBuffer2.AvailableRead(), 4);
-  EXPECT_EQ(ringBuffer1.AvailableRead(), 8);
+  EXPECT_EQ(rv, 4u);
+  EXPECT_EQ(ringBuffer2.AvailableRead(), 4u);
+  EXPECT_EQ(ringBuffer1.AvailableRead(), 8u);
 
   short out[4] = {};
   rv = ringBuffer2.Read(Span(out, 4));
-  for (int i = 0; i < rv; ++i) {
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_EQ(out[i], in[i]);
   }
 
   rv = ringBuffer2.Write(ringBuffer1, 4);
-  EXPECT_EQ(rv, 4);
-  EXPECT_EQ(ringBuffer2.AvailableRead(), 4);
-  EXPECT_EQ(ringBuffer1.AvailableRead(), 8);
+  EXPECT_EQ(rv, 4u);
+  EXPECT_EQ(ringBuffer2.AvailableRead(), 4u);
+  EXPECT_EQ(ringBuffer1.AvailableRead(), 8u);
 
   ringBuffer1.Discard(4);
   rv = ringBuffer2.Write(ringBuffer1, 4);
-  EXPECT_EQ(rv, 4);
-  EXPECT_EQ(ringBuffer2.AvailableRead(), 8);
-  EXPECT_EQ(ringBuffer1.AvailableRead(), 4);
+  EXPECT_EQ(rv, 4u);
+  EXPECT_EQ(ringBuffer2.AvailableRead(), 8u);
+  EXPECT_EQ(ringBuffer1.AvailableRead(), 4u);
 
   short out2[8] = {};
   rv = ringBuffer2.Read(Span(out2, 8));
-  for (int i = 0; i < rv; ++i) {
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_EQ(out2[i], in[i]);
   }
 }
 
 TEST(TestAudioRingBuffer, WriteFromRingFloat)
 {
   AudioRingBuffer ringBuffer1(11 * sizeof(float));
   ringBuffer1.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   float in[8] = {.0, .1, .2, .3, .4, .5, .6, .7};
-  int rv = ringBuffer1.Write(Span(in, 8));
-  EXPECT_EQ(rv, 8);
+  uint32_t rv = ringBuffer1.Write(Span(in, 8));
+  EXPECT_EQ(rv, 8u);
 
   AudioRingBuffer ringBuffer2(11 * sizeof(float));
   ringBuffer2.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   rv = ringBuffer2.Write(ringBuffer1, 4);
-  EXPECT_EQ(rv, 4);
-  EXPECT_EQ(ringBuffer2.AvailableRead(), 4);
-  EXPECT_EQ(ringBuffer1.AvailableRead(), 8);
+  EXPECT_EQ(rv, 4u);
+  EXPECT_EQ(ringBuffer2.AvailableRead(), 4u);
+  EXPECT_EQ(ringBuffer1.AvailableRead(), 8u);
 
   float out[4] = {};
   rv = ringBuffer2.Read(Span(out, 4));
-  for (int i = 0; i < rv; ++i) {
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_FLOAT_EQ(out[i], in[i]);
   }
 
   rv = ringBuffer2.Write(ringBuffer1, 4);
-  EXPECT_EQ(rv, 4);
-  EXPECT_EQ(ringBuffer2.AvailableRead(), 4);
-  EXPECT_EQ(ringBuffer1.AvailableRead(), 8);
+  EXPECT_EQ(rv, 4u);
+  EXPECT_EQ(ringBuffer2.AvailableRead(), 4u);
+  EXPECT_EQ(ringBuffer1.AvailableRead(), 8u);
 
   ringBuffer1.Discard(4);
   rv = ringBuffer2.Write(ringBuffer1, 4);
-  EXPECT_EQ(rv, 4);
-  EXPECT_EQ(ringBuffer2.AvailableRead(), 8);
-  EXPECT_EQ(ringBuffer1.AvailableRead(), 4);
+  EXPECT_EQ(rv, 4u);
+  EXPECT_EQ(ringBuffer2.AvailableRead(), 8u);
+  EXPECT_EQ(ringBuffer1.AvailableRead(), 4u);
 
   float out2[8] = {};
   rv = ringBuffer2.Read(Span(out2, 8));
-  for (int i = 0; i < rv; ++i) {
+  for (uint32_t i = 0; i < rv; ++i) {
     EXPECT_FLOAT_EQ(out2[i], in[i]);
   }
 }
--- a/dom/media/gtest/TestDynamicResampler.cpp
+++ b/dom/media/gtest/TestDynamicResampler.cpp
@@ -10,19 +10,19 @@
 #include "DynamicResampler.h"
 
 using namespace mozilla;
 
 TEST(TestDynamicResampler, SameRates_Float1)
 {
   const uint32_t in_frames = 100;
   const uint32_t out_frames = 100;
-  int channels = 2;
-  int in_rate = 44100;
-  int out_rate = 44100;
+  uint32_t channels = 2;
+  uint32_t in_rate = 44100;
+  uint32_t out_rate = 44100;
 
   DynamicResampler dr(in_rate, out_rate);
   dr.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
   EXPECT_EQ(dr.GetOutRate(), out_rate);
   EXPECT_EQ(dr.GetChannels(), channels);
 
   // float in_ch1[] = {.1, .2, .3, .4, .5, .6, .7, .8, .9, 1.0};
   // float in_ch2[] = {.1, .2, .3, .4, .5, .6, .7, .8, .9, 1.0};
@@ -76,19 +76,19 @@ TEST(TestDynamicResampler, SameRates_Flo
   EXPECT_FALSE(rv);
   EXPECT_EQ(out_frames_used, 0u);
 }
 
 TEST(TestDynamicResampler, SameRates_Short1)
 {
   uint32_t in_frames = 2;
   uint32_t out_frames = 2;
-  int channels = 2;
-  int in_rate = 44100;
-  int out_rate = 44100;
+  uint32_t channels = 2;
+  uint32_t in_rate = 44100;
+  uint32_t out_rate = 44100;
 
   DynamicResampler dr(in_rate, out_rate);
   dr.SetSampleFormat(AUDIO_FORMAT_S16);
   EXPECT_EQ(dr.GetOutRate(), out_rate);
   EXPECT_EQ(dr.GetChannels(), channels);
 
   short in_ch1[] = {1, 2, 3};
   short in_ch2[] = {4, 5, 6};
@@ -121,19 +121,19 @@ TEST(TestDynamicResampler, SameRates_Sho
   EXPECT_FALSE(rv);
   EXPECT_EQ(out_frames, 0u);
 }
 
 TEST(TestDynamicResampler, SameRates_Float2)
 {
   uint32_t in_frames = 3;
   uint32_t out_frames = 2;
-  int channels = 2;
-  int in_rate = 44100;
-  int out_rate = 44100;
+  uint32_t channels = 2;
+  uint32_t in_rate = 44100;
+  uint32_t out_rate = 44100;
 
   DynamicResampler dr(in_rate, out_rate);
   dr.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   float in_ch1[] = {0.1, 0.2, 0.3};
   float in_ch2[] = {0.4, 0.5, 0.6};
   AutoTArray<const float*, 2> in_buffer;
   in_buffer.AppendElements(channels);
@@ -176,19 +176,19 @@ TEST(TestDynamicResampler, SameRates_Flo
   EXPECT_FALSE(rv);
   EXPECT_EQ(out_frames, 0u);
 }
 
 TEST(TestDynamicResampler, SameRates_Short2)
 {
   uint32_t in_frames = 3;
   uint32_t out_frames = 2;
-  int channels = 2;
-  int in_rate = 44100;
-  int out_rate = 44100;
+  uint32_t channels = 2;
+  uint32_t in_rate = 44100;
+  uint32_t out_rate = 44100;
 
   DynamicResampler dr(in_rate, out_rate);
   dr.SetSampleFormat(AUDIO_FORMAT_S16);
 
   short in_ch1[] = {1, 2, 3};
   short in_ch2[] = {4, 5, 6};
   AutoTArray<const short*, 2> in_buffer;
   in_buffer.AppendElements(channels);
@@ -231,19 +231,19 @@ TEST(TestDynamicResampler, SameRates_Sho
   EXPECT_FALSE(rv);
   EXPECT_EQ(out_frames, 0u);
 }
 
 TEST(TestDynamicResampler, SameRates_Float3)
 {
   uint32_t in_frames = 2;
   uint32_t out_frames = 3;
-  int channels = 2;
-  int in_rate = 44100;
-  int out_rate = 44100;
+  uint32_t channels = 2;
+  uint32_t in_rate = 44100;
+  uint32_t out_rate = 44100;
 
   DynamicResampler dr(in_rate, out_rate);
   dr.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   float in_ch1[] = {0.1, 0.2, 0.3};
   float in_ch2[] = {0.4, 0.5, 0.6};
   AutoTArray<const float*, 2> in_buffer;
   in_buffer.AppendElements(channels);
@@ -279,19 +279,19 @@ TEST(TestDynamicResampler, SameRates_Flo
     EXPECT_FLOAT_EQ(in_ch2[i], out_ch2[i]);
   }
 }
 
 TEST(TestDynamicResampler, SameRates_Short3)
 {
   uint32_t in_frames = 2;
   uint32_t out_frames = 3;
-  int channels = 2;
-  int in_rate = 44100;
-  int out_rate = 44100;
+  uint32_t channels = 2;
+  uint32_t in_rate = 44100;
+  uint32_t out_rate = 44100;
 
   DynamicResampler dr(in_rate, out_rate);
   dr.SetSampleFormat(AUDIO_FORMAT_S16);
 
   short in_ch1[] = {1, 2, 3};
   short in_ch2[] = {4, 5, 6};
   AutoTArray<const short*, 2> in_buffer;
   in_buffer.AppendElements(channels);
@@ -327,19 +327,19 @@ TEST(TestDynamicResampler, SameRates_Sho
     EXPECT_EQ(in_ch2[i], out_ch2[i]);
   }
 }
 
 TEST(TestDynamicResampler, UpdateOutRate_Float)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 40;
-  int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   uint32_t pre_buffer = 20;
 
   DynamicResampler dr(in_rate, out_rate, pre_buffer);
   dr.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
   EXPECT_EQ(dr.GetOutRate(), out_rate);
   EXPECT_EQ(dr.GetChannels(), channels);
 
@@ -385,19 +385,19 @@ TEST(TestDynamicResampler, UpdateOutRate
   EXPECT_TRUE(rv);
   EXPECT_EQ(out_frames, 18u);
 }
 
 TEST(TestDynamicResampler, UpdateOutRate_Short)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 40;
-  int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   uint32_t pre_buffer = 20;
 
   DynamicResampler dr(in_rate, out_rate, pre_buffer);
   dr.SetSampleFormat(AUDIO_FORMAT_S16);
   EXPECT_EQ(dr.GetOutRate(), out_rate);
   EXPECT_EQ(dr.GetChannels(), channels);
 
@@ -443,111 +443,111 @@ TEST(TestDynamicResampler, UpdateOutRate
   EXPECT_TRUE(rv);
   EXPECT_EQ(out_frames, 18u);
 }
 
 TEST(TestDynamicResampler, BigRangeOutRates_Float)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 10;
-  int channels = 2;
-  int in_rate = 44100;
-  int out_rate = 44100;
+  uint32_t channels = 2;
+  uint32_t in_rate = 44100;
+  uint32_t out_rate = 44100;
   uint32_t pre_buffer = 20;
 
   DynamicResampler dr(in_rate, out_rate, pre_buffer);
   dr.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
-  const int in_capacity = 40;
+  const uint32_t in_capacity = 40;
   float in_ch1[in_capacity] = {};
   float in_ch2[in_capacity] = {};
   for (uint32_t i = 0; i < in_capacity; ++i) {
     in_ch1[i] = in_ch2[i] = 0.01f * i;
   }
   AutoTArray<const float*, 2> in_buffer;
   in_buffer.AppendElements(channels);
   in_buffer[0] = in_ch1;
   in_buffer[1] = in_ch2;
 
-  const int out_capacity = 1000;
+  const uint32_t out_capacity = 1000;
   float out_ch1[out_capacity] = {};
   float out_ch2[out_capacity] = {};
 
-  for (int rate = 10000; rate < 90000; ++rate) {
+  for (uint32_t rate = 10000; rate < 90000; ++rate) {
     out_rate = rate;
     dr.UpdateResampler(out_rate, channels);
     EXPECT_EQ(dr.GetOutRate(), out_rate);
     EXPECT_EQ(dr.GetChannels(), channels);
     in_frames = 20;  // more than we need
     out_frames = in_frames * out_rate / in_rate;
     uint32_t expected_out_frames = out_frames;
-    for (int y = 0; y < 2; ++y) {
+    for (uint32_t y = 0; y < 2; ++y) {
       dr.AppendInput(in_buffer, in_frames);
       bool rv = dr.Resample(out_ch1, &out_frames, 0);
       EXPECT_TRUE(rv);
       EXPECT_EQ(out_frames, expected_out_frames);
       rv = dr.Resample(out_ch2, &out_frames, 1);
       EXPECT_TRUE(rv);
       EXPECT_EQ(out_frames, expected_out_frames);
     }
   }
 }
 
 TEST(TestDynamicResampler, BigRangeOutRates_Short)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 10;
-  int channels = 2;
-  int in_rate = 44100;
-  int out_rate = 44100;
+  uint32_t channels = 2;
+  uint32_t in_rate = 44100;
+  uint32_t out_rate = 44100;
   uint32_t pre_buffer = 20;
 
   DynamicResampler dr(in_rate, out_rate, pre_buffer);
   dr.SetSampleFormat(AUDIO_FORMAT_S16);
 
-  const int in_capacity = 40;
+  const uint32_t in_capacity = 40;
   short in_ch1[in_capacity] = {};
   short in_ch2[in_capacity] = {};
   for (uint32_t i = 0; i < in_capacity; ++i) {
     in_ch1[i] = in_ch2[i] = i;
   }
   AutoTArray<const short*, 2> in_buffer;
   in_buffer.AppendElements(channels);
   in_buffer[0] = in_ch1;
   in_buffer[1] = in_ch2;
 
-  const int out_capacity = 1000;
+  const uint32_t out_capacity = 1000;
   short out_ch1[out_capacity] = {};
   short out_ch2[out_capacity] = {};
 
-  for (int rate = 10000; rate < 90000; ++rate) {
+  for (uint32_t rate = 10000; rate < 90000; ++rate) {
     out_rate = rate;
     dr.UpdateResampler(out_rate, channels);
     in_frames = 20;  // more than we need
     out_frames = in_frames * out_rate / in_rate;
     uint32_t expected_out_frames = out_frames;
-    for (int y = 0; y < 2; ++y) {
+    for (uint32_t y = 0; y < 2; ++y) {
       dr.AppendInput(in_buffer, in_frames);
       bool rv = dr.Resample(out_ch1, &out_frames, 0);
       EXPECT_TRUE(rv);
       EXPECT_EQ(out_frames, expected_out_frames);
       rv = dr.Resample(out_ch2, &out_frames, 1);
       EXPECT_TRUE(rv);
       EXPECT_EQ(out_frames, expected_out_frames);
     }
   }
 }
 
 TEST(TestDynamicResampler, UpdateChannels_Float)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 10;
-  int channels = 2;
-  int in_rate = 44100;
-  int out_rate = 48000;
+  uint32_t channels = 2;
+  uint32_t in_rate = 44100;
+  uint32_t out_rate = 48000;
 
   DynamicResampler dr(in_rate, out_rate);
   dr.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   float in_ch1[10] = {};
   float in_ch2[10] = {};
   for (uint32_t i = 0; i < in_frames; ++i) {
     in_ch1[i] = in_ch2[i] = 0.01f * i;
@@ -566,17 +566,17 @@ TEST(TestDynamicResampler, UpdateChannel
   EXPECT_EQ(out_frames, 10u);
   rv = dr.Resample(out_ch2, &out_frames, 1);
   EXPECT_TRUE(rv);
   EXPECT_EQ(out_frames, 10u);
 
   // Add 3rd channel
   dr.UpdateResampler(out_rate, 3);
   EXPECT_EQ(dr.GetOutRate(), out_rate);
-  EXPECT_EQ(dr.GetChannels(), 3);
+  EXPECT_EQ(dr.GetChannels(), 3u);
 
   float in_ch3[10] = {};
   for (uint32_t i = 0; i < in_frames; ++i) {
     in_ch3[i] = 0.01f * i;
   }
   in_buffer.AppendElement();
   in_buffer[2] = in_ch3;
   float out_ch3[10] = {};
@@ -598,17 +598,17 @@ TEST(TestDynamicResampler, UpdateChannel
     in_ch3[i] = 0.01f * i;
   }
   in_buffer.AppendElement();
   in_buffer[3] = in_ch4;
   float out_ch4[10] = {};
 
   dr.UpdateResampler(out_rate, 4);
   EXPECT_EQ(dr.GetOutRate(), out_rate);
-  EXPECT_EQ(dr.GetChannels(), 4);
+  EXPECT_EQ(dr.GetChannels(), 4u);
   dr.AppendInput(in_buffer, in_frames);
 
   rv = dr.Resample(out_ch1, &out_frames, 0);
   EXPECT_TRUE(rv);
   EXPECT_EQ(out_frames, 10u);
   rv = dr.Resample(out_ch2, &out_frames, 1);
   EXPECT_TRUE(rv);
   EXPECT_EQ(out_frames, 10u);
@@ -619,19 +619,19 @@ TEST(TestDynamicResampler, UpdateChannel
   EXPECT_TRUE(rv);
   EXPECT_EQ(out_frames, 10u);
 }
 
 TEST(TestDynamicResampler, UpdateChannels_Short)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 10;
-  int channels = 2;
-  int in_rate = 44100;
-  int out_rate = 48000;
+  uint32_t channels = 2;
+  uint32_t in_rate = 44100;
+  uint32_t out_rate = 48000;
 
   DynamicResampler dr(in_rate, out_rate);
   dr.SetSampleFormat(AUDIO_FORMAT_S16);
 
   short in_ch1[10] = {};
   short in_ch2[10] = {};
   for (uint32_t i = 0; i < in_frames; ++i) {
     in_ch1[i] = in_ch2[i] = i;
@@ -650,17 +650,17 @@ TEST(TestDynamicResampler, UpdateChannel
   EXPECT_EQ(out_frames, 10u);
   rv = dr.Resample(out_ch2, &out_frames, 1);
   EXPECT_TRUE(rv);
   EXPECT_EQ(out_frames, 10u);
 
   // Add 3rd channel
   dr.UpdateResampler(out_rate, 3);
   EXPECT_EQ(dr.GetOutRate(), out_rate);
-  EXPECT_EQ(dr.GetChannels(), 3);
+  EXPECT_EQ(dr.GetChannels(), 3u);
 
   short in_ch3[10] = {};
   for (uint32_t i = 0; i < in_frames; ++i) {
     in_ch3[i] = i;
   }
   in_buffer.AppendElement();
   in_buffer[2] = in_ch3;
   short out_ch3[10] = {};
@@ -683,17 +683,17 @@ TEST(TestDynamicResampler, UpdateChannel
     in_ch3[i] = i;
   }
   in_buffer.AppendElement();
   in_buffer[3] = in_ch4;
   short out_ch4[10] = {};
 
   dr.UpdateResampler(out_rate, 4);
   EXPECT_EQ(dr.GetOutRate(), out_rate);
-  EXPECT_EQ(dr.GetChannels(), 4);
+  EXPECT_EQ(dr.GetChannels(), 4u);
   dr.AppendInput(in_buffer, in_frames);
 
   rv = dr.Resample(out_ch1, &out_frames, 0);
   EXPECT_TRUE(rv);
   EXPECT_EQ(out_frames, 10u);
   rv = dr.Resample(out_ch2, &out_frames, 1);
   EXPECT_TRUE(rv);
   EXPECT_EQ(out_frames, 10u);
@@ -704,96 +704,96 @@ TEST(TestDynamicResampler, UpdateChannel
   EXPECT_TRUE(rv);
   EXPECT_EQ(out_frames, 10u);
 }
 
 TEST(TestAudioChunkList, Basic1)
 {
   AudioChunkList list(256, 2);
   list.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
-  EXPECT_EQ(list.ChunkCapacity(), 128);
-  EXPECT_EQ(list.TotalCapacity(), 256);
+  EXPECT_EQ(list.ChunkCapacity(), 128u);
+  EXPECT_EQ(list.TotalCapacity(), 256u);
 
   AudioChunk& c1 = list.GetNext();
   float* c1_ch1 = c1.ChannelDataForWrite<float>(0);
   float* c1_ch2 = c1.ChannelDataForWrite<float>(1);
   EXPECT_EQ(c1.mBufferFormat, AUDIO_FORMAT_FLOAT32);
-  for (int i = 0; i < list.ChunkCapacity(); ++i) {
+  for (uint32_t i = 0; i < list.ChunkCapacity(); ++i) {
     c1_ch1[i] = c1_ch2[i] = 0.01f * static_cast<float>(i);
   }
   AudioChunk& c2 = list.GetNext();
   EXPECT_EQ(c2.mBufferFormat, AUDIO_FORMAT_FLOAT32);
   EXPECT_NE(c1.mBuffer.get(), c2.mBuffer.get());
   AudioChunk& c3 = list.GetNext();
   EXPECT_EQ(c3.mBufferFormat, AUDIO_FORMAT_FLOAT32);
   // Cycle
   EXPECT_EQ(c1.mBuffer.get(), c3.mBuffer.get());
   float* c3_ch1 = c3.ChannelDataForWrite<float>(0);
   float* c3_ch2 = c3.ChannelDataForWrite<float>(1);
-  for (int i = 0; i < list.ChunkCapacity(); ++i) {
+  for (uint32_t i = 0; i < list.ChunkCapacity(); ++i) {
     EXPECT_FLOAT_EQ(c1_ch1[i], c3_ch1[i]);
     EXPECT_FLOAT_EQ(c1_ch2[i], c3_ch2[i]);
   }
 }
 
 TEST(TestAudioChunkList, Basic2)
 {
   AudioChunkList list(256, 2);
   list.SetSampleFormat(AUDIO_FORMAT_S16);
-  EXPECT_EQ(list.ChunkCapacity(), 256);
-  EXPECT_EQ(list.TotalCapacity(), 512);
+  EXPECT_EQ(list.ChunkCapacity(), 256u);
+  EXPECT_EQ(list.TotalCapacity(), 512u);
 
   AudioChunk& c1 = list.GetNext();
   EXPECT_EQ(c1.mBufferFormat, AUDIO_FORMAT_S16);
   short* c1_ch1 = c1.ChannelDataForWrite<short>(0);
   short* c1_ch2 = c1.ChannelDataForWrite<short>(1);
-  for (int i = 0; i < list.ChunkCapacity(); ++i) {
+  for (uint32_t i = 0; i < list.ChunkCapacity(); ++i) {
     c1_ch1[i] = c1_ch2[i] = static_cast<short>(i);
   }
   AudioChunk& c2 = list.GetNext();
   EXPECT_EQ(c2.mBufferFormat, AUDIO_FORMAT_S16);
   EXPECT_NE(c1.mBuffer.get(), c2.mBuffer.get());
   AudioChunk& c3 = list.GetNext();
   EXPECT_EQ(c3.mBufferFormat, AUDIO_FORMAT_S16);
   AudioChunk& c4 = list.GetNext();
   EXPECT_EQ(c4.mBufferFormat, AUDIO_FORMAT_S16);
   // Cycle
   AudioChunk& c5 = list.GetNext();
   EXPECT_EQ(c5.mBufferFormat, AUDIO_FORMAT_S16);
   EXPECT_EQ(c1.mBuffer.get(), c5.mBuffer.get());
   short* c5_ch1 = c5.ChannelDataForWrite<short>(0);
   short* c5_ch2 = c5.ChannelDataForWrite<short>(1);
-  for (int i = 0; i < list.ChunkCapacity(); ++i) {
+  for (uint32_t i = 0; i < list.ChunkCapacity(); ++i) {
     EXPECT_EQ(c1_ch1[i], c5_ch1[i]);
     EXPECT_EQ(c1_ch2[i], c5_ch2[i]);
   }
 }
 
 TEST(TestAudioChunkList, Basic3)
 {
   AudioChunkList list(260, 2);
   list.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
-  EXPECT_EQ(list.ChunkCapacity(), 128);
-  EXPECT_EQ(list.TotalCapacity(), 256 + 128);
+  EXPECT_EQ(list.ChunkCapacity(), 128u);
+  EXPECT_EQ(list.TotalCapacity(), 256u + 128u);
 
   AudioChunk& c1 = list.GetNext();
   AudioChunk& c2 = list.GetNext();
   EXPECT_NE(c1.mBuffer.get(), c2.mBuffer.get());
   AudioChunk& c3 = list.GetNext();
   EXPECT_NE(c1.mBuffer.get(), c3.mBuffer.get());
   AudioChunk& c4 = list.GetNext();
   EXPECT_EQ(c1.mBuffer.get(), c4.mBuffer.get());
 }
 
 TEST(TestAudioChunkList, Basic4)
 {
   AudioChunkList list(260, 2);
   list.SetSampleFormat(AUDIO_FORMAT_S16);
-  EXPECT_EQ(list.ChunkCapacity(), 256);
-  EXPECT_EQ(list.TotalCapacity(), 512 + 256);
+  EXPECT_EQ(list.ChunkCapacity(), 256u);
+  EXPECT_EQ(list.TotalCapacity(), 512u + 256u);
 
   AudioChunk& c1 = list.GetNext();
   AudioChunk& c2 = list.GetNext();
   EXPECT_NE(c1.mBuffer.get(), c2.mBuffer.get());
   AudioChunk& c3 = list.GetNext();
   EXPECT_NE(c1.mBuffer.get(), c3.mBuffer.get());
   AudioChunk& c4 = list.GetNext();
   EXPECT_EQ(c1.mBuffer.get(), c4.mBuffer.get());
@@ -821,73 +821,73 @@ TEST(TestAudioChunkList, UpdateChannels)
 TEST(TestAudioChunkList, UpdateBetweenMonoAndStereo)
 {
   AudioChunkList list(256, 2);
   list.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
   AudioChunk& c1 = list.GetNext();
   float* c1_ch1 = c1.ChannelDataForWrite<float>(0);
   float* c1_ch2 = c1.ChannelDataForWrite<float>(1);
-  for (int i = 0; i < list.ChunkCapacity(); ++i) {
+  for (uint32_t i = 0; i < list.ChunkCapacity(); ++i) {
     c1_ch1[i] = c1_ch2[i] = 0.01f * static_cast<float>(i);
   }
 
   AudioChunk& c2 = list.GetNext();
   EXPECT_EQ(c1.ChannelCount(), 2u);
   EXPECT_EQ(c2.ChannelCount(), 2u);
 
   // Downmix to mono
   list.Update(1);
 
   AudioChunk& c3 = list.GetNext();
   float* c3_ch1 = c3.ChannelDataForWrite<float>(0);
-  for (int i = 0; i < list.ChunkCapacity(); ++i) {
+  for (uint32_t i = 0; i < list.ChunkCapacity(); ++i) {
     EXPECT_FLOAT_EQ(c3_ch1[i], c1_ch1[i]);
   }
 
   AudioChunk& c4 = list.GetNext();
   EXPECT_EQ(c3.ChannelCount(), 1u);
   EXPECT_EQ(c4.ChannelCount(), 1u);
   EXPECT_EQ(static_cast<SharedChannelArrayBuffer<float>*>(c3.mBuffer.get())
                 ->mBuffers[0]
                 .Length(),
-            (uint32_t)list.ChunkCapacity());
+            list.ChunkCapacity());
 
   // Upmix to stereo
   list.Update(2);
 
   AudioChunk& c5 = list.GetNext();
   AudioChunk& c6 = list.GetNext();
   EXPECT_EQ(c5.ChannelCount(), 2u);
   EXPECT_EQ(c6.ChannelCount(), 2u);
   EXPECT_EQ(static_cast<SharedChannelArrayBuffer<float>*>(c5.mBuffer.get())
                 ->mBuffers[0]
                 .Length(),
-            (uint32_t)list.ChunkCapacity());
+            list.ChunkCapacity());
   EXPECT_EQ(static_cast<SharedChannelArrayBuffer<float>*>(c5.mBuffer.get())
                 ->mBuffers[1]
                 .Length(),
-            (uint32_t)list.ChunkCapacity());
+            list.ChunkCapacity());
 
   // Downmix to mono
   list.Update(1);
 
   AudioChunk& c7 = list.GetNext();
   float* c7_ch1 = c7.ChannelDataForWrite<float>(0);
-  for (int i = 0; i < list.ChunkCapacity(); ++i) {
+  for (uint32_t i = 0; i < list.ChunkCapacity(); ++i) {
     EXPECT_FLOAT_EQ(c7_ch1[i], c1_ch1[i]);
   }
 
   AudioChunk& c8 = list.GetNext();
   EXPECT_EQ(c7.ChannelCount(), 1u);
   EXPECT_EQ(c8.ChannelCount(), 1u);
   EXPECT_EQ(static_cast<SharedChannelArrayBuffer<float>*>(c7.mBuffer.get())
                 ->mBuffers[0]
                 .Length(),
-            (uint32_t)list.ChunkCapacity());
+            list.ChunkCapacity());
 }
 
 TEST(TestAudioChunkList, ConsumeAndForget)
 {
   AudioSegment s;
   AudioChunkList list(256, 2);
   list.SetSampleFormat(AUDIO_FORMAT_FLOAT32);
 
@@ -904,63 +904,63 @@ TEST(TestAudioChunkList, ConsumeAndForge
   EXPECT_EQ(c2.ChannelData<float>().Length(), 2u);
 
   s.ForgetUpTo(256);
   list.GetNext();
   list.GetNext();
 }
 
 template <class T>
-AudioChunk CreateAudioChunk(uint32_t aFrames, int aChannels,
+AudioChunk CreateAudioChunk(uint32_t aFrames, uint32_t aChannels,
                             AudioSampleFormat aSampleFormat) {
   AudioChunk chunk;
   nsTArray<nsTArray<T>> buffer;
   buffer.AppendElements(aChannels);
 
   nsTArray<const T*> bufferPtrs;
   bufferPtrs.AppendElements(aChannels);
 
-  for (int i = 0; i < aChannels; ++i) {
+  for (uint32_t i = 0; i < aChannels; ++i) {
     T* ptr = buffer[i].AppendElements(aFrames);
     bufferPtrs[i] = ptr;
     for (uint32_t j = 0; j < aFrames; ++j) {
       if (aSampleFormat == AUDIO_FORMAT_FLOAT32) {
         ptr[j] = 0.01 * j;
       } else {
         ptr[j] = j;
       }
     }
   }
 
   chunk.mBuffer = new mozilla::SharedChannelArrayBuffer(std::move(buffer));
   chunk.mBufferFormat = aSampleFormat;
   chunk.mChannelData.AppendElements(aChannels);
-  for (int i = 0; i < aChannels; ++i) {
+  for (uint32_t i = 0; i < aChannels; ++i) {
     chunk.mChannelData[i] = bufferPtrs[i];
   }
   chunk.mDuration = aFrames;
   return chunk;
 }
 
 template <class T>
-AudioSegment CreateAudioSegment(uint32_t aFrames, int aChannels,
+AudioSegment CreateAudioSegment(uint32_t aFrames, uint32_t aChannels,
                                 AudioSampleFormat aSampleFormat) {
   AudioSegment segment;
   AudioChunk chunk = CreateAudioChunk<T>(aFrames, aChannels, aSampleFormat);
   segment.AppendAndConsumeChunk(&chunk);
   return segment;
 }
 
 TEST(TestAudioResampler, OutAudioSegment_Float)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 40;
-  int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   uint32_t pre_buffer = 21;
 
   AudioResampler dr(in_rate, out_rate, pre_buffer);
 
   AudioSegment inSegment =
       CreateAudioSegment<float>(in_frames, channels, AUDIO_FORMAT_FLOAT32);
   dr.AppendInput(inSegment);
@@ -994,19 +994,19 @@ TEST(TestAudioResampler, OutAudioSegment
   EXPECT_TRUE(!s1.IsNull());
   EXPECT_TRUE(!s1.IsEmpty());
 }
 
 TEST(TestAudioResampler, OutAudioSegment_Short)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 40;
-  int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   uint32_t pre_buffer = 21;
 
   AudioResampler dr(in_rate, out_rate, pre_buffer);
 
   AudioSegment inSegment =
       CreateAudioSegment<short>(in_frames, channels, AUDIO_FORMAT_S16);
   dr.AppendInput(inSegment);
@@ -1040,19 +1040,19 @@ TEST(TestAudioResampler, OutAudioSegment
   EXPECT_TRUE(!s1.IsNull());
   EXPECT_TRUE(!s1.IsEmpty());
 }
 
 TEST(TestAudioResampler, OutAudioSegmentFail_Float)
 {
   const uint32_t in_frames = 130;
   const uint32_t out_frames = 300;
-  int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   uint32_t pre_buffer = 5;
 
   AudioResampler dr(in_rate, out_rate, pre_buffer);
   AudioSegment inSegment =
       CreateAudioSegment<float>(in_frames, channels, AUDIO_FORMAT_FLOAT32);
   dr.AppendInput(inSegment);
 
@@ -1062,19 +1062,19 @@ TEST(TestAudioResampler, OutAudioSegment
   EXPECT_TRUE(s.IsNull());
   EXPECT_TRUE(s.IsEmpty());
 }
 
 TEST(TestAudioResampler, InAudioSegment_Float)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 40;
-  int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   uint32_t pre_buffer = 10;
   AudioResampler dr(in_rate, out_rate, pre_buffer);
 
   AudioSegment inSegment;
 
   AudioChunk chunk1;
   chunk1.SetNull(in_frames / 2);
@@ -1082,28 +1082,28 @@ TEST(TestAudioResampler, InAudioSegment_
 
   AudioChunk chunk2;
   nsTArray<nsTArray<float>> buffer;
   buffer.AppendElements(channels);
 
   nsTArray<const float*> bufferPtrs;
   bufferPtrs.AppendElements(channels);
 
-  for (int i = 0; i < channels; ++i) {
+  for (uint32_t i = 0; i < channels; ++i) {
     float* ptr = buffer[i].AppendElements(5);
     bufferPtrs[i] = ptr;
     for (uint32_t j = 0; j < 5; ++j) {
       ptr[j] = 0.01f * j;
     }
   }
 
   chunk2.mBuffer = new mozilla::SharedChannelArrayBuffer(std::move(buffer));
   chunk2.mBufferFormat = AUDIO_FORMAT_FLOAT32;
   chunk2.mChannelData.AppendElements(channels);
-  for (int i = 0; i < channels; ++i) {
+  for (uint32_t i = 0; i < channels; ++i) {
     chunk2.mChannelData[i] = bufferPtrs[i];
   }
   chunk2.mDuration = in_frames / 2;
   inSegment.AppendAndConsumeChunk(&chunk2);
 
   dr.AppendInput(inSegment);
   AudioSegment outSegment = dr.Resample(out_frames);
   // Faild because the first chunk is ignored
@@ -1116,19 +1116,19 @@ TEST(TestAudioResampler, InAudioSegment_
   EXPECT_EQ(outSegment2.GetDuration(), 40u);
   EXPECT_EQ(outSegment2.MaxChannelCount(), 2u);
 }
 
 TEST(TestAudioResampler, InAudioSegment_Short)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 40;
-  int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   uint32_t pre_buffer = 10;
   AudioResampler dr(in_rate, out_rate, pre_buffer);
 
   AudioSegment inSegment;
 
   // The null chunk at the beginning will be ignored.
   AudioChunk chunk1;
@@ -1137,28 +1137,28 @@ TEST(TestAudioResampler, InAudioSegment_
 
   AudioChunk chunk2;
   nsTArray<nsTArray<short>> buffer;
   buffer.AppendElements(channels);
 
   nsTArray<const short*> bufferPtrs;
   bufferPtrs.AppendElements(channels);
 
-  for (int i = 0; i < channels; ++i) {
+  for (uint32_t i = 0; i < channels; ++i) {
     short* ptr = buffer[i].AppendElements(5);
     bufferPtrs[i] = ptr;
     for (uint32_t j = 0; j < 5; ++j) {
       ptr[j] = j;
     }
   }
 
   chunk2.mBuffer = new mozilla::SharedChannelArrayBuffer(std::move(buffer));
   chunk2.mBufferFormat = AUDIO_FORMAT_S16;
   chunk2.mChannelData.AppendElements(channels);
-  for (int i = 0; i < channels; ++i) {
+  for (uint32_t i = 0; i < channels; ++i) {
     chunk2.mChannelData[i] = bufferPtrs[i];
   }
   chunk2.mDuration = in_frames / 2;
   inSegment.AppendAndConsumeChunk(&chunk2);
 
   dr.AppendInput(inSegment);
   AudioSegment outSegment = dr.Resample(out_frames);
   // Faild because the first chunk is ignored
@@ -1170,19 +1170,19 @@ TEST(TestAudioResampler, InAudioSegment_
   EXPECT_EQ(outSegment2.GetDuration(), 40u);
   EXPECT_EQ(outSegment2.MaxChannelCount(), 2u);
 }
 
 TEST(TestAudioResampler, ChannelChange_MonoToStereo)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 40;
-  // int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  // uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   uint32_t pre_buffer = 0;
 
   AudioResampler dr(in_rate, out_rate, pre_buffer);
 
   AudioChunk monoChunk =
       CreateAudioChunk<float>(in_frames, 1, AUDIO_FORMAT_FLOAT32);
   AudioChunk stereoChunk =
@@ -1200,19 +1200,19 @@ TEST(TestAudioResampler, ChannelChange_M
   EXPECT_TRUE(!s.IsEmpty());
   EXPECT_EQ(s.MaxChannelCount(), 2u);
 }
 
 TEST(TestAudioResampler, ChannelChange_StereoToMono)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 40;
-  // int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  // uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   uint32_t pre_buffer = 0;
 
   AudioResampler dr(in_rate, out_rate, pre_buffer);
 
   AudioChunk monoChunk =
       CreateAudioChunk<float>(in_frames, 1, AUDIO_FORMAT_FLOAT32);
   AudioChunk stereoChunk =
@@ -1230,19 +1230,19 @@ TEST(TestAudioResampler, ChannelChange_S
   EXPECT_TRUE(!s.IsEmpty());
   EXPECT_EQ(s.MaxChannelCount(), 1u);
 }
 
 TEST(TestAudioResampler, ChannelChange_StereoToQuad)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 40;
-  // int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  // uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   uint32_t pre_buffer = 0;
 
   AudioResampler dr(in_rate, out_rate, pre_buffer);
 
   AudioChunk stereoChunk =
       CreateAudioChunk<float>(in_frames, 2, AUDIO_FORMAT_FLOAT32);
   AudioChunk quadChunk =
@@ -1265,19 +1265,19 @@ TEST(TestAudioResampler, ChannelChange_S
   EXPECT_TRUE(!s2.IsNull());
   EXPECT_TRUE(!s2.IsEmpty());
 }
 
 TEST(TestAudioResampler, ChannelChange_QuadToStereo)
 {
   uint32_t in_frames = 10;
   uint32_t out_frames = 40;
-  // int channels = 2;
-  int in_rate = 24000;
-  int out_rate = 48000;
+  // uint32_t channels = 2;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   AudioResampler dr(in_rate, out_rate);
 
   AudioChunk stereoChunk =
       CreateAudioChunk<float>(in_frames, 2, AUDIO_FORMAT_FLOAT32);
   AudioChunk quadChunk =
       CreateAudioChunk<float>(in_frames, 4, AUDIO_FORMAT_FLOAT32);
 
@@ -1298,39 +1298,39 @@ TEST(TestAudioResampler, ChannelChange_Q
   EXPECT_TRUE(!s2.IsNull());
   EXPECT_TRUE(!s2.IsEmpty());
 }
 
 void printAudioSegment(const AudioSegment& segment);
 
 TEST(TestAudioResampler, ChannelChange_Discontinuity)
 {
-  int in_rate = 24000;
-  int out_rate = 48000;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   const float amplitude = 0.5;
   const float frequency = 200;
   const float phase = 0.0;
   float time = 0.0;
   const float deltaTime = 1.0f / static_cast<float>(in_rate);
 
-  int in_frames = in_rate / 100;
-  int out_frames = out_rate / 100;
+  uint32_t in_frames = in_rate / 100;
+  uint32_t out_frames = out_rate / 100;
   AudioResampler dr(in_rate, out_rate);
 
   AudioChunk monoChunk =
       CreateAudioChunk<float>(in_frames, 1, AUDIO_FORMAT_FLOAT32);
-  for (int i = 0; i < monoChunk.GetDuration(); ++i) {
+  for (uint32_t i = 0; i < monoChunk.GetDuration(); ++i) {
     double value = amplitude * sin(2 * M_PI * frequency * time + phase);
     monoChunk.ChannelDataForWrite<float>(0)[i] = static_cast<float>(value);
     time += deltaTime;
   }
   AudioChunk stereoChunk =
       CreateAudioChunk<float>(in_frames, 2, AUDIO_FORMAT_FLOAT32);
-  for (int i = 0; i < stereoChunk.GetDuration(); ++i) {
+  for (uint32_t i = 0; i < stereoChunk.GetDuration(); ++i) {
     double value = amplitude * sin(2 * M_PI * frequency * time + phase);
     stereoChunk.ChannelDataForWrite<float>(0)[i] = static_cast<float>(value);
     if (stereoChunk.ChannelCount() == 2) {
       stereoChunk.ChannelDataForWrite<float>(1)[i] = value;
     }
     time += deltaTime;
   }
 
@@ -1354,39 +1354,39 @@ TEST(TestAudioResampler, ChannelChange_D
   EXPECT_EQ(s2.GetType(), MediaSegment::AUDIO);
   EXPECT_TRUE(!s2.IsNull());
   EXPECT_TRUE(!s2.IsEmpty());
   EXPECT_EQ(s2.MaxChannelCount(), 1u);
 }
 
 TEST(TestAudioResampler, ChannelChange_Discontinuity2)
 {
-  int in_rate = 24000;
-  int out_rate = 48000;
+  uint32_t in_rate = 24000;
+  uint32_t out_rate = 48000;
 
   const float amplitude = 0.5;
   const float frequency = 200;
   const float phase = 0.0;
   float time = 0.0;
   const float deltaTime = 1.0f / static_cast<float>(in_rate);
 
-  int in_frames = in_rate / 100;
-  int out_frames = out_rate / 100;
+  uint32_t in_frames = in_rate / 100;
+  uint32_t out_frames = out_rate / 100;
   AudioResampler dr(in_rate, out_rate, 10);
 
   AudioChunk monoChunk =
       CreateAudioChunk<float>(in_frames / 2, 1, AUDIO_FORMAT_FLOAT32);
-  for (int i = 0; i < monoChunk.GetDuration(); ++i) {
+  for (uint32_t i = 0; i < monoChunk.GetDuration(); ++i) {
     double value = amplitude * sin(2 * M_PI * frequency * time + phase);
     monoChunk.ChannelDataForWrite<float>(0)[i] = static_cast<float>(value);
     time += deltaTime;
   }
   AudioChunk stereoChunk =
       CreateAudioChunk<float>(in_frames / 2, 2, AUDIO_FORMAT_FLOAT32);
-  for (int i = 0; i < stereoChunk.GetDuration(); ++i) {
+  for (uint32_t i = 0; i < stereoChunk.GetDuration(); ++i) {
     double value = amplitude * sin(2 * M_PI * frequency * time + phase);
     stereoChunk.ChannelDataForWrite<float>(0)[i] = static_cast<float>(value);
     if (stereoChunk.ChannelCount() == 2) {
       stereoChunk.ChannelDataForWrite<float>(1)[i] = value;
     }
     time += deltaTime;
   }
 
@@ -1415,32 +1415,32 @@ TEST(TestAudioResampler, ChannelChange_D
   EXPECT_EQ(s2.GetType(), MediaSegment::AUDIO);
   EXPECT_TRUE(!s2.IsNull());
   EXPECT_TRUE(!s2.IsEmpty());
   EXPECT_EQ(s2.MaxChannelCount(), 2u);
 }
 
 TEST(TestAudioResampler, ChannelChange_Discontinuity3)
 {
-  int in_rate = 48000;
-  int out_rate = 48000;
+  uint32_t in_rate = 48000;
+  uint32_t out_rate = 48000;
 
   const float amplitude = 0.5;
   const float frequency = 200;
   const float phase = 0.0;
   float time = 0.0;
   const float deltaTime = 1.0f / static_cast<float>(in_rate);
 
-  int in_frames = in_rate / 100;
-  int out_frames = out_rate / 100;
+  uint32_t in_frames = in_rate / 100;
+  uint32_t out_frames = out_rate / 100;
   AudioResampler dr(in_rate, out_rate, 10);
 
   AudioChunk stereoChunk =
       CreateAudioChunk<float>(in_frames, 2, AUDIO_FORMAT_FLOAT32);
-  for (int i = 0; i < stereoChunk.GetDuration(); ++i) {
+  for (uint32_t i = 0; i < stereoChunk.GetDuration(); ++i) {
     double value = amplitude * sin(2 * M_PI * frequency * time + phase);
     stereoChunk.ChannelDataForWrite<float>(0)[i] = static_cast<float>(value);
     if (stereoChunk.ChannelCount() == 2) {
       stereoChunk.ChannelDataForWrite<float>(1)[i] = value;
     }
     time += deltaTime;
   }