CUE: Fix playback position tracking for DSD
DSD wasn't tracking the correct sample count, because DSD Audio Chunks store the byte count, rather than the bit count. This may be changed in the future, so I'll have to remember. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
440ba24c57
commit
16072b3af3
2 changed files with 10 additions and 3 deletions
|
@ -20,6 +20,7 @@
|
||||||
NSURL *sourceURL;
|
NSURL *sourceURL;
|
||||||
|
|
||||||
BOOL seekedToStart;
|
BOOL seekedToStart;
|
||||||
|
BOOL isDSD;
|
||||||
|
|
||||||
int bytesPerFrame; // Number of bytes per frame, ie channels * (bitsPerSample/8)
|
int bytesPerFrame; // Number of bytes per frame, ie channels * (bitsPerSample/8)
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,8 @@ static void *kCueSheetDecoderContext = &kCueSheetDecoderContext;
|
||||||
int channels = [[properties objectForKey:@"channels"] intValue];
|
int channels = [[properties objectForKey:@"channels"] intValue];
|
||||||
float sampleRate = [[properties objectForKey:@"sampleRate"] floatValue];
|
float sampleRate = [[properties objectForKey:@"sampleRate"] floatValue];
|
||||||
|
|
||||||
|
isDSD = bitsPerSample == 1;
|
||||||
|
|
||||||
bytesPerFrame = ((bitsPerSample + 7) / 8) * channels;
|
bytesPerFrame = ((bitsPerSample + 7) / 8) * channels;
|
||||||
|
|
||||||
double _trackStart = [track time];
|
double _trackStart = [track time];
|
||||||
|
@ -195,6 +197,8 @@ static void *kCueSheetDecoderContext = &kCueSheetDecoderContext;
|
||||||
int bitsPerSample = [[properties objectForKey:@"bitsPerSample"] intValue];
|
int bitsPerSample = [[properties objectForKey:@"bitsPerSample"] intValue];
|
||||||
int channels = [[properties objectForKey:@"channels"] intValue];
|
int channels = [[properties objectForKey:@"channels"] intValue];
|
||||||
|
|
||||||
|
isDSD = bitsPerSample == 1;
|
||||||
|
|
||||||
bytesPerFrame = ((bitsPerSample + 7) / 8) * channels;
|
bytesPerFrame = ((bitsPerSample + 7) / 8) * channels;
|
||||||
|
|
||||||
trackStart = 0;
|
trackStart = 0;
|
||||||
|
@ -348,14 +352,16 @@ static void *kCueSheetDecoderContext = &kCueSheetDecoderContext;
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t frameScale = isDSD ? 8 : 1;
|
||||||
|
|
||||||
AudioChunk *chunk = [decoder readAudio];
|
AudioChunk *chunk = [decoder readAudio];
|
||||||
|
|
||||||
size_t n = chunk.frameCount;
|
size_t n = chunk.frameCount * frameScale;
|
||||||
if(n > frames) {
|
if(n > frames) {
|
||||||
[chunk setFrameCount:frames];
|
[chunk setFrameCount:frames / frameScale];
|
||||||
}
|
}
|
||||||
|
|
||||||
framePosition += chunk.frameCount;
|
framePosition += chunk.frameCount * frameScale;
|
||||||
|
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue