Bug Fix: Correct playback of DSD formats
DSD formats were buffering incorrectly and terminating way too soon. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
36a2d8efd5
commit
aafe817a1f
3 changed files with 7 additions and 4 deletions
|
@ -174,11 +174,12 @@ static const uint32_t AudioChannelConfigTable[] = {
|
|||
if(formatAssigned) {
|
||||
@autoreleasepool {
|
||||
const double secondsDuration = (double)(frameCount) / format.mSampleRate;
|
||||
const double DSDrate = (format.mBitsPerChannel == 1) ? 8.0 : 1.0;
|
||||
const size_t bytesPerPacket = format.mBytesPerPacket;
|
||||
const size_t byteCount = bytesPerPacket * frameCount;
|
||||
NSData *ret = [chunkData subdataWithRange:NSMakeRange(0, byteCount)];
|
||||
[chunkData replaceBytesInRange:NSMakeRange(0, byteCount) withBytes:NULL length:0];
|
||||
streamTimestamp += secondsDuration * streamTimeRatio;
|
||||
streamTimestamp += secondsDuration * streamTimeRatio * DSDrate;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +212,8 @@ static const uint32_t AudioChannelConfigTable[] = {
|
|||
if(formatAssigned && [chunkData length]) {
|
||||
const size_t bytesPerPacket = format.mBytesPerPacket;
|
||||
const double sampleRate = format.mSampleRate;
|
||||
return (double)([chunkData length] / bytesPerPacket) / sampleRate;
|
||||
const double DSDrate = (format.mBitsPerChannel == 1) ? 8.0 : 1.0;
|
||||
return ((double)([chunkData length] / bytesPerPacket) / sampleRate) * DSDrate;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ void scale_by_volume(float *buffer, size_t count, float volume) {
|
|||
AudioChunk *chunk = nil;
|
||||
chunk = [self convert];
|
||||
if(!chunk || ![chunk frameCount]) {
|
||||
if([previousNode endOfStream] == YES) {
|
||||
if([[previousNode buffer] isEmpty] && [previousNode endOfStream] == YES) {
|
||||
endOfStream = YES;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -258,7 +258,8 @@ int32_t WriteBytesProc(void *ds, void *data, int32_t bcount) {
|
|||
ALog(@"Unsupported sample size: %d", bitsPerSample);
|
||||
}
|
||||
|
||||
double streamTimestamp = (double)(frame) / frequency;
|
||||
double DSDrate = (bitsPerSample == 1) ? 8.0 : 1.0;
|
||||
double streamTimestamp = (double)(frame) / frequency * DSDrate;
|
||||
frame += samplesRead;
|
||||
|
||||
[chunk setStreamTimestamp:streamTimestamp];
|
||||
|
|
Loading…
Reference in a new issue