APL: Fix position handling for DSD
Correctly scale the AudioChunk frame counts. This more and more makes me think I should be scaling this in the AudioChunk code instead, but then code may not know about the special case of every 8 frames only being one byte per channel. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
7f0fe33f9d
commit
6cda7696f3
2 changed files with 9 additions and 3 deletions
|
@ -18,6 +18,8 @@
|
|||
long trackEnd; // frames until end of track.
|
||||
long trackLength; // track len in frames
|
||||
|
||||
BOOL isDSD;
|
||||
|
||||
APLFile *apl;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@
|
|||
int channels = [[properties objectForKey:@"channels"] intValue];
|
||||
// float sampleRate = [[properties objectForKey:@"sampleRate"] floatValue];
|
||||
|
||||
isDSD = bitsPerSample == 1;
|
||||
|
||||
bytesPerFrame = ((bitsPerSample + 7) / 8) * channels;
|
||||
|
||||
if([apl endBlock] > [apl startBlock])
|
||||
|
@ -119,12 +121,14 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
size_t frameScale = isDSD ? 8 : 1;
|
||||
|
||||
AudioChunk *chunk = [decoder readAudio];
|
||||
if(chunk.frameCount > maxFrames) {
|
||||
[chunk setFrameCount:maxFrames];
|
||||
if(chunk.frameCount * frameScale > maxFrames) {
|
||||
[chunk setFrameCount:maxFrames / frameScale];
|
||||
}
|
||||
|
||||
framePosition += chunk.frameCount;
|
||||
framePosition += chunk.frameCount * frameScale;
|
||||
return chunk;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue