output/alsa: move redundant code to UnregisterSockets()

This commit is contained in:
Max Kellermann 2024-07-29 15:28:06 +02:00
parent d466deedad
commit 9d9c4045e2

View File

@ -258,6 +258,11 @@ public:
} }
private: private:
void UnregisterSockets() noexcept {
MultiSocketMonitor::Reset();
defer_invalidate_sockets.Cancel();
}
std::map<std::string, std::string, std::less<>> GetAttributes() const noexcept override; std::map<std::string, std::string, std::less<>> GetAttributes() const noexcept override;
void SetAttribute(std::string &&name, std::string &&value) override; void SetAttribute(std::string &&name, std::string &&value) override;
@ -1103,8 +1108,7 @@ AlsaOutput::CancelInternal() noexcept
active = false; active = false;
waiting = false; waiting = false;
MultiSocketMonitor::Reset(); UnregisterSockets();
defer_invalidate_sockets.Cancel();
silence_timer.Cancel(); silence_timer.Cancel();
} }
@ -1159,8 +1163,7 @@ AlsaOutput::Close() noexcept
{ {
/* make sure the I/O thread isn't inside DispatchSockets() */ /* make sure the I/O thread isn't inside DispatchSockets() */
BlockingCall(GetEventLoop(), [this](){ BlockingCall(GetEventLoop(), [this](){
MultiSocketMonitor::Reset(); UnregisterSockets();
defer_invalidate_sockets.Cancel();
silence_timer.Cancel(); silence_timer.Cancel();
}); });
@ -1317,8 +1320,7 @@ try {
event (but after setting the "waiting" event (but after setting the "waiting"
flag) */ flag) */
if (!CopyRingToPeriodBuffer()) { if (!CopyRingToPeriodBuffer()) {
MultiSocketMonitor::Reset(); UnregisterSockets();
defer_invalidate_sockets.Cancel();
/* just in case Play() doesn't get /* just in case Play() doesn't get
called soon enough, schedule a called soon enough, schedule a