Handle unsupported equalizer
This commit is contained in:
parent
7876993a11
commit
ee9f8b05ae
@ -370,7 +370,11 @@ public final class PlaybackService extends Service
|
|||||||
mMediaPlayer.setOnErrorListener(this);
|
mMediaPlayer.setOnErrorListener(this);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
|
||||||
mEqualizer = new CompatEq(mMediaPlayer);
|
try {
|
||||||
|
mEqualizer = new CompatEq(mMediaPlayer);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// equalizer not supported
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
|
mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
|
||||||
@ -559,9 +563,11 @@ public final class PlaybackService extends Service
|
|||||||
// In Gingerbread and above, MediaPlayer no longer accepts volumes
|
// In Gingerbread and above, MediaPlayer no longer accepts volumes
|
||||||
// > 1.0. So we use an equalizer instead.
|
// > 1.0. So we use an equalizer instead.
|
||||||
CompatEq eq = mEqualizer;
|
CompatEq eq = mEqualizer;
|
||||||
short gain = (short)(2000 * Math.log10(base));
|
if (eq != null) {
|
||||||
for (short i = eq.getNumberOfBands(); --i != -1; ) {
|
short gain = (short)(2000 * Math.log10(base));
|
||||||
eq.setBandLevel(i, gain);
|
for (short i = eq.getNumberOfBands(); --i != -1; ) {
|
||||||
|
eq.setBandLevel(i, gain);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
base = 1.0f;
|
base = 1.0f;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user