Commit ea212c6e authored by hwangjeff's avatar hwangjeff Committed by Facebook GitHub Bot
Browse files

Swap in assertions for decoder setup checks (#3235)

Summary: Pull Request resolved: https://github.com/pytorch/audio/pull/3235

Reviewed By: mthrok

Differential Revision: D44653654

Pulled By: hwangjeff

fbshipit-source-id: f28a6068e826581d76ed4a216adb6019b6486e53
parent 0d57a3af
......@@ -303,9 +303,9 @@ bool StreamProcessor::is_decoder_set() const {
// 0: some kind of success
// <0: Some error happened
int StreamProcessor::process_packet(AVPacket* packet) {
if (!is_decoder_set()) {
return 0;
}
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(
is_decoder_set(),
"Decoder must have been set prior to calling this function.");
int ret = avcodec_send_packet(codec_ctx, packet);
while (ret >= 0) {
ret = avcodec_receive_frame(codec_ctx, frame);
......@@ -361,11 +361,12 @@ int StreamProcessor::process_packet(AVPacket* packet) {
}
void StreamProcessor::flush() {
if (is_decoder_set()) {
avcodec_flush_buffers(codec_ctx);
for (auto& ite : post_processes) {
ite.second->flush();
}
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(
is_decoder_set(),
"Decoder must have been set prior to calling this function.");
avcodec_flush_buffers(codec_ctx);
for (auto& ite : post_processes) {
ite.second->flush();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment