I would like to change the Android OS (the official image from AOSP) to add preprocessing to the normal sound of playing phone calls.
I have already achieved this filtering for playing audio in an application (by changing the HAL and audio fragmenter).
I'm fine targeting only a specific device (Nexus 5X). In addition, I only need to filter the playback - I do not care about the recording (uplink).
UPDATE: To make it clear - I'm fine with the modification of certain Qualcomm drivers, or any part that works on the Nexus 5X can help me change the playback in call mode.
UPDATE # 2:
I am trying to create a Java-level application that directs phone playback to a music stream in real time. I already managed to install it as a system application, having received permissions to initialize AudioRecord using AudioSource.VOICE_DOWNLINK . However, the record gives empty samples; it does not record a voice call.
Code inside my workflow:
// Start recording int recBufferSize = AudioRecord.getMinBufferSize(44100, AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT); mRecord = new AudioRecord(MediaRecorder.AudioSource.VOICE_DOWNLINK, 44100, AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT, recBufferSize); // Start playback int playBufferSize = AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT); mTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT, playBufferSize, AudioTrack.MODE_STREAM); mRecord.startRecording();; mTrack.play(); int bufSize = 1024; short[] buffer = new short[bufSize]; int res; while (!interrupted()) { // Pull recording buffers and play back res = mRecord.read(buffer, 0, bufSize, AudioRecord.READ_NON_BLOCKING); mTrack.write(buffer, 0, res, AudioTrack.WRITE_BLOCKING); } // Stop recording mRecord.stop(); mRecord.release(); mRecord = null; // Stop playback mTrack.stop(); mTrack.release();; mTrack = null;
I work on Nexus 5X, my own AOSP-ROM, Android 7.1.1. I need to find a place that will allow me to work with recording calls - perhaps somewhere in hardware/qcom/audio/hal in the platform code.
Also I looked: Function voice_check_and_set_incall_rec_usecase with hardware/qcom/audio/hal/voice.c But he couldn’t understand from this or how to make it work.
UPDATE # 3: I opened a more specific question about using AudioSource.VOICE_DOWNLINK , which may attract attention and ultimately help me resolve this issue. Call recording - make it work on Nexus 5X (possibly rooting or user disk)