[Android] AudioPlayer: fix ConcurrentModificationException
Thomas Guillem
git at videolan.org
Tue Mar 28 11:46:23 CEST 2017
vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Mar 28 11:41:46 2017 +0200| [23bf14aad9145810cfc931e7fccbc394409abc62] | committer: Thomas Guillem
AudioPlayer: fix ConcurrentModificationException
showAudioPlayer() can modify the service callbacks and was called from a
service callback.
As addCallback() triggers a updateProgress() event, we can also init the
AudioPlayer from the onConnected() callback.
> https://code.videolan.org/videolan/vlc-android/commit/23bf14aad9145810cfc931e7fccbc394409abc62
---
.../vlc/gui/AudioPlayerContainerActivity.java | 25 ++++------------------
1 file changed, 4 insertions(+), 21 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index ba8a614..cf2d080 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -48,7 +48,6 @@ import android.widget.TextView;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.MediaPlayer;
-import org.videolan.medialibrary.Medialibrary;
import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.MediaParsingService;
import org.videolan.vlc.PlaybackService;
@@ -58,14 +57,13 @@ import org.videolan.vlc.gui.audio.AudioPlayer;
import org.videolan.vlc.gui.browser.StorageBrowserFragment;
import org.videolan.vlc.interfaces.IRefreshable;
import org.videolan.vlc.media.MediaUtils;
-import org.videolan.vlc.util.FileUtils;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.WeakHandler;
import static org.videolan.vlc.MediaParsingService.EXTRA_PATH;
import static org.videolan.vlc.MediaParsingService.EXTRA_UUID;
-public class AudioPlayerContainerActivity extends BaseActivity implements PlaybackService.Client.Callback, PlaybackService.Callback {
+public class AudioPlayerContainerActivity extends BaseActivity implements PlaybackService.Client.Callback {
public static final String TAG = "VLC/AudioPlayerContainerActivity";
public static final String ACTION_SHOW_PLAYER = Strings.buildPkgString("gui.ShowPlayer");
@@ -318,21 +316,6 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
private static final int ACTION_MEDIA_MOUNTED = 1337;
private static final int ACTION_MEDIA_UNMOUNTED = 1338;
- @Override
- public void update() {}
-
- @Override
- public void updateProgress() {
- if (!isAudioPlayerReady())
- showAudioPlayer();
- }
-
- @Override
- public void onMediaEvent(Media.Event event) {}
-
- @Override
- public void onMediaPlayerEvent(MediaPlayer.Event event) {}
-
public boolean isAudioPlayerReady() {
return mAudioPlayer != null;
}
@@ -403,14 +386,14 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
@Override
public void onConnected(PlaybackService service) {
- service.addCallback(this);
mService = service;
+
+ if (!isAudioPlayerReady())
+ showAudioPlayer();
}
@Override
public void onDisconnected() {
- if (mService != null)
- mService.removeCallback(this);
mService = null;
}
}
More information about the Android
mailing list