Bug 726891. Move rate/channels/format up to nsAudioStream and add inline getters. r=kinetik

This commit is contained in:
Robert O'Callahan 2012-02-14 17:39:33 +13:00
parent b2ec9bd05d
commit 8dc6b990e1
2 changed files with 14 additions and 18 deletions

View File

@ -117,10 +117,6 @@ class nsNativeAudioStream : public nsAudioStream
double mVolume; double mVolume;
void* mAudioHandle; void* mAudioHandle;
int mRate;
int mChannels;
SampleFormat mFormat;
// True if this audio stream is paused. // True if this audio stream is paused.
bool mPaused; bool mPaused;
@ -155,10 +151,6 @@ class nsRemotedAudioStream : public nsAudioStream
private: private:
nsRefPtr<AudioChild> mAudioChild; nsRefPtr<AudioChild> mAudioChild;
SampleFormat mFormat;
int mRate;
int mChannels;
PRInt32 mBytesPerFrame; PRInt32 mBytesPerFrame;
// True if this audio stream is paused. // True if this audio stream is paused.
@ -430,9 +422,6 @@ nsAudioStream::~nsAudioStream()
nsNativeAudioStream::nsNativeAudioStream() : nsNativeAudioStream::nsNativeAudioStream() :
mVolume(1.0), mVolume(1.0),
mAudioHandle(0), mAudioHandle(0),
mRate(0),
mChannels(0),
mFormat(FORMAT_S16_LE),
mPaused(false), mPaused(false),
mInError(false) mInError(false)
{ {
@ -654,9 +643,6 @@ PRInt32 nsNativeAudioStream::GetMinWriteSize()
#if defined(REMOTE_AUDIO) #if defined(REMOTE_AUDIO)
nsRemotedAudioStream::nsRemotedAudioStream() nsRemotedAudioStream::nsRemotedAudioStream()
: mAudioChild(nsnull), : mAudioChild(nsnull),
mFormat(FORMAT_S16_LE),
mRate(0),
mChannels(0),
mBytesPerFrame(0), mBytesPerFrame(0),
mPaused(false) mPaused(false)
{} {}
@ -876,9 +862,6 @@ private:
// nsAutoRef's destructor. // nsAutoRef's destructor.
nsAutoRef<cubeb_stream> mCubebStream; nsAutoRef<cubeb_stream> mCubebStream;
PRInt32 mRate;
PRInt32 mChannels;
SampleFormat mFormat;
PRUint32 mBytesPerFrame; PRUint32 mBytesPerFrame;
enum StreamState { enum StreamState {
@ -917,7 +900,7 @@ nsAudioStream* nsAudioStream::AllocateStream()
#if defined(MOZ_CUBEB) #if defined(MOZ_CUBEB)
nsBufferedAudioStream::nsBufferedAudioStream() nsBufferedAudioStream::nsBufferedAudioStream()
: mMonitor("nsBufferedAudioStream"), mLostFrames(0), mVolume(1.0), mRate(0), mChannels(0), : mMonitor("nsBufferedAudioStream"), mLostFrames(0), mVolume(1.0),
mBytesPerFrame(0), mState(INITIALIZED) mBytesPerFrame(0), mState(INITIALIZED)
{ {
} }

View File

@ -54,6 +54,12 @@ public:
FORMAT_FLOAT32 FORMAT_FLOAT32
}; };
nsAudioStream()
: mRate(0),
mChannels(0),
mFormat(FORMAT_S16_LE)
{}
virtual ~nsAudioStream(); virtual ~nsAudioStream();
// Initialize Audio Library. Some Audio backends require initializing the // Initialize Audio Library. Some Audio backends require initializing the
@ -122,8 +128,15 @@ public:
// Unsafe to call with the decoder monitor held. // Unsafe to call with the decoder monitor held.
virtual PRInt32 GetMinWriteSize() = 0; virtual PRInt32 GetMinWriteSize() = 0;
int GetRate() { return mRate; }
int GetChannels() { return mChannels; }
SampleFormat GetFormat() { return mFormat; }
protected: protected:
nsCOMPtr<nsIThread> mAudioPlaybackThread; nsCOMPtr<nsIThread> mAudioPlaybackThread;
int mRate;
int mChannels;
SampleFormat mFormat;
}; };
#endif #endif