mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibAudio: Remove the strong reference to the PulseAudio control thread
Now that `Thread` keeps itself alive when it is running detached, we do not need to hold onto it in the PulseAudio playback stream's internal state object. This was a hack that did not work correctly because the `Thread` object and its action `Function` would be deleted before the action had exited and cause a crash.
This commit is contained in:
parent
aff64b6a03
commit
5ea5ae85d2
2 changed files with 0 additions and 15 deletions
|
@ -45,7 +45,6 @@ ErrorOr<NonnullRefPtr<PlaybackStream>> PlaybackStreamPulseAudio::create(OutputSt
|
||||||
},
|
},
|
||||||
"Audio::PlaybackStream"sv));
|
"Audio::PlaybackStream"sv));
|
||||||
|
|
||||||
internal_state->set_thread(thread);
|
|
||||||
thread->start();
|
thread->start();
|
||||||
thread->detach();
|
thread->detach();
|
||||||
return playback_stream;
|
return playback_stream;
|
||||||
|
@ -136,12 +135,6 @@ ErrorOr<void> PlaybackStreamPulseAudio::InternalState::check_is_running()
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaybackStreamPulseAudio::InternalState::set_thread(NonnullRefPtr<Threading::Thread> const& thread)
|
|
||||||
{
|
|
||||||
Threading::MutexLocker locker { m_mutex };
|
|
||||||
m_thread = thread;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlaybackStreamPulseAudio::InternalState::set_stream(NonnullRefPtr<PulseAudioStream> const& stream)
|
void PlaybackStreamPulseAudio::InternalState::set_stream(NonnullRefPtr<PulseAudioStream> const& stream)
|
||||||
{
|
{
|
||||||
m_stream = stream;
|
m_stream = stream;
|
||||||
|
@ -177,10 +170,6 @@ void PlaybackStreamPulseAudio::InternalState::thread_loop()
|
||||||
}
|
}
|
||||||
task();
|
task();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop holding onto our thread so it can be deleted.
|
|
||||||
Threading::MutexLocker locker { m_mutex };
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaybackStreamPulseAudio::InternalState::exit()
|
void PlaybackStreamPulseAudio::InternalState::exit()
|
||||||
|
|
|
@ -31,8 +31,6 @@ private:
|
||||||
// the UI thread.
|
// the UI thread.
|
||||||
class InternalState : public AtomicRefCounted<InternalState> {
|
class InternalState : public AtomicRefCounted<InternalState> {
|
||||||
public:
|
public:
|
||||||
void set_thread(NonnullRefPtr<Threading::Thread> const&);
|
|
||||||
|
|
||||||
void set_stream(NonnullRefPtr<PulseAudioStream> const&);
|
void set_stream(NonnullRefPtr<PulseAudioStream> const&);
|
||||||
RefPtr<PulseAudioStream> stream();
|
RefPtr<PulseAudioStream> stream();
|
||||||
|
|
||||||
|
@ -49,8 +47,6 @@ private:
|
||||||
Threading::ConditionVariable m_wake_condition { m_mutex };
|
Threading::ConditionVariable m_wake_condition { m_mutex };
|
||||||
|
|
||||||
Atomic<bool> m_exit { false };
|
Atomic<bool> m_exit { false };
|
||||||
|
|
||||||
RefPtr<Threading::Thread> m_thread { nullptr };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PlaybackStreamPulseAudio(NonnullRefPtr<InternalState>);
|
PlaybackStreamPulseAudio(NonnullRefPtr<InternalState>);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue