2017-10-13 192 views
0

我有以下代碼播放MP3:強制USB音頻輸出

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卡上播放聲音?

謝謝。

回答

0

SuperpoweredAndroidAudioIO和SuperpoweredUSBAudio都使用音頻回調。將您的播放器代碼放入SuperpoweredUSBAudio的音頻處理回調中。我看到在你的例子中這兩個回調都被稱爲audioProcessing。