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

Commit 10ffc783 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

Audio player delayed start: don't throw exception

When the framework sets a delayed start on a PlayerBase instance
  (e.g. MediaPlayer or AudioTrack), catch the IllegalStateException
  that can be thrown if the player's state has changed by the time
  the actual start command gets executed.

Test: generate notifications played by NotificationPlayer
Bug 35019197

Change-Id: I51fd0305bc83b34e33fbcf9331f55627d32702f3
parent 49e57a2d
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1956,7 +1956,13 @@ public class AudioTrack extends PlayerBase
                        e.printStackTrace();
                    }
                    baseSetStartDelayMs(0);
                    try {
                        startImpl();
                    } catch (IllegalStateException e) {
                        // fail silently for a state exception when it is happening after
                        // a delayed start, as the player state could have changed between the
                        // call to start() and the execution of startImpl()
                    }
                }
            }.start();
        }
+7 −1
Original line number Diff line number Diff line
@@ -1258,7 +1258,13 @@ public class MediaPlayer extends PlayerBase
                        e.printStackTrace();
                    }
                    baseSetStartDelayMs(0);
                    try {
                        startImpl();
                    } catch (IllegalStateException e) {
                        // fail silently for a state exception when it is happening after
                        // a delayed start, as the player state could have changed between the
                        // call to start() and the execution of startImpl()
                    }
                }
            }.start();
        }