[mpp_buffer]: access the index field of buffer info

The external buffer would request the index of a buffer to
manage it in an array.

Change-Id: Ifbb169c75dfb6342b428b1fd640db9ec45ff5f73
Signed-off-by: Randy Li <randy.li@rock-chips.com>
This commit is contained in:
Randy Li
2017-02-22 11:17:10 +08:00
committed by Herman Chen
parent 8900385917
commit bd43fac60e
2 changed files with 35 additions and 0 deletions

View File

@@ -246,6 +246,12 @@ typedef struct MppBufferInfo_t {
#define mpp_buffer_get_size(buffer) \
mpp_buffer_get_size_with_caller(buffer, __FUNCTION__)
#define mpp_buffer_get_index(buffer) \
mpp_buffer_get_index_with_caller(buffer, __FUNCTION__)
#define mpp_buffer_set_index(buffer, index) \
mpp_buffer_set_index_with_caller(buffer, index, __FUNCTION__)
#define mpp_buffer_group_get_internal(group, type, ...) \
mpp_buffer_group_get(group, type, MPP_BUFFER_INTERNAL, MODULE_TAG, __FUNCTION__)
@@ -278,6 +284,8 @@ MPP_RET mpp_buffer_write_with_caller(MppBuffer buffer, size_t offset, void *data
void *mpp_buffer_get_ptr_with_caller(MppBuffer buffer, const char *caller);
int mpp_buffer_get_fd_with_caller(MppBuffer buffer, const char *caller);
size_t mpp_buffer_get_size_with_caller(MppBuffer buffer, const char *caller);
int mpp_buffer_get_index_with_caller(MppBuffer buffer, const char *caller);
MPP_RET mpp_buffer_set_index_with_caller(MppBuffer buffer, int index, const char *caller);
MPP_RET mpp_buffer_group_get(MppBufferGroup *group, MppBufferType type, MppBufferMode mode,
const char *tag, const char *caller);

View File

@@ -209,6 +209,33 @@ size_t mpp_buffer_get_size_with_caller(MppBuffer buffer, const char *caller)
return p->info.size;
}
int mpp_buffer_get_index_with_caller(MppBuffer buffer, const char *caller)
{
if (NULL == buffer) {
mpp_err_f("invalid NULL input\n");
return -1;
}
MppBufferImpl *p = (MppBufferImpl*)buffer;
(void)caller;
return p->info.index;
}
MPP_RET mpp_buffer_set_index_with_caller(MppBuffer buffer, int index,
const char *caller)
{
if (NULL == buffer) {
mpp_err_f("invalid NULL input\n");
return MPP_ERR_UNKNOW;
}
MppBufferImpl *p = (MppBufferImpl*)buffer;
p->info.index = index;
(void)caller;
return MPP_OK;
}
MPP_RET mpp_buffer_info_get_with_caller(MppBuffer buffer, MppBufferInfo *info, const char *caller)
{
if (NULL == buffer || NULL == info) {