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

Commit 0b5a1314 authored by Nicholas Sauer's avatar Nicholas Sauer Committed by Android (Google) Code Review
Browse files

Merge "[FM] There is no sound in speaker while playing FM in speaker mode" into lmp-mr1-dev

parents c393989f 7c38d146
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -384,7 +384,21 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
    }

    private synchronized void startRender() {
        Log.d(TAG, "startRender");
        Log.d(TAG, "startRender " + AudioSystem.getForceUse(FOR_PROPRIETARY));
        // Stop old AudioRecord and create a new AudioRecord
        // when plugging out and then plugging in wired headset.
        // Otherwise, reading data from old AudioRecord will be blocked.
        if (AudioSystem.getForceUse(FOR_PROPRIETARY) ==
                AudioSystem.FORCE_SPEAKER && mIsSpeakerUsed) {
            if (mAudioRecord != null) {
                mAudioRecord.stop();
            }
            if (mAudioTrack != null) {
                mAudioTrack.stop();
            }
            initAudioRecordSink();
        }

        mIsRender = true;
        synchronized (mRenderLock) {
            mRenderLock.notify();
@@ -467,6 +481,11 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
                            Log.d(TAG, "EYES ignore " + mCurrentFrame);
                            continue ;
                        }
                        if (size <= 0) {
                            Log.e(TAG, "RenderThread read data from AudioRecord "
                                    + "error size: " + size);
                            continue;
                        }
                        byte[] tmpBuf = new byte[size];
                        System.arraycopy(buffer, 0, tmpBuf, 0, size);
                        // write to audio track
@@ -1640,6 +1659,7 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
            AudioPortConfig sinkConfig = sinks[0];
            AudioPort sourcePort = sourceConfig.port();
            AudioPort sinkPort = sinkConfig.port();
            Log.d(TAG, "isPatchMixerToEarphone " + sourcePort + " ====> " + sinkPort);
            if (sourcePort instanceof AudioMixPort && sinkPort instanceof AudioDevicePort) {
                deviceCount++;
                int type = ((AudioDevicePort) sinkPort).type();