Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
12147f6d58 | ||
![]() |
40bc60d6ae | ||
![]() |
7778210269 | ||
![]() |
6229210d51 | ||
![]() |
5d0d5b5d97 | ||
![]() |
1aa3c1e543 | ||
![]() |
b90e32fe4e | ||
![]() |
1f4df2a64d | ||
![]() |
2efc1db6a9 | ||
![]() |
e2d4654e20 | ||
![]() |
2b8f1170a6 | ||
![]() |
5c4743441e | ||
![]() |
cb288439a4 | ||
![]() |
69f741e8a6 | ||
![]() |
4b4f47002b | ||
![]() |
615c301961 | ||
![]() |
dc07180e48 | ||
![]() |
d3b235bab5 | ||
![]() |
7c920ddebe | ||
![]() |
bbc088ae4e | ||
![]() |
fe195257d8 | ||
![]() |
57d5df8118 | ||
![]() |
59792cb0b8 | ||
![]() |
cc557c4d60 | ||
![]() |
956c5faebb | ||
![]() |
cd0396c1f1 | ||
![]() |
79f9b268bb | ||
![]() |
b45f3c8deb | ||
![]() |
f8a8de87e4 | ||
![]() |
2183f0553c |
NEWS
android
doc
meson.buildpython/build
src
Main.cxxPartition.cxxPartition.hxxStateFile.cxx
android
command
decoder
filter
fs
input
plugins
java
lib
mixer
output
test
win32
15
NEWS
15
NEWS
@@ -1,3 +1,18 @@
|
||||
ver 0.23.9 (2022/08/18)
|
||||
* input
|
||||
- cdio_paranoia: add options "mode" and "skip"
|
||||
* decoder
|
||||
- ffmpeg: support FFmpeg 5.1
|
||||
* filter
|
||||
- replay gain: fix delayed volume display with handler=mixer
|
||||
* output
|
||||
- pipewire: set app icon
|
||||
* fix bogus volume levels with multiple partitions
|
||||
* improve iconv detection
|
||||
* macOS: fix macOS 10 build problem (0.23.8 regression)
|
||||
* Android
|
||||
- load mpd.conf from app data directory
|
||||
|
||||
ver 0.23.8 (2022/07/09)
|
||||
* storage
|
||||
- curl: fix crash if web server does not understand WebDAV
|
||||
|
@@ -2,10 +2,10 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.musicpd"
|
||||
android:installLocation="auto"
|
||||
android:versionCode="66"
|
||||
android:versionName="0.23.7">
|
||||
android:versionCode="68"
|
||||
android:versionName="0.23.9">
|
||||
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/>
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30"/>
|
||||
|
||||
<uses-feature android:name="android.software.leanback"
|
||||
android:required="false" />
|
||||
|
@@ -12,18 +12,30 @@ unsigned_apk = custom_target(
|
||||
],
|
||||
)
|
||||
|
||||
aligned_apk = custom_target(
|
||||
'mpd-aligned.apk',
|
||||
output: 'mpd-aligned.apk',
|
||||
input: unsigned_apk,
|
||||
command: [
|
||||
android_zipalign,
|
||||
'-f', '4',
|
||||
'@INPUT@', '@OUTPUT@',
|
||||
],
|
||||
)
|
||||
|
||||
if get_option('android_debug_keystore') != ''
|
||||
debug_apk = custom_target(
|
||||
'mpd-debug.apk',
|
||||
output: 'mpd-debug.apk',
|
||||
input: unsigned_apk,
|
||||
input: aligned_apk,
|
||||
command: [
|
||||
jarsigner,
|
||||
'-keystore', get_option('android_debug_keystore'),
|
||||
'-storepass', 'android',
|
||||
'-signedjar', '@OUTPUT@',
|
||||
'@INPUT@',
|
||||
'androiddebugkey',
|
||||
apksigner, 'sign',
|
||||
'--in', '@INPUT@',
|
||||
'--out', '@OUTPUT@',
|
||||
'--debuggable-apk-permitted',
|
||||
'-ks', get_option('android_debug_keystore'),
|
||||
'--ks-key-alias', 'androiddebugkey',
|
||||
'--ks-pass', 'pass:android',
|
||||
],
|
||||
build_by_default: true
|
||||
)
|
||||
@@ -31,29 +43,16 @@ endif
|
||||
|
||||
if get_option('android_keystore') != '' and get_option('android_keyalias') != '' and get_option('android_keypass') != ''
|
||||
unaligned_apk = custom_target(
|
||||
'mpd-unaligned.apk',
|
||||
output: 'mpd-unaligned.apk',
|
||||
input: unsigned_apk,
|
||||
command: [
|
||||
jarsigner,
|
||||
'-digestalg', 'SHA1', '-sigalg', 'MD5withRSA',
|
||||
'-keystore', get_option('android_keystore'),
|
||||
'-storepass', get_option('android_keypass'),
|
||||
'-signedjar', '@OUTPUT@',
|
||||
'@INPUT@',
|
||||
get_option('android_keyalias'),
|
||||
],
|
||||
)
|
||||
|
||||
apk = custom_target(
|
||||
'mpd.apk',
|
||||
output: 'mpd.apk',
|
||||
input: unaligned_apk,
|
||||
input: aligned_apk,
|
||||
command: [
|
||||
android_zipalign,
|
||||
'-f', '4',
|
||||
'@INPUT@', '@OUTPUT@',
|
||||
apksigner, 'sign',
|
||||
'--in', '@INPUT@',
|
||||
'--out', '@OUTPUT@',
|
||||
'-ks', get_option('android_keystore'),
|
||||
'--ks-key-alias', get_option('android_keyalias'),
|
||||
'--ks-pass', 'pass:' + get_option('android_keypass'),
|
||||
],
|
||||
build_by_default: true
|
||||
)
|
||||
endif
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env -S python3 -u
|
||||
|
||||
import os, os.path
|
||||
import sys, subprocess
|
||||
|
@@ -17,7 +17,7 @@ android_dx = join_paths(android_build_tools_dir, 'dx')
|
||||
android_zipalign = join_paths(android_build_tools_dir, 'zipalign')
|
||||
|
||||
javac = find_program('javac')
|
||||
jarsigner = find_program('jarsigner')
|
||||
apksigner = find_program('apksigner')
|
||||
rsvg_convert = find_program('rsvg-convert')
|
||||
convert = find_program('convert')
|
||||
zip = find_program('zip')
|
||||
|
@@ -38,7 +38,7 @@ author = 'Max Kellermann'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.23.8'
|
||||
version = '0.23.9'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
#release = version + '~git'
|
||||
|
||||
|
@@ -206,6 +206,11 @@ Plays audio CDs using libcdio. The URI has the form: "cdda://[DEVICE][/TRACK]".
|
||||
- If the CD drive does not specify a byte order, MPD assumes it is the CPU's native byte order. This setting allows overriding this.
|
||||
* - **speed N**
|
||||
- Request CDParanoia cap the extraction speed to Nx normal CD audio rotation speed, keeping the drive quiet.
|
||||
* - **mode disable|overlap|full**
|
||||
- Set the paranoia mode; ``disable`` means no fixups, ``overlap``
|
||||
performs overlapped reads, and ``full`` enables all options.
|
||||
* - **skip yes|no**
|
||||
- If set to ``no``, then never skip failed reads.
|
||||
|
||||
curl
|
||||
----
|
||||
|
@@ -36,7 +36,9 @@ Installing on Android
|
||||
|
||||
An experimental Android build is available on Google Play. After installing and launching it, :program:`MPD` will scan the music in your Music directory and you can control it as usual with a :program:`MPD` client.
|
||||
|
||||
If you need to tweak the configuration, you can create a file called :file:`mpd.conf` on the data partition (the directory which is returned by Android's :dfn:`getExternalStorageDirectory()` API function).
|
||||
If you need to tweak the configuration, you can create a file called
|
||||
:file:`mpd.conf` in MPD's data directory on the external storage
|
||||
(usually :file:`Android/data/org.musicpd/files/mpd.conf`).
|
||||
|
||||
ALSA is not available on Android; only the :ref:`OpenSL ES
|
||||
<sles_output>` output plugin can be used for local playback.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
project(
|
||||
'mpd',
|
||||
['c', 'cpp'],
|
||||
version: '0.23.8',
|
||||
version: '0.23.9',
|
||||
meson_version: '>= 0.56.0',
|
||||
default_options: [
|
||||
'c_std=c11',
|
||||
@@ -352,7 +352,7 @@ sources = [
|
||||
'src/TagStream.cxx',
|
||||
'src/TagAny.cxx',
|
||||
'src/TimePrint.cxx',
|
||||
'src/mixer/Volume.cxx',
|
||||
'src/mixer/Memento.cxx',
|
||||
'src/PlaylistFile.cxx',
|
||||
]
|
||||
|
||||
|
@@ -151,8 +151,8 @@ gme = CmakeProject(
|
||||
)
|
||||
|
||||
ffmpeg = FfmpegProject(
|
||||
'http://ffmpeg.org/releases/ffmpeg-5.0.1.tar.xz',
|
||||
'ef2efae259ce80a240de48ec85ecb062cecca26e4352ffb3fda562c21a93007b',
|
||||
'http://ffmpeg.org/releases/ffmpeg-5.1.tar.xz',
|
||||
'55eb6aab5ee235550fa54a33eaf8bf1b4ec66c01453182b12f6a993d75698b03',
|
||||
'lib/libavcodec.a',
|
||||
[
|
||||
'--disable-shared', '--enable-static',
|
||||
@@ -166,7 +166,6 @@ ffmpeg = FfmpegProject(
|
||||
'--disable-swscale',
|
||||
'--disable-postproc',
|
||||
'--disable-avfilter',
|
||||
'--disable-lzo',
|
||||
'--disable-faan',
|
||||
'--disable-pixelutils',
|
||||
'--disable-network',
|
||||
|
48
src/Main.cxx
48
src/Main.cxx
@@ -590,19 +590,46 @@ MainConfigured(const CommandLineOptions &options,
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
/**
|
||||
* Wrapper for ReadConfigFile() which returns false if the file was
|
||||
* not found.
|
||||
*/
|
||||
static bool
|
||||
TryReadConfigFile(ConfigData &config, Path path)
|
||||
{
|
||||
if (!FileExists(path))
|
||||
return false;
|
||||
|
||||
ReadConfigFile(config, path);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
AndroidMain()
|
||||
LoadConfigFile(JNIEnv *env, ConfigData &config)
|
||||
{
|
||||
/* try loading mpd.conf from
|
||||
"Android/data/org.musicpd/files/mpd.conf" (the app specific
|
||||
data directory) first */
|
||||
if (const auto dir = context->GetExternalFilesDir(env);
|
||||
!dir.IsNull() &&
|
||||
TryReadConfigFile(config, dir / Path::FromFS("mpd.conf")))
|
||||
return;
|
||||
|
||||
/* if that fails, attempt to load "mpd.conf" from the root of
|
||||
the SD card (pre-0.23.9, ceases to work since Android
|
||||
12) */
|
||||
if (const auto dir = Environment::getExternalStorageDirectory(env);
|
||||
!dir.IsNull())
|
||||
TryReadConfigFile(config, dir / Path::FromFS("mpd.conf"));
|
||||
}
|
||||
|
||||
static void
|
||||
AndroidMain(JNIEnv *env)
|
||||
{
|
||||
CommandLineOptions options;
|
||||
ConfigData raw_config;
|
||||
|
||||
const auto sdcard = Environment::getExternalStorageDirectory();
|
||||
if (!sdcard.IsNull()) {
|
||||
const auto config_path =
|
||||
sdcard / Path::FromFS("mpd.conf");
|
||||
if (FileExists(config_path))
|
||||
ReadConfigFile(raw_config, config_path);
|
||||
}
|
||||
LoadConfigFile(env, raw_config);
|
||||
|
||||
MainConfigured(options, raw_config);
|
||||
}
|
||||
@@ -614,9 +641,12 @@ Java_org_musicpd_Bridge_run(JNIEnv *env, jclass, jobject _context, jobject _logL
|
||||
Java::Init(env);
|
||||
Java::Object::Initialise(env);
|
||||
Java::File::Initialise(env);
|
||||
|
||||
Environment::Initialise(env);
|
||||
AtScopeExit(env) { Environment::Deinitialise(env); };
|
||||
|
||||
Context::Initialise(env);
|
||||
|
||||
context = new Context(env, _context);
|
||||
AtScopeExit() { delete context; };
|
||||
|
||||
@@ -625,7 +655,7 @@ Java_org_musicpd_Bridge_run(JNIEnv *env, jclass, jobject _context, jobject _logL
|
||||
AtScopeExit() { delete logListener; };
|
||||
|
||||
try {
|
||||
AndroidMain();
|
||||
AndroidMain(env);
|
||||
} catch (...) {
|
||||
LogError(std::current_exception());
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#include "Log.hxx"
|
||||
#include "lib/fmt/ExceptionFormatter.hxx"
|
||||
#include "song/DetachedSong.hxx"
|
||||
#include "mixer/Volume.hxx"
|
||||
#include "IdleFlags.hxx"
|
||||
#include "client/Listener.hxx"
|
||||
#include "client/Client.hxx"
|
||||
@@ -206,7 +205,7 @@ Partition::OnBorderPause() noexcept
|
||||
void
|
||||
Partition::OnMixerVolumeChanged(Mixer &, int) noexcept
|
||||
{
|
||||
InvalidateHardwareVolume();
|
||||
mixer_memento.InvalidateHardwareVolume();
|
||||
|
||||
/* notify clients */
|
||||
EmitIdle(IDLE_MIXER);
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "queue/Listener.hxx"
|
||||
#include "output/MultipleOutputs.hxx"
|
||||
#include "mixer/Listener.hxx"
|
||||
#include "mixer/Memento.hxx"
|
||||
#include "player/Control.hxx"
|
||||
#include "player/Listener.hxx"
|
||||
#include "protocol/RangeArg.hxx"
|
||||
@@ -76,6 +77,8 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
|
||||
|
||||
MultipleOutputs outputs;
|
||||
|
||||
MixerMemento mixer_memento;
|
||||
|
||||
PlayerControl pc;
|
||||
|
||||
ReplayGainMode replay_gain_mode = ReplayGainMode::OFF;
|
||||
|
@@ -27,7 +27,6 @@
|
||||
#include "storage/StorageState.hxx"
|
||||
#include "Partition.hxx"
|
||||
#include "Instance.hxx"
|
||||
#include "mixer/Volume.hxx"
|
||||
#include "SongLoader.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
@@ -47,7 +46,7 @@ StateFile::StateFile(StateFileConfig &&_config,
|
||||
void
|
||||
StateFile::RememberVersions() noexcept
|
||||
{
|
||||
prev_volume_version = sw_volume_state_get_hash();
|
||||
prev_volume_version = partition.mixer_memento.GetSoftwareVolumeStateHash();
|
||||
prev_output_version = audio_output_state_get_version();
|
||||
prev_playlist_version = playlist_state_get_hash(partition.playlist,
|
||||
partition.pc);
|
||||
@@ -59,7 +58,7 @@ StateFile::RememberVersions() noexcept
|
||||
bool
|
||||
StateFile::IsModified() const noexcept
|
||||
{
|
||||
return prev_volume_version != sw_volume_state_get_hash() ||
|
||||
return prev_volume_version != partition.mixer_memento.GetSoftwareVolumeStateHash() ||
|
||||
prev_output_version != audio_output_state_get_version() ||
|
||||
prev_playlist_version != playlist_state_get_hash(partition.playlist,
|
||||
partition.pc)
|
||||
@@ -72,7 +71,7 @@ StateFile::IsModified() const noexcept
|
||||
inline void
|
||||
StateFile::Write(BufferedOutputStream &os)
|
||||
{
|
||||
save_sw_volume_state(os);
|
||||
partition.mixer_memento.SaveSoftwareVolumeState(os);
|
||||
audio_output_state_save(os, partition.outputs);
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
@@ -125,7 +124,7 @@ try {
|
||||
|
||||
const char *line;
|
||||
while ((line = file.ReadLine()) != nullptr) {
|
||||
success = read_sw_volume_state(line, partition.outputs) ||
|
||||
success = partition.mixer_memento.LoadSoftwareVolumeState(line, partition.outputs) ||
|
||||
audio_output_state_read(line, partition.outputs) ||
|
||||
playlist_state_restore(config, line, file, song_loader,
|
||||
partition.playlist,
|
||||
|
@@ -26,19 +26,30 @@
|
||||
|
||||
#include "AudioManager.hxx"
|
||||
|
||||
static jmethodID getExternalFilesDir_method,
|
||||
getCacheDir_method,
|
||||
getSystemService_method;
|
||||
|
||||
void
|
||||
Context::Initialise(JNIEnv *env) noexcept
|
||||
{
|
||||
Java::Class cls{env, "android/content/Context"};
|
||||
|
||||
getExternalFilesDir_method = env->GetMethodID(cls, "getExternalFilesDir",
|
||||
"(Ljava/lang/String;)Ljava/io/File;");
|
||||
getCacheDir_method = env->GetMethodID(cls, "getCacheDir",
|
||||
"()Ljava/io/File;");
|
||||
getSystemService_method = env->GetMethodID(cls, "getSystemService",
|
||||
"(Ljava/lang/String;)Ljava/lang/Object;");
|
||||
}
|
||||
|
||||
AllocatedPath
|
||||
Context::GetExternalFilesDir(JNIEnv *env, const char *_type) noexcept
|
||||
Context::GetExternalFilesDir(JNIEnv *env, const char *type) noexcept
|
||||
{
|
||||
assert(_type != nullptr);
|
||||
|
||||
Java::Class cls{env, env->GetObjectClass(Get())};
|
||||
jmethodID method = env->GetMethodID(cls, "getExternalFilesDir",
|
||||
"(Ljava/lang/String;)Ljava/io/File;");
|
||||
assert(method);
|
||||
|
||||
Java::String type{env, _type};
|
||||
|
||||
jobject file = env->CallObjectMethod(Get(), method, type.Get());
|
||||
jobject file = env->CallObjectMethod(Get(), getExternalFilesDir_method,
|
||||
Java::String::Optional(env, type).Get());
|
||||
if (Java::DiscardException(env) || file == nullptr)
|
||||
return nullptr;
|
||||
|
||||
@@ -50,12 +61,7 @@ Context::GetCacheDir(JNIEnv *env) const noexcept
|
||||
{
|
||||
assert(env != nullptr);
|
||||
|
||||
Java::Class cls(env, env->GetObjectClass(Get()));
|
||||
jmethodID method = env->GetMethodID(cls, "getCacheDir",
|
||||
"()Ljava/io/File;");
|
||||
assert(method);
|
||||
|
||||
jobject file = env->CallObjectMethod(Get(), method);
|
||||
jobject file = env->CallObjectMethod(Get(), getCacheDir_method);
|
||||
if (Java::DiscardException(env) || file == nullptr)
|
||||
return nullptr;
|
||||
|
||||
@@ -67,13 +73,8 @@ Context::GetAudioManager(JNIEnv *env) noexcept
|
||||
{
|
||||
assert(env != nullptr);
|
||||
|
||||
Java::Class cls(env, env->GetObjectClass(Get()));
|
||||
jmethodID method = env->GetMethodID(cls, "getSystemService",
|
||||
"(Ljava/lang/String;)Ljava/lang/Object;");
|
||||
assert(method);
|
||||
|
||||
Java::String name(env, "audio");
|
||||
jobject am = env->CallObjectMethod(Get(), method, name.Get());
|
||||
jobject am = env->CallObjectMethod(Get(), getSystemService_method, name.Get());
|
||||
if (Java::DiscardException(env) || am == nullptr)
|
||||
return nullptr;
|
||||
|
||||
|
@@ -27,12 +27,21 @@ class AudioManager;
|
||||
|
||||
class Context : public Java::GlobalObject {
|
||||
public:
|
||||
/**
|
||||
* Global initialisation. Looks up the methods of the
|
||||
* Context Java class.
|
||||
*/
|
||||
static void Initialise(JNIEnv *env) noexcept;
|
||||
|
||||
Context(JNIEnv *env, jobject obj) noexcept
|
||||
:Java::GlobalObject(env, obj) {}
|
||||
|
||||
/**
|
||||
* @param type the subdirectory name; may be nullptr
|
||||
*/
|
||||
[[gnu::pure]]
|
||||
AllocatedPath GetExternalFilesDir(JNIEnv *env,
|
||||
const char *type) noexcept;
|
||||
const char *type=nullptr) noexcept;
|
||||
|
||||
[[gnu::pure]]
|
||||
AllocatedPath GetCacheDir(JNIEnv *env) const noexcept;
|
||||
|
@@ -25,13 +25,13 @@
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
|
||||
namespace Environment {
|
||||
static Java::TrivialClass cls;
|
||||
static jmethodID getExternalStorageDirectory_method;
|
||||
static jmethodID getExternalStoragePublicDirectory_method;
|
||||
}
|
||||
|
||||
static Java::TrivialClass cls;
|
||||
static jmethodID getExternalStorageDirectory_method;
|
||||
static jmethodID getExternalStoragePublicDirectory_method;
|
||||
|
||||
void
|
||||
Environment::Initialise(JNIEnv *env) noexcept
|
||||
Initialise(JNIEnv *env) noexcept
|
||||
{
|
||||
cls.Find(env, "android/os/Environment");
|
||||
|
||||
@@ -45,16 +45,14 @@ Environment::Initialise(JNIEnv *env) noexcept
|
||||
}
|
||||
|
||||
void
|
||||
Environment::Deinitialise(JNIEnv *env) noexcept
|
||||
Deinitialise(JNIEnv *env) noexcept
|
||||
{
|
||||
cls.Clear(env);
|
||||
}
|
||||
|
||||
AllocatedPath
|
||||
Environment::getExternalStorageDirectory() noexcept
|
||||
getExternalStorageDirectory(JNIEnv *env) noexcept
|
||||
{
|
||||
JNIEnv *env = Java::GetEnv();
|
||||
|
||||
jobject file =
|
||||
env->CallStaticObjectMethod(cls,
|
||||
getExternalStorageDirectory_method);
|
||||
@@ -65,20 +63,20 @@ Environment::getExternalStorageDirectory() noexcept
|
||||
}
|
||||
|
||||
AllocatedPath
|
||||
Environment::getExternalStoragePublicDirectory(const char *type) noexcept
|
||||
getExternalStoragePublicDirectory(JNIEnv *env, const char *type) noexcept
|
||||
{
|
||||
if (getExternalStoragePublicDirectory_method == nullptr)
|
||||
/* needs API level 8 */
|
||||
return nullptr;
|
||||
|
||||
JNIEnv *env = Java::GetEnv();
|
||||
|
||||
Java::String type2(env, type);
|
||||
jobject file = env->CallStaticObjectMethod(Environment::cls,
|
||||
Environment::getExternalStoragePublicDirectory_method,
|
||||
jobject file = env->CallStaticObjectMethod(cls,
|
||||
getExternalStoragePublicDirectory_method,
|
||||
type2.Get());
|
||||
if (file == nullptr)
|
||||
return nullptr;
|
||||
|
||||
return Java::File::ToAbsolutePath(env, file);
|
||||
}
|
||||
|
||||
} // namespace Environment
|
||||
|
@@ -17,27 +17,29 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_ANDROID_ENVIRONMENT_HXX
|
||||
#define MPD_ANDROID_ENVIRONMENT_HXX
|
||||
|
||||
#include "util/Compiler.h"
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
class AllocatedPath;
|
||||
|
||||
namespace Environment {
|
||||
void Initialise(JNIEnv *env) noexcept;
|
||||
void Deinitialise(JNIEnv *env) noexcept;
|
||||
|
||||
/**
|
||||
* Determine the mount point of the external SD card.
|
||||
*/
|
||||
[[gnu::pure]]
|
||||
AllocatedPath getExternalStorageDirectory() noexcept;
|
||||
void
|
||||
Initialise(JNIEnv *env) noexcept;
|
||||
|
||||
[[gnu::pure]]
|
||||
AllocatedPath getExternalStoragePublicDirectory(const char *type) noexcept;
|
||||
}
|
||||
void
|
||||
Deinitialise(JNIEnv *env) noexcept;
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Determine the mount point of the external SD card.
|
||||
*/
|
||||
[[gnu::pure]]
|
||||
AllocatedPath
|
||||
getExternalStorageDirectory(JNIEnv *env) noexcept;
|
||||
|
||||
[[gnu::pure]]
|
||||
AllocatedPath
|
||||
getExternalStoragePublicDirectory(JNIEnv *env, const char *type) noexcept;
|
||||
|
||||
} // namespace Environment
|
||||
|
@@ -33,7 +33,6 @@
|
||||
#include "TimePrint.hxx"
|
||||
#include "decoder/DecoderPrint.hxx"
|
||||
#include "ls.hxx"
|
||||
#include "mixer/Volume.hxx"
|
||||
#include "time/ChronoUtil.hxx"
|
||||
#include "util/UriUtil.hxx"
|
||||
#include "util/StringAPI.hxx"
|
||||
@@ -325,7 +324,7 @@ handle_getvol(Client &client, Request, Response &r)
|
||||
{
|
||||
auto &partition = client.GetPartition();
|
||||
|
||||
const auto volume = volume_level_get(partition.outputs);
|
||||
const auto volume = partition.mixer_memento.GetVolume(partition.outputs);
|
||||
if (volume >= 0)
|
||||
r.Fmt(FMT_STRING("volume: {}\n"), volume);
|
||||
|
||||
@@ -337,7 +336,9 @@ handle_setvol(Client &client, Request args, Response &)
|
||||
{
|
||||
unsigned level = args.ParseUnsigned(0, 100);
|
||||
|
||||
volume_level_change(client.GetPartition().outputs, level);
|
||||
auto &partition = client.GetPartition();
|
||||
partition.mixer_memento.SetVolume(partition.outputs, level);
|
||||
partition.EmitIdle(IDLE_MIXER);
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
@@ -346,9 +347,11 @@ handle_volume(Client &client, Request args, Response &r)
|
||||
{
|
||||
int relative = args.ParseInt(0, -100, 100);
|
||||
|
||||
auto &outputs = client.GetPartition().outputs;
|
||||
auto &partition = client.GetPartition();
|
||||
auto &outputs = partition.outputs;
|
||||
auto &mixer_memento = partition.mixer_memento;
|
||||
|
||||
const int old_volume = volume_level_get(outputs);
|
||||
const int old_volume = mixer_memento.GetVolume(outputs);
|
||||
if (old_volume < 0) {
|
||||
r.Error(ACK_ERROR_SYSTEM, "No mixer");
|
||||
return CommandResult::ERROR;
|
||||
@@ -360,8 +363,10 @@ handle_volume(Client &client, Request args, Response &r)
|
||||
else if (new_volume > 100)
|
||||
new_volume = 100;
|
||||
|
||||
if (new_volume != old_volume)
|
||||
volume_level_change(outputs, new_volume);
|
||||
if (new_volume != old_volume) {
|
||||
mixer_memento.SetVolume(outputs, new_volume);
|
||||
partition.EmitIdle(IDLE_MIXER);
|
||||
}
|
||||
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
@@ -33,7 +33,11 @@ handle_enableoutput(Client &client, Request args, Response &r)
|
||||
assert(args.size == 1);
|
||||
unsigned device = args.ParseUnsigned(0);
|
||||
|
||||
if (!audio_output_enable_index(client.GetPartition().outputs, device)) {
|
||||
auto &partition = client.GetPartition();
|
||||
|
||||
if (!audio_output_enable_index(partition.outputs,
|
||||
partition.mixer_memento,
|
||||
device)) {
|
||||
r.Error(ACK_ERROR_NO_EXIST, "No such audio output");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
@@ -47,7 +51,11 @@ handle_disableoutput(Client &client, Request args, Response &r)
|
||||
assert(args.size == 1);
|
||||
unsigned device = args.ParseUnsigned(0);
|
||||
|
||||
if (!audio_output_disable_index(client.GetPartition().outputs, device)) {
|
||||
auto &partition = client.GetPartition();
|
||||
|
||||
if (!audio_output_disable_index(partition.outputs,
|
||||
partition.mixer_memento,
|
||||
device)) {
|
||||
r.Error(ACK_ERROR_NO_EXIST, "No such audio output");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
@@ -61,7 +69,11 @@ handle_toggleoutput(Client &client, Request args, Response &r)
|
||||
assert(args.size == 1);
|
||||
unsigned device = args.ParseUnsigned(0);
|
||||
|
||||
if (!audio_output_toggle_index(client.GetPartition().outputs, device)) {
|
||||
auto &partition = client.GetPartition();
|
||||
|
||||
if (!audio_output_toggle_index(partition.outputs,
|
||||
partition.mixer_memento,
|
||||
device)) {
|
||||
r.Error(ACK_ERROR_NO_EXIST, "No such audio output");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include "SingleMode.hxx"
|
||||
#include "client/Client.hxx"
|
||||
#include "client/Response.hxx"
|
||||
#include "mixer/Volume.hxx"
|
||||
#include "Partition.hxx"
|
||||
#include "Instance.hxx"
|
||||
#include "IdleFlags.hxx"
|
||||
@@ -131,7 +130,7 @@ handle_status(Client &client, [[maybe_unused]] Request args, Response &r)
|
||||
|
||||
const auto &playlist = partition.playlist;
|
||||
|
||||
const auto volume = volume_level_get(partition.outputs);
|
||||
const auto volume = partition.mixer_memento.GetVolume(partition.outputs);
|
||||
if (volume >= 0)
|
||||
r.Fmt(FMT_STRING("volume: {}\n"), volume);
|
||||
|
||||
|
@@ -523,9 +523,15 @@ FfmpegDecode(DecoderClient &client, InputStream *input,
|
||||
return;
|
||||
}
|
||||
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100)
|
||||
const unsigned channels = codec_context->ch_layout.nb_channels;
|
||||
#else
|
||||
const unsigned channels = codec_context->channels;
|
||||
#endif
|
||||
|
||||
const auto audio_format = CheckAudioFormat(codec_context->sample_rate,
|
||||
sample_format,
|
||||
codec_context->channels);
|
||||
channels);
|
||||
|
||||
const SignedSongTime total_time =
|
||||
av_stream.duration != (int64_t)AV_NOPTS_VALUE
|
||||
@@ -635,10 +641,17 @@ FfmpegScanStream(AVFormatContext &format_context, TagHandler &handler)
|
||||
AV_TIME_BASE_Q));
|
||||
|
||||
const auto &codec_params = *stream.codecpar;
|
||||
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100)
|
||||
const unsigned channels = codec_params.ch_layout.nb_channels;
|
||||
#else
|
||||
const unsigned channels = codec_params.channels;
|
||||
#endif
|
||||
|
||||
try {
|
||||
handler.OnAudioFormat(CheckAudioFormat(codec_params.sample_rate,
|
||||
ffmpeg_sample_format(AVSampleFormat(codec_params.format)),
|
||||
codec_params.channels));
|
||||
channels));
|
||||
} catch (...) {
|
||||
}
|
||||
|
||||
|
@@ -21,10 +21,13 @@
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
|
||||
#include "FfmpegIo.hxx"
|
||||
#include "libavutil/mem.h"
|
||||
#include "../DecoderAPI.hxx"
|
||||
#include "input/InputStream.hxx"
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/mem.h>
|
||||
}
|
||||
|
||||
AvioStream::~AvioStream()
|
||||
{
|
||||
if (io != nullptr) {
|
||||
|
@@ -40,10 +40,15 @@ FfmpegFilter::FfmpegFilter(const AudioFormat &in_audio_format,
|
||||
buffer_sink(_buffer_sink),
|
||||
in_format(Ffmpeg::ToFfmpegSampleFormat(in_audio_format.format)),
|
||||
in_sample_rate(in_audio_format.sample_rate),
|
||||
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(57, 25, 100)
|
||||
in_channels(in_audio_format.channels),
|
||||
#endif
|
||||
in_audio_frame_size(in_audio_format.GetFrameSize()),
|
||||
out_audio_frame_size(_out_audio_format.GetFrameSize())
|
||||
{
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100)
|
||||
av_channel_layout_default(&in_ch_layout, in_audio_format.channels);
|
||||
#endif
|
||||
}
|
||||
|
||||
ConstBuffer<void>
|
||||
@@ -54,7 +59,11 @@ FfmpegFilter::FilterPCM(ConstBuffer<void> src)
|
||||
frame.Unref();
|
||||
frame->format = in_format;
|
||||
frame->sample_rate = in_sample_rate;
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100)
|
||||
frame->ch_layout = in_ch_layout;
|
||||
#else
|
||||
frame->channels = in_channels;
|
||||
#endif
|
||||
frame->nb_samples = src.size / in_audio_frame_size;
|
||||
|
||||
frame.GetBuffer();
|
||||
|
@@ -35,7 +35,13 @@ class FfmpegFilter final : public Filter {
|
||||
|
||||
FfmpegBuffer interleave_buffer;
|
||||
|
||||
const int in_format, in_sample_rate, in_channels;
|
||||
const int in_format, in_sample_rate;
|
||||
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100)
|
||||
AVChannelLayout in_ch_layout;
|
||||
#else
|
||||
const int in_channels;
|
||||
#endif
|
||||
|
||||
const size_t in_audio_frame_size;
|
||||
const size_t out_audio_frame_size;
|
||||
|
@@ -23,6 +23,8 @@
|
||||
#include "ReplayGainInfo.hxx"
|
||||
#include "ReplayGainConfig.hxx"
|
||||
#include "mixer/MixerControl.hxx"
|
||||
#include "mixer/MixerInternal.hxx"
|
||||
#include "mixer/Listener.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "pcm/Volume.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
@@ -171,9 +173,11 @@ ReplayGainFilter::Update()
|
||||
try {
|
||||
mixer_set_volume(mixer, _volume);
|
||||
|
||||
/* TODO: emit this idle event only for the
|
||||
current partition */
|
||||
idle_add(IDLE_MIXER);
|
||||
/* invoke the mixer's listener manually, just
|
||||
in case the mixer implementation didn't do
|
||||
that already (this depends on the
|
||||
implementation) */
|
||||
mixer->listener.OnMixerVolumeChanged(*mixer, _volume);
|
||||
} catch (...) {
|
||||
LogError(std::current_exception(),
|
||||
"Failed to update hardware mixer");
|
||||
|
@@ -254,7 +254,8 @@ GetUserMusicDir() noexcept
|
||||
#elif defined(USE_XDG)
|
||||
return GetUserDir("XDG_MUSIC_DIR");
|
||||
#elif defined(ANDROID)
|
||||
return Environment::getExternalStoragePublicDirectory("Music");
|
||||
return Environment::getExternalStoragePublicDirectory(Java::GetEnv(),
|
||||
"Music");
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
|
@@ -45,6 +45,14 @@
|
||||
|
||||
#include <cdio/cd_types.h>
|
||||
|
||||
static constexpr Domain cdio_domain("cdio");
|
||||
|
||||
static bool default_reverse_endian;
|
||||
static unsigned speed = 0;
|
||||
|
||||
/* Default to full paranoia, but allow skipping sectors. */
|
||||
static int mode_flags = PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP;
|
||||
|
||||
class CdioParanoiaInputStream final : public InputStream {
|
||||
cdrom_drive_t *const drv;
|
||||
CdIo_t *const cdio;
|
||||
@@ -65,9 +73,7 @@ class CdioParanoiaInputStream final : public InputStream {
|
||||
lsn_from(_lsn_from),
|
||||
buffer_lsn(-1)
|
||||
{
|
||||
/* Set reading mode for full paranoia, but allow
|
||||
skipping sectors. */
|
||||
para.SetMode(PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP);
|
||||
para.SetMode(mode_flags);
|
||||
|
||||
/* seek to beginning of the track */
|
||||
para.Seek(lsn_from);
|
||||
@@ -98,11 +104,6 @@ class CdioParanoiaInputStream final : public InputStream {
|
||||
void Seek(std::unique_lock<Mutex> &lock, offset_type offset) override;
|
||||
};
|
||||
|
||||
static constexpr Domain cdio_domain("cdio");
|
||||
|
||||
static bool default_reverse_endian;
|
||||
static unsigned speed = 0;
|
||||
|
||||
static void
|
||||
input_cdio_init(EventLoop &, const ConfigBlock &block)
|
||||
{
|
||||
@@ -117,6 +118,26 @@ input_cdio_init(EventLoop &, const ConfigBlock &block)
|
||||
value);
|
||||
}
|
||||
speed = block.GetBlockValue("speed",0U);
|
||||
|
||||
if (const auto *param = block.GetBlockParam("mode")) {
|
||||
param->With([](const char *s){
|
||||
if (StringIsEqual(s, "disable"))
|
||||
mode_flags = PARANOIA_MODE_DISABLE;
|
||||
else if (StringIsEqual(s, "overlap"))
|
||||
mode_flags = PARANOIA_MODE_OVERLAP;
|
||||
else if (StringIsEqual(s, "full"))
|
||||
mode_flags = PARANOIA_MODE_FULL;
|
||||
else
|
||||
throw std::invalid_argument{"Invalid paranoia mode"};
|
||||
});
|
||||
}
|
||||
|
||||
if (const auto *param = block.GetBlockParam("skip")) {
|
||||
if (param->GetBoolValue())
|
||||
mode_flags &= ~PARANOIA_MODE_NEVERSKIP;
|
||||
else
|
||||
mode_flags |= PARANOIA_MODE_NEVERSKIP;
|
||||
}
|
||||
}
|
||||
|
||||
struct CdioUri {
|
||||
|
@@ -89,6 +89,16 @@ public:
|
||||
String(JNIEnv *_env, const char *_value) noexcept
|
||||
:LocalRef<jstring>(_env, _env->NewStringUTF(_value)) {}
|
||||
|
||||
/**
|
||||
* This constructor allows passing a nullptr value, which maps
|
||||
* to a "null" in Java.
|
||||
*/
|
||||
static String Optional(JNIEnv *_env, const char *_value) noexcept {
|
||||
return _value != nullptr
|
||||
? String{_env, _value}
|
||||
: String{};
|
||||
}
|
||||
|
||||
static StringUTFChars GetUTFChars(JNIEnv *env, jstring s) noexcept {
|
||||
return {env, s, env->GetStringUTFChars(s, nullptr)};
|
||||
}
|
||||
|
@@ -48,7 +48,11 @@ DetectFilterOutputFormat(const AudioFormat &in_audio_format,
|
||||
Frame frame;
|
||||
frame->format = ToFfmpegSampleFormat(in_audio_format.format);
|
||||
frame->sample_rate = in_audio_format.sample_rate;
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100)
|
||||
av_channel_layout_default(&frame->ch_layout, in_audio_format.channels);
|
||||
#else
|
||||
frame->channels = in_audio_format.channels;
|
||||
#endif
|
||||
frame->nb_samples = 1;
|
||||
|
||||
frame.GetBuffer();
|
||||
@@ -75,8 +79,14 @@ DetectFilterOutputFormat(const AudioFormat &in_audio_format,
|
||||
if (sample_format == SampleFormat::UNDEFINED)
|
||||
throw std::runtime_error("Unsupported FFmpeg sample format");
|
||||
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100)
|
||||
const unsigned out_channels = frame->ch_layout.nb_channels;
|
||||
#else
|
||||
const unsigned out_channels = frame->channels;
|
||||
#endif
|
||||
|
||||
return CheckAudioFormat(frame->sample_rate, sample_format,
|
||||
frame->channels);
|
||||
out_channels);
|
||||
}
|
||||
|
||||
} // namespace Ffmpeg
|
||||
|
@@ -38,7 +38,11 @@ InterleaveFrame(const AVFrame &frame, FfmpegBuffer &buffer)
|
||||
assert(frame.nb_samples > 0);
|
||||
|
||||
const auto format = AVSampleFormat(frame.format);
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100)
|
||||
const unsigned channels = frame.ch_layout.nb_channels;
|
||||
#else
|
||||
const unsigned channels = frame.channels;
|
||||
#endif
|
||||
const std::size_t n_frames = frame.nb_samples;
|
||||
|
||||
int plane_size;
|
||||
|
@@ -18,17 +18,25 @@ if icu_dep.found()
|
||||
'Util.cxx',
|
||||
'Init.cxx',
|
||||
]
|
||||
elif not get_option('iconv').disabled()
|
||||
# an installed iconv library will make the builtin iconv() unavailable,
|
||||
# so search for the library first and pass it as (possible) dependency
|
||||
iconv_dep = compiler.find_library('libiconv', required: false)
|
||||
have_iconv = compiler.has_function('iconv',
|
||||
dependencies: iconv_dep,
|
||||
prefix : '#include <iconv.h>')
|
||||
if not have_iconv and get_option('iconv').enabled()
|
||||
error('iconv() not available')
|
||||
else
|
||||
if meson.version().version_compare('>= 0.60')
|
||||
iconv_dep = dependency('iconv', required: get_option('iconv'))
|
||||
conf.set('HAVE_ICONV', iconv_dep.found())
|
||||
elif not get_option('iconv').disabled()
|
||||
iconv_open_snippet = '''#include <iconv.h>
|
||||
int main() {
|
||||
iconv_open("","");
|
||||
}'''
|
||||
have_iconv = compiler.links(iconv_open_snippet, name: 'iconv_open')
|
||||
if not have_iconv
|
||||
iconv_dep = compiler.find_library('iconv', required: false)
|
||||
have_iconv = compiler.links(iconv_open_snippet, dependencies: iconv_dep, name: 'iconv_open')
|
||||
endif
|
||||
if not have_iconv and get_option('iconv').enabled()
|
||||
error('iconv() not available')
|
||||
endif
|
||||
conf.set('HAVE_ICONV', have_iconv)
|
||||
endif
|
||||
conf.set('HAVE_ICONV', have_iconv)
|
||||
endif
|
||||
|
||||
icu = static_library(
|
||||
|
@@ -17,14 +17,11 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "Volume.hxx"
|
||||
#include "Memento.hxx"
|
||||
#include "output/MultipleOutputs.hxx"
|
||||
#include "Idle.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "system/PeriodClock.hxx"
|
||||
#include "io/BufferedOutputStream.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@@ -32,24 +29,8 @@
|
||||
|
||||
#define SW_VOLUME_STATE "sw_volume: "
|
||||
|
||||
static constexpr Domain volume_domain("volume");
|
||||
|
||||
static unsigned volume_software_set = 100;
|
||||
|
||||
/** the cached hardware mixer value; invalid if negative */
|
||||
static int last_hardware_volume = -1;
|
||||
/** the age of #last_hardware_volume */
|
||||
static PeriodClock hardware_volume_clock;
|
||||
|
||||
void
|
||||
InvalidateHardwareVolume() noexcept
|
||||
{
|
||||
/* flush the hardware volume cache */
|
||||
last_hardware_volume = -1;
|
||||
}
|
||||
|
||||
int
|
||||
volume_level_get(const MultipleOutputs &outputs) noexcept
|
||||
MixerMemento::GetVolume(const MultipleOutputs &outputs) noexcept
|
||||
{
|
||||
if (last_hardware_volume >= 0 &&
|
||||
!hardware_volume_clock.CheckUpdate(std::chrono::seconds(1)))
|
||||
@@ -60,8 +41,8 @@ volume_level_get(const MultipleOutputs &outputs) noexcept
|
||||
return last_hardware_volume;
|
||||
}
|
||||
|
||||
static bool
|
||||
software_volume_change(MultipleOutputs &outputs, unsigned volume)
|
||||
inline bool
|
||||
MixerMemento::SetSoftwareVolume(MultipleOutputs &outputs, unsigned volume)
|
||||
{
|
||||
assert(volume <= 100);
|
||||
|
||||
@@ -71,8 +52,8 @@ software_volume_change(MultipleOutputs &outputs, unsigned volume)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
hardware_volume_change(MultipleOutputs &outputs, unsigned volume)
|
||||
inline void
|
||||
MixerMemento::SetHardwareVolume(MultipleOutputs &outputs, unsigned volume)
|
||||
{
|
||||
/* reset the cache */
|
||||
last_hardware_volume = -1;
|
||||
@@ -81,19 +62,17 @@ hardware_volume_change(MultipleOutputs &outputs, unsigned volume)
|
||||
}
|
||||
|
||||
void
|
||||
volume_level_change(MultipleOutputs &outputs, unsigned volume)
|
||||
MixerMemento::SetVolume(MultipleOutputs &outputs, unsigned volume)
|
||||
{
|
||||
assert(volume <= 100);
|
||||
|
||||
volume_software_set = volume;
|
||||
|
||||
idle_add(IDLE_MIXER);
|
||||
|
||||
hardware_volume_change(outputs, volume);
|
||||
SetHardwareVolume(outputs, volume);
|
||||
}
|
||||
|
||||
bool
|
||||
read_sw_volume_state(const char *line, MultipleOutputs &outputs)
|
||||
MixerMemento::LoadSoftwareVolumeState(const char *line, MultipleOutputs &outputs)
|
||||
{
|
||||
char *end = nullptr;
|
||||
long int sv;
|
||||
@@ -104,21 +83,13 @@ read_sw_volume_state(const char *line, MultipleOutputs &outputs)
|
||||
|
||||
sv = strtol(line, &end, 10);
|
||||
if (*end == 0 && sv >= 0 && sv <= 100)
|
||||
software_volume_change(outputs, sv);
|
||||
else
|
||||
FmtWarning(volume_domain,
|
||||
"Can't parse software volume: {}", line);
|
||||
SetSoftwareVolume(outputs, sv);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
save_sw_volume_state(BufferedOutputStream &os)
|
||||
MixerMemento::SaveSoftwareVolumeState(BufferedOutputStream &os) const
|
||||
{
|
||||
os.Format(SW_VOLUME_STATE "%u\n", volume_software_set);
|
||||
}
|
||||
|
||||
unsigned
|
||||
sw_volume_state_get_hash() noexcept
|
||||
{
|
||||
return volume_software_set;
|
||||
}
|
75
src/mixer/Memento.hxx
Normal file
75
src/mixer/Memento.hxx
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2003-2021 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "system/PeriodClock.hxx"
|
||||
|
||||
class MultipleOutputs;
|
||||
class BufferedOutputStream;
|
||||
|
||||
/**
|
||||
* Cache for hardware/software volume levels.
|
||||
*/
|
||||
class MixerMemento {
|
||||
unsigned volume_software_set = 100;
|
||||
|
||||
/** the cached hardware mixer value; invalid if negative */
|
||||
int last_hardware_volume = -1;
|
||||
|
||||
/** the age of #last_hardware_volume */
|
||||
PeriodClock hardware_volume_clock;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Flush the hardware volume cache.
|
||||
*/
|
||||
void InvalidateHardwareVolume() noexcept {
|
||||
last_hardware_volume = -1;
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
int GetVolume(const MultipleOutputs &outputs) noexcept;
|
||||
|
||||
/**
|
||||
* Throws on error.
|
||||
*
|
||||
* Note: the caller is responsible for emitting #IDLE_MIXER.
|
||||
*/
|
||||
void SetVolume(MultipleOutputs &outputs, unsigned volume);
|
||||
|
||||
bool LoadSoftwareVolumeState(const char *line, MultipleOutputs &outputs);
|
||||
|
||||
void SaveSoftwareVolumeState(BufferedOutputStream &os) const;
|
||||
|
||||
/**
|
||||
* Generates a hash number for the current state of the software
|
||||
* volume control. This is used by timer_save_state_file() to
|
||||
* determine whether the state has changed and the state file should
|
||||
* be saved.
|
||||
*/
|
||||
[[gnu::pure]]
|
||||
unsigned GetSoftwareVolumeStateHash() const noexcept {
|
||||
return volume_software_set;
|
||||
}
|
||||
|
||||
private:
|
||||
bool SetSoftwareVolume(MultipleOutputs &outputs, unsigned volume);
|
||||
void SetHardwareVolume(MultipleOutputs &outputs, unsigned volume);
|
||||
};
|
@@ -188,8 +188,8 @@ MultipleOutputs::SetSoftwareVolume(unsigned volume) noexcept
|
||||
auto *mixer = ao->GetMixer();
|
||||
|
||||
if (mixer != nullptr &&
|
||||
(&mixer->plugin == &software_mixer_plugin ||
|
||||
&mixer->plugin == &null_mixer_plugin))
|
||||
(mixer->IsPlugin(software_mixer_plugin) ||
|
||||
mixer->IsPlugin(null_mixer_plugin)))
|
||||
mixer_set_volume(mixer, volume);
|
||||
}
|
||||
}
|
||||
|
@@ -92,7 +92,7 @@ mixer_close(Mixer *mixer)
|
||||
void
|
||||
mixer_auto_close(Mixer *mixer)
|
||||
{
|
||||
if (!mixer->plugin.global)
|
||||
if (!mixer->IsGlobal())
|
||||
mixer_close(mixer);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ mixer_get_volume(Mixer *mixer)
|
||||
|
||||
assert(mixer != nullptr);
|
||||
|
||||
if (mixer->plugin.global && !mixer->failure)
|
||||
if (mixer->IsGlobal() && !mixer->failure)
|
||||
mixer_open(mixer);
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mixer->mutex);
|
||||
@@ -128,7 +128,7 @@ mixer_set_volume(Mixer *mixer, unsigned volume)
|
||||
assert(mixer != nullptr);
|
||||
assert(volume <= 100);
|
||||
|
||||
if (mixer->plugin.global && !mixer->failure)
|
||||
if (mixer->IsGlobal() && !mixer->failure)
|
||||
mixer_open(mixer);
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mixer->mutex);
|
||||
|
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2003-2021 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_VOLUME_HXX
|
||||
#define MPD_VOLUME_HXX
|
||||
|
||||
class MultipleOutputs;
|
||||
class BufferedOutputStream;
|
||||
|
||||
void
|
||||
InvalidateHardwareVolume() noexcept;
|
||||
|
||||
[[gnu::pure]]
|
||||
int
|
||||
volume_level_get(const MultipleOutputs &outputs) noexcept;
|
||||
|
||||
/**
|
||||
* Throws on error.
|
||||
*/
|
||||
void
|
||||
volume_level_change(MultipleOutputs &outputs, unsigned volume);
|
||||
|
||||
bool
|
||||
read_sw_volume_state(const char *line, MultipleOutputs &outputs);
|
||||
|
||||
void
|
||||
save_sw_volume_state(BufferedOutputStream &os);
|
||||
|
||||
/**
|
||||
* Generates a hash number for the current state of the software
|
||||
* volume control. This is used by timer_save_state_file() to
|
||||
* determine whether the state has changed and the state file should
|
||||
* be saved.
|
||||
*/
|
||||
[[gnu::pure]]
|
||||
unsigned
|
||||
sw_volume_state_get_hash() noexcept;
|
||||
|
||||
#endif
|
@@ -28,13 +28,15 @@
|
||||
#include "MultipleOutputs.hxx"
|
||||
#include "Client.hxx"
|
||||
#include "mixer/MixerControl.hxx"
|
||||
#include "mixer/Volume.hxx"
|
||||
#include "mixer/Memento.hxx"
|
||||
#include "Idle.hxx"
|
||||
|
||||
extern unsigned audio_output_state_version;
|
||||
|
||||
bool
|
||||
audio_output_enable_index(MultipleOutputs &outputs, unsigned idx)
|
||||
audio_output_enable_index(MultipleOutputs &outputs,
|
||||
MixerMemento &mixer_memento,
|
||||
unsigned idx)
|
||||
{
|
||||
if (idx >= outputs.Size())
|
||||
return false;
|
||||
@@ -46,7 +48,7 @@ audio_output_enable_index(MultipleOutputs &outputs, unsigned idx)
|
||||
idle_add(IDLE_OUTPUT);
|
||||
|
||||
if (ao.GetMixer() != nullptr) {
|
||||
InvalidateHardwareVolume();
|
||||
mixer_memento.InvalidateHardwareVolume();
|
||||
idle_add(IDLE_MIXER);
|
||||
}
|
||||
|
||||
@@ -58,7 +60,9 @@ audio_output_enable_index(MultipleOutputs &outputs, unsigned idx)
|
||||
}
|
||||
|
||||
bool
|
||||
audio_output_disable_index(MultipleOutputs &outputs, unsigned idx)
|
||||
audio_output_disable_index(MultipleOutputs &outputs,
|
||||
MixerMemento &mixer_memento,
|
||||
unsigned idx)
|
||||
{
|
||||
if (idx >= outputs.Size())
|
||||
return false;
|
||||
@@ -72,7 +76,7 @@ audio_output_disable_index(MultipleOutputs &outputs, unsigned idx)
|
||||
auto *mixer = ao.GetMixer();
|
||||
if (mixer != nullptr) {
|
||||
mixer_close(mixer);
|
||||
InvalidateHardwareVolume();
|
||||
mixer_memento.InvalidateHardwareVolume();
|
||||
idle_add(IDLE_MIXER);
|
||||
}
|
||||
|
||||
@@ -84,7 +88,9 @@ audio_output_disable_index(MultipleOutputs &outputs, unsigned idx)
|
||||
}
|
||||
|
||||
bool
|
||||
audio_output_toggle_index(MultipleOutputs &outputs, unsigned idx)
|
||||
audio_output_toggle_index(MultipleOutputs &outputs,
|
||||
MixerMemento &mixer_memento,
|
||||
unsigned idx)
|
||||
{
|
||||
if (idx >= outputs.Size())
|
||||
return false;
|
||||
@@ -97,7 +103,7 @@ audio_output_toggle_index(MultipleOutputs &outputs, unsigned idx)
|
||||
auto *mixer = ao.GetMixer();
|
||||
if (mixer != nullptr) {
|
||||
mixer_close(mixer);
|
||||
InvalidateHardwareVolume();
|
||||
mixer_memento.InvalidateHardwareVolume();
|
||||
idle_add(IDLE_MIXER);
|
||||
}
|
||||
}
|
||||
|
@@ -28,26 +28,33 @@
|
||||
#define MPD_OUTPUT_COMMAND_HXX
|
||||
|
||||
class MultipleOutputs;
|
||||
class MixerMemento;
|
||||
|
||||
/**
|
||||
* Enables an audio output. Returns false if the specified output
|
||||
* does not exist.
|
||||
*/
|
||||
bool
|
||||
audio_output_enable_index(MultipleOutputs &outputs, unsigned idx);
|
||||
audio_output_enable_index(MultipleOutputs &outputs,
|
||||
MixerMemento &mixer_memento,
|
||||
unsigned idx);
|
||||
|
||||
/**
|
||||
* Disables an audio output. Returns false if the specified output
|
||||
* does not exist.
|
||||
*/
|
||||
bool
|
||||
audio_output_disable_index(MultipleOutputs &outputs, unsigned idx);
|
||||
audio_output_disable_index(MultipleOutputs &outputs,
|
||||
MixerMemento &mixer_memento,
|
||||
unsigned idx);
|
||||
|
||||
/**
|
||||
* Toggles an audio output. Returns false if the specified output
|
||||
* does not exist.
|
||||
*/
|
||||
bool
|
||||
audio_output_toggle_index(MultipleOutputs &outputs, unsigned idx);
|
||||
audio_output_toggle_index(MultipleOutputs &outputs,
|
||||
MixerMemento &mixer_memento,
|
||||
unsigned idx);
|
||||
|
||||
#endif
|
||||
|
@@ -47,6 +47,15 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
// Backward compatibility from OSX 12.0 API change
|
||||
#if (__MAC_OS_X_VERSION_MAX_ALLOWED >= 120000)
|
||||
#define KAUDIO_OBJECT_PROPERTY_ELEMENT_MM kAudioObjectPropertyElementMain
|
||||
#define KAUDIO_HARDWARE_SERVICE_DEVICE_PROPERTY_VV kAudioHardwareServiceDeviceProperty_VirtualMainVolume
|
||||
#else
|
||||
#define KAUDIO_OBJECT_PROPERTY_ELEMENT_MM kAudioObjectPropertyElementMaster
|
||||
#define KAUDIO_HARDWARE_SERVICE_DEVICE_PROPERTY_VV kAudioHardwareServiceDeviceProperty_VirtualMasterVolume
|
||||
#endif
|
||||
|
||||
static constexpr unsigned MPD_OSX_BUFFER_TIME_MS = 100;
|
||||
|
||||
static StringBuffer<64>
|
||||
@@ -160,13 +169,13 @@ OSXOutput::Create(EventLoop &, const ConfigBlock &block)
|
||||
static constexpr AudioObjectPropertyAddress default_system_output_device{
|
||||
kAudioHardwarePropertyDefaultSystemOutputDevice,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain,
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM,
|
||||
};
|
||||
|
||||
static constexpr AudioObjectPropertyAddress default_output_device{
|
||||
kAudioHardwarePropertyDefaultOutputDevice,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
|
||||
};
|
||||
|
||||
const auto &aopa =
|
||||
@@ -195,9 +204,9 @@ int
|
||||
OSXOutput::GetVolume()
|
||||
{
|
||||
static constexpr AudioObjectPropertyAddress aopa = {
|
||||
kAudioHardwareServiceDeviceProperty_VirtualMainVolume,
|
||||
KAUDIO_HARDWARE_SERVICE_DEVICE_PROPERTY_VV,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain,
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM,
|
||||
};
|
||||
|
||||
const auto vol = AudioObjectGetPropertyDataT<Float32>(dev_id,
|
||||
@@ -211,9 +220,9 @@ OSXOutput::SetVolume(unsigned new_volume)
|
||||
{
|
||||
Float32 vol = new_volume / 100.0;
|
||||
static constexpr AudioObjectPropertyAddress aopa = {
|
||||
kAudioHardwareServiceDeviceProperty_VirtualMainVolume,
|
||||
KAUDIO_HARDWARE_SERVICE_DEVICE_PROPERTY_VV,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
|
||||
};
|
||||
UInt32 size = sizeof(vol);
|
||||
OSStatus status = AudioObjectSetPropertyData(dev_id,
|
||||
@@ -366,25 +375,25 @@ osx_output_set_device_format(AudioDeviceID dev_id,
|
||||
static constexpr AudioObjectPropertyAddress aopa_device_streams = {
|
||||
kAudioDevicePropertyStreams,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
|
||||
};
|
||||
|
||||
static constexpr AudioObjectPropertyAddress aopa_stream_direction = {
|
||||
kAudioStreamPropertyDirection,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
|
||||
};
|
||||
|
||||
static constexpr AudioObjectPropertyAddress aopa_stream_phys_formats = {
|
||||
kAudioStreamPropertyAvailablePhysicalFormats,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
|
||||
};
|
||||
|
||||
static constexpr AudioObjectPropertyAddress aopa_stream_phys_format = {
|
||||
kAudioStreamPropertyPhysicalFormat,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
|
||||
};
|
||||
|
||||
OSStatus err;
|
||||
@@ -484,7 +493,7 @@ osx_output_hog_device(AudioDeviceID dev_id, bool hog) noexcept
|
||||
static constexpr AudioObjectPropertyAddress aopa = {
|
||||
kAudioDevicePropertyHogMode,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM
|
||||
};
|
||||
|
||||
pid_t hog_pid;
|
||||
@@ -538,7 +547,7 @@ IsAudioDeviceName(AudioDeviceID id, const char *expected_name) noexcept
|
||||
static constexpr AudioObjectPropertyAddress aopa_name{
|
||||
kAudioObjectPropertyName,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMain,
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM,
|
||||
};
|
||||
|
||||
char actual_name[256];
|
||||
@@ -561,7 +570,7 @@ FindAudioDeviceByName(const char *name)
|
||||
static constexpr AudioObjectPropertyAddress aopa_hw_devices{
|
||||
kAudioHardwarePropertyDevices,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMain,
|
||||
KAUDIO_OBJECT_PROPERTY_ELEMENT_MM,
|
||||
};
|
||||
|
||||
const auto ids =
|
||||
|
@@ -514,6 +514,7 @@ PipeWireOutput::Open(AudioFormat &audio_format)
|
||||
PW_KEY_MEDIA_CATEGORY, "Playback",
|
||||
PW_KEY_MEDIA_ROLE, "Music",
|
||||
PW_KEY_APP_NAME, "Music Player Daemon",
|
||||
PW_KEY_APP_ICON_NAME, "mpd",
|
||||
nullptr);
|
||||
|
||||
pw_properties_setf(props, PW_KEY_NODE_NAME, "mpd.%s", name);
|
||||
|
@@ -148,8 +148,6 @@ public:
|
||||
}
|
||||
|
||||
DecoderCommand GetCommand() noexcept override {
|
||||
assert(IsInitialized());
|
||||
|
||||
if (seek_where != SongTime{}) {
|
||||
if (!seekable)
|
||||
return DecoderCommand::STOP;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env -S python3 -u
|
||||
|
||||
import os, os.path
|
||||
import sys, subprocess
|
||||
|
Reference in New Issue
Block a user