VLC  3.0.21
statistic.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * statistic.h : vout statistic
3  *****************************************************************************
4  * Copyright (C) 2009 Laurent Aimar
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23 
24 #ifndef LIBVLC_VOUT_STATISTIC_H
25 # define LIBVLC_VOUT_STATISTIC_H
26 # include <vlc_atomic.h>
27 
28 /* NOTE: Both statistics are atomic on their own, so one might be older than
29  * the other one. Currently, only one of them is updated at a time, so this
30  * is a non-issue. */
31 typedef struct {
32  atomic_uint displayed;
33  atomic_uint lost;
35 
36 static inline void vout_statistic_Init(vout_statistic_t *stat)
37 {
38  atomic_init(&stat->displayed, 0);
39  atomic_init(&stat->lost, 0);
40 }
41 
42 static inline void vout_statistic_Clean(vout_statistic_t *stat)
43 {
44  (void) stat;
45 }
46 
47 static inline void vout_statistic_GetReset(vout_statistic_t *stat,
48  unsigned *restrict displayed,
49  unsigned *restrict lost)
50 {
51  *displayed = atomic_exchange(&stat->displayed, 0);
52  *lost = atomic_exchange(&stat->lost, 0);
53 }
54 
55 static inline void vout_statistic_AddDisplayed(vout_statistic_t *stat,
56  int displayed)
57 {
58  atomic_fetch_add(&stat->displayed, displayed);
59 }
60 
61 static inline void vout_statistic_AddLost(vout_statistic_t *stat, int lost)
62 {
63  atomic_fetch_add(&stat->lost, lost);
64 }
65 
66 #endif
vout_statistic_t
Definition: statistic.h:30
vout_statistic_AddDisplayed
static void vout_statistic_AddDisplayed(vout_statistic_t *stat, int displayed)
Definition: statistic.h:54
vout_statistic_Clean
static void vout_statistic_Clean(vout_statistic_t *stat)
Definition: statistic.h:41
vlc_atomic.h
vout_statistic_AddLost
static void vout_statistic_AddLost(vout_statistic_t *stat, int lost)
Definition: statistic.h:60
vout_statistic_Init
static void vout_statistic_Init(vout_statistic_t *stat)
Definition: statistic.h:35
vout_statistic_t::displayed
atomic_uint displayed
Definition: statistic.h:51
vout_statistic_t::lost
atomic_uint lost
Definition: statistic.h:52
vout_statistic_GetReset
static void vout_statistic_GetReset(vout_statistic_t *stat, unsigned *restrict displayed, unsigned *restrict lost)
Definition: statistic.h:46