diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/MusicChunk.hxx | 10 | ||||
-rw-r--r-- | src/db/plugins/simple/Directory.cxx | 2 | ||||
-rw-r--r-- | src/db/plugins/simple/Directory.hxx | 1 | ||||
-rw-r--r-- | src/db/update/Walk.cxx | 2 | ||||
-rw-r--r-- | src/lib/upnp/Compat.hxx | 7 | ||||
-rw-r--r-- | src/output/Source.cxx | 3 | ||||
-rw-r--r-- | src/player/Thread.cxx | 2 | ||||
-rw-r--r-- | src/queue/PlaylistControl.cxx | 3 | ||||
-rw-r--r-- | src/queue/PlaylistEdit.cxx | 2 | ||||
-rw-r--r-- | src/queue/Queue.cxx | 14 | ||||
-rw-r--r-- | src/queue/Queue.hxx | 9 |
11 files changed, 40 insertions, 15 deletions
diff --git a/src/MusicChunk.hxx b/src/MusicChunk.hxx index c5be179a9..a730a0b2d 100644 --- a/src/MusicChunk.hxx +++ b/src/MusicChunk.hxx @@ -80,11 +80,19 @@ struct MusicChunk { ReplayGainInfo replay_gain_info; /** + * A magic value for #replay_gain_serial which omits updating + * the #ReplayGainFilter. This is used by "silence" chunks + * (see PlayerThread::SendSilence()) so they don't affect the + * replay gain. + */ + static constexpr unsigned IGNORE_REPLAY_GAIN = ~0u; + + /** * A serial number for checking if replay gain info has * changed since the last chunk. The magic value 0 indicates * that there is no replay gain info available. */ - unsigned replay_gain_serial = 0; + unsigned replay_gain_serial; /** the data (probably PCM) */ uint8_t data[CHUNK_SIZE]; diff --git a/src/db/plugins/simple/Directory.cxx b/src/db/plugins/simple/Directory.cxx index 7d1ca5afa..4c784fd8b 100644 --- a/src/db/plugins/simple/Directory.cxx +++ b/src/db/plugins/simple/Directory.cxx @@ -106,7 +106,7 @@ Directory::PruneEmpty() noexcept child != end;) { child->PruneEmpty(); - if (child->IsEmpty()) + if (child->IsEmpty() && !child->IsMount()) child = children.erase_and_dispose(child, DeleteDisposer()); else diff --git a/src/db/plugins/simple/Directory.hxx b/src/db/plugins/simple/Directory.hxx index 942c86115..7370aea9b 100644 --- a/src/db/plugins/simple/Directory.hxx +++ b/src/db/plugins/simple/Directory.hxx @@ -130,7 +130,6 @@ public: * * @param name_utf8 the UTF-8 encoded name of the new sub directory */ - gcc_malloc Directory *CreateChild(const char *name_utf8); /** diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index c3af3f789..1ef37e4d1 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -104,7 +104,7 @@ inline void UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) { directory.ForEachChildSafe([&](Directory &child){ - if (DirectoryExists(storage, child)) + if (child.IsMount() || DirectoryExists(storage, child)) return; editor.LockDeleteDirectory(&child); diff --git a/src/lib/upnp/Compat.hxx b/src/lib/upnp/Compat.hxx index 2e2d2f1de..c9f1cc47f 100644 --- a/src/lib/upnp/Compat.hxx +++ b/src/lib/upnp/Compat.hxx @@ -23,12 +23,15 @@ #include <upnp/upnp.h> #if UPNP_VERSION < 10800 -#include "Compiler.h" - /* emulate the libupnp 1.8 API with older versions */ using UpnpDiscovery = Upnp_Discovery; +#endif + +#if UPNP_VERSION < 10624 +#include "Compiler.h" + gcc_pure static inline int UpnpDiscovery_get_Expires(const UpnpDiscovery *disco) noexcept diff --git a/src/output/Source.cxx b/src/output/Source.cxx index d5cbbe2c8..4bfad46a6 100644 --- a/src/output/Source.cxx +++ b/src/output/Source.cxx @@ -142,7 +142,8 @@ AudioOutputSource::GetChunkData(const MusicChunk &chunk, replay_gain_filter_set_mode(*replay_gain_filter, replay_gain_mode); - if (chunk.replay_gain_serial != *replay_gain_serial_p) { + if (chunk.replay_gain_serial != *replay_gain_serial_p && + chunk.replay_gain_serial != MusicChunk::IGNORE_REPLAY_GAIN) { replay_gain_filter_set_info(*replay_gain_filter, chunk.replay_gain_serial != 0 ? &chunk.replay_gain_info diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index efbcfedd0..23409d308 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -556,8 +556,10 @@ Player::SendSilence() partial frames */ unsigned num_frames = sizeof(chunk->data) / frame_size; + chunk->bit_rate = 0; chunk->time = SignedSongTime::Negative(); /* undefined time stamp */ chunk->length = num_frames * frame_size; + chunk->replay_gain_serial = MusicChunk::IGNORE_REPLAY_GAIN; PcmSilence({chunk->data, chunk->length}, play_audio_format.format); try { diff --git a/src/queue/PlaylistControl.cxx b/src/queue/PlaylistControl.cxx index c744e42c8..e0e07b87e 100644 --- a/src/queue/PlaylistControl.cxx +++ b/src/queue/PlaylistControl.cxx @@ -75,8 +75,7 @@ playlist::MoveOrderToCurrent(unsigned old_order) } else { /* not playing anything: move the specified song to the front */ - queue.SwapOrders(old_order, 0); - return 0; + return queue.MoveOrderBefore(old_order, 0); } } diff --git a/src/queue/PlaylistEdit.cxx b/src/queue/PlaylistEdit.cxx index a4a1a29e2..24ee1faab 100644 --- a/src/queue/PlaylistEdit.cxx +++ b/src/queue/PlaylistEdit.cxx @@ -112,7 +112,7 @@ playlist::AppendSong(PlayerControl &pc, DetachedSong &&song) else start = current + 1; if (start < queue.GetLength()) - queue.ShuffleOrderLast(start, queue.GetLength()); + queue.ShuffleOrderLastWithPriority(start, queue.GetLength()); } UpdateQueuedSong(pc, queued_song); diff --git a/src/queue/Queue.cxx b/src/queue/Queue.cxx index ea6ee9e0d..ada0346d3 100644 --- a/src/queue/Queue.cxx +++ b/src/queue/Queue.cxx @@ -359,8 +359,20 @@ Queue::ShuffleOrderFirst(unsigned start, unsigned end) noexcept } void -Queue::ShuffleOrderLast(unsigned start, unsigned end) noexcept +Queue::ShuffleOrderLastWithPriority(unsigned start, unsigned end) noexcept { + assert(end <= length); + assert(start < end); + + /* skip all items at the start which have a higher priority, + because the last item shall only be shuffled within its + priority group */ + const auto last_priority = items[OrderToPosition(end - 1)].priority; + while (items[OrderToPosition(start)].priority != last_priority) { + ++start; + assert(start < end); + } + rand.AutoCreate(); std::uniform_int_distribution<unsigned> distribution(start, end - 1); diff --git a/src/queue/Queue.hxx b/src/queue/Queue.hxx index 9a1d46f7a..557f74ed8 100644 --- a/src/queue/Queue.hxx +++ b/src/queue/Queue.hxx @@ -357,11 +357,12 @@ struct Queue { void ShuffleOrderFirst(unsigned start, unsigned end) noexcept; /** - * Shuffles the virtual order of the last song in the specified - * (order) range. This is used in random mode after a song has been - * appended by queue_append(). + * Shuffles the virtual order of the last song in the + * specified (order) range; only songs which match this song's + * priority are considered. This is used in random mode after + * a song has been appended by Append(). */ - void ShuffleOrderLast(unsigned start, unsigned end) noexcept; + void ShuffleOrderLastWithPriority(unsigned start, unsigned end) noexcept; /** * Shuffles a (position) range in the queue. The songs are physically |