aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-02-06 17:51:23 -0800
committerScott Jackson <daneren2005@gmail.com>2013-02-06 17:51:23 -0800
commitbfeb0640c7b4894ef3e1349d66028c4309ceba38 (patch)
tree926c6aaa8f9916f296d064b2eee47342966020b4 /subsonic-android/src
parent4fdaa88b473a210472b638995608a0a2c9f6ac15 (diff)
downloaddsub-bfeb0640c7b4894ef3e1349d66028c4309ceba38.tar.gz
dsub-bfeb0640c7b4894ef3e1349d66028c4309ceba38.tar.bz2
dsub-bfeb0640c7b4894ef3e1349d66028c4309ceba38.zip
Only load visualizer when started
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java8
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java1
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java1
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java39
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java4
6 files changed, 36 insertions, 21 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
index dd5b3f0a..f6017a54 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
@@ -343,8 +343,8 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
downloadService.setShufflePlayEnabled(true);
}
- boolean visualizerAvailable = downloadService != null && downloadService.getVisualizerController() != null;
- boolean equalizerAvailable = downloadService != null && downloadService.getEqualizerController() != null;
+ boolean visualizerAvailable = downloadService != null && downloadService.getVisualizerAvailable();
+ boolean equalizerAvailable = downloadService != null && downloadService.getEqualizerAvailable();
if (!equalizerAvailable) {
equalizerButton.setVisibility(View.GONE);
@@ -400,8 +400,8 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
- if (visualizerView != null) {
- visualizerView.setActive(downloadService != null && downloadService.getShowVisualization());
+ if (visualizerView != null && downloadService != null && downloadService.getShowVisualization()) {
+ visualizerView.setActive(true);
}
updateButtons();
diff --git a/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java b/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java
index f16ff968..4206b156 100644
--- a/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java
+++ b/subsonic-android/src/github/daneren2005/dsub/audiofx/EqualizerController.java
@@ -56,6 +56,7 @@ public class EqualizerController {
}
public EqualizerController(Context context, MediaPlayer mediaPlayer) {
+ Log.d(TAG, "Setting up equalizer");
this.context = context;
try {
equalizer = new Equalizer(0, mediaPlayer.getAudioSessionId());
diff --git a/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java b/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java
index 184aeb51..dc46ee18 100644
--- a/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java
+++ b/subsonic-android/src/github/daneren2005/dsub/audiofx/VisualizerController.java
@@ -54,6 +54,7 @@ public class VisualizerController {
}
public VisualizerController(Context context, MediaPlayer mediaPlayer) {
+ Log.d(TAG, "Setting up visualizer");
this.context = context;
try {
visualizer = new Visualizer(mediaPlayer.getAudioSessionId());
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
index 663a6e6c..0536c198 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
@@ -106,6 +106,10 @@ public interface DownloadService {
void setSuggestedPlaylistName(String name);
String getSuggestedPlaylistName();
+
+ boolean getEqualizerAvailable();
+
+ boolean getVisualizerAvailable();
EqualizerController getEqualizerController();
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 72198850..340ff179 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -158,21 +158,6 @@ public class DownloadServiceImpl extends Service implements DownloadService {
mRemoteControl.register(this, mediaButtonReceiverComponent);
}
- if (equalizerAvailable) {
- equalizerController = new EqualizerController(this, mediaPlayer);
- if (!equalizerController.isAvailable()) {
- equalizerController = null;
- } else {
- equalizerController.loadSettings();
- }
- }
- if (visualizerAvailable) {
- visualizerController = new VisualizerController(this, mediaPlayer);
- if (!visualizerController.isAvailable()) {
- visualizerController = null;
- }
- }
-
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName());
wakeLock.setReferenceCounted(false);
@@ -781,14 +766,38 @@ public class DownloadServiceImpl extends Service implements DownloadService {
public String getSuggestedPlaylistName() {
return suggestedPlaylistName;
}
+
+ @Override
+ public boolean getEqualizerAvailable() {
+ return equalizerAvailable;
+ }
+
+ @Override
+ public boolean getVisualizerAvailable() {
+ return visualizerAvailable;
+ }
@Override
public EqualizerController getEqualizerController() {
+ if (equalizerAvailable && equalizerController == null) {
+ equalizerController = new EqualizerController(this, mediaPlayer);
+ if (!equalizerController.isAvailable()) {
+ equalizerController = null;
+ } else {
+ equalizerController.loadSettings();
+ }
+ }
return equalizerController;
}
@Override
public VisualizerController getVisualizerController() {
+ if (visualizerAvailable && visualizerController == null) {
+ visualizerController = new VisualizerController(this, mediaPlayer);
+ if (!visualizerController.isAvailable()) {
+ visualizerController = null;
+ }
+ }
return visualizerController;
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java b/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java
index 9bff3a2d..19097885 100644
--- a/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java
+++ b/subsonic-android/src/github/daneren2005/dsub/view/VisualizerView.java
@@ -45,14 +45,14 @@ public class VisualizerView extends View {
private byte[] data;
private float[] points;
- private boolean active;
+ private boolean active = false;
public VisualizerView(Context context) {
super(context);
paint.setStrokeWidth(2f);
paint.setAntiAlias(true);
- paint.setColor(Color.rgb(129, 201, 54));
+ paint.setColor(Color.rgb(51, 181, 229));
}
public boolean isActive() {