summaryrefslogtreecommitdiffstats
path: root/media/java
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2011-11-14 10:50:33 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-14 10:50:33 -0800
commit527c44e8a455dd0fdef1aeb6d7d8f99bb0839295 (patch)
tree118f8d3b784b29fc519957bba613d4339b04af36 /media/java
parentb14d771cf07479e3186a167a219fb2d42d8d4d30 (diff)
parent62b9aec7a0a4e1cf8cfec7e39ea3103ab510d72e (diff)
downloadframeworks_base-527c44e8a455dd0fdef1aeb6d7d8f99bb0839295.zip
frameworks_base-527c44e8a455dd0fdef1aeb6d7d8f99bb0839295.tar.gz
frameworks_base-527c44e8a455dd0fdef1aeb6d7d8f99bb0839295.tar.bz2
Merge "Don't check return value of new for being == null"
Diffstat (limited to 'media/java')
-rw-r--r--media/java/android/media/AudioService.java54
-rw-r--r--media/java/android/media/SoundPool.java10
-rw-r--r--media/java/android/media/ThumbnailUtils.java4
3 files changed, 29 insertions, 39 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index fe15605..a06afc8 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -1026,10 +1026,6 @@ public class AudioService extends IAudioService.Stub {
return true;
}
mSoundPool = new SoundPool(NUM_SOUNDPOOL_CHANNELS, AudioSystem.STREAM_SYSTEM, 0);
- if (mSoundPool == null) {
- Log.w(TAG, "loadSoundEffects() could not allocate sound pool");
- return false;
- }
try {
mSoundPoolCallBack = null;
@@ -2104,32 +2100,30 @@ public class AudioService extends IAudioService.Stub {
mSoundPool.play(SOUND_EFFECT_FILES_MAP[effectType][1], volFloat, volFloat, 0, 0, 1.0f);
} else {
MediaPlayer mediaPlayer = new MediaPlayer();
- if (mediaPlayer != null) {
- try {
- String filePath = Environment.getRootDirectory() + SOUND_EFFECTS_PATH + SOUND_EFFECT_FILES[SOUND_EFFECT_FILES_MAP[effectType][0]];
- mediaPlayer.setDataSource(filePath);
- mediaPlayer.setAudioStreamType(AudioSystem.STREAM_SYSTEM);
- mediaPlayer.prepare();
- mediaPlayer.setVolume(volFloat, volFloat);
- mediaPlayer.setOnCompletionListener(new OnCompletionListener() {
- public void onCompletion(MediaPlayer mp) {
- cleanupPlayer(mp);
- }
- });
- mediaPlayer.setOnErrorListener(new OnErrorListener() {
- public boolean onError(MediaPlayer mp, int what, int extra) {
- cleanupPlayer(mp);
- return true;
- }
- });
- mediaPlayer.start();
- } catch (IOException ex) {
- Log.w(TAG, "MediaPlayer IOException: "+ex);
- } catch (IllegalArgumentException ex) {
- Log.w(TAG, "MediaPlayer IllegalArgumentException: "+ex);
- } catch (IllegalStateException ex) {
- Log.w(TAG, "MediaPlayer IllegalStateException: "+ex);
- }
+ try {
+ String filePath = Environment.getRootDirectory() + SOUND_EFFECTS_PATH + SOUND_EFFECT_FILES[SOUND_EFFECT_FILES_MAP[effectType][0]];
+ mediaPlayer.setDataSource(filePath);
+ mediaPlayer.setAudioStreamType(AudioSystem.STREAM_SYSTEM);
+ mediaPlayer.prepare();
+ mediaPlayer.setVolume(volFloat, volFloat);
+ mediaPlayer.setOnCompletionListener(new OnCompletionListener() {
+ public void onCompletion(MediaPlayer mp) {
+ cleanupPlayer(mp);
+ }
+ });
+ mediaPlayer.setOnErrorListener(new OnErrorListener() {
+ public boolean onError(MediaPlayer mp, int what, int extra) {
+ cleanupPlayer(mp);
+ return true;
+ }
+ });
+ mediaPlayer.start();
+ } catch (IOException ex) {
+ Log.w(TAG, "MediaPlayer IOException: "+ex);
+ } catch (IllegalArgumentException ex) {
+ Log.w(TAG, "MediaPlayer IllegalArgumentException: "+ex);
+ } catch (IllegalStateException ex) {
+ Log.w(TAG, "MediaPlayer IllegalStateException: "+ex);
}
}
}
diff --git a/media/java/android/media/SoundPool.java b/media/java/android/media/SoundPool.java
index 5e9c018..0f68e98 100644
--- a/media/java/android/media/SoundPool.java
+++ b/media/java/android/media/SoundPool.java
@@ -161,12 +161,10 @@ public class SoundPool
int id = 0;
try {
File f = new File(path);
- if (f != null) {
- ParcelFileDescriptor fd = ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
- if (fd != null) {
- id = _load(fd.getFileDescriptor(), 0, f.length(), priority);
- fd.close();
- }
+ ParcelFileDescriptor fd = ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
+ if (fd != null) {
+ id = _load(fd.getFileDescriptor(), 0, f.length(), priority);
+ fd.close();
}
} catch (java.io.IOException e) {
Log.e(TAG, "error loading " + path);
diff --git a/media/java/android/media/ThumbnailUtils.java b/media/java/android/media/ThumbnailUtils.java
index 078d4af..b320515 100644
--- a/media/java/android/media/ThumbnailUtils.java
+++ b/media/java/android/media/ThumbnailUtils.java
@@ -472,9 +472,7 @@ public class ThumbnailUtils {
byte [] thumbData = null;
try {
exif = new ExifInterface(filePath);
- if (exif != null) {
- thumbData = exif.getThumbnail();
- }
+ thumbData = exif.getThumbnail();
} catch (IOException ex) {
Log.w(TAG, ex);
}