telecapoland/jamendo-android — pull request #26 by isdes (2012-09-10 17:34:03+00:00)
Title: Equalizer on ICS/JB

I think I have a solution for the Equalizer problem ([issue #24](https://github.com/telecapoland/jamendo-android/issues/24)).

The root cause was the fact that most probably on ICS+ versions Equalizer is bound to the lifetime of a MediaPlayer. As a result every time after MediaPlayer is released Equalizer needs to be released as well.

This caused some architectural changes - a global equalizer object can no longer be used (since it was valid only as long as the same song was playing).

There were two special cases to be handled (when the global equalizer is unavailable):
* the song is stopped (no MediaPlayer object) and we want to manipulate the equalizer
* we open the equalizer during one song, it finishes and the next one is played - then we manipulate the equalizer
Those cases needed to be covered by some kind of settings serialization and passing to the next Equalizer. Luckily, the Equalizer.Settings class have all what was needed for that purpose.

The global Equalizer object is used only when available (this is checked by the JamendoApplication.isEqualizerRunning method) to apply the settings in runtime. All other situations (no media playback) are covered using the Settings object instance passed to the newly created equalizer.

As a side effect I have implemented an Equalizer settings persistence mechanism to store settings between app launches.

Additionally I have found a typo in layout-mdpi/player.xml - pressing the Equalizer button was triggering 'Add to playlist' action.

I have added an additional permission (android.permission.MODIFY_AUDIO_SETTINGS) to the manifest. This was necessary to occasionally create a global Equalizer object to obtain some common settings (presets, number of bands and their level range) when the JamendoApplication.mEqualizer was not available.

I have verified this solution on Nexus S (JB), Sony Xperia P (ICS) and Samsung Galaxy Gio (GB). Seems to be working correctly.