我正在使用 Superpowered Android C++ 库开发混音器,我在录制时遇到播放器问题,播放器没有播放,只有录音机正在录制。下面是代码,任何人都可以指导我在哪里放错了东西
bool processRecording(short int *input, unsigned int numberOfSamples) {
pthread_mutex_lock(&mutex);
if (askRecording) {
unsigned int data = 0;
SuperpoweredShortIntToFloat(input, stereoBufferRecording, numberOfSamples);
data = recorder->process(stereoBufferRecording, NULL, numberOfSamples);
playerA->process( musicBuffer, false, numberOfSamples, 0.5f );
SuperpoweredShortIntToFloat(input, stereoBufferRecording, numberOfSamples);
SuperpoweredFloatToShortInt(musicBuffer, input, numberOfSamples);
pthread_mutex_unlock(&mutex);
return true;
}
pthread_mutex_unlock(&mutex);
return false;
}
有人知道把它放在正确的地方吗?
@Gabor 建议的更改之后是代码片段
bool processRecording(short int *input, unsigned int numberOfSamples) {
pthread_mutex_lock(&mutex);
if (askRecording) {
unsigned int data = 0;
SuperpoweredShortIntToFloat(input, stereoBufferRecording, numberOfSamples);
playerA->process( musicBuffer, false, numberOfSamples, 1.0f );
//=====================================================================================
// ================== Mixing Two Buffer ==================
mixerInputs[0] = musicBuffer;
mixerInputs[1] = stereoBufferRecording;
mixerInputs[2] = NULL;
mixerInputs[3] = NULL;
mixerOutputs[0] = outputBuffer;
mixerOutputs[1] = NULL;
float inputLevels[] = { 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
float outputLevels[] = { 1.0f, 1.0f };
__android_log_print(ANDROID_LOG_INFO, "NativeSuperpoweredRecorder ", " processRecording 2>>");
mixerBackend->process(mixerInputs, mixerOutputs, inputLevels, outputLevels, NULL, NULL, numberOfSamples);
//=====================================================================================
data = recorder->process(mixerOutputs[0], NULL, numberOfSamples);
SuperpoweredFloatToShortInt(musicBuffer, input, numberOfSamples);
pthread_mutex_unlock(&mutex);
return true;
}
pthread_mutex_unlock(&mutex);
return false; }