Revert bug 1647717 to workaround the issue of occational tab crashing when
using any cubeb backends other than pulse-rust to play media. The loss of
such change will be that users will not be able to do profiling on threads
created by libcubeb.

--- dom/media/AudioStream.cpp.orig	2022-04-19 19:43:36.505544000 +0200
+++ dom/media/AudioStream.cpp	2022-04-19 19:47:53.111474000 +0200
@@ -27,7 +27,6 @@
 #endif
 #include "Tracing.h"
 #include "webaudio/blink/DenormalDisabler.h"
-#include "AudioThreadRegistry.h"
 #include "mozilla/StaticPrefs_media.h"
 
 // Use abort() instead of exception in SoundTouch.
@@ -144,8 +143,6 @@
       mOutChannels(aOutputChannels),
       mState(INITIALIZED),
       mDataSource(aSource),
-      mAudioThreadId(ProfilerThreadId{}),
-      mSandboxed(CubebUtils::SandboxEnabled()),
       mPlaybackComplete(false),
       mPlaybackRate(1.0f),
       mPreservesPitch(true) {}
@@ -552,17 +549,6 @@
       aWriter.Available());
 }
 
-bool AudioStream::CheckThreadIdChanged() {
-  ProfilerThreadId id = profiler_current_thread_id();
-  if (id != mAudioThreadId) {
-    mAudioThreadId = id;
-    mAudioThreadChanged = true;
-    return true;
-  }
-  mAudioThreadChanged = false;
-  return false;
-}
-
 void AudioStream::AssertIsOnAudioThread() const {
   // This can be called right after CheckThreadIdChanged, because the audio
   // thread can change when not sandboxed.
@@ -591,9 +577,6 @@
 }
 
 long AudioStream::DataCallback(void* aBuffer, long aFrames) {
-  if (CheckThreadIdChanged() && !mSandboxed) {
-    CubebUtils::GetAudioThreadRegistry()->Register(mAudioThreadId);
-  }
   WebCore::DenormalDisabler disabler;
 
   TRACE_AUDIO_CALLBACK_BUDGET(aFrames, mAudioClock.GetInputRate());
@@ -648,9 +631,6 @@
   mDumpFile.Write(static_cast<const AudioDataValue*>(aBuffer),
                   aFrames * mOutChannels);
 
-  if (!mSandboxed && writer.Available() != 0) {
-    CubebUtils::GetAudioThreadRegistry()->Unregister(mAudioThreadId);
-  }
   return aFrames - writer.Available();
 }
 
--- dom/media/AudioStream.h.orig	2022-04-19 19:43:45.457171000 +0200
+++ dom/media/AudioStream.h	2022-04-19 19:45:30.463633000 +0200
@@ -329,7 +329,6 @@
 
   template <typename Function, typename... Args>
   int InvokeCubeb(Function aFunction, Args&&... aArgs) REQUIRES(mMonitor);
-  bool CheckThreadIdChanged();
   void AssertIsOnAudioThread() const;
 
   soundtouch::SoundTouch* mTimeStretcher;
@@ -368,9 +367,6 @@
   // the default device is used. It is set
   // during the Init() in decoder thread.
   RefPtr<AudioDeviceInfo> mSinkInfo;
-  // Contains the id of the audio thread, from profiler_get_thread_id.
-  std::atomic<ProfilerThreadId> mAudioThreadId;
-  const bool mSandboxed = false;
 
   MozPromiseHolder<MediaSink::EndedPromise> mEndedPromise GUARDED_BY(mMonitor);
   std::atomic<bool> mPlaybackComplete;
