Commit 4f448f9c authored by NzSN's avatar NzSN

Add Flag interface to Proto.

parent 6176e8bb
......@@ -18,6 +18,10 @@ static int mmRead(void *priv, uint8_t *buf, int size) {
return AVERROR(EINVAL);
}
if (protoIsFlagSeted(&proto->Base, PROTO_FLAG_EOF)) {
return AVERROR_EOF;
}
// No Datas
if (mmcEmpty(context) && listEmpty(buffers)) {
return AVERROR(EAGAIN);
......@@ -30,7 +34,7 @@ static int mmRead(void *priv, uint8_t *buf, int size) {
free(info);
}
if (mmcIsEOF(context) || flag & PROTO_FLAG_EOF) {
if (mmcIsEOF(context)) {
protoSetFlag(&proto->Base, PROTO_FLAG_EOF);
return AVERROR_EOF;
}
......
......@@ -34,6 +34,7 @@ typedef struct Proto {
#define Super(DerivedPtr) ((Proto*)(DerivedPtr))
#define protoFlag(P) ((P)->flag)
#define protoSetFlag(P, F) ((P)->flag = (P)->flag | (F))
#define protoIsFlagSeted(P, F) ((P)->flag & (F))
/* Prototypes */
......
......@@ -110,7 +110,10 @@ CTEST2(PROTO_TEST, TO_AVIO) {
CTEST2(PROTO_TEST, FLAGS_SET_UNSET) {
ASSERT_EQUAL(protoFlag(data->proto), PROTO_NO_FLAG_SET);
ASSERT_TRUE(!protoIsFlagSeted(data->proto, PROTO_FLAG_EOF));
protoSetFlag(data->proto, PROTO_FLAG_EOF);
ASSERT_EQUAL(protoFlag(data->proto), PROTO_FLAG_EOF);
ASSERT_TRUE(protoIsFlagSeted(data->proto, PROTO_FLAG_EOF));
}
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