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
267948350a
commit
216cc52719
3 changed files with 7 additions and 4 deletions
|
@ -174,11 +174,12 @@ static const uint32_t AudioChannelConfigTable[] = {
|
||||||
if(formatAssigned) {
|
if(formatAssigned) {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
const double secondsDuration = (double)(frameCount) / format.mSampleRate;
|
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 bytesPerPacket = format.mBytesPerPacket;
|
||||||
const size_t byteCount = bytesPerPacket * frameCount;
|
const size_t byteCount = bytesPerPacket * frameCount;
|
||||||
NSData *ret = [chunkData subdataWithRange:NSMakeRange(0, byteCount)];
|
NSData *ret = [chunkData subdataWithRange:NSMakeRange(0, byteCount)];
|
||||||
[chunkData replaceBytesInRange:NSMakeRange(0, byteCount) withBytes:NULL length:0];
|
[chunkData replaceBytesInRange:NSMakeRange(0, byteCount) withBytes:NULL length:0];
|
||||||
streamTimestamp += secondsDuration * streamTimeRatio;
|
streamTimestamp += secondsDuration * streamTimeRatio * DSDrate;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +212,8 @@ static const uint32_t AudioChannelConfigTable[] = {
|
||||||
if(formatAssigned && [chunkData length]) {
|
if(formatAssigned && [chunkData length]) {
|
||||||
const size_t bytesPerPacket = format.mBytesPerPacket;
|
const size_t bytesPerPacket = format.mBytesPerPacket;
|
||||||
const double sampleRate = format.mSampleRate;
|
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;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ void scale_by_volume(float *buffer, size_t count, float volume) {
|
||||||
AudioChunk *chunk = nil;
|
AudioChunk *chunk = nil;
|
||||||
chunk = [self convert];
|
chunk = [self convert];
|
||||||
if(!chunk || ![chunk frameCount]) {
|
if(!chunk || ![chunk frameCount]) {
|
||||||
if([previousNode endOfStream] == YES) {
|
if([[previousNode buffer] isEmpty] && [previousNode endOfStream] == YES) {
|
||||||
endOfStream = YES;
|
endOfStream = YES;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,8 @@ int32_t WriteBytesProc(void *ds, void *data, int32_t bcount) {
|
||||||
ALog(@"Unsupported sample size: %d", bitsPerSample);
|
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;
|
frame += samplesRead;
|
||||||
|
|
||||||
[chunk setStreamTimestamp:streamTimestamp];
|
[chunk setStreamTimestamp:streamTimestamp];
|
||||||
|
|
Loading…
Reference in a new issue