Change validity checks to assert statements.

This commit is contained in:
Dr. Chat 2015-08-29 22:14:20 -05:00
parent afa013f4bf
commit 50535b07c3
1 changed files with 6 additions and 15 deletions

View File

@ -588,24 +588,15 @@ void XmaContext::DecodePackets(XMA_CONTEXT_DATA* data) {
// Copy to the output buffer. // Copy to the output buffer.
size_t written_bytes = 0; size_t written_bytes = 0;
#ifdef DEBUG
// Validity checks. // Validity checks.
if (decoded_frame_->nb_samples > kSamplesPerFrame) { assert(decoded_frame_->nb_samples <= kSamplesPerFrame);
XELOGAPU("Decoded frame has an invalid sample count!"); assert(context_->sample_fmt == AV_SAMPLE_FMT_FLTP);
return;
} else if (context_->sample_fmt != AV_SAMPLE_FMT_FLTP) {
XELOGAPU("libav decoder did not output floating point samples!");
return;
}
// Check the returned buffer size. // Check the returned buffer size.
if (av_samples_get_buffer_size(NULL, context_->channels, assert(av_samples_get_buffer_size(NULL, context_->channels,
decoded_frame_->nb_samples, decoded_frame_->nb_samples,
context_->sample_fmt, 1) != context_->sample_fmt, 1) ==
context_->channels * decoded_frame_->nb_samples * sizeof(float)) { context_->channels * decoded_frame_->nb_samples * sizeof(float));
return;
}
#endif
// Convert the frame. // Convert the frame.
ConvertFrame((const uint8_t**)decoded_frame_->data, context_->channels, ConvertFrame((const uint8_t**)decoded_frame_->data, context_->channels,