我有以下代码播放mp3:

audioPlayer = new SuperpoweredAdvancedAudioPlayer(&audioPlayer, playerEventCallbackA, samplerate, 0);

audioPlayer->open(path, 0, fileLength);

audioSystem = new SuperpoweredAndroidAudioIO(samplerate, buffersize, false, true, audioProcessing, this, -1, SL_ANDROID_STREAM_MEDIA, 0);

……………

bool silence = !audioPlayer->process(stereoBuffer, false, numberOfSamples);

if (!silence) {

  // The stereoBuffer is ready now, let’s put the finished audio into the requested buffers.

  SuperpoweredFloatToShortInt(stereoBuffer, output, numberOfSamples);

 }

而且我有以下代码连接到USB卡:
int r = SuperpoweredUSBSystem::onConnect(deviceID, fd, (unsigned char *) rd, env->GetArrayLength(rawDescriptor));

if (r & 1) {

  SuperpoweredUSBAudio::easyIO(deviceID, 44100, 16, 0, 256, SuperpoweredUSBLatency_Low, this, audioProcessing);

  }

请帮助我知道-如何在USB卡上播放来自播放器的声音?

谢谢。

最佳答案

SuperpoweredAndroidAudioIO和SuperpoweredUSBAudio都使用音频回调。将您的播放器代码放入SuperpoweredUSBAudio的音频处理回调中。我看到在您的示例中,这两个回调都称为audioProcessing。

关于android - 强制USB音频输出,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46727792/

10-12 06:18