mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 18:32:28 -05: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));
|
||||
|
||||
internal_state->set_thread(thread);
|
||||
thread->start();
|
||||
thread->detach();
|
||||
return playback_stream;
|
||||
|
@ -136,12 +135,6 @@ ErrorOr<void> PlaybackStreamPulseAudio::InternalState::check_is_running()
|
|||
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)
|
||||
{
|
||||
m_stream = stream;
|
||||
|
@ -177,10 +170,6 @@ void PlaybackStreamPulseAudio::InternalState::thread_loop()
|
|||
}
|
||||
task();
|
||||
}
|
||||
|
||||
// Stop holding onto our thread so it can be deleted.
|
||||
Threading::MutexLocker locker { m_mutex };
|
||||
m_thread = nullptr;
|
||||
}
|
||||
|
||||
void PlaybackStreamPulseAudio::InternalState::exit()
|
||||
|
|
|
@ -31,8 +31,6 @@ private:
|
|||
// the UI thread.
|
||||
class InternalState : public AtomicRefCounted<InternalState> {
|
||||
public:
|
||||
void set_thread(NonnullRefPtr<Threading::Thread> const&);
|
||||
|
||||
void set_stream(NonnullRefPtr<PulseAudioStream> const&);
|
||||
RefPtr<PulseAudioStream> stream();
|
||||
|
||||
|
@ -49,8 +47,6 @@ private:
|
|||
Threading::ConditionVariable m_wake_condition { m_mutex };
|
||||
|
||||
Atomic<bool> m_exit { false };
|
||||
|
||||
RefPtr<Threading::Thread> m_thread { nullptr };
|
||||
};
|
||||
|
||||
PlaybackStreamPulseAudio(NonnullRefPtr<InternalState>);
|
||||
|
|
Loading…
Add table
Reference in a new issue