From e304d0f8ee404ef7e1223a324012d4fb4049185d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 13 Sep 2014 11:26:17 +0200 Subject: thread/Posix{Cond,Mutex}: don't ues PTHREAD_*_INITIALIZER on NetBSD On NetBSD, PTHREAD_MUTEX_INITIALIZER and PTHREAD_COND_INITIALIZER are not compatible with C++11 "constexpr" (see Mantis ticket 0004110). As a workaround, don't ues "constexpr", and use the functions pthread_mutex_init(), pthread_mutex_destroy(), pthread_cond_init() and pthread_cond_destroy() instead. This adds some runtime overhead, but is portable to POSIX implementations that have awkward initializer macros. --- src/notify.hxx | 2 +- src/thread/PosixCond.hxx | 14 ++++++++++++++ src/thread/PosixMutex.hxx | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/notify.hxx b/src/notify.hxx index 6b9e95368..1024dd8d9 100644 --- a/src/notify.hxx +++ b/src/notify.hxx @@ -28,7 +28,7 @@ struct notify { Cond cond; bool pending; -#ifndef WIN32 +#if !defined(WIN32) && !defined(__NetBSD__) constexpr #endif notify():pending(false) {} diff --git a/src/thread/PosixCond.hxx b/src/thread/PosixCond.hxx index 6f98d3ad0..c2797649a 100644 --- a/src/thread/PosixCond.hxx +++ b/src/thread/PosixCond.hxx @@ -41,7 +41,21 @@ class PosixCond { pthread_cond_t cond; public: +#ifdef __NetBSD__ + /* NetBSD's PTHREAD_COND_INITIALIZER is not compatible with + "constexpr" */ + PosixCond() { + pthread_cond_init(&cond, nullptr); + } + + ~PosixCond() { + pthread_cond_destroy(&cond); + } +#else + /* optimized constexpr constructor for sane POSIX + implementations */ constexpr PosixCond():cond(PTHREAD_COND_INITIALIZER) {} +#endif PosixCond(const PosixCond &other) = delete; PosixCond &operator=(const PosixCond &other) = delete; diff --git a/src/thread/PosixMutex.hxx b/src/thread/PosixMutex.hxx index d50764af4..445c0ace2 100644 --- a/src/thread/PosixMutex.hxx +++ b/src/thread/PosixMutex.hxx @@ -41,7 +41,21 @@ class PosixMutex { pthread_mutex_t mutex; public: +#ifdef __NetBSD__ + /* NetBSD's PTHREAD_MUTEX_INITIALIZER is not compatible with + "constexpr" */ + PosixMutex() { + pthread_mutex_init(&mutex, nullptr); + } + + ~PosixMutex() { + pthread_mutex_destroy(&mutex); + } +#else + /* optimized constexpr constructor for sane POSIX + implementations */ constexpr PosixMutex():mutex(PTHREAD_MUTEX_INITIALIZER) {} +#endif PosixMutex(const PosixMutex &other) = delete; PosixMutex &operator=(const PosixMutex &other) = delete; -- cgit v1.2.3 From a0ef27a0cd97d53f89def5ed5c94250b92cbd587 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Tue, 16 Sep 2014 12:54:16 +0200 Subject: command/list: reset used size after the list has been processed --- src/command/CommandListBuilder.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/command/CommandListBuilder.cxx b/src/command/CommandListBuilder.cxx index cc10f7205..4e0a8bd2a 100644 --- a/src/command/CommandListBuilder.cxx +++ b/src/command/CommandListBuilder.cxx @@ -27,6 +27,7 @@ void CommandListBuilder::Reset() { list.clear(); + size = 0; mode = Mode::DISABLED; } -- cgit v1.2.3 From b6fa22bd84b6f60bb73bec99a1182832b761542b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 18 Sep 2014 13:50:23 +0200 Subject: OutputThread: retain negative mix ratio Fixes MixRamp breakage. --- src/OutputThread.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/OutputThread.cxx b/src/OutputThread.cxx index 30d3ba30f..b96ba4efd 100644 --- a/src/OutputThread.cxx +++ b/src/OutputThread.cxx @@ -385,11 +385,20 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk, if (length > other_length) length = other_length; + float mix_ratio = chunk->mix_ratio; + if (mix_ratio >= 0) + /* reverse the mix ratio (because the + arguments to pcm_mix() are reversed), but + only if the mix ratio is non-negative; a + negative mix ratio is a MixRamp special + case */ + mix_ratio = 1.0 - mix_ratio; + void *dest = ao->cross_fade_buffer.Get(other_length); memcpy(dest, other_data, other_length); if (!pcm_mix(dest, data, length, ao->in_audio_format.format, - 1.0 - chunk->mix_ratio)) { + mix_ratio)) { FormatError(output_domain, "Cannot cross-fade format %s", sample_format_to_string(ao->in_audio_format.format)); -- cgit v1.2.3