summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2011-11-07 11:10:16 -0800
committerGlenn Kasten <gkasten@google.com>2011-11-11 07:30:19 -0800
commit62b9aec7a0a4e1cf8cfec7e39ea3103ab510d72e (patch)
tree7fbec5605ee4f4f82bb4bd1a57d48af8eda5b367 /media
parente2d58e95a09590a63f1c597bb808b925bcab9a69 (diff)
downloadframeworks_base-62b9aec7a0a4e1cf8cfec7e39ea3103ab510d72e.zip
frameworks_base-62b9aec7a0a4e1cf8cfec7e39ea3103ab510d72e.tar.gz
frameworks_base-62b9aec7a0a4e1cf8cfec7e39ea3103ab510d72e.tar.bz2
Don't check return value of new for being == null
new either succeeds or throws an exception Change-Id: I1615e10c4f6730495c49e56b64714a00141ea8ff
Diffstat (limited to 'media')
-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 2f32bd8..459b145 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -1015,10 +1015,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;
@@ -2093,32 +2089,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);
}