Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 765b475b authored by Dean Wheatley's avatar Dean Wheatley
Browse files

Add E-AC3-JOC as allowed AudioRecord format

Loopback policy mixes may be defined with E-AC3-JOC format, so support
AudioRecord with this format.

Change-Id: I03b3e64599c48d4fb64f2a42a2c863164a26cd96
parent 287ac573
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -212,14 +212,11 @@ static jint android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject w
            return (jint) AUDIORECORD_ERROR_SETUP_INVALIDFORMAT;
        }

        size_t bytesPerSample = audio_bytes_per_sample(format);

        if (buffSizeInBytes == 0) {
            ALOGE("Error creating AudioRecord: frameCount is 0.");
            return (jint) AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT;
        }
        size_t frameSize = channelCount * bytesPerSample;
        size_t frameCount = buffSizeInBytes / frameSize;
        size_t frameCount = buffSizeInBytes / audio_bytes_per_frame(channelCount, format);

        // create an uninitialized AudioRecord object
        Parcel* parcel = parcelForJavaObject(env, jAttributionSource);
+3 −10
Original line number Diff line number Diff line
@@ -1176,6 +1176,7 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection,
            case AudioFormat.ENCODING_PCM_FLOAT:
            case AudioFormat.ENCODING_PCM_16BIT:
            case AudioFormat.ENCODING_PCM_8BIT:
            case AudioFormat.ENCODING_E_AC3_JOC:
                mAudioFormat = audioFormat;
                break;
            default:
@@ -1188,20 +1189,12 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection,


    // Convenience method for the contructor's audio buffer size check.
    // preconditions:
    //    mChannelCount is valid
    //    mAudioFormat is AudioFormat.ENCODING_PCM_8BIT, AudioFormat.ENCODING_PCM_16BIT,
    //                 or AudioFormat.ENCODING_PCM_FLOAT
    // postcondition:
    //    mNativeBufferSizeInBytes is valid (multiple of frame size, positive)
    private void audioBuffSizeCheck(int audioBufferSize) throws IllegalArgumentException {
        // NB: this section is only valid with PCM data.
        // To update when supporting compressed formats
        int frameSizeInBytes = mChannelCount
            * (AudioFormat.getBytesPerSample(mAudioFormat));
        if ((audioBufferSize % frameSizeInBytes != 0) || (audioBufferSize < 1)) {
        if ((audioBufferSize % getFormat().getFrameSizeInBytes() != 0) || (audioBufferSize < 1)) {
            throw new IllegalArgumentException("Invalid audio buffer size " + audioBufferSize
                    + " (frame size " + frameSizeInBytes + ")");
                    + " (frame size " + getFormat().getFrameSizeInBytes() + ")");
        }

        mNativeBufferSizeInBytes = audioBufferSize;