audio_core: Dispose of current audio sink before opening new one. (#6567)

This commit is contained in:
Steveice10 2023-05-25 15:44:56 -07:00 committed by GitHub
parent 72b82ef6ed
commit 848116b5be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,9 @@ DspInterface::DspInterface() = default;
DspInterface::~DspInterface() = default;
void DspInterface::SetSink(AudioCore::SinkType sink_type, std::string_view audio_device) {
// Dispose of the current sink first to avoid contention.
sink.reset();
sink = CreateSinkFromID(sink_type, audio_device);
sink->SetCallback(
[this](s16* buffer, std::size_t num_frames) { OutputCallback(buffer, num_frames); });