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. */
30typedef struct {
31 atomic_uint displayed;
32 atomic_uint lost;
33 atomic_uint late;
35
36static inline void vout_statistic_Init(vout_statistic_t *stat)
37{
38 atomic_init(&stat->displayed, 0);
39 atomic_init(&stat->lost, 0);
40 atomic_init(&stat->late, 0);
41}
42
43static inline void vout_statistic_Clean(vout_statistic_t *stat)
44{
45 (void) stat;
46}
47
49 unsigned *restrict displayed,
50 unsigned *restrict lost,
51 unsigned *restrict late)
52{
53 *displayed = atomic_exchange_explicit(&stat->displayed, 0,
54 memory_order_relaxed);
55 *lost = atomic_exchange_explicit(&stat->lost, 0, memory_order_relaxed);
56 *late = atomic_exchange_explicit(&stat->late, 0, memory_order_relaxed);
57}
58
60 int displayed)
61{
62 atomic_fetch_add_explicit(&stat->displayed, displayed,
63 memory_order_relaxed);
64}
65
66static inline void vout_statistic_AddLost(vout_statistic_t *stat, int lost)
67{
68 atomic_fetch_add_explicit(&stat->lost, lost, memory_order_relaxed);
69}
70
71static inline void vout_statistic_AddLate(vout_statistic_t *stat, int late)
72{
73 atomic_fetch_add_explicit(&stat->late, late, memory_order_relaxed);
74}
75
76#endif
static void vout_statistic_AddLate(vout_statistic_t *stat, int late)
Definition: statistic.h:71
static void vout_statistic_AddDisplayed(vout_statistic_t *stat, int displayed)
Definition: statistic.h:59
static void vout_statistic_GetReset(vout_statistic_t *stat, unsigned *restrict displayed, unsigned *restrict lost, unsigned *restrict late)
Definition: statistic.h:48
static void vout_statistic_AddLost(vout_statistic_t *stat, int lost)
Definition: statistic.h:66
static void vout_statistic_Clean(vout_statistic_t *stat)
Definition: statistic.h:43
static void vout_statistic_Init(vout_statistic_t *stat)
Definition: statistic.h:36
Definition: statistic.h:30
atomic_uint lost
Definition: statistic.h:32
atomic_uint late
Definition: statistic.h:33
atomic_uint displayed
Definition: statistic.h:31