-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix debug assert in CachingReader #2309
Changes from all commits
ca6c414
bbf2d17
5cbab1e
0e7cbf9
f2802da
ff61eeb
d02ae6f
26dd7ce
b893fe6
c1bab77
d7737df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
#ifndef ENGINE_CACHINGREADER_H | ||
#define ENGINE_CACHINGREADER_H | ||
|
||
#include <QtDebug> | ||
#include <QAtomicInt> | ||
#include <QList> | ||
#include <QVector> | ||
#include <QLinkedList> | ||
|
@@ -78,9 +78,9 @@ class CachingReader : public QObject { | |
// Construct a CachingReader with the given group. | ||
CachingReader(QString group, | ||
UserSettingsPointer _config); | ||
virtual ~CachingReader(); | ||
~CachingReader() override; | ||
|
||
virtual void process(); | ||
void process(); | ||
|
||
enum class ReadResult { | ||
// No samples read and buffer untouched(!), try again later in case of a cache miss | ||
|
@@ -101,12 +101,12 @@ class CachingReader : public QObject { | |
// that is not in the cache. If any hints do request a chunk not in cache, | ||
// then wake the reader so that it can process them. Must only be called | ||
// from the engine callback. | ||
virtual void hintAndMaybeWake(const HintVector& hintList); | ||
void hintAndMaybeWake(const HintVector& hintList); | ||
|
||
// Request that the CachingReader load a new track. These requests are | ||
// processed in the work thread, so the reader must be woken up via wake() | ||
// for this to take effect. | ||
virtual void newTrack(TrackPointer pTrack); | ||
void newTrack(TrackPointer pTrack); | ||
|
||
void setScheduler(EngineWorkerScheduler* pScheduler) { | ||
m_worker.setScheduler(pScheduler); | ||
|
@@ -124,7 +124,7 @@ class CachingReader : public QObject { | |
// Thread-safe FIFOs for communication between the engine callback and | ||
// reader thread. | ||
FIFO<CachingReaderChunkReadRequest> m_chunkReadRequestFIFO; | ||
FIFO<ReaderStatusUpdate> m_stateFIFO; | ||
FIFO<ReaderStatusUpdate> m_readerStatusUpdateFIFO; | ||
|
||
// Looks for the provided chunk number in the index of in-memory chunks and | ||
// returns it if it is present. If not, returns nullptr. If it is present then | ||
|
@@ -151,12 +151,13 @@ class CachingReader : public QObject { | |
// Gets a chunk from the free list, frees the LRU CachingReaderChunk if none available. | ||
CachingReaderChunkForOwner* allocateChunkExpireLRU(SINT chunkIndex); | ||
|
||
enum class State { | ||
Idle, | ||
TrackLoading, | ||
TrackLoaded, | ||
enum State { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this changed from an enum class to an enum? Please change it back to an enum class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we need integers for the atomic. I didn't check if this still works with an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So cast it to an int and back when needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually had a version with a static_cast() one every use. But @uklotzde version with a plain enum conviced me, because it is less distracting. In this case we have no namespace pollution issue, because the enum is class private. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this special case the enum literals are just private integer constants and a classical enum is a good fit. |
||
STATE_IDLE, | ||
STATE_TRACK_LOADING, | ||
STATE_TRACK_UNLOADING, | ||
STATE_TRACK_LOADED, | ||
}; | ||
State m_state; | ||
QAtomicInt m_state; | ||
|
||
// Keeps track of all CachingReaderChunks we've allocated. | ||
QVector<CachingReaderChunkForOwner*> m_chunks; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The final lineOk, I see you moved it.m_worker.workReady();
got lost along the wayThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from your template :-)