1 /*****************************************************************************
2 * picture_pool.c: test cases for picture_poo_t
3 *****************************************************************************
4 * Copyright (C) 2014 RĂ©mi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
29 #include <vlc_common.h>
31 #include <vlc_picture_pool.h>
35 static video_format_t fmt;
36 static picture_pool_t *pool, *reserve;
38 static void test(bool zombie)
40 picture_t *pics[PICTURES];
42 pool = picture_pool_NewFromFormat(&fmt, PICTURES);
45 for (unsigned i = 0; i < PICTURES; i++) {
46 pics[i] = picture_pool_Get(pool);
47 assert(pics[i] != NULL);
50 for (unsigned i = 0; i < PICTURES; i++)
51 assert(picture_pool_Get(pool) == NULL);
53 // Reserve currently assumes that all pictures are free (or reserved).
54 //assert(picture_pool_Reserve(pool, 1) == NULL);
56 for (unsigned i = 0; i < PICTURES / 2; i++)
57 picture_Hold(pics[i]);
59 for (unsigned i = 0; i < PICTURES / 2; i++)
60 picture_Release(pics[i]);
62 for (unsigned i = 0; i < PICTURES; i++) {
63 picture_Release(pics[i]);
64 assert(picture_pool_Get(pool) == pics[i]);
67 for (unsigned i = 0; i < PICTURES; i++)
68 picture_Release(pics[i]);
70 reserve = picture_pool_Reserve(pool, PICTURES / 2);
71 assert(reserve != NULL);
73 for (unsigned i = 0; i < PICTURES / 2; i++) {
74 pics[i] = picture_pool_Get(pool);
75 assert(pics[i] != NULL);
78 for (unsigned i = PICTURES / 2; i < PICTURES; i++) {
79 assert(picture_pool_Get(pool) == NULL);
80 pics[i] = picture_pool_Get(reserve);
81 assert(pics[i] != NULL);
85 for (unsigned i = 0; i < PICTURES; i++)
86 picture_Release(pics[i]);
88 picture_pool_Release(reserve);
89 picture_pool_Release(pool);
92 for (unsigned i = 0; i < PICTURES; i++)
93 picture_Release(pics[i]);
98 video_format_Setup(&fmt, VLC_CODEC_I420, 320, 200, 320, 200, 1, 1);
100 pool = picture_pool_NewFromFormat(&fmt, PICTURES);
101 assert(pool != NULL);
102 assert(picture_pool_GetSize(pool) == PICTURES);
104 reserve = picture_pool_Reserve(pool, PICTURES / 2);
105 assert(reserve != NULL);
107 picture_pool_Release(reserve);
108 picture_pool_Release(pool);