You need to sign in or sign up before continuing.
Commit 0f843326 authored by Max Kellermann's avatar Max Kellermann

output/alsa: make "mode" const

parent 46c82259
...@@ -93,7 +93,7 @@ class AlsaOutput final ...@@ -93,7 +93,7 @@ class AlsaOutput final
const unsigned period_time; const unsigned period_time;
/** the mode flags passed to snd_pcm_open */ /** the mode flags passed to snd_pcm_open */
int mode = 0; const int mode;
std::forward_list<Alsa::AllowedFormat> allowed_formats; std::forward_list<Alsa::AllowedFormat> allowed_formats;
...@@ -408,21 +408,11 @@ private: ...@@ -408,21 +408,11 @@ private:
static constexpr Domain alsa_output_domain("alsa_output"); static constexpr Domain alsa_output_domain("alsa_output");
AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block) static int
:AudioOutput(FLAG_ENABLE_DISABLE), GetAlsaOpenMode(const ConfigBlock &block)
MultiSocketMonitor(_loop),
defer_invalidate_sockets(_loop, BIND_THIS_METHOD(InvalidateSockets)),
silence_timer(_loop, BIND_THIS_METHOD(OnSilenceTimer)),
device(block.GetBlockValue("device", "")),
#ifdef ENABLE_DSD
dop_setting(block.GetBlockValue("dop", false) ||
/* legacy name from MPD 0.18 and older: */
block.GetBlockValue("dsd_usb", false)),
#endif
buffer_time(block.GetPositiveValue("buffer_time",
MPD_ALSA_BUFFER_TIME_US)),
period_time(block.GetPositiveValue("period_time", 0U))
{ {
int mode = 0;
#ifdef SND_PCM_NO_AUTO_RESAMPLE #ifdef SND_PCM_NO_AUTO_RESAMPLE
if (!block.GetBlockValue("auto_resample", true)) if (!block.GetBlockValue("auto_resample", true))
mode |= SND_PCM_NO_AUTO_RESAMPLE; mode |= SND_PCM_NO_AUTO_RESAMPLE;
...@@ -438,6 +428,25 @@ AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block) ...@@ -438,6 +428,25 @@ AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block)
mode |= SND_PCM_NO_AUTO_FORMAT; mode |= SND_PCM_NO_AUTO_FORMAT;
#endif #endif
return mode;
}
AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block)
:AudioOutput(FLAG_ENABLE_DISABLE),
MultiSocketMonitor(_loop),
defer_invalidate_sockets(_loop, BIND_THIS_METHOD(InvalidateSockets)),
silence_timer(_loop, BIND_THIS_METHOD(OnSilenceTimer)),
device(block.GetBlockValue("device", "")),
#ifdef ENABLE_DSD
dop_setting(block.GetBlockValue("dop", false) ||
/* legacy name from MPD 0.18 and older: */
block.GetBlockValue("dsd_usb", false)),
#endif
buffer_time(block.GetPositiveValue("buffer_time",
MPD_ALSA_BUFFER_TIME_US)),
period_time(block.GetPositiveValue("period_time", 0U)),
mode(GetAlsaOpenMode(block))
{
const char *allowed_formats_string = const char *allowed_formats_string =
block.GetBlockValue("allowed_formats", nullptr); block.GetBlockValue("allowed_formats", nullptr);
if (allowed_formats_string != nullptr) if (allowed_formats_string != nullptr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment