Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Back out 60fc46d5b1ca (bug 723793) for Windows crashtest assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
philor committed Feb 3, 2012
1 parent 35f5269 commit b2d562a
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions content/media/nsAudioStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ using mozilla::TimeStamp;
PRLogModuleInfo* gAudioStreamLog = nsnull;
#endif

#if defined(MOZ_CUBEB)
static cubeb* gCubebContext;
#endif

static const PRUint32 FAKE_BUFFER_SIZE = 176400;

// Number of milliseconds per second.
Expand Down Expand Up @@ -359,19 +363,6 @@ static bool GetUseCubeb()
mozilla::MutexAutoLock lock(*gAudioPrefsLock);
return gUseCubeb;
}

static cubeb* gCubebContext;

static cubeb* GetCubebContext()
{
mozilla::MutexAutoLock lock(*gAudioPrefsLock);
if (gCubebContext ||
cubeb_init(&gCubebContext, "nsAudioStream") == CUBEB_OK) {
return gCubebContext;
}
NS_WARNING("cubeb_init failed");
return nsnull;
}
#endif

void nsAudioStream::InitLibrary()
Expand All @@ -385,6 +376,9 @@ void nsAudioStream::InitLibrary()
#if defined(MOZ_CUBEB)
PrefChanged(PREF_USE_CUBEB, nsnull);
Preferences::RegisterCallback(PrefChanged, PREF_USE_CUBEB);
if (cubeb_init(&gCubebContext, "nsAudioStream") != 0) {
NS_WARNING("cubeb_init failed");
}
#endif
}

Expand Down Expand Up @@ -938,9 +932,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS0(nsBufferedAudioStream)
nsresult
nsBufferedAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat)
{
cubeb* cubebContext = GetCubebContext();

if (!cubebContext || aNumChannels < 0 || aRate < 0) {
if (!gCubebContext || aNumChannels < 0 || aRate < 0) {
return NS_ERROR_FAILURE;
}

Expand All @@ -966,7 +958,7 @@ nsBufferedAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aF

{
cubeb_stream* stream;
if (cubeb_stream_init(cubebContext, &stream, "nsBufferedAudioStream", params,
if (cubeb_stream_init(gCubebContext, &stream, "nsBufferedAudioStream", params,
DEFAULT_LATENCY_MS, DataCallback_S, StateCallback_S, this) == CUBEB_OK) {
mCubebStream.own(stream);
}
Expand Down

0 comments on commit b2d562a

Please sign in to comment.