From 54ebf2a699777961ebb30bc4b4fca459880d4329 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 26 Apr 2014 22:08:08 +0200 Subject: [PATCH 1/4] configure.ac: prepare for 0.18.11 --- NEWS | 2 ++ configure.ac | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d87626bd9..27c43988a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +ver 0.18.11 (not yet released) + ver 0.18.10 (2014/04/10) * decoder - ffmpeg: fix seeking bug diff --git a/configure.ac b/configure.ac index ae3a2341c..48933c4cf 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ(2.60) -AC_INIT(mpd, 0.18.10, mpd-devel@musicpd.org) +AC_INIT(mpd, 0.18.11, mpd-devel@musicpd.org) VERSION_MAJOR=0 VERSION_MINOR=18 From 0efb67b51e0d9d34c65bbdbd9df567a8a991cc4c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 26 Apr 2014 22:11:23 +0200 Subject: [PATCH 2/4] DeferredMonitor: fix race condition when using GLib event loop Turns out the lock-free code using atomics was not thread-safe. The given callback could be invoked by GLib before the source_id attribute was assigned. This commit changes the DeferredMonitor class to use a Mutex to block the event loop until source_id is assigned. This bug does not exist in the 0.19 branch because it does not use the GLib main loop anymore. --- NEWS | 1 + src/event/DeferredMonitor.cxx | 28 ++++++++++++++++++---------- src/event/DeferredMonitor.hxx | 5 ++++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index 27c43988a..ff0d0f141 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ ver 0.18.11 (not yet released) +* fix race condition when using GLib event loop (non-Linux) ver 0.18.10 (2014/04/10) * decoder diff --git a/src/event/DeferredMonitor.cxx b/src/event/DeferredMonitor.cxx index 4ffffaa89..62edb7817 100644 --- a/src/event/DeferredMonitor.cxx +++ b/src/event/DeferredMonitor.cxx @@ -27,9 +27,11 @@ DeferredMonitor::Cancel() #ifdef USE_EPOLL pending = false; #else - const auto id = source_id.exchange(0); - if (id != 0) - g_source_remove(id); + const ScopeLock protect(mutex); + if (source_id != 0) { + g_source_remove(source_id); + source_id = 0; + } #endif } @@ -40,10 +42,9 @@ DeferredMonitor::Schedule() if (!pending.exchange(true)) fd.Write(); #else - const unsigned id = loop.AddIdle(Callback, this); - const auto old_id = source_id.exchange(id); - if (old_id != 0) - g_source_remove(old_id); + const ScopeLock protect(mutex); + if (source_id == 0) + source_id = loop.AddIdle(Callback, this); #endif } @@ -65,9 +66,16 @@ DeferredMonitor::OnSocketReady(unsigned) void DeferredMonitor::Run() { - const auto id = source_id.exchange(0); - if (id != 0) - RunDeferred(); + { + const ScopeLock protect(mutex); + if (source_id == 0) + /* cancelled */ + return; + + source_id = 0; + } + + RunDeferred(); } gboolean diff --git a/src/event/DeferredMonitor.hxx b/src/event/DeferredMonitor.hxx index 2380fb66f..2ac832a0a 100644 --- a/src/event/DeferredMonitor.hxx +++ b/src/event/DeferredMonitor.hxx @@ -27,6 +27,7 @@ #include "SocketMonitor.hxx" #include "WakeFD.hxx" #else +#include "thread/Mutex.hxx" #include #endif @@ -48,7 +49,9 @@ class DeferredMonitor #else EventLoop &loop; - std::atomic source_id; + Mutex mutex; + + guint source_id; #endif public: From 70bd35abe2ab774b70e37822f0200fcd4ebcd6c6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 29 Apr 2014 11:56:05 +0200 Subject: [PATCH 3/4] decoder/OggUtil: allow skipping up to 32 kB after seek Fixes missing song length on high-latency Opus files. According to tests with 320 kbit/s opus files with 60ms packets, we need to skip up to 29 kB. --- NEWS | 2 ++ src/decoder/OggUtil.cxx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ff0d0f141..753ab2748 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.18.11 (not yet released) +* decoder + - opus: fix missing song length on high-latency files * fix race condition when using GLib event loop (non-Linux) ver 0.18.10 (2014/04/10) diff --git a/src/decoder/OggUtil.cxx b/src/decoder/OggUtil.cxx index fd137f110..8f181ce57 100644 --- a/src/decoder/OggUtil.cxx +++ b/src/decoder/OggUtil.cxx @@ -81,7 +81,7 @@ bool OggExpectPageSeek(ogg_sync_state &oy, ogg_page &page, Decoder *decoder, InputStream &input_stream) { - size_t remaining_skipped = 16384; + size_t remaining_skipped = 32768; while (true) { int r = ogg_sync_pageseek(&oy, &page); From 8bfdb4ed0c09a576aacbbe01e93b2673360cf817 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 12 May 2014 18:20:26 +0200 Subject: [PATCH 4/4] release v0.18.11 --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 753ab2748..d8e901654 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -ver 0.18.11 (not yet released) +ver 0.18.11 (2014/05/12) * decoder - opus: fix missing song length on high-latency files * fix race condition when using GLib event loop (non-Linux)