openipc-video 0.1.40

Low-latency platform video decoding for OpenIPC applications
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::sync::{Arc, Mutex};

use crate::DecoderStats;

#[derive(Debug, Clone, Default)]
pub(crate) struct StatsHandle(Arc<Mutex<DecoderStats>>);

impl StatsHandle {
    pub(crate) fn update(&self, update: impl FnOnce(&mut DecoderStats)) {
        update(&mut self.0.lock().expect("decoder statistics mutex poisoned"));
    }

    pub(crate) fn snapshot(&self) -> DecoderStats {
        *self.0.lock().expect("decoder statistics mutex poisoned")
    }
}