From 263d1ba002731eaab3686ce7429b47356e5cd53f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 24 Aug 2021 22:11:54 +0200 Subject: [PATCH] Main: playlist_directory defaults to "/sdcard/Android/data/org.musicpd/files/playlists" Closes https://github.com/MusicPlayerDaemon/MPD/issues/1233 --- NEWS | 1 + src/Main.cxx | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3107a602f..770a72aca 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ ver 0.22.11 (not yet released) - ffmpeg: support double-precision samples (by converting to single precision) * Android - build with NDK r23 + - playlist_directory defaults to "/sdcard/Android/data/org.musicpd/files/playlists" ver 0.22.10 (2021/08/06) * protocol diff --git a/src/Main.cxx b/src/Main.cxx index 1a2a94ef5..c522fca61 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -157,7 +157,17 @@ glue_daemonize_init(const struct options *options, static void glue_mapper_init(const ConfigData &config) { - mapper_init(config.GetPath(ConfigOption::PLAYLIST_DIR)); + auto playlist_directory = config.GetPath(ConfigOption::PLAYLIST_DIR); + +#ifdef ANDROID + /* if there is no explicit configuration, store playlists in + "/sdcard/Android/data/org.musicpd/files/playlists" */ + if (playlist_directory.IsNull()) + playlist_directory = context->GetExternalFilesDir(Java::GetEnv(), + "playlists"); +#endif + + mapper_init(std::move(playlist_directory)); } #ifdef ENABLE_DATABASE