我有点绝望。
I2S似乎不起作用。
如果我尝试使用audioTrack播放声音。在树莓派3中,它可以正常工作,但是如果我在imx7d中执行它,则会出现以下错误:
audio_hw_primary:卡0,端口0设备0x1000000
audio_hw_primary:速率48000,通道2 period_size 0xc0
audio_hw_primary:无法打开pcm_out驱动程序0:无法设置硬件参数:无效的参数
i2s麦克风也会发生同样的事情
这是代码:
final AudioDeviceInfo audioOuputDevice = findAudioDevice(AudioManager.GET_DEVICES_OUTPUTS, AudioDeviceInfo.TYPE_BUS);
int mBufferSize = AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
AudioFormat audioOutputFormat = new AudioFormat.Builder()
.setChannelMask(AudioFormat.CHANNEL_IN_MONO)
.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
.setSampleRate(44100)
.build();
audioTrack = new AudioTrack.Builder()
.setAudioFormat(audioOutputFormat)
.setBufferSizeInBytes(mBufferSize * 2)
.setTransferMode(AudioTrack.MODE_STREAM)
.build();
audioTrack.setPreferredDevice(audioOuputDevice);
audioTrack.setPlaybackRate(44100);
audioTrack.setVolume(AudioTrack.getMaxVolume());