aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/values-hu/strings.xml8
-rw-r--r--res/xml/settings.xml2
-rw-r--r--src/github/daneren2005/dsub/audiofx/EqualizerController.java9
-rw-r--r--src/github/daneren2005/dsub/fragments/MainFragment.java6
-rw-r--r--src/github/daneren2005/dsub/fragments/NowPlayingFragment.java22
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java16
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java44
-rw-r--r--src/github/daneren2005/dsub/service/OfflineMusicService.java14
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java11
9 files changed, 105 insertions, 27 deletions
diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml
index 6982d67a..6e0ff106 100644
--- a/res/values-hu/strings.xml
+++ b/res/values-hu/strings.xml
@@ -431,8 +431,12 @@
<string name="settings.admin_enabled">Admin engedélyezése</string>
<string name="settings.admin_enabled_summary">Admin menüpont megjelenítése az elhúzható oldalsávon.</string>
<string name="settings.replay_gain">Hangerő-kiegyenlítés (Replay Gain)</string>
- <string name="settings.replay_gain_summary">Hangerő kiegyenlítése (normalizálása) a dal és az album hangerőszint értékei alapján.</string>
- <string name="settings.replay_gain_bump">Hangerő-kiegyenlítés előerősítés</string>
+ <string name="settings.replay_gain_summary">Hangerő kiegyenlítése (normalizálása) a dal vagy az album hangerőszint értékei (tags) alapján.</string>
+ <string name="settings.replay_gain_type">Hangerőszint meghatározása</string>
+ <string name="settings.replay_gain_type.smart">Intelligens módon</string>
+ <string name="settings.replay_gain_type.album">Album értékeiből</string>
+ <string name="settings.replay_gain_type.track">Dal értékeiből</string>
+ <string name="settings.replay_gain_bump">Hangerő-kiegyenlítés előerősítése</string>
<string name="settings.replay_gain_untagged">Dalok hangerő-kiegyenlítés nélkül</string>
<string name="shuffle.title">Sorrend keverése</string>
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index 795ae39d..d0dcdc43 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -217,7 +217,7 @@
android:key="cacheSize"
android:defaultValue="2000"
android:dialogLayout="@layout/seekbar_preference"
- myns:max="50000"
+ myns:max="20000"
myns:display="%.0f MB"/>
<EditTextPreference
diff --git a/src/github/daneren2005/dsub/audiofx/EqualizerController.java b/src/github/daneren2005/dsub/audiofx/EqualizerController.java
index 4f0624d7..f170af0b 100644
--- a/src/github/daneren2005/dsub/audiofx/EqualizerController.java
+++ b/src/github/daneren2005/dsub/audiofx/EqualizerController.java
@@ -47,12 +47,8 @@ public class EqualizerController {
public EqualizerController(Context context, int audioSessionId) {
this.context = context;
- try {
- this.audioSessionId = audioSessionId;
- init();
- } catch (Throwable x) {
- Log.w(TAG, "Failed to create equalizer.", x);
- }
+ this.audioSessionId = audioSessionId;
+ init();
}
private void init() {
@@ -117,6 +113,7 @@ public class EqualizerController {
init();
} catch (Throwable x) {
equalizer = null;
+ released = true;
Log.w(TAG, "Failed to create equalizer.", x);
}
}
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java
index bbdc4de6..403bad03 100644
--- a/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -264,7 +264,7 @@ public class MainFragment extends SubsonicFragment {
// Clear out recently added count when viewing
if("newest".equals(type)) {
SharedPreferences.Editor editor = Util.getPreferences(context).edit();
- editor.putInt(Constants.PREFERENCES_KEY_RECENT_COUNT, 0);
+ editor.putInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), 0);
editor.commit();
// Clear immediately so doesn't still show when pressing back
@@ -467,7 +467,7 @@ public class MainFragment extends SubsonicFragment {
private void getMostRecentCount() {
// Use stashed value until after refresh occurs
SharedPreferences prefs = Util.getPreferences(context);
- final int startCount = prefs.getInt(Constants.PREFERENCES_KEY_RECENT_COUNT, 0);
+ final int startCount = prefs.getInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), 0);
setMostRecentCount(startCount);
new SilentBackgroundTask<Integer>(context) {
@@ -506,7 +506,7 @@ public class MainFragment extends SubsonicFragment {
// Add the old count which will get cleared out after viewing recents
count += startCount;
SharedPreferences.Editor editor = Util.getPreferences(context).edit();
- editor.putInt(Constants.PREFERENCES_KEY_RECENT_COUNT, count);
+ editor.putInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), count);
editor.commit();
return count;
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index 1f5c7b88..eb4ce5ab 100644
--- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -55,6 +55,7 @@ import android.widget.TextView;
import android.widget.ViewFlipper;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.activity.SubsonicFragmentActivity;
+import github.daneren2005.dsub.audiofx.EqualizerController;
import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.PlayerState;
import github.daneren2005.dsub.domain.RepeatMode;
@@ -574,7 +575,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
}
boolean equalizerAvailable = downloadService != null && downloadService.getEqualizerAvailable();
- if(equalizerAvailable) {
+ if(equalizerAvailable && !downloadService.isRemoteEnabled()) {
SharedPreferences prefs = Util.getPreferences(context);
boolean equalizerOn = prefs.getBoolean(Constants.PREFERENCES_EQUALIZER_ON, false);
if (equalizerOn && getDownloadService() != null && getDownloadService().getEqualizerController() != null &&
@@ -814,14 +815,19 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
return true;
case R.id.menu_equalizer: {
DownloadService downloadService = getDownloadService();
- if (downloadService != null && downloadService.getEqualizerController() != null
- && downloadService.getEqualizerController().getEqualizer() != null) {
- SubsonicFragment fragment = new EqualizerFragment();
- replaceFragment(fragment);
- setControlsVisible(true);
- } else {
- Util.toast(context, "Failed to start equalizer. Try restarting.");
+ if (downloadService != null) {
+ EqualizerController controller = downloadService.getEqualizerController();
+ if(controller != null) {
+ SubsonicFragment fragment = new EqualizerFragment();
+ replaceFragment(fragment);
+ setControlsVisible(true);
+
+ return true;
+ }
}
+
+ // Any failed condition will get here
+ Util.toast(context, "Failed to start equalizer. Try restarting.");
return true;
} default:
return false;
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index 70a3b027..68ca5189 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -1178,6 +1178,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
}
public void displaySongInfo(final Entry song) {
+ Integer duration = null;
Integer bitrate = null;
String format = null;
long size = 0;
@@ -1188,10 +1189,21 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
if(file.exists()) {
MediaMetadataRetriever metadata = new MediaMetadataRetriever();
metadata.setDataSource(file.getAbsolutePath());
- String tmp = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE);
- bitrate = Integer.parseInt((tmp != null) ? tmp : "0") / 1000;
+
+ String tmp = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
+ duration = Integer.parseInt((tmp != null) ? tmp : "0") / 1000;
format = FileUtil.getExtension(file.getName());
size = file.length();
+
+ // If no duration try to read bitrate tag
+ if(duration == null) {
+ tmp = metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE);
+ bitrate = Integer.parseInt((tmp != null) ? tmp : "0") / 1000;
+ } else {
+ // Otherwise do a calculation for it
+ // Divide by 1000 so in kbps
+ bitrate = (int) (size / duration) / 1000 * 8;
+ }
if(Util.isOffline(context)) {
song.setGenre(metadata.extractMetadata(MediaMetadataRetriever.METADATA_KEY_GENRE));
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 49a3bec1..90fb48d7 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -70,6 +70,7 @@ import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.audiofx.AudioEffect;
+import android.media.audiofx.Equalizer;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
@@ -1021,6 +1022,10 @@ public class DownloadService extends Service {
}
mediaPlayer.setOnErrorListener(null);
mediaPlayer.setOnCompletionListener(null);
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && nextSetup) {
+ mediaPlayer.setNextMediaPlayer(null);
+ nextSetup = false;
+ }
mediaPlayer.reset();
subtractPosition = 0;
} catch (Exception x) {
@@ -1210,7 +1215,42 @@ public class DownloadService extends Service {
}
public EqualizerController getEqualizerController() {
- return effectsController.getEqualizerController();
+ EqualizerController controller = null;
+ try {
+ controller = effectsController.getEqualizerController();
+ if(controller.getEqualizer() == null) {
+ throw new Exception("Failed to get EQ");
+ }
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to start EQ, retrying with new mediaPlayer: " + e);
+
+ // If we failed, we are going to try to reinitialize the MediaPlayer
+ boolean playing = playerState == STARTED;
+ int pos = getPlayerPosition();
+ mediaPlayer.pause();
+ Util.sleepQuietly(10L);
+ reset();
+
+ try {
+ // Resetup media player
+ mediaPlayer.setAudioSessionId(audioSessionId);
+ mediaPlayer.setDataSource(currentPlaying.getFile().getCanonicalPath());
+
+ controller = effectsController.getEqualizerController();
+ if(controller.getEqualizer() == null) {
+ throw new Exception("Failed to get EQ");
+ }
+ } catch(Exception e2) {
+ Log.w(TAG, "Failed to setup EQ even after reinitialization");
+ // Don't try again, just resetup media player and continue on
+ controller = null;
+ }
+
+ // Restart from same position and state we left off in
+ play(getCurrentPlayingIndex(), false, pos);
+ }
+
+ return controller;
}
public MediaRouteSelector getRemoteSelector() {
@@ -1393,7 +1433,7 @@ public class DownloadService extends Service {
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
}
String dataSource = file.getAbsolutePath();
- if(isPartial) {
+ if(isPartial && !Util.isOffline(this)) {
if (proxy == null) {
proxy = new BufferProxy(this);
proxy.start();
diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java
index 22b12cde..c26a2fc4 100644
--- a/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -428,12 +428,20 @@ public class OfflineMusicService implements MusicService {
if(!"#EXTM3U".equals(line)) return playlist;
while( (line = buffer.readLine()) != null ){
+ // No matter what, end file can't have .complete in it
+ line = line.replace(".complete", "");
File entryFile = new File(line);
- if(!entryFile.exists()) {
- entryFile = new File(line.replace(".complete", ""));
+
+ // Don't add file to playlist if it doesn't exist as cached or pinned!
+ File checkFile = entryFile;
+ if(!checkFile.exists()) {
+ // If normal file doens't exist, check if .complete version does
+ checkFile = new File(entryFile.getParent(), FileUtil.getBaseName(entryFile.getName())
+ + ".complete." + FileUtil.getExtension(entryFile.getName()));
}
+
String entryName = getName(entryFile);
- if(entryFile.exists() && entryName != null){
+ if(checkFile.exists() && entryName != null){
playlist.addChild(createEntry(context, entryFile, entryName, false));
}
}
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index ca937bcc..db1504f0 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -636,6 +636,12 @@ public class RESTMusicService implements MusicService {
}
byte[] bytes = Util.toByteArray(in);
+
+ // Handle case where partial was downloaded before being cancelled
+ if(task != null && task.isCancelled()) {
+ return null;
+ }
+
OutputStream out = null;
try {
out = new FileOutputStream(FileUtil.getAlbumArtFile(context, entry));
@@ -1351,6 +1357,11 @@ public class RESTMusicService implements MusicService {
}
byte[] bytes = Util.toByteArray(in);
+ if(task != null && task.isCancelled()) {
+ // Handle case where partial is downloaded and cancelled
+ return null;
+ }
+
OutputStream out = null;
try {
out = new FileOutputStream(FileUtil.getAvatarFile(context, username));