Skip to content

Commit

Permalink
Shuffle some stuff around to reduce indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed Jul 26, 2015
1 parent 998a778 commit 7477df0
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/core/audiosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,36 +291,36 @@ void FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
// Should only ever happen if the user chose to ignore decoding errors
// during indexing, so continue to just ignore decoding errors
if (Ret < 0) break;

if (Ret > 0) {
Packet.size -= Ret;
Packet.data += Ret;
if (GotFrame && DecodeFrame->nb_samples > 0) {
GotSamples = true;
if (pos)
CachedBlock = CacheBlock(*pos);
}
if (Ret == 0) continue;

Packet.size -= Ret;
Packet.data += Ret;
if (GotFrame && DecodeFrame->nb_samples > 0) {
GotSamples = true;
if (pos)
CachedBlock = CacheBlock(*pos);
}
}
Packet.data = Data;
FreePacket(&Packet);

// Zero sample packets aren't included in the index
if (GotSamples) {
++PacketNumber;

// Add padding after the packet, if needed
if (CachedBlock && CachedBlock->Samples < CurrentFrame->SampleCount) {
const auto MissingSamples = static_cast<size_t>(CurrentFrame->SampleCount - CachedBlock->Samples);
CachedBlock->Samples += MissingSamples;
const auto MissingBytes = MissingSamples * BytesPerSample;
if (MissingSamples > 200 || MissingSamples > CachedBlock->Samples - MissingSamples)
memset(CachedBlock->Grow(MissingBytes), 0, MissingBytes);
else {
auto ptr = CachedBlock->Grow(MissingBytes);
memcpy(ptr, ptr - MissingBytes, MissingBytes);
}
}
if (!GotSamples)
return;
++PacketNumber;

// Add padding after the packet, if needed
if (!CachedBlock || CachedBlock->Samples == CurrentFrame->SampleCount)
return;

const auto MissingSamples = static_cast<size_t>(CurrentFrame->SampleCount - CachedBlock->Samples);
CachedBlock->Samples += MissingSamples;
const auto MissingBytes = MissingSamples * BytesPerSample;
if (MissingSamples > 200 || MissingSamples > CachedBlock->Samples - MissingSamples)
memset(CachedBlock->Grow(MissingBytes), 0, MissingBytes);
else {
auto ptr = CachedBlock->Grow(MissingBytes);
memcpy(ptr, ptr - MissingBytes, MissingBytes);
}
}

Expand Down

0 comments on commit 7477df0

Please sign in to comment.