2008-07-30 10:50:14 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2012-11-14 23:46:40 +04:00
|
|
|
#if !defined(AudioStream_h_)
|
|
|
|
#define AudioStream_h_
|
2008-11-06 23:53:20 +03:00
|
|
|
|
2012-10-25 14:09:40 +04:00
|
|
|
#include "AudioSampleFormat.h"
|
2012-11-28 20:25:57 +04:00
|
|
|
#include "nsAutoPtr.h"
|
2013-09-25 06:10:24 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2014-04-09 23:59:07 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2014-04-10 21:39:20 +04:00
|
|
|
#include "mozilla/dom/AudioChannelBinding.h"
|
2015-08-27 05:49:17 +03:00
|
|
|
#include "mozilla/Monitor.h"
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2015-08-27 05:49:17 +03:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2014-08-18 21:12:08 +04:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2014-08-25 17:26:09 +04:00
|
|
|
#include "CubebUtils.h"
|
2015-07-06 22:08:56 +03:00
|
|
|
#include "soundtouch/SoundTouchFactory.h"
|
2013-09-06 00:25:17 +04:00
|
|
|
|
2012-11-14 23:45:33 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2015-03-08 04:07:17 +03:00
|
|
|
struct CubebDestroyPolicy
|
2014-08-18 21:12:08 +04:00
|
|
|
{
|
2015-01-15 10:47:00 +03:00
|
|
|
void operator()(cubeb_stream* aStream) const {
|
2014-08-18 21:12:08 +04:00
|
|
|
cubeb_stream_destroy(aStream);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-11-22 14:38:28 +04:00
|
|
|
class AudioStream;
|
2014-06-26 06:56:23 +04:00
|
|
|
class FrameHistory;
|
2012-11-22 14:38:28 +04:00
|
|
|
|
|
|
|
class AudioClock
|
|
|
|
{
|
2013-11-28 09:09:08 +04:00
|
|
|
public:
|
2014-09-01 07:50:23 +04:00
|
|
|
explicit AudioClock(AudioStream* aStream);
|
2013-11-28 09:09:08 +04:00
|
|
|
// Initialize the clock with the current AudioStream. Need to be called
|
|
|
|
// before querying the clock. Called on the audio thread.
|
|
|
|
void Init();
|
|
|
|
// Update the number of samples that has been written in the audio backend.
|
|
|
|
// Called on the state machine thread.
|
2014-06-26 06:56:23 +04:00
|
|
|
void UpdateFrameHistory(uint32_t aServiced, uint32_t aUnderrun);
|
2013-11-28 09:09:08 +04:00
|
|
|
// Get the read position of the stream, in microseconds.
|
|
|
|
// Called on the state machine thead.
|
2014-05-21 11:28:22 +04:00
|
|
|
// Assumes the AudioStream lock is held and thus calls Unlocked versions
|
|
|
|
// of AudioStream funcs.
|
2014-06-26 06:56:23 +04:00
|
|
|
int64_t GetPositionUnlocked() const;
|
2013-11-28 09:09:08 +04:00
|
|
|
// Get the read position of the stream, in frames.
|
|
|
|
// Called on the state machine thead.
|
2014-06-26 06:56:23 +04:00
|
|
|
int64_t GetPositionInFrames() const;
|
2013-11-28 09:09:08 +04:00
|
|
|
// Set the playback rate.
|
|
|
|
// Called on the audio thread.
|
2014-05-21 11:28:22 +04:00
|
|
|
// Assumes the AudioStream lock is held and thus calls Unlocked versions
|
|
|
|
// of AudioStream funcs.
|
|
|
|
void SetPlaybackRateUnlocked(double aPlaybackRate);
|
2013-11-28 09:09:08 +04:00
|
|
|
// Get the current playback rate.
|
|
|
|
// Called on the audio thread.
|
2014-06-26 06:56:23 +04:00
|
|
|
double GetPlaybackRate() const;
|
2013-11-28 09:09:08 +04:00
|
|
|
// Set if we are preserving the pitch.
|
|
|
|
// Called on the audio thread.
|
|
|
|
void SetPreservesPitch(bool aPreservesPitch);
|
|
|
|
// Get the current pitch preservation state.
|
|
|
|
// Called on the audio thread.
|
2014-06-26 06:56:23 +04:00
|
|
|
bool GetPreservesPitch() const;
|
2013-11-28 09:09:08 +04:00
|
|
|
private:
|
|
|
|
// This AudioStream holds a strong reference to this AudioClock. This
|
|
|
|
// pointer is garanteed to always be valid.
|
2014-06-26 06:56:23 +04:00
|
|
|
AudioStream* const mAudioStream;
|
2013-11-28 09:09:08 +04:00
|
|
|
// Output rate in Hz (characteristic of the playback rate)
|
2016-01-21 16:11:14 +03:00
|
|
|
uint32_t mOutRate;
|
2013-11-28 09:09:08 +04:00
|
|
|
// Input rate in Hz (characteristic of the media being played)
|
2016-01-21 16:11:14 +03:00
|
|
|
uint32_t mInRate;
|
2013-11-28 09:09:08 +04:00
|
|
|
// True if the we are timestretching, false if we are resampling.
|
|
|
|
bool mPreservesPitch;
|
2015-08-27 05:49:17 +03:00
|
|
|
// The history of frames sent to the audio engine in each DataCallback.
|
2014-06-26 06:56:23 +04:00
|
|
|
const nsAutoPtr<FrameHistory> mFrameHistory;
|
2013-11-28 09:09:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class CircularByteBuffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CircularByteBuffer()
|
|
|
|
: mBuffer(nullptr), mCapacity(0), mStart(0), mCount(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// Set the capacity of the buffer in bytes. Must be called before any
|
|
|
|
// call to append or pop elements.
|
|
|
|
void SetCapacity(uint32_t aCapacity) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mBuffer, "Buffer allocated.");
|
2013-11-28 09:09:08 +04:00
|
|
|
mCapacity = aCapacity;
|
2015-12-03 02:07:59 +03:00
|
|
|
mBuffer = MakeUnique<uint8_t[]>(mCapacity);
|
2013-11-28 09:09:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Length() {
|
|
|
|
return mCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Capacity() {
|
|
|
|
return mCapacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Available() {
|
|
|
|
return Capacity() - Length();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append aLength bytes from aSrc to the buffer. Caller must check that
|
|
|
|
// sufficient space is available.
|
|
|
|
void AppendElements(const uint8_t* aSrc, uint32_t aLength) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mBuffer && mCapacity, "Buffer not initialized.");
|
|
|
|
MOZ_ASSERT(aLength <= Available(), "Buffer full.");
|
2013-11-28 09:09:08 +04:00
|
|
|
|
|
|
|
uint32_t end = (mStart + mCount) % mCapacity;
|
|
|
|
|
|
|
|
uint32_t toCopy = std::min(mCapacity - end, aLength);
|
|
|
|
memcpy(&mBuffer[end], aSrc, toCopy);
|
|
|
|
memcpy(&mBuffer[0], aSrc + toCopy, aLength - toCopy);
|
|
|
|
mCount += aLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove aSize bytes from the buffer. Caller must check returned size in
|
|
|
|
// aSize{1,2} before using the pointer returned in aData{1,2}. Caller
|
|
|
|
// must not specify an aSize larger than Length().
|
|
|
|
void PopElements(uint32_t aSize, void** aData1, uint32_t* aSize1,
|
|
|
|
void** aData2, uint32_t* aSize2) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mBuffer && mCapacity, "Buffer not initialized.");
|
|
|
|
MOZ_ASSERT(aSize <= Length(), "Request too large.");
|
2013-11-28 09:09:08 +04:00
|
|
|
|
|
|
|
*aData1 = &mBuffer[mStart];
|
|
|
|
*aSize1 = std::min(mCapacity - mStart, aSize);
|
|
|
|
*aData2 = &mBuffer[0];
|
|
|
|
*aSize2 = aSize - *aSize1;
|
|
|
|
mCount -= *aSize1 + *aSize2;
|
|
|
|
mStart += *aSize1 + *aSize2;
|
|
|
|
mStart %= mCapacity;
|
|
|
|
}
|
|
|
|
|
2014-04-13 22:08:10 +04:00
|
|
|
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
|
|
|
{
|
|
|
|
size_t amount = 0;
|
2015-12-03 02:07:59 +03:00
|
|
|
amount += aMallocSizeOf(mBuffer.get());
|
2014-04-13 22:08:10 +04:00
|
|
|
return amount;
|
|
|
|
}
|
|
|
|
|
2013-11-28 09:09:08 +04:00
|
|
|
private:
|
2015-12-03 02:07:59 +03:00
|
|
|
UniquePtr<uint8_t[]> mBuffer;
|
2013-11-28 09:09:08 +04:00
|
|
|
uint32_t mCapacity;
|
|
|
|
uint32_t mStart;
|
|
|
|
uint32_t mCount;
|
2012-11-22 14:38:28 +04:00
|
|
|
};
|
|
|
|
|
2016-01-18 06:24:06 +03:00
|
|
|
/*
|
|
|
|
* A bookkeeping class to track the read/write position of an audio buffer.
|
|
|
|
*/
|
|
|
|
class AudioBufferCursor {
|
|
|
|
public:
|
|
|
|
AudioBufferCursor(AudioDataValue* aPtr, uint32_t aChannels, uint32_t aFrames)
|
|
|
|
: mPtr(aPtr), mChannels(aChannels), mFrames(aFrames) {}
|
|
|
|
|
|
|
|
// Advance the cursor to account for frames that are consumed.
|
|
|
|
uint32_t Advance(uint32_t aFrames) {
|
|
|
|
MOZ_ASSERT(mFrames >= aFrames);
|
|
|
|
mFrames -= aFrames;
|
|
|
|
mPtr += mChannels * aFrames;
|
|
|
|
return aFrames;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The number of frames available for read/write in this buffer.
|
|
|
|
uint32_t Available() const { return mFrames; }
|
|
|
|
|
|
|
|
// Return a pointer where read/write should begin.
|
|
|
|
AudioDataValue* Ptr() const { return mPtr; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
AudioDataValue* mPtr;
|
|
|
|
const uint32_t mChannels;
|
|
|
|
uint32_t mFrames;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A helper class to encapsulate pointer arithmetic and provide means to modify
|
|
|
|
* the underlying audio buffer.
|
|
|
|
*/
|
|
|
|
class AudioBufferWriter : private AudioBufferCursor {
|
|
|
|
public:
|
|
|
|
AudioBufferWriter(AudioDataValue* aPtr, uint32_t aChannels, uint32_t aFrames)
|
|
|
|
: AudioBufferCursor(aPtr, aChannels, aFrames) {}
|
|
|
|
|
|
|
|
uint32_t WriteZeros(uint32_t aFrames) {
|
|
|
|
memset(mPtr, 0, sizeof(AudioDataValue) * mChannels * aFrames);
|
|
|
|
return Advance(aFrames);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Write(const AudioDataValue* aPtr, uint32_t aFrames) {
|
|
|
|
memcpy(mPtr, aPtr, sizeof(AudioDataValue) * mChannels * aFrames);
|
|
|
|
return Advance(aFrames);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Provide a write fuction to update the audio buffer with the following
|
|
|
|
// signature: uint32_t(const AudioDataValue* aPtr, uint32_t aFrames)
|
|
|
|
// aPtr: Pointer to the audio buffer.
|
|
|
|
// aFrames: The number of frames available in the buffer.
|
|
|
|
// return: The number of frames actually written by the function.
|
|
|
|
template <typename Function>
|
|
|
|
uint32_t Write(const Function& aFunction, uint32_t aFrames) {
|
|
|
|
return Advance(aFunction(mPtr, aFrames));
|
|
|
|
}
|
|
|
|
|
|
|
|
using AudioBufferCursor::Available;
|
|
|
|
};
|
|
|
|
|
2012-06-01 08:45:01 +04:00
|
|
|
// Access to a single instance of this class must be synchronized by
|
|
|
|
// callers, or made from a single thread. One exception is that access to
|
2014-07-29 20:45:03 +04:00
|
|
|
// GetPosition, GetPositionInFrames, SetVolume, and Get{Rate,Channels},
|
|
|
|
// SetMicrophoneActive is thread-safe without external synchronization.
|
2015-03-21 19:28:04 +03:00
|
|
|
class AudioStream final
|
2008-07-30 10:50:14 +04:00
|
|
|
{
|
2014-06-20 15:08:24 +04:00
|
|
|
virtual ~AudioStream();
|
|
|
|
|
2010-11-17 07:14:19 +03:00
|
|
|
public:
|
2014-04-09 23:59:07 +04:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AudioStream)
|
2016-01-12 16:48:25 +03:00
|
|
|
|
|
|
|
class Chunk {
|
|
|
|
public:
|
|
|
|
// Return a pointer to the audio data.
|
|
|
|
virtual const AudioDataValue* Data() const = 0;
|
|
|
|
// Return the number of frames in this chunk.
|
|
|
|
virtual uint32_t Frames() const = 0;
|
2016-01-21 16:11:14 +03:00
|
|
|
// Return the number of audio channels.
|
|
|
|
virtual uint32_t Channels() const = 0;
|
|
|
|
// Return the sample rate of this chunk.
|
|
|
|
virtual uint32_t Rate() const = 0;
|
2016-01-12 16:48:25 +03:00
|
|
|
// Return a writable pointer for downmixing.
|
|
|
|
virtual AudioDataValue* GetWritable() const = 0;
|
|
|
|
virtual ~Chunk() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class DataSource {
|
|
|
|
public:
|
|
|
|
// Return a chunk which contains at most aFrames frames or zero if no
|
|
|
|
// frames in the source at all.
|
|
|
|
virtual UniquePtr<Chunk> PopFrames(uint32_t aFrames) = 0;
|
|
|
|
// Return true if no more data will be added to the source.
|
|
|
|
virtual bool Ended() const = 0;
|
|
|
|
// Notify that all data is drained by the AudioStream.
|
|
|
|
virtual void Drained() = 0;
|
|
|
|
protected:
|
|
|
|
virtual ~DataSource() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit AudioStream(DataSource& aSource);
|
2013-11-28 09:09:08 +04:00
|
|
|
|
2011-09-27 07:31:18 +04:00
|
|
|
// Initialize the audio stream. aNumChannels is the number of audio
|
|
|
|
// channels (1 for mono, 2 for stereo, etc) and aRate is the sample rate
|
|
|
|
// (22050Hz, 44100Hz, etc).
|
2016-01-21 16:11:14 +03:00
|
|
|
nsresult Init(uint32_t aNumChannels, uint32_t aRate,
|
2015-08-27 05:49:17 +03:00
|
|
|
const dom::AudioChannel aAudioStreamChannel);
|
2008-07-30 10:50:14 +04:00
|
|
|
|
|
|
|
// Closes the stream. All future use of the stream is an error.
|
2013-11-28 09:09:08 +04:00
|
|
|
void Shutdown();
|
2008-07-30 10:50:14 +04:00
|
|
|
|
2014-07-18 21:22:03 +04:00
|
|
|
void Reset();
|
|
|
|
|
2008-07-30 10:50:14 +04:00
|
|
|
// Set the current volume of the audio playback. This is a value from
|
2012-06-01 08:45:01 +04:00
|
|
|
// 0 (meaning muted) to 1 (meaning full volume). Thread-safe.
|
2013-11-28 09:09:08 +04:00
|
|
|
void SetVolume(double aVolume);
|
2008-07-30 10:50:14 +04:00
|
|
|
|
2012-11-26 18:13:08 +04:00
|
|
|
// Start the stream.
|
2013-11-28 09:09:08 +04:00
|
|
|
void Start();
|
2012-11-26 18:13:08 +04:00
|
|
|
|
|
|
|
// Pause audio playback.
|
2013-11-28 09:09:08 +04:00
|
|
|
void Pause();
|
2009-05-15 05:29:05 +04:00
|
|
|
|
2012-11-26 18:13:08 +04:00
|
|
|
// Resume audio playback.
|
2013-11-28 09:09:08 +04:00
|
|
|
void Resume();
|
2009-05-15 05:29:05 +04:00
|
|
|
|
2011-09-27 07:31:18 +04:00
|
|
|
// Return the position in microseconds of the audio frame being played by
|
2012-11-22 14:38:28 +04:00
|
|
|
// the audio hardware, compensated for playback rate change. Thread-safe.
|
2013-11-28 09:09:08 +04:00
|
|
|
int64_t GetPosition();
|
2010-04-02 07:03:07 +04:00
|
|
|
|
2011-09-27 07:31:18 +04:00
|
|
|
// Return the position, measured in audio frames played since the stream
|
2012-06-01 08:45:01 +04:00
|
|
|
// was opened, of the audio hardware. Thread-safe.
|
2013-11-28 09:09:08 +04:00
|
|
|
int64_t GetPositionInFrames();
|
2010-08-25 17:10:00 +04:00
|
|
|
|
2011-09-30 03:34:37 +04:00
|
|
|
// Returns true when the audio stream is paused.
|
2013-11-28 09:09:08 +04:00
|
|
|
bool IsPaused();
|
2010-11-30 08:37:32 +03:00
|
|
|
|
2016-01-21 16:11:14 +03:00
|
|
|
uint32_t GetRate() { return mOutRate; }
|
|
|
|
uint32_t GetChannels() { return mChannels; }
|
|
|
|
uint32_t GetOutChannels() { return mOutChannels; }
|
2012-10-25 14:09:38 +04:00
|
|
|
|
2012-11-22 14:38:28 +04:00
|
|
|
// Set playback rate as a multiple of the intrinsic playback rate. This is to
|
|
|
|
// be called only with aPlaybackRate > 0.0.
|
2013-11-28 09:09:08 +04:00
|
|
|
nsresult SetPlaybackRate(double aPlaybackRate);
|
2012-11-22 14:38:28 +04:00
|
|
|
// Switch between resampling (if false) and time stretching (if true, default).
|
2013-11-28 09:09:08 +04:00
|
|
|
nsresult SetPreservesPitch(bool aPreservesPitch);
|
|
|
|
|
2014-04-13 22:08:10 +04:00
|
|
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
|
|
|
|
2014-05-21 11:28:22 +04:00
|
|
|
protected:
|
|
|
|
friend class AudioClock;
|
|
|
|
|
2014-06-26 06:56:23 +04:00
|
|
|
// Return the position, measured in audio frames played since the stream was
|
|
|
|
// opened, of the audio hardware, not adjusted for the changes of playback
|
|
|
|
// rate or underrun frames.
|
2014-05-21 11:28:22 +04:00
|
|
|
// Caller must own the monitor.
|
|
|
|
int64_t GetPositionInFramesUnlocked();
|
|
|
|
|
2013-11-28 09:09:08 +04:00
|
|
|
private:
|
2015-08-27 05:49:17 +03:00
|
|
|
nsresult OpenCubeb(cubeb_stream_params &aParams);
|
2014-04-09 23:59:07 +04:00
|
|
|
|
2016-01-21 19:51:36 +03:00
|
|
|
static long DataCallback_S(cubeb_stream*, void* aThis,
|
|
|
|
const void* /* aInputBuffer */, void* aOutputBuffer,
|
|
|
|
long aFrames)
|
2013-11-28 09:09:08 +04:00
|
|
|
{
|
2016-01-21 19:51:36 +03:00
|
|
|
return static_cast<AudioStream*>(aThis)->DataCallback(aOutputBuffer, aFrames);
|
2013-11-28 09:09:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void StateCallback_S(cubeb_stream*, void* aThis, cubeb_state aState)
|
|
|
|
{
|
|
|
|
static_cast<AudioStream*>(aThis)->StateCallback(aState);
|
|
|
|
}
|
|
|
|
|
2014-07-29 20:45:03 +04:00
|
|
|
|
2013-11-28 09:09:08 +04:00
|
|
|
long DataCallback(void* aBuffer, long aFrames);
|
|
|
|
void StateCallback(cubeb_state aState);
|
|
|
|
|
|
|
|
nsresult EnsureTimeStretcherInitializedUnlocked();
|
|
|
|
|
2016-01-12 16:48:25 +03:00
|
|
|
// Return true if downmixing succeeds otherwise false.
|
2016-01-21 16:11:14 +03:00
|
|
|
bool Downmix(Chunk* aChunk);
|
2016-01-12 16:48:25 +03:00
|
|
|
|
2016-01-18 06:24:06 +03:00
|
|
|
void GetUnprocessed(AudioBufferWriter& aWriter);
|
|
|
|
void GetTimeStretched(AudioBufferWriter& aWriter);
|
2013-11-28 09:09:08 +04:00
|
|
|
|
|
|
|
void StartUnlocked();
|
|
|
|
|
2016-01-12 16:48:25 +03:00
|
|
|
// The monitor is held to protect all access to member variables.
|
2013-11-28 09:09:08 +04:00
|
|
|
Monitor mMonitor;
|
2012-11-22 14:38:28 +04:00
|
|
|
|
|
|
|
// Input rate in Hz (characteristic of the media being played)
|
2016-01-21 16:11:14 +03:00
|
|
|
uint32_t mInRate;
|
2012-11-22 14:38:28 +04:00
|
|
|
// Output rate in Hz (characteristic of the playback rate)
|
2016-01-21 16:11:14 +03:00
|
|
|
uint32_t mOutRate;
|
|
|
|
uint32_t mChannels;
|
|
|
|
uint32_t mOutChannels;
|
2014-07-18 21:22:03 +04:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
dom::AudioChannel mAudioChannel;
|
|
|
|
#endif
|
2012-11-22 14:38:28 +04:00
|
|
|
AudioClock mAudioClock;
|
2015-07-06 22:08:56 +03:00
|
|
|
soundtouch::SoundTouch* mTimeStretcher;
|
2013-10-26 02:13:42 +04:00
|
|
|
|
2015-08-27 05:49:17 +03:00
|
|
|
// Stream start time for stream open delay telemetry.
|
2013-10-26 02:13:42 +04:00
|
|
|
TimeStamp mStartTime;
|
2013-11-28 09:09:08 +04:00
|
|
|
|
|
|
|
// Output file for dumping audio
|
|
|
|
FILE* mDumpFile;
|
|
|
|
|
2014-08-18 21:12:08 +04:00
|
|
|
// Owning reference to a cubeb_stream.
|
2015-03-08 04:07:17 +03:00
|
|
|
UniquePtr<cubeb_stream, CubebDestroyPolicy> mCubebStream;
|
2013-11-28 09:09:08 +04:00
|
|
|
|
|
|
|
enum StreamState {
|
|
|
|
INITIALIZED, // Initialized, playback has not begun.
|
2014-04-09 23:59:07 +04:00
|
|
|
STARTED, // cubeb started, but callbacks haven't started
|
|
|
|
RUNNING, // DataCallbacks have started after STARTED, or after Resume().
|
2013-11-28 09:09:08 +04:00
|
|
|
STOPPED, // Stopped by a call to Pause().
|
|
|
|
DRAINED, // StateCallback has indicated that the drain is complete.
|
2014-04-09 23:59:07 +04:00
|
|
|
ERRORED, // Stream disabled due to an internal error.
|
|
|
|
SHUTDOWN // Shutdown has been called
|
2013-11-28 09:09:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
StreamState mState;
|
2014-06-04 22:52:32 +04:00
|
|
|
bool mIsFirst;
|
2015-08-06 09:30:22 +03:00
|
|
|
// Get this value from the preferece, if true, we would downmix the stereo.
|
|
|
|
bool mIsMonoAudioEnabled;
|
2016-01-12 16:48:25 +03:00
|
|
|
|
|
|
|
DataSource& mDataSource;
|
2008-07-30 10:50:14 +04:00
|
|
|
};
|
2010-11-17 07:14:19 +03:00
|
|
|
|
2012-11-14 23:45:33 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2008-11-06 23:53:20 +03:00
|
|
|
#endif
|