From f4b7c22bc20b5b065cb3e2dd91a51f1c1b92736a Mon Sep 17 00:00:00 2001 From: Mark Furneaux Date: Mon, 15 Jun 2015 16:27:40 -0400 Subject: [PATCH] Revert "Revert "Add track intro mode"" This reverts commit ece262f7f49dec4b3ee9dbe5b386823f4bcc4dfd. --- .../remotecontrolmessages.proto | 1 + src/core/player.cpp | 2 ++ src/core/player.h | 3 ++- src/engines/engine_fwd.h | 1 + src/engines/gstengine.cpp | 20 +++++++++--------- src/networkremote/outgoingdatacreator.cpp | 21 ++++++++++++------- src/playlist/playlist.cpp | 1 + src/playlist/playlistsequence.cpp | 8 +++++++ src/playlist/playlistsequence.h | 1 + src/playlist/playlistsequence.ui | 8 +++++++ src/ui/mainwindow.cpp | 9 ++++++++ src/ui/mainwindow.h | 2 ++ src/widgets/osd.cpp | 3 +++ 13 files changed, 61 insertions(+), 19 deletions(-) diff --git a/ext/libclementine-remote/remotecontrolmessages.proto b/ext/libclementine-remote/remotecontrolmessages.proto index f28a78894..1e59774f0 100644 --- a/ext/libclementine-remote/remotecontrolmessages.proto +++ b/ext/libclementine-remote/remotecontrolmessages.proto @@ -127,6 +127,7 @@ enum RepeatMode { Repeat_Album = 2; Repeat_Playlist = 3; Repeat_OneByOne = 4; + Repeat_Intro = 5; } // Valid Shuffle modes diff --git a/src/core/player.cpp b/src/core/player.cpp index bd0a107cd..23894a028 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -589,6 +589,8 @@ void Player::TrackAboutToEnd() { next_item->Metadata().end_nanosec()); } +void Player::IntroPointReached() { NextInternal(Engine::Intro); } + void Player::ValidSongRequested(const QUrl& url) { emit SongChangeRequestProcessed(url, true); } diff --git a/src/core/player.h b/src/core/player.h index bba893e7c..347c9dc14 100644 --- a/src/core/player.h +++ b/src/core/player.h @@ -92,7 +92,7 @@ class PlayerInterface : public QObject { virtual void Play() = 0; virtual void ShowOSD() = 0; - signals: +signals: void Playing(); void Paused(); void Stopped(); @@ -163,6 +163,7 @@ class Player : public PlayerInterface { void Pause(); void Stop(bool stop_after = false); void StopAfterCurrent(); + void IntroPointReached(); void Play(); void ShowOSD(); void TogglePrettyOSD(); diff --git a/src/engines/engine_fwd.h b/src/engines/engine_fwd.h index 31377e618..2a6eac2c3 100644 --- a/src/engines/engine_fwd.h +++ b/src/engines/engine_fwd.h @@ -27,6 +27,7 @@ enum TrackChangeType { First = 0x01, Manual = 0x02, Auto = 0x04, + Intro = 0x08, // Any of: SameAlbum = 0x10, diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index f9e18843d..d8c6b0ea1 100755 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -302,8 +302,8 @@ void GstEngine::UpdateScope(int chunk_length) { gst_buffer_map(latest_buffer_, &map, GST_MAP_READ); // determine where to split the buffer - int chunk_density = (map.size * kNsecPerMsec) / - GST_BUFFER_DURATION(latest_buffer_); + int chunk_density = + (map.size * kNsecPerMsec) / GST_BUFFER_DURATION(latest_buffer_); int chunk_size = chunk_length * chunk_density; @@ -321,10 +321,9 @@ void GstEngine::UpdateScope(int chunk_length) { // make sure we don't go beyond the end of the buffer if (scope_chunk_ == scope_chunks_ - 1) { - bytes = - qMin(static_cast( - map.size - (chunk_size * scope_chunk_)), - scope_.size() * sizeof(sample_type)); + bytes = qMin(static_cast( + map.size - (chunk_size * scope_chunk_)), + scope_.size() * sizeof(sample_type)); } else { bytes = qMin(static_cast(chunk_size), scope_.size() * sizeof(sample_type)); @@ -380,7 +379,9 @@ bool GstEngine::Load(const QUrl& url, Engine::TrackChangeFlags change, bool crossfade = current_pipeline_ && ((crossfade_enabled_ && change & Engine::Manual) || - (autocrossfade_enabled_ && change & Engine::Auto)); + (autocrossfade_enabled_ && change & Engine::Auto) || + ((crossfade_enabled_ || autocrossfade_enabled_) && + change & Engine::Intro)); if (change & Engine::Auto && change & Engine::SameAlbum && !crossfade_same_album_) @@ -767,9 +768,8 @@ GstEngine::PluginDetailsList GstEngine::GetPluginList( if (QString(gst_element_factory_get_klass(factory)).contains(classname)) { PluginDetails details; details.name = QString::fromUtf8(gst_plugin_feature_get_name(p->data)); - details.description = QString::fromUtf8( - gst_element_factory_get_metadata(factory, - GST_ELEMENT_METADATA_DESCRIPTION)); + details.description = QString::fromUtf8(gst_element_factory_get_metadata( + factory, GST_ELEMENT_METADATA_DESCRIPTION)); ret << details; } p = g_list_next(p); diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index 1fb1ba29d..92c2c0a77 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -79,10 +79,8 @@ void OutgoingDataCreator::SetClients(QList* clients) { SLOT(ResultsAvailable(int, SearchProvider::ResultList)), Qt::QueuedConnection); - connect(app_->global_search(), - SIGNAL(SearchFinished(int)), - SLOT(SearchFinished(int)), - Qt::QueuedConnection); + connect(app_->global_search(), SIGNAL(SearchFinished(int)), + SLOT(SearchFinished(int)), Qt::QueuedConnection); } void OutgoingDataCreator::CheckEnabledProviders() { @@ -379,7 +377,8 @@ void OutgoingDataCreator::CreateSong(const Song& song, const QImage& art, song_metadata->set_file_size(song.filesize()); song_metadata->set_rating(song.rating()); song_metadata->set_url(DataCommaSizeFromQString(song.url().toString())); - song_metadata->set_art_automatic(DataCommaSizeFromQString(song.art_automatic())); + song_metadata->set_art_automatic( + DataCommaSizeFromQString(song.art_automatic())); song_metadata->set_art_manual(DataCommaSizeFromQString(song.art_manual())); song_metadata->set_type( static_cast<::pb::remote::SongMetadata_Type>(song.filetype())); @@ -507,6 +506,9 @@ void OutgoingDataCreator::SendRepeatMode(PlaylistSequence::RepeatMode mode) { case PlaylistSequence::Repeat_OneByOne: msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_OneByOne); break; + case PlaylistSequence::Repeat_Intro: + msg.mutable_repeat()->set_repeat_mode(pb::remote::Repeat_Intro); + break; } SendDataToClients(&msg); @@ -674,7 +676,8 @@ void OutgoingDataCreator::DoGlobalSearch(const QString& query, // Send status message pb::remote::Message msg; - pb::remote::ResponseGlobalSearchStatus* status = msg.mutable_response_global_search_status(); + pb::remote::ResponseGlobalSearchStatus* status = + msg.mutable_response_global_search_status(); msg.set_type(pb::remote::GLOBAL_SEARCH_STATUS); status->set_id(id); @@ -719,7 +722,8 @@ void OutgoingDataCreator::ResultsAvailable( client->SendData(&msg); - qLog(Debug) << "ResultsAvailable" << id << results.first().provider_->name() << results.size(); + qLog(Debug) << "ResultsAvailable" << id << results.first().provider_->name() + << results.size(); } void OutgoingDataCreator::SearchFinished(int id) { @@ -729,7 +733,8 @@ void OutgoingDataCreator::SearchFinished(int id) { // Send status message pb::remote::Message msg; - pb::remote::ResponseGlobalSearchStatus* status = msg.mutable_response_global_search_status(); + pb::remote::ResponseGlobalSearchStatus* status = + msg.mutable_response_global_search_status(); msg.set_type(pb::remote::GLOBAL_SEARCH_STATUS); status->set_id(req.id_); diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index dcb0897d3..1ed5e4c45 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -563,6 +563,7 @@ int Playlist::next_row(bool ignore_repeat_track) const { switch (playlist_sequence_->repeat_mode()) { case PlaylistSequence::Repeat_Off: + case PlaylistSequence::Repeat_Intro: return -1; case PlaylistSequence::Repeat_Track: next_virtual_index = current_virtual_index_; diff --git a/src/playlist/playlistsequence.cpp b/src/playlist/playlistsequence.cpp index 43cfe0162..abedde1f5 100644 --- a/src/playlist/playlistsequence.cpp +++ b/src/playlist/playlistsequence.cpp @@ -53,6 +53,7 @@ PlaylistSequence::PlaylistSequence(QWidget* parent, SettingsProvider* settings) repeat_group->addAction(ui_->action_repeat_album); repeat_group->addAction(ui_->action_repeat_playlist); repeat_group->addAction(ui_->action_repeat_onebyone); + repeat_group->addAction(ui_->action_repeat_intro); repeat_menu_->addActions(repeat_group->actions()); ui_->repeat->setMenu(repeat_menu_); @@ -120,6 +121,7 @@ void PlaylistSequence::RepeatActionTriggered(QAction* action) { if (action == ui_->action_repeat_album) mode = Repeat_Album; if (action == ui_->action_repeat_playlist) mode = Repeat_Playlist; if (action == ui_->action_repeat_onebyone) mode = Repeat_OneByOne; + if (action == ui_->action_repeat_intro) mode = Repeat_Intro; SetRepeatMode(mode); } @@ -152,6 +154,9 @@ void PlaylistSequence::SetRepeatMode(RepeatMode mode) { case Repeat_OneByOne: ui_->action_repeat_onebyone->setChecked(true); break; + case Repeat_Intro: + ui_->action_repeat_intro->setChecked(true); + break; } if (mode != repeat_mode_) { @@ -245,6 +250,9 @@ void PlaylistSequence::CycleRepeatMode() { mode = Repeat_OneByOne; break; case Repeat_OneByOne: + mode = Repeat_Intro; + break; + case Repeat_Intro: break; } diff --git a/src/playlist/playlistsequence.h b/src/playlist/playlistsequence.h index 65ddd79ee..855504d50 100644 --- a/src/playlist/playlistsequence.h +++ b/src/playlist/playlistsequence.h @@ -41,6 +41,7 @@ class PlaylistSequence : public QWidget { Repeat_Album = 2, Repeat_Playlist = 3, Repeat_OneByOne = 4, + Repeat_Intro = 5, }; enum ShuffleMode { Shuffle_Off = 0, diff --git a/src/playlist/playlistsequence.ui b/src/playlist/playlistsequence.ui index bac173756..2b66de3cf 100644 --- a/src/playlist/playlistsequence.ui +++ b/src/playlist/playlistsequence.ui @@ -106,6 +106,14 @@ Stop after each track + + + true + + + Intro tracks + + true diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 3ff22148a..85e50ccff 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -494,6 +494,8 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd, connect(app_->player(), SIGNAL(Seeked(qlonglong)), SLOT(Seeked(qlonglong))); connect(app_->player(), SIGNAL(TrackSkipped(PlaylistItemPtr)), SLOT(TrackSkipped(PlaylistItemPtr))); + connect(this, SIGNAL(IntroPointReached()), app_->player(), + SLOT(IntroPointReached())); connect(app_->player(), SIGNAL(VolumeChanged(int)), SLOT(VolumeChanged(int))); connect(app_->player(), SIGNAL(Paused()), ui_->playlist, @@ -1338,6 +1340,13 @@ void MainWindow::UpdateTrackPosition() { } } + // (just after) the scrobble point is a good point to change tracks in intro mode + if (position >= scrobble_point + 5) { + if (playlist->sequence()->repeat_mode() == PlaylistSequence::Repeat_Intro) { + emit IntroPointReached(); + } + } + // Update the tray icon every 10 seconds if (position % 10 == 0) { qLog(Debug) << "position" << position << "scrobble point" << scrobble_point diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index b1dd0b660..b9400c793 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -137,6 +137,8 @@ signals: // Signals that stop playing after track was toggled. void StopAfterToggled(bool stop); + void IntroPointReached(); + private slots: void FilePathChanged(const QString& path); diff --git a/src/widgets/osd.cpp b/src/widgets/osd.cpp index 8bb636dbe..ba00e9188 100644 --- a/src/widgets/osd.cpp +++ b/src/widgets/osd.cpp @@ -317,6 +317,9 @@ void OSD::RepeatModeChanged(PlaylistSequence::RepeatMode mode) { case PlaylistSequence::Repeat_OneByOne: current_mode = tr("Stop after every track"); break; + case PlaylistSequence::Repeat_Intro: + current_mode = tr("Intro tracks"); + break; } ShowMessage(QCoreApplication::applicationName(), current_mode); }