From 16b2ac547c2d17f7398a7a3d9257c6c073e7646c Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Sat, 6 Dec 2014 17:54:13 +0100 Subject: [PATCH 1/3] Sort music brainz releases according to status --- src/musicbrainz/musicbrainzclient.cpp | 3 +++ src/musicbrainz/musicbrainzclient.h | 32 ++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/musicbrainz/musicbrainzclient.cpp b/src/musicbrainz/musicbrainzclient.cpp index 149cd9b79..576af44d8 100644 --- a/src/musicbrainz/musicbrainzclient.cpp +++ b/src/musicbrainz/musicbrainzclient.cpp @@ -295,6 +295,7 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseTrack( if (releases.isEmpty()) { ret << result; } else { + qStableSort(releases); for (const Release& release : releases) { ret << release.CopyAndMergeInto(result); } @@ -336,6 +337,8 @@ MusicBrainzClient::Release MusicBrainzClient::ParseRelease( QStringRef name = reader->name(); if (name == "title") { ret.album_ = reader->readElementText(); + } else if (name == "status") { + ret.SetStatusFromString(reader->readElementText()); } else if (name == "date") { QRegExp regex(kDateRegex); if (regex.indexIn(reader->readElementText()) == 0) { diff --git a/src/musicbrainz/musicbrainzclient.h b/src/musicbrainz/musicbrainzclient.h index 0bb20de8b..6627d8ae4 100644 --- a/src/musicbrainz/musicbrainzclient.h +++ b/src/musicbrainz/musicbrainzclient.h @@ -110,7 +110,16 @@ signals: }; struct Release { - Release() : track_(0), year_(0) {} + + enum Status { + Status_Unknown = 0, + Status_PseudoRelease, + Status_Bootleg, + Status_Promotional, + Status_Official + }; + + Release() : track_(0), year_(0), status_(Status_Unknown) {} Result CopyAndMergeInto(const Result& orig) const { Result ret(orig); @@ -120,9 +129,30 @@ signals: return ret; } + void SetStatusFromString(const QString& s) { + if (s.compare("Official", Qt::CaseInsensitive) == 0) { + status_ = Status_Official; + } else if (s.compare("Promotion", Qt::CaseInsensitive) == 0) { + status_ = Status_Promotional; + } else if (s.compare("Bootleg", Qt::CaseInsensitive) == 0) { + status_ = Status_Bootleg; + } else if (s.compare("Pseudo-release", Qt::CaseInsensitive) == 0) { + status_ = Status_PseudoRelease; + } else { + status_ = Status_Unknown; + } + } + + bool operator<(const Release& other) const { + // Compare status so that "best" status (e.g. Official) will be first + // when sorting a list of releases. + return status_ > other.status_; + } + QString album_; int track_; int year_; + Status status_; }; struct PendingResults { From 0f1b29a523b89769ae2cd0e756aceccfdd178d66 Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 7 Dec 2014 13:54:18 +0100 Subject: [PATCH 2/3] Make sure SongSender is deleted when client disconnects. --- src/networkremote/remoteclient.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/networkremote/remoteclient.cpp b/src/networkremote/remoteclient.cpp index 2f9c87947..e3860221c 100644 --- a/src/networkremote/remoteclient.cpp +++ b/src/networkremote/remoteclient.cpp @@ -54,6 +54,8 @@ RemoteClient::~RemoteClient() { client_->close(); if (client_->state() == QAbstractSocket::ConnectedState) client_->waitForDisconnected(2000); + + song_sender_->deleteLater(); } void RemoteClient::setDownloader(bool downloader) { downloader_ = downloader; } From b5567a7b27285a611531df7606ef8b88359008ba Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 7 Dec 2014 14:07:53 +0100 Subject: [PATCH 3/3] Try fixing race condition in fftw by adding mutex for fftw_* function calls suggested here: http://www.fftw.org/fftw3_doc/Thread-safety.html. Updates #4643. --- gst/moodbar/gstfastspectrum.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gst/moodbar/gstfastspectrum.cpp b/gst/moodbar/gstfastspectrum.cpp index a54a37bae..7e9b800a1 100644 --- a/gst/moodbar/gstfastspectrum.cpp +++ b/gst/moodbar/gstfastspectrum.cpp @@ -19,6 +19,8 @@ * Boston, MA 02110-1301, USA. */ +#include + #include #include #include "gstfastspectrum.h" @@ -48,6 +50,8 @@ enum { PROP_BANDS }; +static QMutex fftw_mutex; + #define gst_fastspectrum_parent_class parent_class G_DEFINE_TYPE (GstFastSpectrum, gst_fastspectrum, GST_TYPE_AUDIO_FILTER); @@ -123,6 +127,8 @@ gst_fastspectrum_init (GstFastSpectrum * spectrum) static void gst_fastspectrum_alloc_channel_data (GstFastSpectrum * spectrum) { + fftw_mutex.lock(); + guint bands = spectrum->bands; guint nfft = 2 * bands - 2; @@ -139,12 +145,16 @@ gst_fastspectrum_alloc_channel_data (GstFastSpectrum * spectrum) spectrum->fft_output, FFTW_ESTIMATE); spectrum->channel_data_initialised = true; + + fftw_mutex.unlock(); } static void gst_fastspectrum_free_channel_data (GstFastSpectrum * spectrum) { if (spectrum->channel_data_initialised) { + fftw_mutex.lock(); + fftw_destroy_plan(spectrum->plan); fftw_free(spectrum->fft_input); fftw_free(spectrum->fft_output); @@ -152,6 +162,8 @@ gst_fastspectrum_free_channel_data (GstFastSpectrum * spectrum) delete[] spectrum->spect_magnitude; spectrum->channel_data_initialised = false; + + fftw_mutex.unlock(); } } @@ -373,6 +385,8 @@ gst_fastspectrum_run_fft (GstFastSpectrum * spectrum, guint input_pos) guint bands = spectrum->bands; guint nfft = 2 * bands - 2; + fftw_mutex.lock(); + for (i = 0; i < nfft; i++) spectrum->fft_input[i] = spectrum->input_ring_buffer[(input_pos + i) % nfft]; @@ -387,6 +401,8 @@ gst_fastspectrum_run_fft (GstFastSpectrum * spectrum, guint input_pos) val /= nfft * nfft; spectrum->spect_magnitude[i] += val; } + + fftw_mutex.unlock(); } static GstFlowReturn