impl NADecoder for TTADecoder {
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
- if let NACodecTypeInfo::Audio(_ainfo) = info.get_properties() {
+ if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
if let Some(buf) = info.get_extradata() {
if !check_crc(&buf) {
return Err(DecoderError::ChecksumError);
self.ainfo = NAAudioInfo::new(srate, channels as u8, fmt, self.framelen as usize);
Ok(())
} else {
- Err(DecoderError::InvalidData)
+ println!("no TTA header was provided, trying to make data up");
+
+ self.nsamples = u32::MAX;
+ self.framelen = ainfo.sample_rate * 256 / 245;
+ self.chmap = if ainfo.channels == 1 {
+ NAChannelMap::from_str("C").unwrap()
+ } else if ainfo.channels == 2 {
+ NAChannelMap::from_str("L,R").unwrap()
+ } else {
+ return Err(DecoderError::NotImplemented);
+ };
+ self.ainfo = ainfo;
+ self.ainfo.format = match ainfo.format.bits {
+ 8 | 16 => SND_S16P_FORMAT,
+ 24 | 32 => SND_S32P_FORMAT,
+ _ => return Err(DecoderError::NotImplemented),
+ };
+ self.ainfo.block_len = self.framelen as usize;
+ self.bpp = (ainfo.format.bits / 8) as u8;
+ self.ch_dec = Vec::with_capacity(usize::from(ainfo.channels));
+ for _ in 0..ainfo.channels {
+ self.ch_dec.push(ChannelDecoder::new());
+ }
+ Ok(())
}
} else {
Err(DecoderError::InvalidData)