[xcode] Fix incorrect error check, unsigned int can't be negative

av_find_best_stream() returns an int, with negative being an error

Credit lgtm.com
This commit is contained in:
ejurgensen 2020-08-10 22:56:08 +02:00
parent d9177dfb25
commit d77927d3c3

View File

@ -750,14 +750,16 @@ open_decoder(unsigned int *stream_index, struct decode_ctx *ctx, enum AVMediaTyp
AVCodec *decoder;
int ret;
*stream_index = av_find_best_stream(ctx->ifmt_ctx, type, -1, -1, &decoder, 0);
if ((*stream_index < 0) || (!decoder))
ret = av_find_best_stream(ctx->ifmt_ctx, type, -1, -1, &decoder, 0);
if ((ret < 0) || (!decoder))
{
if (!ctx->settings.silent)
DPRINTF(E_LOG, L_XCODE, "No stream data or decoder for stream #%d\n", *stream_index);
DPRINTF(E_LOG, L_XCODE, "No stream data or decoder found: %s\n", err2str(ret));
return NULL;
}
*stream_index = (unsigned int)ret;
CHECK_NULL(L_XCODE, dec_ctx = avcodec_alloc_context3(decoder));
// In open_filter() we need to tell the sample rate and format that the decoder