[Play Counts] Track play counts of correct track

Track play counts for the correct track, even on short tracks. Also
correctly track the play count of the last played item in the play queue
which stops with bufferChain set to nil, so the previous iteration was
not tracking it.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-06-27 21:46:36 -07:00
parent ae019409c5
commit 2ed78a0639
2 changed files with 6 additions and 3 deletions

View File

@ -39,6 +39,8 @@ using std::atomic_bool;
id nextStreamUserInfo; id nextStreamUserInfo;
NSDictionary *nextStreamRGInfo; NSDictionary *nextStreamRGInfo;
id previousUserInfo; // Track currently last heard track for play counts
id delegate; id delegate;
BOOL outputLaunched; BOOL outputLaunched;

View File

@ -113,6 +113,7 @@
outputLaunched = NO; outputLaunched = NO;
startedPaused = paused; startedPaused = paused;
initialBufferFilled = NO; initialBufferFilled = NO;
previousUserInfo = userInfo;
[bufferChain launchThreads]; [bufferChain launchThreads];
@ -296,6 +297,8 @@
- (BOOL)endOfInputReached:(BufferChain *)sender // Sender is a BufferChain - (BOOL)endOfInputReached:(BufferChain *)sender // Sender is a BufferChain
{ {
previousUserInfo = [sender userInfo];
BufferChain *newChain = nil; BufferChain *newChain = nil;
if(atomic_load_explicit(&resettingNow, memory_order_relaxed)) if(atomic_load_explicit(&resettingNow, memory_order_relaxed))
@ -424,9 +427,7 @@
} }
- (void)reportPlayCount { - (void)reportPlayCount {
if(bufferChain) { [self reportPlayCountForTrack:previousUserInfo];
[self reportPlayCountForTrack:[bufferChain userInfo]];
}
} }
- (BOOL)selectNextBuffer { - (BOOL)selectNextBuffer {