From b76d78e6aeae5a6e638194fed03bd003d5b9f49d Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Sun, 17 Mar 2019 18:04:40 +0100
Subject: [PATCH] output/sles: enable power saving mode

---
 NEWS                                         | 2 ++
 src/output/plugins/sles/SlesOutputPlugin.cxx | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/NEWS b/NEWS
index 0060ff1ff..d140a88bf 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ ver 0.21.6 (not yet released)
 * support abstract sockets on Linux
 * Windows
   - remove the unused libwinpthread-1.dll dependency
+* Android
+  - enable SLES power saving mode
 
 ver 0.21.5 (2019/02/22)
 * protocol
diff --git a/src/output/plugins/sles/SlesOutputPlugin.cxx b/src/output/plugins/sles/SlesOutputPlugin.cxx
index 3ebe08dfd..f1ef758e4 100644
--- a/src/output/plugins/sles/SlesOutputPlugin.cxx
+++ b/src/output/plugins/sles/SlesOutputPlugin.cxx
@@ -229,6 +229,14 @@ SlesOutput::Open(AudioFormat &audio_format)
 						    SL_ANDROID_KEY_STREAM_TYPE,
 						    &stream_type,
 						    sizeof(stream_type));
+
+		/* MPD doesn't care much about latency, so let's
+		   configure power saving mode */
+		SLuint32 performance_mode = SL_ANDROID_PERFORMANCE_POWER_SAVING;
+		(*android_config)->SetConfiguration(android_config,
+						    SL_ANDROID_KEY_PERFORMANCE_MODE,
+						    &performance_mode,
+						    sizeof(performance_mode));
 	}
 
 	result = play_object.Realize(false);