diff --git a/mpp/mpp.cpp b/mpp/mpp.cpp index f3d407c0..f2ec654a 100644 --- a/mpp/mpp.cpp +++ b/mpp/mpp.cpp @@ -167,11 +167,22 @@ MPP_RET Mpp::put_packet(MppPacket packet) MPP_RET Mpp::get_frame(MppFrame *frame) { Mutex::Autolock autoLock(mFrames->mutex()); + MppFrame first = NULL; if (mFrames->list_size()) { - mFrames->del_at_tail(frame, sizeof(frame)); + mFrames->del_at_tail(&first, sizeof(frame)); mFrameGetCount++; + + MppFrame prev = first; + MppFrame next = NULL; + while (mFrames->list_size()) { + mFrames->del_at_tail(&next, sizeof(frame)); + mFrameGetCount++; + mpp_frame_set_next(prev, next); + prev = next; + } } mThreadHal->signal(); + *frame = first; return MPP_OK; } diff --git a/mpp/mpp_frame.cpp b/mpp/mpp_frame.cpp index f8a55e18..3d6bc178 100644 --- a/mpp/mpp_frame.cpp +++ b/mpp/mpp_frame.cpp @@ -37,13 +37,13 @@ MPP_FRAME_ACCESSORS(MppBuffer, buffer) MPP_RET mpp_frame_init(MppFrame *frame) { if (NULL == frame) { - mpp_err("mpp_frame_init invalid NULL pointer input\n"); + mpp_err_f("invalid NULL pointer input\n"); return MPP_ERR_NULL_PTR; } MppFrameImpl *p = mpp_calloc(MppFrameImpl, 1); if (NULL == p) { - mpp_err("mpp_frame_init malloc failed\n"); + mpp_err_f("malloc failed\n"); return MPP_ERR_NULL_PTR; } @@ -55,7 +55,7 @@ MPP_RET mpp_frame_init(MppFrame *frame) MPP_RET mpp_frame_deinit(MppFrame *frame) { if (NULL == frame || NULL == *frame) { - mpp_err("mpp_frame_deinit invalid NULL pointer input\n"); + mpp_err_f("invalid NULL pointer input\n"); return MPP_ERR_NULL_PTR; } @@ -70,7 +70,7 @@ MPP_RET mpp_frame_deinit(MppFrame *frame) MppFrame mpp_frame_get_next(MppFrame frame) { if (NULL == frame) { - mpp_err("mpp_frame_get_next invalid NULL pointer input\n"); + mpp_err_f("invalid NULL pointer input\n"); return NULL; } @@ -78,3 +78,15 @@ MppFrame mpp_frame_get_next(MppFrame frame) return (MppFrame)p->next; } +MPP_RET mpp_frame_set_next(MppFrame frame, MppFrame next) +{ + if (NULL == frame) { + mpp_err_f("invalid NULL pointer input\n"); + return MPP_ERR_NULL_PTR; + } + + MppFrameImpl *p = (MppFrameImpl *)frame; + p->next = (MppFrameImpl *)next; + return MPP_OK; +} + diff --git a/mpp/mpp_frame_impl.h b/mpp/mpp_frame_impl.h index aee8e41a..8cf2311b 100644 --- a/mpp/mpp_frame_impl.h +++ b/mpp/mpp_frame_impl.h @@ -82,6 +82,6 @@ struct MppFrameImpl_t { type mpp_frame_get_##field(const MppFrame s) { return ((MppFrameImpl*)s)->field; } \ void mpp_frame_set_##field(MppFrame s, type v) { ((MppFrameImpl*)s)->field = v; } - +MPP_RET mpp_frame_set_next(MppFrame frame, MppFrame next); #endif /*__MPP_FRAME_IMPL_H__*/ diff --git a/test/mpi_test.c b/test/mpi_test.c index 7f1a2c44..0be3598b 100644 --- a/test/mpi_test.c +++ b/test/mpi_test.c @@ -133,8 +133,8 @@ int main() mpp_frame_deinit(&dec_out); dec_out = next; + i++; } while (dec_out); - i++; } }