强制USB音频输出

时间:2017-10-13 10:27:44

标签: android audio superpowered

我有以下代码来播放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卡播放器发出声音?

谢谢。

1 个答案:

答案 0 :(得分:0)

SuperpoweredAndroidAudioIO和SuperpoweredUSBAudio都使用音频回调。将您的播放器代码放入SuperpoweredUSBAudio的音频处理回调中。我发现在你的例子中,两个回调都被称为audioProcessing。