superpoweredSDK / Low-Latency-Android-iOS-Linux-Windows-tvOS-macOS-Interactive-Audio-Platform

🇸Superpowered Audio, Networking and Cryptographics SDKs. High performance and cross platform on Android, iOS, macOS, tvOS, Linux, Windows and modern web browsers.
https://superpowered.com
1.34k stars 285 forks source link

Audio Clicks/Pops while recording using Superpowered Recorder #283

Closed shivamsingh closed 7 years ago

shivamsingh commented 7 years ago

Hi Superpowered,

Hope you are well. On a certain set of Android devices, I been experiencing pretty severe audio clicks and pops while recording audio via the device microphone/headset mic. I understand that you do not provide free code reviews but I'm beginning to wonder whether my implementation of the SuperpoweredRecorder class and process method is correct. Here's the code fragment concerned with recording.

bool AudioRecorder::process(short int *output, unsigned int numberOfSamples) { pthread_mutex_lock(&mutex); bool processed = false; if (isRecording) { SuperpoweredShortIntToFloat(output, recordBuffer, numberOfSamples); if (isBacktrack) { processed = player->process(stereoBuffer, false, numberOfSamples); if (processed) { SuperpoweredFloatToShortInt(stereoBuffer, output, numberOfSamples); } }

    recorder->process(recordBuffer, NULL, numberOfSamples);
    pthread_mutex_unlock(&mutex);
    return isBacktrack ? processed : isRecording;

}

I'm also attaching a sample recording from one of these devices to give you an idea of how the problem sounds.

https://drive.google.com/open?id=0B3k6apsbcwwkS3JBU3dIZzhnaDQ

Any advice would be hugely helpful. Thanks

superpoweredSDK commented 7 years ago

None of the Superpowered stuff seems wrong. Please check your mutex, locking in an audio processing callback is not recommended.