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

Commit 7c38d146 authored by Benson Huang's avatar Benson Huang Committed by Nicholas Sauer
Browse files

[FM] There is no sound in speaker while playing FM in speaker mode

Launch FM and play a station -> Plug out headphones
-> Plug in headphones -> Switch to speaker mode, There
is no sound via speaker.

The fix is to let FM sound output via speaker.

from: https://partner-android-review.googlesource.com/#/c/192523/3


Bug 18795162

Change-Id: I16fce6914ea0b3d463c1205708d11265925097e4
Signed-off-by: default avatarBenson Huang <benson.huang@mediatek.com>
parent 51530a28
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();