1
0
mirror of https://github.com/danog/libdvb.git synced 2024-11-26 20:04:39 +01:00
This commit is contained in:
Daniil Gentili 2022-03-30 19:30:36 +02:00
parent 4e8bf47e16
commit 01687203e8
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
3 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "libdvb-rs"
version = "0.4.4"
version = "0.4.5"
description = "Safer and feature-complete pure-Rust interface for DVB-API v5 devices in Linux"
authors = ["Cesbo Developers Team <info@cesbo.com>", "Daniil Gentili <daniil@daniil.it>"]
license = "MIT"

View File

@ -199,18 +199,18 @@ impl FeStatus {
}
fn normalize_snr(&mut self, stats: DtvFrontendStats) {
self.signal_strength_decibel = stats.get_decibel_float();
self.signal_strength_percentage = match (stats.get_relative(), stats.get_decibel()) {
self.snr_decibel = stats.get_decibel_float();
self.snr_percentage = match (stats.get_relative(), stats.get_decibel()) {
(Some(v), _) => Some(((v as u32) * 100 / 65535) as u8),
(None, Some(decibel)) if self.status.contains(fe_status::FE_HAS_CARRIER) => {
match match self.delivery_system {
Some(SYS_DVBS | SYS_DVBS2) => Some(15000),
Some(SYS_DVBS) | Some(SYS_DVBS2) => Some(15000),
Some(SYS_DVBC_ANNEX_A | SYS_DVBC_ANNEX_B | SYS_DVBC_ANNEX_C | SYS_DVBC2) => {
Some(SYS_DVBC_ANNEX_A) | Some(SYS_DVBC_ANNEX_B) | Some(SYS_DVBC_ANNEX_C) | Some(SYS_DVBC2) => {
Some(28000)
}
Some(SYS_DVBT | SYS_DVBT2) => Some(19000),
Some(SYS_DVBT) | Some(SYS_DVBT2) => Some(19000),
Some(SYS_ATSC) => Some(match self.modulation {
Some(VSB_8 | VSB_16) => 19000,
@ -252,12 +252,12 @@ impl FeStatus {
self.normalize_snr(snr);
self.ber = match ber.get_counter() {
Some(v) => Some(v),
None if self.status.contains(fe_status::FE_HAS_LOCK) => Some(fe.read_ber()?),
None if self.status.contains(fe_status::FE_HAS_LOCK) => fe.read_ber().ok(),
None => None,
};
self.unc = match unc.get_counter() {
Some(v) => Some(v),
None if self.status.contains(fe_status::FE_HAS_LOCK) => Some(fe.read_unc()?),
None if self.status.contains(fe_status::FE_HAS_LOCK) => fe.read_unc().ok(),
None => None,
};

View File

@ -860,18 +860,21 @@ pub enum DtvProperty {
#[macro_export]
macro_rules! dtv_property {
( $property:ident ) => {
$property($crate::fe::sys::DtvPropertyRequest::new(()))
};
( $property:ident($data:expr) ) => {
$property(DtvPropertyRequest::new($data))
$property($crate::fe::sys::DtvPropertyRequest::new($data))
};
( $property:ident, $data:expr ) => {
$property(DtvPropertyRequest::new($data))
$property($crate::fe::sys::DtvPropertyRequest::new($data))
};
}
#[macro_export]
macro_rules! dtv_property_parse {
( $property:ident($data:expr)) => {
$property(DtvPropertyRequest::new($data.parse().with_context(||format!("Invalid {}: {}", stringify!($property), $data))?))
$property($crate::fe::sys::DtvPropertyRequest::new($data.parse().with_context(||format!("Invalid {}: {}", stringify!($property), $data))?))
};
}