Merge branch 'v0.23.x'

This commit is contained in:
Max Kellermann
2022-04-26 18:30:34 +02:00
16 changed files with 187 additions and 89 deletions

View File

@@ -12,17 +12,23 @@ if is_windows
icu_sources += 'Win32.cxx'
endif
iconv_dep = []
if icu_dep.found()
icu_sources += [
'Util.cxx',
'Init.cxx',
]
elif not get_option('iconv').disabled()
have_iconv = compiler.has_function('iconv', prefix : '#include <iconv.h>')
conf.set('HAVE_ICONV', have_iconv)
# an installed iconv library will make the builtin iconv() unavailable,
# so search for the library first and pass it as (possible) dependency
iconv_dep = compiler.find_library('libiconv', required: false)
have_iconv = compiler.has_function('iconv',
dependencies: iconv_dep,
prefix : '#include <iconv.h>')
if not have_iconv and get_option('iconv').enabled()
error('iconv() not available')
endif
conf.set('HAVE_ICONV', have_iconv)
endif
icu = static_library(
@@ -31,6 +37,7 @@ icu = static_library(
include_directories: inc,
dependencies: [
icu_dep,
iconv_dep,
fmt_dep,
],
)

View File

@@ -35,13 +35,7 @@ static unsigned upnp_ref;
static void
DoInit(const char* iface)
{
#ifdef UPNP_ENABLE_IPV6
auto code = UpnpInit2(iface, 0);
#else
auto code = UpnpInit(iface, 0);
#endif
if (code != UPNP_E_SUCCESS)
if (auto code = UpnpInit2(iface, 0); code != UPNP_E_SUCCESS)
throw FormatRuntimeError("UpnpInit() failed: %s",
UpnpGetErrorMessage(code));

View File

@@ -84,7 +84,7 @@ output_mixer_set_volume(AudioOutputControl &ao, unsigned volume) noexcept
/* software mixers are always updated, even if they are
disabled */
if (!ao.IsEnabled() && !mixer->IsPlugin(software_mixer_plugin))
if (!ao.IsReallyEnabled() && !mixer->IsPlugin(software_mixer_plugin))
return false;
try {

View File

@@ -288,6 +288,13 @@ public:
return !output;
}
/**
* Caller must lock the mutex.
*/
bool IsReallyEnabled() const noexcept {
return really_enabled;
}
/**
* Caller must lock the mutex.
*/

View File

@@ -638,8 +638,8 @@ PipeWireOutput::ParamChanged([[maybe_unused]] uint32_t id,
[[maybe_unused]] const struct spa_pod *param) noexcept
{
if (restore_volume) {
SetVolume(volume);
restore_volume = false;
SetVolume(volume);
}
#if defined(ENABLE_DSD) && defined(SPA_AUDIO_DSD_FLAG_NONE)

View File

@@ -59,7 +59,7 @@ class ShoutConfig {
public:
ShoutConfig(const ConfigBlock &block, const char *mime_type);
void Setup(shout_t *connection) const;
void Setup(shout_t &connection) const;
};
struct ShoutOutput final : AudioOutput {
@@ -229,41 +229,56 @@ ShoutOutput::Create(EventLoop &, const ConfigBlock &block)
return new ShoutOutput(block);
}
inline void
ShoutConfig::Setup(shout_t *connection) const
static void
SetMeta(shout_t &connection, const char *name, const char *value)
{
if (shout_set_host(connection, host) != SHOUTERR_SUCCESS ||
shout_set_port(connection, port) != SHOUTERR_SUCCESS ||
shout_set_password(connection, passwd) != SHOUTERR_SUCCESS ||
shout_set_mount(connection, mount) != SHOUTERR_SUCCESS ||
shout_set_name(connection, name) != SHOUTERR_SUCCESS ||
shout_set_user(connection, user) != SHOUTERR_SUCCESS ||
shout_set_public(connection, is_public) != SHOUTERR_SUCCESS ||
shout_set_format(connection, format) != SHOUTERR_SUCCESS ||
shout_set_protocol(connection, protocol) != SHOUTERR_SUCCESS ||
#ifdef SHOUT_TLS
shout_set_tls(connection, tls) != SHOUTERR_SUCCESS ||
if (shout_set_meta(&connection, name, value) != SHOUTERR_SUCCESS)
throw std::runtime_error(shout_get_error(&connection));
}
static void
SetOptionalMeta(shout_t &connection, const char *name, const char *value)
{
if (value != nullptr)
SetMeta(connection, name, value);
}
inline void
ShoutConfig::Setup(shout_t &connection) const
{
if (shout_set_host(&connection, host) != SHOUTERR_SUCCESS ||
shout_set_port(&connection, port) != SHOUTERR_SUCCESS ||
shout_set_password(&connection, passwd) != SHOUTERR_SUCCESS ||
shout_set_mount(&connection, mount) != SHOUTERR_SUCCESS ||
shout_set_user(&connection, user) != SHOUTERR_SUCCESS ||
shout_set_public(&connection, is_public) != SHOUTERR_SUCCESS ||
#ifdef SHOUT_USAGE_AUDIO
/* since libshout 2.4.3 */
shout_set_content_format(&connection, format, SHOUT_USAGE_AUDIO,
nullptr) != SHOUTERR_SUCCESS ||
#else
shout_set_format(&connection, format) != SHOUTERR_SUCCESS ||
#endif
shout_set_agent(connection, "MPD") != SHOUTERR_SUCCESS)
throw std::runtime_error(shout_get_error(connection));
shout_set_protocol(&connection, protocol) != SHOUTERR_SUCCESS ||
#ifdef SHOUT_TLS
shout_set_tls(&connection, tls) != SHOUTERR_SUCCESS ||
#endif
shout_set_agent(&connection, "MPD") != SHOUTERR_SUCCESS)
throw std::runtime_error(shout_get_error(&connection));
SetMeta(connection, SHOUT_META_NAME, name);
/* optional paramters */
if (genre != nullptr && shout_set_genre(connection, genre))
throw std::runtime_error(shout_get_error(connection));
if (description != nullptr &&
shout_set_description(connection, description))
throw std::runtime_error(shout_get_error(connection));
if (url != nullptr && shout_set_url(connection, url))
throw std::runtime_error(shout_get_error(connection));
SetOptionalMeta(connection, SHOUT_META_GENRE, genre);
SetOptionalMeta(connection, SHOUT_META_DESCRIPTION, description);
SetOptionalMeta(connection, SHOUT_META_URL, url);
if (quality != nullptr)
shout_set_audio_info(connection, SHOUT_AI_QUALITY, quality);
shout_set_audio_info(&connection, SHOUT_AI_QUALITY, quality);
if (bitrate != nullptr)
shout_set_audio_info(connection, SHOUT_AI_BITRATE, bitrate);
shout_set_audio_info(&connection, SHOUT_AI_BITRATE, bitrate);
}
void
@@ -274,7 +289,7 @@ ShoutOutput::Enable()
throw std::bad_alloc{};
try {
config.Setup(shout_conn);
config.Setup(*shout_conn);
} catch (...) {
shout_free(shout_conn);
throw;
@@ -418,7 +433,7 @@ ShoutOutput::Pause()
}
static void
shout_tag_to_metadata(const Tag &tag, char *dest, size_t size)
shout_tag_to_metadata(const Tag &tag, char *dest, size_t size) noexcept
{
const char *artist = tag.GetValue(TAG_ARTIST);
const char *title = tag.GetValue(TAG_TITLE);
@@ -446,9 +461,15 @@ ShoutOutput::SendTag(const Tag &tag)
char song[1024];
shout_tag_to_metadata(tag, song, sizeof(song));
shout_metadata_add(meta, "song", song);
shout_metadata_add(meta, "charset", "UTF-8");
if (SHOUTERR_SUCCESS != shout_set_metadata(shout_conn, meta)) {
if (SHOUTERR_SUCCESS != shout_metadata_add(meta, "song", song) ||
#ifdef SHOUT_FORMAT_TEXT
/* since libshout 2.4.6 */
SHOUTERR_SUCCESS != shout_set_metadata_utf8(shout_conn, meta)
#else
SHOUTERR_SUCCESS != shout_metadata_add(meta, "charset", "UTF-8") ||
SHOUTERR_SUCCESS != shout_set_metadata(shout_conn, meta)
#endif
) {
LogWarning(shout_output_domain,
"error setting shout metadata");
}

View File

@@ -99,7 +99,7 @@ if get_option('recorder')
need_encoder = true
endif
libshout_dep = dependency('shout', required: get_option('shout'))
libshout_dep = dependency('shout', version: '>= 2.4.0', required: get_option('shout'))
output_features.set('HAVE_SHOUT', libshout_dep.found())
if libshout_dep.found()
output_plugins_sources += 'ShoutOutputPlugin.cxx'