[Android] AudioService: fix a possible "Cannot draw recycled bitmaps" exception.
Adrien Maglo
git at videolan.org
Wed Apr 9 10:45:42 CEST 2014
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Wed Apr 9 10:45:33 2014 +0200| [353774a55f73523c413402548671557d37a69862] | committer: Adrien Maglo
AudioService: fix a possible "Cannot draw recycled bitmaps" exception.
Copy the cover bitmap for the RemoteControlClient as it can recycle it even if VLC GUI still needs it.
https://github.com/android/platform_frameworks_base/blob/master/media/java/android/media/RemoteControlClient.java#L512
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=353774a55f73523c413402548671557d37a69862
---
vlc-android/src/org/videolan/vlc/AudioService.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index 211ce84..689ac93 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -870,7 +870,9 @@ public class AudioService extends Service {
editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, media.getGenre());
editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, media.getTitle());
editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, media.getLength());
- editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, getCover());
+ // Copy the cover bitmap because the RemonteControlClient can recycle its artwork bitmap.
+ Bitmap cover = getCover();
+ editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, cover.copy(cover.getConfig(), false));
editor.apply();
}
}
More information about the Android
mailing list