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