+
+ const PCM12: &[u8] = &[ 0x02, 0x50, 0x00, 0x07, 0x70, 0x00, 0x0D, 0x00 ];
+ const PCM12_SAMPLES: usize = 5;
+ let src_ainfo = NAAudioInfo {
+ sample_rate: 44100,
+ channels: 1,
+ format: NASoniton::new(12, SONITON_FLAG_PACKED | SONITON_FLAG_SIGNED),
+ block_len: 3,
+ };
+ let dst_ainfo = NAAudioInfo {
+ sample_rate: 44100,
+ channels: 1,
+ format: SND_S16P_FORMAT,
+ block_len: 512,
+ };
+ let mono = NAChannelMap::from_str("C").unwrap();
+ let mut src_frm = alloc_audio_buffer(src_ainfo, PCM12_SAMPLES, mono.clone()).unwrap();
+ if let NABufferType::AudioPacked(ref mut abuf) = src_frm {
+ let data = abuf.get_data_mut().unwrap();
+ data.copy_from_slice(PCM12);
+ } else {
+ panic!("wrong buffer type");
+ }
+ let out_frm = convert_audio_frame(&src_frm, &dst_ainfo, &mono).unwrap();
+ if let NABufferType::AudioI16(ref abuf) = out_frm {
+ let data = abuf.get_data();
+ assert_eq!(data.len(), PCM12_SAMPLES);
+ assert_eq!(data[0], 0x0020);
+ assert_eq!(data[1], 0x0050);
+ assert_eq!(data[2], 0x0070);
+ assert_eq!(data[3], 0x0070);
+ assert_eq!(data[4], 0x00D0);
+ } else {
+ panic!("wrong buffer type");
+ }