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

Commit 3f0054bd authored by Keith Mok's avatar Keith Mok
Browse files

Revert "tracks: Check track states before transitioning states"

This does not fix the race condition problem

CYNGNOS-2775 FEIJ-1227

This reverts commit 0445f98e.

Change-Id: I8c4f5fb7f064286b6895e084ec726bcbfcce0484
parent 1b678271
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
           mAudioRecord.release();
           mAudioRecord = null;
       }
       if (mAudioTrack != null && mAudioTrack.getState() == AudioTrack.STATE_INITIALIZED) {
       if (mAudioTrack != null) {
           mAudioTrack.stop();
           mAudioTrack.release();
           mAudioTrack = null;
@@ -448,8 +448,7 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
    }

    private void startAudioTrack() {
        if (mAudioTrack.getState() == AudioTrack.STATE_INITIALIZED
                && mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED) {
        if (mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED) {
            ArrayList<AudioPatch> patches = new ArrayList<AudioPatch>();
            mAudioManager.listAudioPatches(patches);
            mAudioTrack.play();
@@ -478,13 +477,11 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
                        // Speaker mode or BT a2dp mode will come here and keep reading and writing.
                        // If we want FM sound output from speaker or BT a2dp, we must record data
                        // to AudioRecrd and write data to AudioTrack.
                        if (mAudioRecord.getRecordingState() == AudioRecord.RECORDSTATE_STOPPED
                                && mAudioRecord.getState() == AudioRecord.STATE_INITIALIZED) {
                        if (mAudioRecord.getRecordingState() == AudioRecord.RECORDSTATE_STOPPED) {
                            mAudioRecord.startRecording();
                        }

                        if (mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED
                                && mAudioTrack.getState() == AudioTrack.STATE_INITIALIZED) {
                        if (mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED) {
                            mAudioTrack.play();
                        }
                        int size = mAudioRecord.read(buffer, 0, RECORD_BUF_SIZE);