diff --git a/dom/media/gtest/MockCubeb.cpp b/dom/media/gtest/MockCubeb.cpp index 80975a53001895b1fee868c3fd963882c5f8b3fe..10422c77571a8b47f9ee6c76d22a45ebf8f9fecc 100644 --- a/dom/media/gtest/MockCubeb.cpp +++ b/dom/media/gtest/MockCubeb.cpp @@ -146,6 +146,7 @@ MockCubebStream::MockCubebStream(cubeb* aContext, cubeb_devid aInputDevice, void* aUserPtr, SmartMockCubebStream* aSelf, bool aFrozenStart) : context(aContext), + mUserPtr(aUserPtr), mHasInput(aInputStreamParams), mHasOutput(aOutputStreamParams), mSelf(aSelf), @@ -153,7 +154,6 @@ MockCubebStream::MockCubebStream(cubeb* aContext, cubeb_devid aInputDevice, mFrozenStart(aFrozenStart), mDataCallback(aDataCallback), mStateCallback(aStateCallback), - mUserPtr(aUserPtr), mInputDeviceID(aInputDevice), mOutputDeviceID(aOutputDevice), mAudioGenerator(aInputStreamParams ? aInputStreamParams->channels diff --git a/dom/media/gtest/MockCubeb.h b/dom/media/gtest/MockCubeb.h index 040b1dfb622439894c035f75dc4d237c5698973c..4adaa4e02b3359aff16eeb3d24b2ca32f94ed646 100644 --- a/dom/media/gtest/MockCubeb.h +++ b/dom/media/gtest/MockCubeb.h @@ -137,6 +137,12 @@ class SmartMockCubebStream; // Represents the fake cubeb_stream. The context instance is needed to // provide access on cubeb_ops struct. class MockCubebStream { + // These members need to have the exact same memory layout as a real + // cubeb_stream, so that AsMock() returns a pointer to this that can be used + // as a cubeb_stream. + cubeb* context; + void* mUserPtr; + public: MockCubebStream(cubeb* aContext, cubeb_devid aInputDevice, cubeb_stream_params* aInputStreamParams, @@ -194,9 +200,6 @@ class MockCubebStream { void Process10Ms(); - private: - cubeb* context = nullptr; - public: const bool mHasInput; const bool mHasOutput; @@ -229,8 +232,6 @@ class MockCubebStream { cubeb_state_callback mStateCallback = nullptr; // The device changed callback cubeb_device_changed_callback mDeviceChangedCallback = nullptr; - // Stream's user data - void* mUserPtr = nullptr; // The stream params cubeb_stream_params mOutputParams = {}; cubeb_stream_params mInputParams = {};