output/Registry: replace output_plugins_for_each() with a container class
This commit is contained in:
parent
29747a213f
commit
cf5970a6e1
|
@ -173,8 +173,9 @@ static void version()
|
||||||
#endif
|
#endif
|
||||||
"\n\n"
|
"\n\n"
|
||||||
"Output plugins:\n");
|
"Output plugins:\n");
|
||||||
audio_output_plugins_for_each(plugin)
|
for (const auto &plugin : GetAllAudioOutputPlugins()) {
|
||||||
fmt::print(" {}", plugin->name);
|
fmt::print(" {}", plugin.name);
|
||||||
|
}
|
||||||
fmt::print("\n"
|
fmt::print("\n"
|
||||||
|
|
||||||
#ifdef ENABLE_ENCODER
|
#ifdef ENABLE_ENCODER
|
||||||
|
|
|
@ -51,15 +51,15 @@ audio_output_detect()
|
||||||
{
|
{
|
||||||
LogInfo(output_domain, "Attempt to detect audio output device");
|
LogInfo(output_domain, "Attempt to detect audio output device");
|
||||||
|
|
||||||
audio_output_plugins_for_each(plugin) {
|
for (const auto &plugin : GetAllAudioOutputPlugins()) {
|
||||||
if (plugin->test_default_device == nullptr)
|
if (plugin.test_default_device == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FmtInfo(output_domain,
|
FmtInfo(output_domain,
|
||||||
"Attempting to detect a {:?} audio device",
|
"Attempting to detect a {:?} audio device",
|
||||||
plugin->name);
|
plugin.name);
|
||||||
if (ao_plugin_test_default_device(plugin))
|
if (ao_plugin_test_default_device(&plugin))
|
||||||
return plugin;
|
return &plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw std::runtime_error("Unable to detect an audio device");
|
throw std::runtime_error("Unable to detect an audio device");
|
||||||
|
|
|
@ -92,9 +92,10 @@ constinit const AudioOutputPlugin *const audio_output_plugins[] = {
|
||||||
const AudioOutputPlugin *
|
const AudioOutputPlugin *
|
||||||
GetAudioOutputPluginByName(const char *name) noexcept
|
GetAudioOutputPluginByName(const char *name) noexcept
|
||||||
{
|
{
|
||||||
audio_output_plugins_for_each(plugin)
|
for (const auto &plugin : GetAllAudioOutputPlugins()) {
|
||||||
if (StringIsEqual(plugin->name, name))
|
if (StringIsEqual(plugin.name, name))
|
||||||
return plugin;
|
return &plugin;
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
// Copyright The Music Player Daemon Project
|
// Copyright The Music Player Daemon Project
|
||||||
|
|
||||||
#ifndef MPD_OUTPUT_LIST_HXX
|
#pragma once
|
||||||
#define MPD_OUTPUT_LIST_HXX
|
|
||||||
|
#include "util/DereferenceIterator.hxx"
|
||||||
|
#include "util/TerminatedArray.hxx"
|
||||||
|
|
||||||
struct AudioOutputPlugin;
|
struct AudioOutputPlugin;
|
||||||
|
|
||||||
extern const AudioOutputPlugin *const audio_output_plugins[];
|
extern const AudioOutputPlugin *const audio_output_plugins[];
|
||||||
|
|
||||||
|
static inline auto
|
||||||
|
GetAllAudioOutputPlugins() noexcept
|
||||||
|
{
|
||||||
|
return DereferenceContainerAdapter{TerminatedArray<const AudioOutputPlugin *const, nullptr>{audio_output_plugins}};
|
||||||
|
}
|
||||||
|
|
||||||
[[gnu::pure]]
|
[[gnu::pure]]
|
||||||
const AudioOutputPlugin *
|
const AudioOutputPlugin *
|
||||||
GetAudioOutputPluginByName(const char *name) noexcept;
|
GetAudioOutputPluginByName(const char *name) noexcept;
|
||||||
|
|
||||||
#define audio_output_plugins_for_each(plugin) \
|
|
||||||
for (const AudioOutputPlugin *plugin, \
|
|
||||||
*const*output_plugin_iterator = &audio_output_plugins[0]; \
|
|
||||||
(plugin = *output_plugin_iterator) != nullptr; ++output_plugin_iterator)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue