}
}
let (dmx_name, _) = res.unwrap_or(("", detect::DetectionScore::No));
- if dmx_name != "" {
+ if !dmx_name.is_empty() {
println!("trying demuxer {} on {}", dmx_name, name);
if let Some(dmx_fact) = reg.dmx_reg.find_demuxer(dmx_name) {
br.seek(SeekFrom::Start(0)).unwrap();
return DemuxerObject::Normal(dmx);
}
}
- if dmx_name != "" {
+ if !dmx_name.is_empty() {
println!("trying raw demuxer {} on {}", dmx_name, name);
if let Some(rdmx_fact) = reg.rdmx_reg.find_demuxer(dmx_name) {
br.seek(SeekFrom::Start(0)).unwrap();
break;
}
}
- if pname != "" {
+ if !pname.is_empty() {
println!("found raw stream of type {} for {}", pname, name);
let pcreate = reg.pkt_reg.find_packetiser(pname).unwrap();
let mut packetiser = (pcreate)();
}
}
pub fn is_none(&self) -> bool {
- match *self {
- DemuxerObject::None => true,
- _ => false,
- }
+ matches!(*self, DemuxerObject::None)
}
pub fn get_duration(&self) -> u64 {
match *self {
self.io.write_u32le(16)?;
self.io.write_u16le(0x0001)?; // PCM
self.io.write_u16le(ainfo.get_channels() as u16)?;
- self.io.write_u32le(ainfo.get_sample_rate() as u32)?;
+ self.io.write_u32le(ainfo.get_sample_rate())?;
if bits <= 8 {
- self.io.write_u32le((ainfo.get_channels() as u32) * (ainfo.get_sample_rate() as u32))?;
+ self.io.write_u32le((ainfo.get_channels() as u32) * ainfo.get_sample_rate())?;
self.io.write_u16le(ainfo.get_channels() as u16)?; // block align
self.io.write_u16le(8)?;
} else {
- self.io.write_u32le(2 * (ainfo.get_channels() as u32) * (ainfo.get_sample_rate() as u32))?;
+ self.io.write_u32le(2 * (ainfo.get_channels() as u32) * ainfo.get_sample_rate())?;
self.io.write_u16le((2 * ainfo.get_channels()) as u16)?; // block align
self.io.write_u16le(16)?;
}
},
12 if !self.be => {
let mut src = data.chunks_exact(3);
- while let Some(chunk) = src.next() {
+ for chunk in src.by_ref() {
self.io.write_byte(chunk[0] << 4)?;
self.io.write_byte((chunk[1] << 4) | (chunk[0] >> 4))?;
self.io.write_byte(chunk[1] & 0xF0)?;
let res = self.io.seek(SeekFrom::Start(4));
let res = self.io.write_u32le((size - 8) as u32);
let res = self.io.seek(SeekFrom::Start(self.data_pos - 4));
- let res = self.io.write_u32le(((size as u64) - self.data_pos) as u32);
+ let res = self.io.write_u32le((size - self.data_pos) as u32);
let res = self.io.flush();
}
}