Commit fb2ff257 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

picture_pool: fix prototypes

parent d15a4777
...@@ -43,8 +43,8 @@ typedef struct picture_pool_t picture_pool_t; ...@@ -43,8 +43,8 @@ typedef struct picture_pool_t picture_pool_t;
* Picture pool configuration * Picture pool configuration
*/ */
typedef struct { typedef struct {
int picture_count; unsigned picture_count;
picture_t **picture; picture_t *const *picture;
int (*lock)(picture_t *); int (*lock)(picture_t *);
void (*unlock)(picture_t *); void (*unlock)(picture_t *);
...@@ -69,14 +69,16 @@ VLC_API picture_pool_t * picture_pool_NewExtended( const picture_pool_configurat ...@@ -69,14 +69,16 @@ VLC_API picture_pool_t * picture_pool_NewExtended( const picture_pool_configurat
* *
* It is provided as convenience. * It is provided as convenience.
*/ */
VLC_API picture_pool_t * picture_pool_New( int picture_count, picture_t *picture[] ) VLC_USED; VLC_API picture_pool_t * picture_pool_New(unsigned count,
picture_t *const *tab) VLC_USED;
/** /**
* It creates a picture_pool_t creating images using the given format. * It creates a picture_pool_t creating images using the given format.
* *
* Provided for convenience. * Provided for convenience.
*/ */
VLC_API picture_pool_t * picture_pool_NewFromFormat( const video_format_t *, int picture_count ) VLC_USED; VLC_API picture_pool_t * picture_pool_NewFromFormat(const video_format_t *,
unsigned count) VLC_USED;
/** /**
* It destroys a pool created by picture_pool_New. * It destroys a pool created by picture_pool_New.
...@@ -121,7 +123,8 @@ void picture_pool_NonEmpty( picture_pool_t * ); ...@@ -121,7 +123,8 @@ void picture_pool_NonEmpty( picture_pool_t * );
* The returned pool must be deleted before the master pool. * The returned pool must be deleted before the master pool.
* When deleted, all pictures return to the master pool. * When deleted, all pictures return to the master pool.
*/ */
VLC_API picture_pool_t * picture_pool_Reserve(picture_pool_t *, int picture_count) VLC_USED; VLC_API picture_pool_t * picture_pool_Reserve(picture_pool_t *, unsigned count)
VLC_USED;
/** /**
* It returns the size of the given pool. * It returns the size of the given pool.
......
...@@ -52,7 +52,7 @@ struct picture_pool_t { ...@@ -52,7 +52,7 @@ struct picture_pool_t {
picture_pool_t *master; picture_pool_t *master;
int64_t tick; int64_t tick;
/* */ /* */
int picture_count; unsigned picture_count;
picture_t **picture; picture_t **picture;
bool *picture_reserved; bool *picture_reserved;
...@@ -147,7 +147,7 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg ...@@ -147,7 +147,7 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg
* when it gets pooled. * when it gets pooled.
* - Picture plane pointers and sizes must not be mangled in any case. * - Picture plane pointers and sizes must not be mangled in any case.
*/ */
for (int i = 0; i < cfg->picture_count; i++) { for (unsigned i = 0; i < cfg->picture_count; i++) {
picture_t *picture = cfg->picture[i]; picture_t *picture = cfg->picture[i];
/* Save the original garbage collector */ /* Save the original garbage collector */
...@@ -175,34 +175,35 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg ...@@ -175,34 +175,35 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg
} }
picture_pool_t *picture_pool_New(int picture_count, picture_t *picture[]) picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab)
{ {
picture_pool_configuration_t cfg; picture_pool_configuration_t cfg;
memset(&cfg, 0, sizeof(cfg)); memset(&cfg, 0, sizeof(cfg));
cfg.picture_count = picture_count; cfg.picture_count = count;
cfg.picture = picture; cfg.picture = tab;
return picture_pool_NewExtended(&cfg); return picture_pool_NewExtended(&cfg);
} }
picture_pool_t *picture_pool_NewFromFormat(const video_format_t *fmt, int picture_count) picture_pool_t *picture_pool_NewFromFormat(const video_format_t *fmt,
unsigned count)
{ {
picture_t *picture[picture_count]; picture_t *picture[count];
for (int i = 0; i < picture_count; i++) { for (unsigned i = 0; i < count; i++) {
picture[i] = picture_NewFromFormat(fmt); picture[i] = picture_NewFromFormat(fmt);
if (!picture[i]) if (!picture[i])
goto error; goto error;
} }
picture_pool_t *pool = picture_pool_New(picture_count, picture); picture_pool_t *pool = picture_pool_New(count, picture);
if (!pool) if (!pool)
goto error; goto error;
return pool; return pool;
error: error:
for (int i = 0; i < picture_count; i++) { for (unsigned i = 0; i < count; i++) {
if (!picture[i]) if (!picture[i])
break; break;
picture_Release(picture[i]); picture_Release(picture[i]);
...@@ -210,7 +211,7 @@ error: ...@@ -210,7 +211,7 @@ error:
return NULL; return NULL;
} }
picture_pool_t *picture_pool_Reserve(picture_pool_t *master, int count) picture_pool_t *picture_pool_Reserve(picture_pool_t *master, unsigned count)
{ {
picture_pool_t *pool = Create(master, count); picture_pool_t *pool = Create(master, count);
if (!pool) if (!pool)
...@@ -219,8 +220,8 @@ picture_pool_t *picture_pool_Reserve(picture_pool_t *master, int count) ...@@ -219,8 +220,8 @@ picture_pool_t *picture_pool_Reserve(picture_pool_t *master, int count)
pool->pic_lock = master->pic_lock; pool->pic_lock = master->pic_lock;
pool->pic_unlock = master->pic_unlock; pool->pic_unlock = master->pic_unlock;
int found = 0; unsigned found = 0;
for (int i = 0; i < master->picture_count && found < count; i++) { for (unsigned i = 0; i < master->picture_count && found < count; i++) {
if (master->picture_reserved[i]) if (master->picture_reserved[i])
continue; continue;
...@@ -240,10 +241,10 @@ picture_pool_t *picture_pool_Reserve(picture_pool_t *master, int count) ...@@ -240,10 +241,10 @@ picture_pool_t *picture_pool_Reserve(picture_pool_t *master, int count)
void picture_pool_Delete(picture_pool_t *pool) void picture_pool_Delete(picture_pool_t *pool)
{ {
for (int i = 0; i < pool->picture_count; i++) { for (unsigned i = 0; i < pool->picture_count; i++) {
picture_t *picture = pool->picture[i]; picture_t *picture = pool->picture[i];
if (pool->master) { if (pool->master) {
for (int j = 0; j < pool->master->picture_count; j++) { for (unsigned j = 0; j < pool->master->picture_count; j++) {
if (pool->master->picture[j] == picture) if (pool->master->picture[j] == picture)
pool->master->picture_reserved[j] = false; pool->master->picture_reserved[j] = false;
} }
...@@ -267,7 +268,7 @@ void picture_pool_Delete(picture_pool_t *pool) ...@@ -267,7 +268,7 @@ void picture_pool_Delete(picture_pool_t *pool)
picture_t *picture_pool_Get(picture_pool_t *pool) picture_t *picture_pool_Get(picture_pool_t *pool)
{ {
for (int i = 0; i < pool->picture_count; i++) { for (unsigned i = 0; i < pool->picture_count; i++) {
if (pool->picture_reserved[i]) if (pool->picture_reserved[i])
continue; continue;
...@@ -292,7 +293,7 @@ picture_t *picture_pool_Get(picture_pool_t *pool) ...@@ -292,7 +293,7 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
void picture_pool_Reset(picture_pool_t *pool) void picture_pool_Reset(picture_pool_t *pool)
{ {
for (int i = 0; i < pool->picture_count; i++) { for (unsigned i = 0; i < pool->picture_count; i++) {
if (pool->picture_reserved[i]) if (pool->picture_reserved[i])
continue; continue;
...@@ -309,7 +310,7 @@ void picture_pool_NonEmpty(picture_pool_t *pool) ...@@ -309,7 +310,7 @@ void picture_pool_NonEmpty(picture_pool_t *pool)
{ {
picture_t *oldest = NULL; picture_t *oldest = NULL;
for (int i = 0; i < pool->picture_count; i++) { for (unsigned i = 0; i < pool->picture_count; i++) {
if (pool->picture_reserved[i]) if (pool->picture_reserved[i])
continue; continue;
......
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