author Kim Moir <>
Mon, 15 May 2017 09:57:26 -0400
changeset 375975 d38398e5144e312301a5635da5e27cb6054ecdaa
parent 326563 232a786cf87fb0f68f9bda6e9316515524d2ac8a
permissions -rw-r--r--
Bug 1358976 - Stop automatic triggers of nightly builds on mozilla-aurora r=dustin DONTBUILD a=test-only CLOSED TREE

/* 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 */


#include "mozilla/StaticPtr.h"
#include "nsAutoPtr.h"
#include "AudioMixer.h"

namespace webrtc {
class SingleRwFifo;

namespace mozilla {

typedef struct FarEndAudioChunk_ {
  uint16_t mSamples;
  bool mOverrun;
  int16_t mData[1]; // variable-length
} FarEndAudioChunk;

// XXX Really a singleton currently
class AudioOutputObserver : public MixerCallbackReceiver


  void MixerCallback(AudioDataValue* aMixedBuffer,
                     AudioSampleFormat aFormat,
                     uint32_t aChannels,
                     uint32_t aFrames,
                     uint32_t aSampleRate) override;

  void Clear();
  void InsertFarEnd(const AudioDataValue *aBuffer, uint32_t aFrames, bool aOverran,
                    int aFreq, int aChannels, AudioSampleFormat aFormat);
  uint32_t PlayoutFrequency() { return mPlayoutFreq; }
  uint32_t PlayoutChannels() { return mPlayoutChannels; }

  FarEndAudioChunk *Pop();
  uint32_t Size();

  virtual ~AudioOutputObserver();
  uint32_t mPlayoutFreq;
  uint32_t mPlayoutChannels;

  nsAutoPtr<webrtc::SingleRwFifo> mPlayoutFifo;
  uint32_t mChunkSize;

  // chunking to 10ms support
  FarEndAudioChunk *mSaved; // can't be nsAutoPtr since we need to use free(), not delete
  uint32_t mSamplesSaved;

extern StaticRefPtr<AudioOutputObserver> gFarendObserver;