Do not cause a floating point exception during stream shutdown in TS-based outputs with AAC audio

This commit is contained in:
Thulinma 2020-10-16 14:39:11 +02:00
parent 84113218b8
commit 19840f32d4

View file

@ -190,13 +190,15 @@ namespace Mist {
tempLen += 7;
//Make sure TS timestamp is sample-aligned, if possible
uint32_t freq = Trk.rate;
uint64_t aacSamples = (packTime/90) * freq / 1000;
//round to nearest packet, assuming all 1024 samples (probably wrong, but meh)
aacSamples += 512;
aacSamples /= 1024;
aacSamples *= 1024;
//Get closest 90kHz clock time to perfect sample alignment
packTime = aacSamples * 90000 / freq;
if (freq){
uint64_t aacSamples = (packTime/90) * freq / 1000;
//round to nearest packet, assuming all 1024 samples (probably wrong, but meh)
aacSamples += 512;
aacSamples /= 1024;
aacSamples *= 1024;
//Get closest 90kHz clock time to perfect sample alignment
packTime = aacSamples * 90000 / freq;
}
}
bs = TS::Packet::getPESAudioLeadIn(tempLen, packTime, Trk.bps);
fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg);