зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1626918 - Don't register the audio callback thread when using audioipc: it's already registered. r=achronop
Depends on D78510 Differential Revision: https://phabricator.services.mozilla.com/D79460
This commit is contained in:
Родитель
32561dcfc4
Коммит
d6a6773f04
|
@ -650,6 +650,11 @@ void ShutdownLibrary() {
|
|||
#endif
|
||||
}
|
||||
|
||||
bool SandboxEnabled() {
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
return !!sCubebSandbox;
|
||||
}
|
||||
|
||||
uint32_t MaxNumberOfChannels() {
|
||||
cubeb* cubebContext = GetCubebContext();
|
||||
uint32_t maxNumberOfChannels;
|
||||
|
|
|
@ -28,6 +28,8 @@ void InitLibrary();
|
|||
// library after using it.
|
||||
void ShutdownLibrary();
|
||||
|
||||
bool SandboxEnabled();
|
||||
|
||||
// Returns the maximum number of channels supported by the audio hardware.
|
||||
uint32_t MaxNumberOfChannels();
|
||||
|
||||
|
|
|
@ -505,7 +505,8 @@ AudioCallbackDriver::AudioCallbackDriver(
|
|||
mAudioThreadId(std::thread::id()),
|
||||
mAudioThreadIdInCb(std::thread::id()),
|
||||
mAudioStreamState(AudioStreamState::None),
|
||||
mFallback("AudioCallbackDriver::mFallback") {
|
||||
mFallback("AudioCallbackDriver::mFallback"),
|
||||
mSandboxed(CubebUtils::SandboxEnabled()) {
|
||||
LOG(LogLevel::Debug, ("%p: AudioCallbackDriver ctor", Graph()));
|
||||
|
||||
NS_WARNING_ASSERTION(mOutputChannelCount != 0,
|
||||
|
@ -854,25 +855,23 @@ AudioCallbackDriver::AutoInCallback::~AutoInCallback() {
|
|||
mDriver->mAudioThreadIdInCb = std::thread::id();
|
||||
}
|
||||
|
||||
void AudioCallbackDriver::OnThreadIdChanged() {
|
||||
char stack;
|
||||
profiler_ensure_thread_registered("NativeAudioCallback", &stack);
|
||||
}
|
||||
|
||||
void AudioCallbackDriver::CheckThreadIdChanged() {
|
||||
bool AudioCallbackDriver::CheckThreadIdChanged() {
|
||||
auto id = std::this_thread::get_id();
|
||||
if (id != mAudioThreadId) {
|
||||
if (id != std::thread::id()) {
|
||||
OnThreadIdChanged();
|
||||
mAudioThreadId = id;
|
||||
return true;
|
||||
}
|
||||
mAudioThreadId = id;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
long AudioCallbackDriver::DataCallback(const AudioDataValue* aInputBuffer,
|
||||
AudioDataValue* aOutputBuffer,
|
||||
long aFrames) {
|
||||
CheckThreadIdChanged();
|
||||
if (!mSandboxed && CheckThreadIdChanged()) {
|
||||
PROFILER_REGISTER_THREAD("NativeAudioCallback");
|
||||
}
|
||||
FallbackDriverState fallbackState = mFallbackDriverState;
|
||||
if (MOZ_UNLIKELY(fallbackState == FallbackDriverState::Running)) {
|
||||
// Wait for the fallback driver to stop. Wake it up so it can stop if it's
|
||||
|
@ -1015,6 +1014,9 @@ long AudioCallbackDriver::DataCallback(const AudioDataValue* aInputBuffer,
|
|||
result.Stopped();
|
||||
// Update the flag before handing over the graph and going to drain.
|
||||
mAudioStreamState = AudioStreamState::Stopping;
|
||||
if (!mSandboxed) {
|
||||
PROFILER_UNREGISTER_THREAD();
|
||||
}
|
||||
return aFrames - 1;
|
||||
}
|
||||
|
||||
|
@ -1026,6 +1028,9 @@ long AudioCallbackDriver::DataCallback(const AudioDataValue* aInputBuffer,
|
|||
mAudioStreamState = AudioStreamState::Stopping;
|
||||
nextDriver->SetState(mIterationStart, mIterationEnd, mStateComputedTime);
|
||||
nextDriver->Start();
|
||||
if (!mSandboxed) {
|
||||
PROFILER_UNREGISTER_THREAD();
|
||||
}
|
||||
// Returning less than aFrames starts the draining and eventually stops the
|
||||
// audio thread. This function will never get called again.
|
||||
return aFrames - 1;
|
||||
|
|
|
@ -625,7 +625,7 @@ class AudioCallbackDriver : public GraphDriver,
|
|||
void OnThreadIdChanged();
|
||||
/* Called at the beginning of the audio callback to check if the thread id has
|
||||
* changed. */
|
||||
void CheckThreadIdChanged();
|
||||
bool CheckThreadIdChanged();
|
||||
|
||||
bool OnThread() override {
|
||||
return mAudioThreadIdInCb.load() == std::this_thread::get_id();
|
||||
|
@ -794,6 +794,7 @@ class AudioCallbackDriver : public GraphDriver,
|
|||
WavDumper mOutputStreamFile;
|
||||
|
||||
virtual ~AudioCallbackDriver();
|
||||
const bool mSandboxed = false;
|
||||
};
|
||||
|
||||
class AsyncCubebTask : public Runnable {
|
||||
|
|
Загрузка…
Ссылка в новой задаче