diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-10-20 12:44:52 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-10-20 12:44:52 +1100 |
| commit | a8b866aafe81fc79931fd8132fa14e4eb1d518bf (patch) | |
| tree | 5a52c706834d6398ca37fe09fe49f56eec5c809c /src | |
| parent | c27880282afc93c63680e8f0162c3200c6cacd6a (diff) | |
| download | tangara-fw-a8b866aafe81fc79931fd8132fa14e4eb1d518bf.tar.gz | |
Don't crash if the current track source encounters a record with no id
This *shouldn't* normally happen, but it's not worth crashing over.
Diffstat (limited to 'src')
| -rw-r--r-- | src/audio/track_queue.cpp | 2 | ||||
| -rw-r--r-- | src/playlist/source.cpp | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/audio/track_queue.cpp b/src/audio/track_queue.cpp index b1cacc00..331aa756 100644 --- a/src/audio/track_queue.cpp +++ b/src/audio/track_queue.cpp @@ -100,6 +100,7 @@ auto TrackQueue::AddNext(std::shared_ptr<playlist::ISource> src) -> void { auto TrackQueue::IncludeNext(std::shared_ptr<playlist::IResetableSource> src) -> void { + assert(src.get() != nullptr); const std::lock_guard<std::mutex> lock(mutex_); enqueued_.push_front(src); @@ -128,6 +129,7 @@ auto TrackQueue::AddLast(std::shared_ptr<playlist::ISource> src) -> void { auto TrackQueue::IncludeLast(std::shared_ptr<playlist::IResetableSource> src) -> void { + assert(src.get() != nullptr); const std::lock_guard<std::mutex> lock(mutex_); enqueued_.push_back(src); diff --git a/src/playlist/source.cpp b/src/playlist/source.cpp index d51d97ab..7a062bc7 100644 --- a/src/playlist/source.cpp +++ b/src/playlist/source.cpp @@ -139,9 +139,12 @@ auto IndexRecordSource::Peek(std::size_t n, std::vector<database::TrackId>* out) working_item = 0; } - out->push_back(working_page->values().at(working_item)->track().value()); - n--; - items_added++; + auto record = working_page->values().at(working_item); + if (record->track()) { + out->push_back(record->track().value()); + n--; + items_added++; + } working_item++; } |
