Bug 1361336 - part1: A new API for AudioStream that it can reset stream to the default device; r=kinetik
MozReview-Commit-ID: ErUYXK9fUvE
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -469,16 +469,26 @@ AudioStream::Shutdown()
// Must not try to shut down cubeb from within the lock! wasapi may still
// call our callback after Pause()/stop()!?! Bug 996162
mCubebStream.reset();
}
mState = SHUTDOWN;
}
+void
+AudioStream::ResetDefaultDevice()
+{
+ MonitorAutoLock mon(mMonitor);
+ auto r = InvokeCubeb(cubeb_stream_reset_default_device);
+ if (!(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED)) {
+ mState = ERRORED;
+ }
+}
+
int64_t
AudioStream::GetPosition()
{
MonitorAutoLock mon(mMonitor);
int64_t frames = GetPositionInFramesUnlocked();
return frames >= 0 ? mAudioClock.GetPosition(frames) : -1;
}
--- a/dom/media/AudioStream.h
+++ b/dom/media/AudioStream.h
@@ -207,16 +207,19 @@ public:
void Start();
// Pause audio playback.
void Pause();
// Resume audio playback.
void Resume();
+ // Reset stream to default device.
+ void ResetDefaultDevice();
+
// Return the position in microseconds of the audio frame being played by
// the audio hardware, compensated for playback rate change. Thread-safe.
int64_t GetPosition();
// Return the position, measured in audio frames played since the stream
// was opened, of the audio hardware. Thread-safe.
int64_t GetPositionInFrames();