{mixer,output}/alsa: migrate from DeferredMonitor to DeferEvent
This commit is contained in:
parent
44c60567dd
commit
390e830994
|
@ -23,7 +23,7 @@
|
|||
#include "mixer/Listener.hxx"
|
||||
#include "output/OutputAPI.hxx"
|
||||
#include "event/MultiSocketMonitor.hxx"
|
||||
#include "event/DeferredMonitor.hxx"
|
||||
#include "event/DeferEvent.hxx"
|
||||
#include "event/Call.hxx"
|
||||
#include "util/ASCII.hxx"
|
||||
#include "util/ReusableArray.hxx"
|
||||
|
@ -43,30 +43,30 @@ extern "C" {
|
|||
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM"
|
||||
static constexpr unsigned VOLUME_MIXER_ALSA_INDEX_DEFAULT = 0;
|
||||
|
||||
class AlsaMixerMonitor final : MultiSocketMonitor, DeferredMonitor {
|
||||
class AlsaMixerMonitor final : MultiSocketMonitor {
|
||||
DeferEvent defer_invalidate_sockets;
|
||||
|
||||
snd_mixer_t *mixer;
|
||||
|
||||
ReusableArray<pollfd> pfd_buffer;
|
||||
|
||||
public:
|
||||
AlsaMixerMonitor(EventLoop &_loop, snd_mixer_t *_mixer)
|
||||
:MultiSocketMonitor(_loop), DeferredMonitor(_loop),
|
||||
:MultiSocketMonitor(_loop),
|
||||
defer_invalidate_sockets(_loop,
|
||||
BIND_THIS_METHOD(InvalidateSockets)),
|
||||
mixer(_mixer) {
|
||||
DeferredMonitor::Schedule();
|
||||
defer_invalidate_sockets.Schedule();
|
||||
}
|
||||
|
||||
~AlsaMixerMonitor() {
|
||||
BlockingCall(MultiSocketMonitor::GetEventLoop(), [this](){
|
||||
MultiSocketMonitor::Reset();
|
||||
DeferredMonitor::Cancel();
|
||||
defer_invalidate_sockets.Cancel();
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void RunDeferred() override {
|
||||
InvalidateSockets();
|
||||
}
|
||||
|
||||
virtual std::chrono::steady_clock::duration PrepareSockets() override;
|
||||
virtual void DispatchSockets() override;
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "util/ConstBuffer.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
#include "event/MultiSocketMonitor.hxx"
|
||||
#include "event/DeferredMonitor.hxx"
|
||||
#include "event/DeferEvent.hxx"
|
||||
#include "event/Call.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
|
@ -51,7 +51,9 @@ static const char default_device[] = "default";
|
|||
static constexpr unsigned MPD_ALSA_BUFFER_TIME_US = 500000;
|
||||
|
||||
class AlsaOutput final
|
||||
: AudioOutput, MultiSocketMonitor, DeferredMonitor {
|
||||
: AudioOutput, MultiSocketMonitor {
|
||||
|
||||
DeferEvent defer_invalidate_sockets;
|
||||
|
||||
Manual<PcmExport> pcm_export;
|
||||
|
||||
|
@ -224,7 +226,7 @@ private:
|
|||
return;
|
||||
|
||||
active = true;
|
||||
DeferredMonitor::Schedule();
|
||||
defer_invalidate_sockets.Schedule();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,11 +296,6 @@ private:
|
|||
return !!error;
|
||||
}
|
||||
|
||||
/* virtual methods from class DeferredMonitor */
|
||||
virtual void RunDeferred() override {
|
||||
InvalidateSockets();
|
||||
}
|
||||
|
||||
/* virtual methods from class MultiSocketMonitor */
|
||||
virtual std::chrono::steady_clock::duration PrepareSockets() override;
|
||||
virtual void DispatchSockets() override;
|
||||
|
@ -306,9 +303,10 @@ private:
|
|||
|
||||
static constexpr Domain alsa_output_domain("alsa_output");
|
||||
|
||||
AlsaOutput::AlsaOutput(EventLoop &loop, const ConfigBlock &block)
|
||||
AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block)
|
||||
:AudioOutput(FLAG_ENABLE_DISABLE),
|
||||
MultiSocketMonitor(loop), DeferredMonitor(loop),
|
||||
MultiSocketMonitor(_loop),
|
||||
defer_invalidate_sockets(_loop, BIND_THIS_METHOD(InvalidateSockets)),
|
||||
device(block.GetBlockValue("device", "")),
|
||||
#ifdef ENABLE_DSD
|
||||
dop_setting(block.GetBlockValue("dop", false) ||
|
||||
|
@ -747,7 +745,7 @@ AlsaOutput::Close() noexcept
|
|||
/* make sure the I/O thread isn't inside DispatchSockets() */
|
||||
BlockingCall(MultiSocketMonitor::GetEventLoop(), [this](){
|
||||
MultiSocketMonitor::Reset();
|
||||
DeferredMonitor::Cancel();
|
||||
defer_invalidate_sockets.Cancel();
|
||||
});
|
||||
|
||||
period_buffer.Free();
|
||||
|
|
Loading…
Reference in New Issue