libav: check for AVERROR_EOF #86

pull/93/head
nick black 5 years ago committed by Nick Black
parent 531340a145
commit d106ebf0d3

@ -10,6 +10,9 @@
#ifdef __cplusplus
extern "C" {
#define RESTRICT
#include <libavutil/pixdesc.h>
#include <libavutil/avconfig.h>
#include <libavcodec/avcodec.h> // ffmpeg doesn't reliably "C"-guard itself
#else
#define RESTRICT restrict
#endif
@ -598,9 +601,9 @@ API struct ncvisual* ncplane_visual_open(struct ncplane* nc, const char* file,
API void ncvisual_destroy(struct ncvisual* ncv);
// extract the next frame from an ncvisual. returns NULL on end of file, writing
// 0 to 'averr'. returns NULL on a decoding or allocation error, placing the
// AVError in 'averr'. this frame is invalidated by a subsequent call to
// ncvisual_decode(), and should not be freed by the caller.
// AVERROR_EOF to 'averr'. returns NULL on a decoding or allocation error,
// placing the AVError in 'averr'. this frame is invalidated by a subsequent
// call to ncvisual_decode(), and should not be freed by the caller.
API struct AVFrame* ncvisual_decode(struct ncvisual* nc, int* averr);
// render the next frame to the associated ncplane at the current cursor

@ -2,13 +2,6 @@
#include <cstdlib>
#include <libgen.h>
#include <iostream>
extern "C" {
#include <libavutil/pixdesc.h>
#include <libavutil/avconfig.h>
#include <libavcodec/avcodec.h>
}
#include "notcurses.h"
static void usage(std::ostream& os, const char* name, int exitcode)
@ -28,7 +21,10 @@ int ncview(struct notcurses* nc, struct ncvisual* ncv, int* averr){
ncplane_printf(n, "Got frame %05d\u2026", frame);
++frame;
}
return *averr;
if(*averr == AVERROR_EOF){
return 0;
}
return -1;
}
int main(int argc, char** argv){

@ -35,7 +35,7 @@ TEST_F(LibavTest, LoadImage) {
EXPECT_EQ(0, averr);
ASSERT_NE(nullptr, ncv);
ASSERT_NE(nullptr, ncvisual_decode(ncv, &averr));
EXPECT_EQ(0, averr);
EXPECT_EQ(AVERROR_EOF, averr);
ncvisual_destroy(ncv);
}

Loading…
Cancel
Save