diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-12-07 16:57:05 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-12-07 17:00:30 +1100 |
| commit | 3f7f199cb940c8d5f6d48f77fd59971adffe49ef (patch) | |
| tree | aa22162e46c5e9ccce4c7ee8537b493f437664d9 /src/playlist/include/shuffler.hpp | |
| parent | 009f69c929eb1d1b65d75b0937fbf3b8de5d9148 (diff) | |
| download | tangara-fw-3f7f199cb940c8d5f6d48f77fd59971adffe49ef.tar.gz | |
Remove pre-iterator concepts
- No more IndexRecord/Result/dbGetPage nonsense
- Queue is just track ids
- i am so tired and have so much to do
Diffstat (limited to 'src/playlist/include/shuffler.hpp')
| -rw-r--r-- | src/playlist/include/shuffler.hpp | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/src/playlist/include/shuffler.hpp b/src/playlist/include/shuffler.hpp deleted file mode 100644 index affc6301..00000000 --- a/src/playlist/include/shuffler.hpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2023 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <deque> -#include <memory> -#include <mutex> -#include <variant> -#include <vector> - -#include "bloom_filter.hpp" -#include "database.hpp" -#include "future_fetcher.hpp" -#include "random.hpp" -#include "source.hpp" -#include "track.hpp" - -namespace playlist { - -/* - * A source composes of other sources and/or specific extra tracks. Supports - * iteration over its contents in a random order. - */ -class Shuffler : public ISource { - public: - static auto Create() -> Shuffler*; - - explicit Shuffler( - util::IRandom* random, - std::unique_ptr<util::BloomFilter<database::TrackId>> filter); - - auto Current() -> std::optional<database::TrackId> override; - auto Advance() -> std::optional<database::TrackId> override; - auto Peek(std::size_t, std::vector<database::TrackId>*) - -> std::size_t override; - - typedef std::variant<database::TrackId, std::shared_ptr<IResetableSource>> - Item; - auto Add(Item) -> void; - - /* - * Returns the enqueued items, starting from the current item, in their - * original insertion order. - */ - auto Unshuffle() -> std::vector<Item>; - - // Not copyable or movable. - - Shuffler(const Shuffler&) = delete; - Shuffler& operator=(const Shuffler&) = delete; - - private: - auto RefillBuffer() -> void; - - util::IRandom* random_; - - std::unique_ptr<util::BloomFilter<database::TrackId>> already_played_; - bool out_of_items_; - - std::deque<Item> ordered_items_; - std::deque<database::TrackId> shuffled_items_buffer_; -}; - -} // namespace playlist |
