Commit e3810937 authored by Aleksei Nikiforov's avatar Aleksei Nikiforov

Merge tag 'v0.20.15' into sisyphus

release v0.20.15
parents 028140df ed4d0aa9

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

*.Plo
*.Po
*.a
*.d
*.la
*.lo
*.o
*.exe
*~
.#*
.stgit*
.deps
.dirstamp
tags
/Makefile
/Makefile.in
/aclocal.m4
/autom4te.cache
/config.h
/config.h.in
/config.log
/config.mk
/config.status
/config_detected.h
/config_detected.mk
/configure
/configure.lineno
/depmode
/libtool
/ltmain.sh
/mkinstalldirs
/build
/src/mpd
/systemd/system/mpd.service
/systemd/user/mpd.service
/stamp-h1
/src/dsd2pcm/dsd2pcm
/src/win32/mpd_win32_rc.rc
/doc/doxygen.conf
/doc/protocol.html
/doc/protocol
/doc/user
/doc/developer
/doc/sticker
/doc/api
/test/software_volume
/test/run_convert
/test/run_decoder
/test/read_tags
/test/run_filter
/test/run_encoder
/test/run_output
/test/read_conf
/test/run_input
/test/read_mixer
/test/dump_playlist
/test/run_normalize
/test/tmp
/test/run_inotify
/test/test_queue_priority
/test/test_protocol
/test/run_ntp_server
/test/run_resolver
/test/run_tcp_connect
/test/test_pcm
/test/dump_rva2
/test/dump_text_file
/test/test_util
/test/test_byte_reverse
/test/test_mixramp
/test/test_vorbis_encoder
/test/DumpDatabase
/lib/
/*.tar.gz
/*.tar.bz2
/*.tar.xz
/mpd-*/
__pycache__/
dist: trusty
language: cpp
addons:
apt:
packages:
- libcppunit-dev
- libboost-dev
os:
- linux
- osx
env:
global:
- MAKEFLAGS="-j2"
before_install:
# C++14
- test "$TRAVIS_OS_NAME" != "linux" || sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- test "$TRAVIS_OS_NAME" != "linux" || sudo apt-get update -qq
- test "$TRAVIS_OS_NAME" != "osx" || brew update
install:
# C++14
- test "$TRAVIS_OS_NAME" != "linux" || sudo apt-get install -qq g++-5
- test "$TRAVIS_OS_NAME" != "osx" || brew install cppunit
script:
- OPTIONS="--enable-test"
- test "$TRAVIS_OS_NAME" != "linux" || export CC=gcc-5 CXX=g++-5
- test "$TRAVIS_OS_NAME" != "osx" || OPTIONS="$OPTIONS --enable-osx"
- ./autogen.sh
- ./configure --disable-silent-rules --disable-dependency-tracking $OPTIONS
- make
- make check
Music Player Daemon - http://www.musicpd.org
Copyright 2003-2017 The Music Player Daemon Project
The following people have contributed code to MPD:
Warren Dukes <warren.dukes@gmail.com>
Avuton Olrich <avuton@gmail.com>
Max Kellermann <max.kellermann@gmail.com>
Laszlo Ashin <kodest@gmail.com>
Viliam Mateicka <viliam.mateicka@gmail.com>
Eric Wollesen <encoded@xmtp.net>
Thomas Jansen <mithi@mithi.net>
Romain Bignon <romain@peerfuse.org>
David Guibert <david.guibert@gmail.com>
Jochen Keil <jochen.keil@gmail.com>
Jeffrey Middleton <jefromi@gmail.com>
Sean McNamara <smcnam@gmail.com>
Niklas Hofer
Jim Ramsay <i.am@jimramsay.com>
Guus Sliepen <guus@sliepen.eu.org>
J. Alexander Treuman <jat@spatialrift.net>
Eric Wong
José Anarch <anarchsss@gmail.com>
Patrik Weiskircher <pat@icore.at>
Nick Welch <mack@incise.org>
Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Anton Khirnov <anton@khirnov.net>
Simon Kagstrom <simon.kagstrom@gmail.com>
Denis Krjuchkov <denis@crazydev.net>
Jurgen Kramer <gtmkramer@xs4all.nl>
Jean-Francois Dockes <jf@dockes.org>
Yue Wang <yuleopen@gmail.com>
Matthew Leon Grinshpun <ml@matthewleon.com>
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
# Music Player Daemon
http://www.musicpd.org
A daemon for playing music of various formats. Music is played through the
server's audio device. The daemon stores info about all available music,
and this info can be easily searched and retrieved. Player control, info
retrieval, and playlist management can all be managed remotely.
For basic installation instructions
[read the manual](https://www.musicpd.org/doc/user/install.html).
# Users
- [Manual](http://www.musicpd.org/doc/user/)
- [Forum](http://forum.musicpd.org/)
- [IRC](irc://chat.freenode.net/#mpd)
- [Bug tracker](https://github.com/MusicPlayerDaemon/MPD/issues/)
# Developers
- [Protocol specification](http://www.musicpd.org/doc/protocol/)
- [Developer manual](http://www.musicpd.org/doc/developer/)
# Legal
MPD is released under the
[GNU General Public License version 2](https://www.gnu.org/licenses/gpl-2.0.txt),
which is distributed in the COPYING file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.musicpd"
android:installLocation="auto"
android:versionCode="13"
android:versionName="0.19.9">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Main"
android:label="@string/app_name"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
#!/usr/bin/env python3
import os, os.path
import sys, subprocess
if len(sys.argv) < 3:
print("Usage: build.py SDK_PATH NDK_PATH [configure_args...]", file=sys.stderr)
sys.exit(1)
sdk_path = sys.argv[1]
ndk_path = sys.argv[2]
configure_args = sys.argv[3:]
if not os.path.isfile(os.path.join(sdk_path, 'tools', 'android')):
print("SDK not found in", ndk_path, file=sys.stderr)
sys.exit(1)
if not os.path.isdir(ndk_path):
print("NDK not found in", ndk_path, file=sys.stderr)
sys.exit(1)
# select the NDK target
arch = 'arm-linux-androideabi'
# the path to the MPD sources
mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
sys.path[0] = os.path.join(mpd_path, 'python')
# output directories
from build.dirs import lib_path, tarball_path, src_path
arch_path = os.path.join(lib_path, arch)
build_path = os.path.join(arch_path, 'build')
# build host configuration
build_arch = 'linux-x86_64'
# set up the NDK toolchain
class AndroidNdkToolchain:
def __init__(self, tarball_path, src_path, build_path,
use_cxx):
self.tarball_path = tarball_path
self.src_path = src_path
self.build_path = build_path
self.ndk_arch = 'arm'
android_abi = 'armeabi-v7a'
ndk_platform = 'android-21'
# select the NDK compiler
gcc_version = '4.9'
ndk_platform_path = os.path.join(ndk_path, 'platforms', ndk_platform)
sysroot = os.path.join(ndk_path, 'sysroot')
target_root = os.path.join(ndk_platform_path, 'arch-' + self.ndk_arch)
install_prefix = os.path.join(arch_path, 'root')
self.arch = arch
self.install_prefix = install_prefix
self.sysroot = sysroot
toolchain_path = os.path.join(ndk_path, 'toolchains', arch + '-' + gcc_version, 'prebuilt', build_arch)
llvm_path = os.path.join(ndk_path, 'toolchains', 'llvm', 'prebuilt', build_arch)
llvm_triple = 'armv7-none-linux-androideabi'
common_flags = '-march=armv7-a -mfloat-abi=softfp'
toolchain_bin = os.path.join(toolchain_path, 'bin')
llvm_bin = os.path.join(llvm_path, 'bin')
self.cc = os.path.join(llvm_bin, 'clang')
self.cxx = os.path.join(llvm_bin, 'clang++')
common_flags += ' -target ' + llvm_triple + ' -integrated-as -gcc-toolchain ' + toolchain_path
common_flags += ' -fvisibility=hidden -fdata-sections -ffunction-sections'
self.ar = os.path.join(toolchain_bin, arch + '-ar')
self.ranlib = os.path.join(toolchain_bin, arch + '-ranlib')
self.nm = os.path.join(toolchain_bin, arch + '-nm')
self.strip = os.path.join(toolchain_bin, arch + '-strip')
self.cflags = '-Os -g ' + common_flags
self.cxxflags = '-Os -g ' + common_flags
self.cppflags = '--sysroot=' + sysroot + \
' -isystem ' + os.path.join(install_prefix, 'include') + \
' -isystem ' + os.path.join(sysroot, 'usr', 'include', arch) + \
' -D__ANDROID_API__=21'
self.ldflags = '--sysroot=' + sysroot + \
' -L' + os.path.join(install_prefix, 'lib') + \
' -L' + os.path.join(target_root, 'usr', 'lib') + \
' -B' + os.path.join(target_root, 'usr', 'lib') + \
' ' + common_flags
self.libs = ''
self.is_arm = self.ndk_arch == 'arm'
self.is_armv7 = self.is_arm and 'armv7' in self.cflags
self.is_windows = False
libcxx_path = os.path.join(ndk_path, 'sources/cxx-stl/llvm-libc++')
libcxx_libs_path = os.path.join(libcxx_path, 'libs', android_abi)
libstdcxx_cppflags = '-nostdinc++ -isystem ' + os.path.join(libcxx_path, 'include') + ' -isystem ' + os.path.join(ndk_path, 'sources/android/support/include')
libstdcxx_ldadd = os.path.join(libcxx_libs_path, 'libc++_static.a') + ' ' + os.path.join(libcxx_libs_path, 'libc++abi.a')
if self.is_armv7:
libstdcxx_ldadd += ' ' + os.path.join(libcxx_libs_path, 'libunwind.a')
if use_cxx:
self.libs += ' ' + libstdcxx_ldadd
self.cppflags += ' ' + libstdcxx_cppflags
self.env = dict(os.environ)
# redirect pkg-config to use our root directory instead of the
# default one on the build host
self.env['PKG_CONFIG_LIBDIR'] = os.path.join(install_prefix, 'lib/pkgconfig')
# a list of third-party libraries to be used by MPD on Android
from build.libs import *
thirdparty_libs = [
libogg,
libvorbis,
opus,
flac,
libid3tag,
libmad,
ffmpeg,
curl,
boost,
]
# build the third-party libraries
for x in thirdparty_libs:
toolchain = AndroidNdkToolchain(tarball_path, src_path, build_path,
use_cxx=x.use_cxx)
if not x.is_installed(toolchain):
x.build(toolchain)
# configure and build MPD
toolchain = AndroidNdkToolchain(tarball_path, src_path, build_path,
use_cxx=True)
configure = [
os.path.join(mpd_path, 'configure'),
'CC=' + toolchain.cc,
'CXX=' + toolchain.cxx,
'CFLAGS=' + toolchain.cflags,
'CXXFLAGS=' + toolchain.cxxflags,
'CPPFLAGS=' + toolchain.cppflags,
'LDFLAGS=' + toolchain.ldflags,
'LIBS=' + toolchain.libs,
'AR=' + toolchain.ar,
'RANLIB=' + toolchain.ranlib,
'STRIP=' + toolchain.strip,
'--host=' + toolchain.arch,
'--prefix=' + toolchain.install_prefix,
'--with-sysroot=' + toolchain.sysroot,
'--with-android-sdk=' + sdk_path,
'--enable-silent-rules',
'--disable-icu',
] + configure_args
from build.cmdline import concatenate_cmdline_variables
configure = concatenate_cmdline_variables(configure,
set(('CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'LIBS')))
subprocess.check_call(configure, env=toolchain.env)
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], env=toolchain.env)
<?xml version="1.0" encoding="UTF-8"?>
<project name="mpd_rules">
<!-- setting these two properties works around a bug in Android
SDK's build.xml, which deletes all .class files every time -->
<property name="build.last.is.packaging.debug" value="true" />
<property name="build.is.packaging.debug" value="true" />
<target name="compile-jni-classes"
depends="-set-debug-mode,-compile"/>
</project>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MPD</string>
</resources>
/*
* Copyright 2003-2017 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.
*/
package org.musicpd;
import android.content.Context;
/**
* Bridge to native code.
*/
public class Bridge {
public static native void run(Context context);
public static native void shutdown();
}
/*
* Copyright 2003-2017 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.
*/
package org.musicpd;
import android.util.Log;
public class Loader {
private static final String TAG = "MPD";
public static boolean loaded = false;
public static String error;
static {
try {
System.loadLibrary("mpd");
loaded = true;
} catch (UnsatisfiedLinkError e) {
Log.e(TAG, e.getMessage());
error = e.getMessage();
}
}
}
/*
* Copyright 2003-2017 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.
*/
package org.musicpd;
import android.app.Activity;
import android.os.Bundle;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.widget.TextView;
import android.util.Log;
public class Main extends Activity implements Runnable {
private static final String TAG = "MPD";
Thread thread;
TextView textView;
final Handler quitHandler = new Handler() {
public void handleMessage(Message msg) {
textView.setText("Music Player Daemon has quit");
// TODO: what now? restart?
}
};
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!Loader.loaded) {
TextView tv = new TextView(this);
tv.setText("Failed to load the native MPD libary.\n" +
"Report this problem to us, and include the following information:\n" +
"ABI=" + Build.CPU_ABI + "\n" +
"PRODUCT=" + Build.PRODUCT + "\n" +
"FINGERPRINT=" + Build.FINGERPRINT + "\n" +
"error=" + Loader.error);
setContentView(tv);
return;
}
if (thread == null || !thread.isAlive()) {
thread = new Thread(this, "NativeMain");
thread.start();
}
textView = new TextView(this);
textView.setText("Music Player Daemon is running"
+ "\nCAUTION: this version is EXPERIMENTAL!");
setContentView(textView);
}
@Override public void run() {
Bridge.run(this);
quitHandler.sendMessage(quitHandler.obtainMessage());
}
}
#!/bin/sh
set -e
rm -rf config.cache build
mkdir build
aclocal -I m4 $ACLOCAL_FLAGS
autoheader
automake --add-missing $AUTOMAKE_FLAGS
autoconf
This diff is collapsed. Click to expand it.
<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<book>
<title>The Music Player Daemon - Developer's Manual</title>
<chapter id="introduction">
<title>Introduction</title>
<para>
This is a guide for those who wish to hack on the MPD source
code. MPD is an open project, and we are always happy about
contributions. So far, more than 150 people have contributed
patches.
</para>
<para>
This document is work in progress. Most of it may be incomplete
yet. Please help!
</para>
</chapter>
<chapter id="code_style">
<title>Code Style</title>
<itemizedlist>
<listitem>
<para>
indent with tabs (width 8)
</para>
</listitem>
<listitem>
<para>
don't write CPP when you can write C++: use inline
functions and constexpr instead of macros
</para>
</listitem>
<listitem>
<para>
comment your code, document your APIs
</para>
</listitem>
<listitem>
<para>
the code should be C++14 compliant, and must compile with
<application>GCC</application> 4.9 and
<application>clang</application> 3.4
</para>
</listitem>
<listitem>
<para>
report error conditions with C++ exceptions, preferable
derived from <varname>std::runtime_error</varname>
</para>
</listitem>
<listitem>
<para>
all code must be exception-safe
</para>
</listitem>
<listitem>
<para>
classes and functions names use CamelCase; variables are
lower-case with words separated by underscore
</para>
</listitem>
<listitem>
<para>
Some example code:
</para>
<programlisting lang="C">static inline int
Foo(const char *abc, int xyz)
{
if (abc == nullptr) {
LogWarning("Foo happened!");
return -1;
}
return xyz;
}
</programlisting>
</listitem>
</itemizedlist>
</chapter>
<chapter id="hacking">
<title>Hacking The Source</title>
<para>
MPD sources are managed in a git repository on <ulink
url="https://github.com/MusicPlayerDaemon/">GitHub</ulink>.
</para>
<para>
Always write your code against the latest git:
</para>
<programlisting>git clone git://github.com/MusicPlayerDaemon/MPD</programlisting>
<para>
If you already have a clone, update it:
</para>
<programlisting>git pull --rebase git://github.com/MusicPlayerDaemon/MPD master</programlisting>
<para>
You can do without "--rebase", but we recommend that you rebase
your repository on the "master" repository all the time.
</para>
<para>
Configure with the options <option>--enable-debug
--enable-werror</option>. Enable as many plugins as possible,
to be sure that you don't break any disabled code.
</para>
<para>
Don't mix several changes in one single patch. Create a
separate patch for every change. Tools like
<application>stgit</application> help you with that. This way,
we can review your patches more easily, and we can pick the
patches we like most first.
</para>
<section>
<title> Basic stgit usage</title>
<para>
stgit allows you to create a set of patches and refine all of
them: you can go back to any patch at any time, and re-edit it
(both the code and the commit message). You can reorder
patches and insert new patches at any position. It encourages
creating separate patches for tiny changes.
</para>
<para>
stgit needs to be initialized on a git repository: stg init
</para>
<para>
Before you edit the code, create a patch: stg new
my-patch-name (stgit now asks you for the commit message).
</para>
<para>
Now edit the code. Once you're finished, you have to "refresh"
the patch, i.e. your edits are incorporated into the patch you
have created: stg refresh
</para>
<para>
You may now continue editing the same patch, and refresh it as
often as you like. Create more patches, edit and refresh them.
</para>
<para>
To view the list of patches, type stg series. To go back to a
specific patch, type stg goto my-patch-name; now you can
re-edit it (don't forget stg refresh when you're finished with
that patch).
</para>
<para>
When the whole patch series is finished, convert stgit patches
to git commits: stg commit
</para>
</section>
</chapter>
<chapter id="submitting_patches">
<title>Submitting Patches</title>
<para>
Send your patches to the mailing list:
<email>mpd-devel@musicpd.org</email> (<ulink
url="http://mailman.blarg.de/listinfo/mpd-devel">subscribe
here</ulink>)
</para>
<para>
<command>git pull</command> requests are preferred.
</para>
</chapter>
<chapter id="tools">
<title>Development Tools</title>
<section>
<title>Clang Static Analyzer</title>
<para>
The <ulink url="http://clang-analyzer.llvm.org/">clang static
analyzer</ulink> is a tool that helps find bugs. To run it on
the MPD code base, install LLVM and clang. Configure MPD to
use clang:
</para>
<programlisting>./configure --enable-debug CXX=clang++ CC=clang ...</programlisting>
<para>
It is recommended to use <option>--enable-debug</option>,
because the analyzer takes advantage of
<function>assert()</function> calls, which are only enabled in
the debug build.
</para>
<para>
Now run the analyzer:
</para>
<programlisting>scan-build --use-c++=clang++ --use-cc=clang make</programlisting>
<para>
The options <option>--use-c++</option> and
<option>--use-cc</option> are necessary because it invokes
<command>cc</command> for actually compiling the sources by
default. That breaks, because MPD requires a C99 compiler.
</para>
</section>
</chapter>
</book>
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE itemizedlist PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<itemizedlist>
<listitem>
<para>
<varname>artist</varname>: the artist name. Its meaning is not
well-defined; see <varname>composer</varname> and
<varname>performer</varname> for more specific tags.
</para>
</listitem>
<listitem>
<para>
<varname>artistsort</varname>: same as
<varname>artist</varname>, but for sorting. This usually omits
prefixes such as "The".
</para>
</listitem>
<listitem>
<para>
<varname>album</varname>: the album name.
</para>
</listitem>
<listitem>
<para>
<varname>albumsort</varname>: same as <varname>album</varname>,
but for sorting.
</para>
</listitem>
<listitem>
<para>
<varname>albumartist</varname>: on multi-artist albums, this is
the artist name which shall be used for the whole album. The
exact meaning of this tag is not well-defined.
</para>
</listitem>
<listitem>
<para>
<varname>albumartistsort</varname>: same as
<varname>albumartist</varname>, but for sorting.
</para>
</listitem>
<listitem>
<para>
<varname>title</varname>: the song title.
</para>
</listitem>
<listitem>
<para>
<varname>track</varname>: the decimal track number within the
album.
</para>
</listitem>
<listitem>
<para>
<varname>name</varname>: a name for this song. This is not the
song title. The exact meaning of this tag is not well-defined.
It is often used by badly configured internet radio stations
with broken tags to squeeze both the artist name and the song
title in one tag.
</para>
</listitem>
<listitem>
<para>
<varname>genre</varname>: the music genre.
</para>
</listitem>
<listitem>
<para>
<varname>date</varname>: the song's release date. This is
usually a 4-digit year.
</para>
</listitem>
<listitem>
<para>
<varname>composer</varname>: the artist who composed the song.
</para>
</listitem>
<listitem>
<para>
<varname>performer</varname>: the artist who performed the song.
</para>
</listitem>
<listitem>
<para>
<varname>comment</varname>: a human-readable comment about this
song. The exact meaning of this tag is not well-defined.
</para>
</listitem>
<listitem>
<para>
<varname>disc</varname>: the decimal disc number in a multi-disc
album.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_artistid</varname>: the artist id in the
<ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_albumid</varname>: the album id in the
<ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_albumartistid</varname>: the album artist
id in the <ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_trackid</varname>: the track id in the
<ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_releasetrackid</varname>: the release track
id in the <ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
</itemizedlist>
.TH "Music Player Daemon" 1
.SH NAME
MPD \- A daemon for playing music
.SH SYNOPSIS
.B mpd
.RI [ options ]
.RI [ CONF_FILE ]
.SH DESCRIPTION
MPD is a daemon for playing music. Music is played through the configured
audio output(s) (which are generally local, but can be remote). The daemon
stores info about all available music, and this info can be easily searched and
retrieved. Player control, info retrieval, and playlist management can all be
managed remotely.
MPD searches for a config file in \fB$XDG_CONFIG_HOME/mpd/mpd.conf\fP then
\fB~/.mpdconf\fP then \fB/etc/mpd.conf\fP or uses CONF_FILE.
Read more about MPD at <\fBhttp://www.musicpd.org/\fP>.
.SH OPTIONS
.TP
.BI \-\-help
Output a brief help message.
.TP
.BI \-\-kill
Kill the currently running mpd session. The pid_file parameter must be
specified in the config file for this to work.
.TP
.BI \-\-no\-daemon
Don't detach from console.
.TP
.BI \-\-stderr
Print messages stderr.
.TP
.BI \-\-verbose
Verbose logging.
.TP
.BI \-\-version
Print version information.
.SH FILES
.TP
.BI ~/.mpdconf
User configuration file.
.TP
.BI /etc/mpd.conf
Global configuration file.
.SH SEE ALSO
mpd.conf(5), mpc(1)
.SH BUGS
If you find a bug, please report it at
.br
<\fBhttps://github.com/MusicPlayerDaemon/MPD/issues/\fP>.
.SH AUTHORS
Max Kellermann <max.kellermann@gmail.com>
Special thanks to all the people that provided feedback and patches.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# For every FLAG1, FLAG2 it is checked whether the compiler works with the
# flag. If it does, the flag is added FLAGS-VARIABLE
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. During the check the flag is always added to the
# current language's flags.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: This macro depends on the AX_APPEND_FLAG and
# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
# AX_APPEND_LINK_FLAGS.
#
# LICENSE
#
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 5
AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
done
])dnl AX_APPEND_COMPILE_FLAGS
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
#
# DESCRIPTION
#
# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
# added in between.
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
# FLAG.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 6
AC_DEFUN([AX_APPEND_FLAG],
[dnl
AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
AS_VAR_SET_IF(FLAGS,[
AS_CASE([" AS_VAR_GET(FLAGS) "],
[*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
[
AS_VAR_APPEND(FLAGS,[" $1"])
AC_RUN_LOG([: FLAGS="$FLAGS"])
])
],
[
AS_VAR_SET(FLAGS,[$1])
AC_RUN_LOG([: FLAGS="$FLAGS"])
])
AS_VAR_POPDEF([FLAGS])dnl
])dnl AX_APPEND_FLAG
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# For every FLAG1, FLAG2 it is checked whether the linker works with the
# flag. If it does, the flag is added FLAGS-VARIABLE
#
# If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is
# used. During the check the flag is always added to the linker's flags.
#
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
# when the check is done. The check is thus made with the flags: "LDFLAGS
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
#
# LICENSE
#
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 5
AC_DEFUN([AX_APPEND_LINK_FLAGS],
[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
done
])dnl AX_APPEND_LINK_FLAGS
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 4
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the linker or gives an error.
# (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
# when the check is done. The check is thus made with the flags: "LDFLAGS
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_LINK_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 4
AC_DEFUN([AX_CHECK_LINK_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
ax_check_save_flags=$LDFLAGS
LDFLAGS="$LDFLAGS $4 $1"
AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
LDFLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_LINK_FLAGS
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_14.html
# ============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_14([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++14
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++14. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 4
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_14], [AX_CXX_COMPILE_STDCXX([14], [$1], [$2])])
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_REQUIRE_DEFINED(MACRO)
#
# DESCRIPTION
#
# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
# been defined and thus are available for use. This avoids random issues
# where a macro isn't expanded. Instead the configure script emits a
# non-fatal:
#
# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
#
# It's like AC_REQUIRE except it doesn't expand the required macro.
#
# Here's an example:
#
# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
#
# LICENSE
#
# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 1
AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
])dnl AX_REQUIRE_DEFINED
dnl
dnl Usage:
dnl AC_CHECK_LIBWRAP([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl
AC_DEFUN([AC_CHECK_LIBWRAP],[
AC_CHECK_HEADERS([tcpd.h],
AC_CHECK_LIB([wrap], [request_init],
[LIBWRAP_CFLAGS=""
LIBWRAP_LDFLAGS="-lwrap"
$1],
$2),
$2)
])
dnl Parameters: varname1, description
AC_DEFUN([MPD_AUTO_ENABLED], [
if test x$[]enable_$1 = xauto; then
AC_MSG_NOTICE([auto-detected $2])
enable_$1=yes
fi
])
dnl Parameters: varname1, description, errmsg
AC_DEFUN([MPD_AUTO_DISABLED], [
if test x$[]enable_$1 = xauto; then
AC_MSG_WARN([$3 -- disabling $2])
enable_$1=no
elif test x$[]enable_$1 = xyes; then
AC_MSG_ERROR([$2: $3])
fi
])
dnl Check whether a prerequisite for a feature was found. This is
dnl very similar to MPD_AUTO_RESULT, but does not finalize the
dnl detection; it assumes that more checks will follow.
AC_DEFUN([MPD_AUTO_PRE], [
if test x$[]enable_$1 != xno && test x$[]found_$1 = xno; then
MPD_AUTO_DISABLED([$1], [$2], [$3])
fi
])
dnl Evaluate a check's result. Abort if the feature was requested
dnl explicitly but is unavailable.
dnl
dnl Parameters: varname1, description, errmsg
AC_DEFUN([MPD_AUTO_RESULT], [
if test x$[]enable_$1 = xno; then
found_$1=no
fi
if test x$[]found_$1 = xyes; then
MPD_AUTO_ENABLED([$1], [$2])
else
MPD_AUTO_DISABLED([$1], [$2], [$3])
fi
])
dnl Invoke a check if its configuration is "yes" or "auto" and call
dnl MPD_AUTO_RESULT.
dnl
dnl Parameters: varname1, description, errmsg, check
AC_DEFUN([MPD_AUTO], [
if test x$[]enable_$1 != xno; then
$4
fi
MPD_AUTO_RESULT([$1], [$2], [$3])
])
dnl Wrapper for MPD_AUTO and PKG_CHECK_MODULES.
dnl
dnl Parameters: varname1, varname2, pkgname, description, errmsg
AC_DEFUN([MPD_AUTO_PKG], [
MPD_AUTO([$1], [$4], [$5],
[PKG_CHECK_MODULES([$2], [$3],
[found_$1=yes],
[found_$1=no])])
])
dnl Check with pkg-config first, fall back to AC_CHECK_LIB.
dnl
dnl Parameters: varname1, varname2, pkgname, libname, symname, libs, cflags, description, errmsg
AC_DEFUN([MPD_AUTO_PKG_LIB], [
MPD_AUTO([$1], [$8], [$9],
[PKG_CHECK_MODULES([$2], [$3],
[found_$1=yes],
AC_CHECK_LIB($4, $5,
[found_$1=yes $2_LIBS='$6' $2_CFLAGS='$7'],
[found_$1=no],
[$6]))])
])
dnl Wrapper for AC_CHECK_LIB.
dnl
dnl Parameters: varname1, varname2, libname, symname, libs, cflags, description, errmsg
AC_DEFUN([MPD_AUTO_LIB], [
AC_SUBST([$2_LIBS], [])
AC_SUBST([$2_CFLAGS], [])
MPD_AUTO([$1], [$7], [$8],
[AC_CHECK_LIB($3, $4,
[found_$1=yes $2_LIBS='$5' $2_CFLAGS='$6'],
[found_$1=no],
[$5])])
])
dnl Wrapper for AC_CHECK_HEADER.
dnl
dnl Parameters: varname1, varname2, header, libs, cflags, description, errmsg
AC_DEFUN([MPD_AUTO_HEADER], [
AC_SUBST([$2_LIBS], [])
AC_SUBST([$2_CFLAGS], [])
MPD_AUTO([$1], [$6], [$7],
[AC_CHECK_HEADER([$3],
[found_$1=yes $2_LIBS='$4' $2_CFLAGS='$5'],
[found_$1=no])])
])
dnl Convert the given string into a string for the "default value" in
dnl the help text. If the string is a literal, then it is returned
dnl as-is; if it contains a variable reference, just "auto" is
dnl emitted.
dnl
dnl Parameters: varname1
AC_DEFUN([MPD_FORMAT_DEFAULT],
[ifelse([$1], [], [auto],
index([$1], [$]), [-1], [$1],
[auto])])
dnl Wrapper for AC_ARG_ENABLE, AC_DEFINE and AM_CONDITIONAL
dnl
dnl Parameters: varname1, varname2, description, default, check
AC_DEFUN([MPD_ARG_ENABLE], [
AC_ARG_ENABLE(translit([$1], [_], [-]),
AS_HELP_STRING([--enable-]translit([$1], [_], [-]),
[enable $3 (default: ]MPD_FORMAT_DEFAULT([$4])[)]),,
[enable_$1=]ifelse([$4], [], [auto], [$4]))
$5
MPD_DEFINE_CONDITIONAL(enable_$1, ENABLE_$2, [$3])
])
dnl Wrapper for MPD_ARG_ENABLE and MPD_AUTO
dnl
dnl Parameters: varname1, varname2, description, errmsg, default, check
AC_DEFUN([MPD_ENABLE_AUTO], [
MPD_ARG_ENABLE([$1], [$2], [$3], [$5], [
MPD_AUTO([$1], [$3], [$4], [$6])
])
])
dnl Wrapper for AC_ARG_ENABLE and MPD_AUTO_PKG
dnl
dnl Parameters: varname1, varname2, pkg, description, errmsg, default, pre
AC_DEFUN([MPD_ENABLE_AUTO_PKG], [
MPD_ARG_ENABLE([$1], [$2], [$4], [$6], [
$7
MPD_AUTO_PKG($1, $2, $3, $4, $5)
])
])
dnl Wrapper for AC_ARG_ENABLE and MPD_AUTO_PKG_LIB
dnl
dnl Parameters: varname1, varname2, pkg, libname, symname, libs, cflags, description, errmsg, default, pre
AC_DEFUN([MPD_ENABLE_AUTO_PKG_LIB], [
MPD_ARG_ENABLE([$1], [$2], [$8], [$10], [
$11
MPD_AUTO_PKG_LIB($1, $2, $3, $4, $5, $6, $7, $8, $9)
])
])
dnl Wrapper for AC_ARG_ENABLE and MPD_AUTO_LIB
dnl
dnl Parameters: varname1, varname2, libname, symname, libs, cflags, description, errmsg, default, pre
AC_DEFUN([MPD_ENABLE_AUTO_LIB], [
MPD_ARG_ENABLE([$1], [$2], [$7], [$9], [
$10
MPD_AUTO_LIB($1, $2, $3, $4, $5, $6, $7, $8)
])
])
dnl Wrapper for AC_ARG_ENABLE and MPD_AUTO_HEADER
dnl
dnl Parameters: varname1, varname2, header, libs, cflags, description, errmsg, default, pre
AC_DEFUN([MPD_ENABLE_AUTO_HEADER], [
MPD_ARG_ENABLE([$1], [$2], [$6], [$8], [
$9
MPD_AUTO_HEADER($1, $2, $3, $4, $5, $6, $7)
])
])
dnl Wrapper for MPD_ENABLE_AUTO_PKG and MPD_DEPENDS
dnl
dnl Parameters: varname1, varname2, pkg, description, errmsg, default, dep_variable, dep_errmsg
AC_DEFUN([MPD_ENABLE_AUTO_PKG_DEPENDS], [
MPD_ENABLE_AUTO_PKG([$1], [$2], [$3], [$4], [$5], [$6],
[MPD_DEPENDS([enable_$1], [$7], [$8])])
])
dnl Wrapper for AC_DEFINE and AM_CONDITIONAL
dnl
dnl Parameters: varname1, varname2, description
AC_DEFUN([MPD_DEFINE_CONDITIONAL], [dnl
AM_CONDITIONAL($2, test x$[]$1 = xyes)
if test x$[]$1 = xyes; then
AC_DEFINE($2, 1, [Define to enable $3])
fi])
AC_DEFUN([MPD_DEPENDS], [
if test x$$2 = xno; then
if test x$$1 = xauto; then
$1=no
elif test x$$1 = xyes; then
AC_MSG_ERROR([$3])
fi
fi
])
dnl MPD_OPTIONAL_FUNC(name, func, macro)
dnl
dnl Allow the user to enable or disable the use of a function. If the
dnl option is not specified, the function is auto-detected.
AC_DEFUN([MPD_OPTIONAL_FUNC], [
AC_ARG_ENABLE([$1],
AS_HELP_STRING([--enable-$1],
[use the function "$1" (default: auto)]),
[test x$[]enable_$1 = xyes && AC_DEFINE([$3], 1, [Define to use $1])],
[AC_CHECK_FUNC([$2],
[AC_DEFINE([$3], 1, [Define to use $1])],)])
])
dnl MPD_OPTIONAL_FUNC_NODEF(name, func)
dnl
dnl Allow the user to enable or disable the use of a function.
dnl Works similar to MPD_OPTIONAL_FUNC, however MPD_OPTIONAL_FUNC_NODEF
dnl does not invoke AC_DEFINE when function is enabled. Shell variable
dnl enable_$name is set to "yes" instead.
AC_DEFUN([MPD_OPTIONAL_FUNC_NODEF], [
AC_ARG_ENABLE([$1],
AS_HELP_STRING([--enable-$1],
[use the function "$1" (default: auto)]),,
[AC_CHECK_FUNC([$2], [enable_$1=yes],)])
])
dnl Run code with the specified CFLAGS/CXXFLAGS and LIBS appended.
dnl Restores the old values afterwards.
dnl
dnl Parameters: cflags, libs, code
AC_DEFUN([MPD_WITH_FLAGS], [
ac_save_CFLAGS="$[]CFLAGS"
ac_save_CXXFLAGS="$[]CXXFLAGS"
ac_save_LIBS="$[]LIBS"
CFLAGS="$[]CFLAGS $1"
CXXFLAGS="$[]CXXFLAGS $1"
LIBS="$[]LIBS $2"
$3
CFLAGS="$[]ac_save_CFLAGS"
CXXFLAGS="$[]ac_save_CXXFLAGS"
LIBS="$[]ac_save_LIBS"
])
dnl Run code with the specified library's CFLAGS/CXXFLAGS and LIBS
dnl appended. Restores the old values afterwards.
dnl
dnl Parameters: libname, code
AC_DEFUN([MPD_WITH_LIBRARY],
[MPD_WITH_FLAGS([$[]$1_CFLAGS], [$[]$1_LIBS], [$2])])
This diff is collapsed. Click to expand it.
AC_DEFUN([results], [
printf '('
if test x$[]enable_$1 = xyes; then
printf '+'
else
printf '-'
fi
printf '%s) ' "$2"
])
# Check if "struct ucred" is available.
#
# Author: Max Kellermann <max.kellermann@gmail.com>
AC_DEFUN([STRUCT_UCRED],[
AC_MSG_CHECKING([for struct ucred])
AC_CACHE_VAL(mpd_cv_have_struct_ucred, [
AC_TRY_COMPILE([#include <sys/socket.h>],
[struct ucred cred;],
mpd_cv_have_struct_ucred=yes,
mpd_cv_have_struct_ucred=no)
])
AC_MSG_RESULT($mpd_cv_have_struct_ucred)
if test x$mpd_cv_have_struct_ucred = xyes; then
AC_DEFINE(HAVE_STRUCT_UCRED, 1, [Define if struct ucred is present from sys/socket.h])
fi
])
This diff is collapsed. Click to expand it.
import os.path, subprocess, sys
from build.makeproject import MakeProject
class AutotoolsProject(MakeProject):
def __init__(self, url, md5, installed, configure_args=[],
autogen=False,
cppflags='',
ldflags='',
libs='',
**kwargs):
MakeProject.__init__(self, url, md5, installed, **kwargs)
self.configure_args = configure_args
self.autogen = autogen
self.cppflags = cppflags
self.ldflags = ldflags
self.libs = libs
def configure(self, toolchain):
src = self.unpack(toolchain)
if self.autogen:
if sys.platform == 'darwin':
subprocess.check_call(['glibtoolize', '--force'], cwd=src)
else:
subprocess.check_call(['libtoolize', '--force'], cwd=src)
subprocess.check_call(['aclocal'], cwd=src)
subprocess.check_call(['automake', '--add-missing', '--force-missing', '--foreign'], cwd=src)
subprocess.check_call(['autoconf'], cwd=src)
build = self.make_build_path(toolchain)
configure = [
os.path.join(src, 'configure'),
'CC=' + toolchain.cc,
'CXX=' + toolchain.cxx,
'CFLAGS=' + toolchain.cflags,
'CXXFLAGS=' + toolchain.cxxflags,
'CPPFLAGS=' + toolchain.cppflags + ' ' + self.cppflags,
'LDFLAGS=' + toolchain.ldflags + ' ' + self.ldflags,
'LIBS=' + toolchain.libs + ' ' + self.libs,
'AR=' + toolchain.ar,
'RANLIB=' + toolchain.ranlib,
'STRIP=' + toolchain.strip,
'--host=' + toolchain.arch,
'--prefix=' + toolchain.install_prefix,
'--enable-silent-rules',
] + self.configure_args
subprocess.check_call(configure, cwd=build, env=toolchain.env)
return build
def build(self, toolchain):
build = self.configure(toolchain)
MakeProject.build(self, toolchain, build)
import os, shutil
import re
from build.project import Project
class BoostProject(Project):
def __init__(self, url, md5, installed,
**kwargs):
m = re.match(r'.*/boost_(\d+)_(\d+)_(\d+)\.tar\.bz2$', url)
version = "%s.%s.%s" % (m.group(1), m.group(2), m.group(3))
Project.__init__(self, url, md5, installed,
name='boost', version=version,
**kwargs)
def build(self, toolchain):
src = self.unpack(toolchain)
# install the headers manually; don't build any library
# (because right now, we only use header-only libraries)
includedir = os.path.join(toolchain.install_prefix, 'include')
dest = os.path.join(includedir, 'boost')
shutil.rmtree(dest, ignore_errors=True)
shutil.copytree(os.path.join(src, 'boost'), dest)
def concatenate_cmdline_variables(src, names):
"""Find duplicate variable declarations on the given source list, and
concatenate the values of those in the 'names' list."""
# the result list being constructed
dest = []
# a map of variable name to destination list index
positions = {}
for item in src:
i = item.find('=')
if i > 0:
# it's a variable
name = item[:i]
if name in names:
# it's a known variable
if name in positions:
# already specified: concatenate instead of
# appending it
dest[positions[name]] += ' ' + item[i + 1:]
continue
else:
# not yet seen: append it and remember the list
# index
positions[name] = len(dest)
dest.append(item)
return dest
import os.path
lib_path = os.path.abspath('lib')
shared_path = lib_path
if 'MPD_SHARED_LIB' in os.environ:
shared_path = os.environ['MPD_SHARED_LIB']
tarball_path = os.path.join(shared_path, 'download')
src_path = os.path.join(shared_path, 'src')
from build.verify import verify_file_digest
import os
import urllib.request
def download_and_verify(url, md5, parent_path):
"""Download a file, verify its MD5 checksum and return the local path."""
os.makedirs(parent_path, exist_ok=True)
path = os.path.join(parent_path, os.path.basename(url))
try:
if verify_file_digest(path, md5): return path
os.unlink(path)
except FileNotFoundError:
pass
tmp_path = path + '.tmp'
print("download", url)
urllib.request.urlretrieve(url, tmp_path)
if not verify_file_digest(tmp_path, md5):
os.unlink(tmp_path)
raise RuntimeError("Digest mismatch")
os.rename(tmp_path, path)
return path
import os.path, subprocess
from build.project import Project
class FfmpegProject(Project):
def __init__(self, url, md5, installed, configure_args=[],
cppflags='',
**kwargs):
Project.__init__(self, url, md5, installed, **kwargs)
self.configure_args = configure_args
self.cppflags = cppflags
def _filter_cflags(self, flags):
# FFmpeg expects the GNU as syntax
flags = flags.replace(' -integrated-as ', ' -no-integrated-as ')
return flags
def build(self, toolchain):
src = self.unpack(toolchain)
build = self.make_build_path(toolchain)
if toolchain.is_arm:
arch = 'arm'
else:
arch = 'x86'
if toolchain.is_windows:
target_os = 'mingw32'
else:
target_os = 'linux'
configure = [
os.path.join(src, 'configure'),
'--cc=' + toolchain.cc,
'--cxx=' + toolchain.cxx,
'--nm=' + toolchain.nm,
'--extra-cflags=' + self._filter_cflags(toolchain.cflags) + ' ' + toolchain.cppflags + ' ' + self.cppflags,
'--extra-cxxflags=' + self._filter_cflags(toolchain.cxxflags) + ' ' + toolchain.cppflags + ' ' + self.cppflags,
'--extra-ldflags=' + toolchain.ldflags,
'--extra-libs=' + toolchain.libs,
'--ar=' + toolchain.ar,
'--ranlib=' + toolchain.ranlib,
'--enable-cross-compile',
'--arch=' + arch,
'--target-os=' + target_os,
'--prefix=' + toolchain.install_prefix,
] + self.configure_args
if toolchain.is_armv7:
configure.append('--cpu=cortex-a8')
subprocess.check_call(configure, cwd=build, env=toolchain.env)
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], cwd=build, env=toolchain.env)
subprocess.check_call(['/usr/bin/make', '--quiet', 'install'], cwd=build, env=toolchain.env)
import subprocess
from build.project import Project
class MakeProject(Project):
def __init__(self, url, md5, installed,
install_target='install',
**kwargs):
Project.__init__(self, url, md5, installed, **kwargs)
self.install_target = install_target
def get_simultaneous_jobs(self):
return 12
def get_make_args(self, toolchain):
return ['--quiet', '-j' + str(self.get_simultaneous_jobs())]
def get_make_install_args(self, toolchain):
return ['--quiet', self.install_target]
def make(self, toolchain, wd, args):
subprocess.check_call(['/usr/bin/make'] + args,
cwd=wd, env=toolchain.env)
def build(self, toolchain, wd, install=True):
self.make(toolchain, wd, self.get_make_args(toolchain))
if install:
self.make(toolchain, wd, self.get_make_install_args(toolchain))
import os, shutil
import re
from build.download import download_and_verify
from build.tar import untar
class Project:
def __init__(self, url, md5, installed, name=None, version=None,
base=None,
edits=None,
use_cxx=False):
if base is None:
basename = os.path.basename(url)
m = re.match(r'^(.+)\.(tar(\.(gz|bz2|xz|lzma))?|zip)$', basename)
if not m: raise
self.base = m.group(1)
else:
self.base = base
if name is None or version is None:
m = re.match(r'^([-\w]+)-(\d[\d.]*[a-z]?)$', self.base)
if name is None: name = m.group(1)
if version is None: version = m.group(2)
self.name = name
self.version = version
self.url = url
self.md5 = md5
self.installed = installed
self.edits = edits
self.use_cxx = use_cxx
def download(self, toolchain):
return download_and_verify(self.url, self.md5, toolchain.tarball_path)
def is_installed(self, toolchain):
tarball = self.download(toolchain)
installed = os.path.join(toolchain.install_prefix, self.installed)
tarball_mtime = os.path.getmtime(tarball)
try:
return os.path.getmtime(installed) >= tarball_mtime
except FileNotFoundError:
return False
def unpack(self, toolchain, out_of_tree=True):
if out_of_tree:
parent_path = toolchain.src_path
else:
parent_path = toolchain.build_path
path = untar(self.download(toolchain), parent_path, self.base)
if self.edits is not None:
for filename, function in self.edits.items():
with open(os.path.join(path, filename), 'r+t') as f:
old_data = f.read()
new_data = function(old_data)
f.seek(0)
f.truncate(0)
f.write(new_data)
return path
def make_build_path(self, toolchain):
path = os.path.join(toolchain.build_path, self.base)
try:
shutil.rmtree(path)
except FileNotFoundError:
pass
os.makedirs(path, exist_ok=True)
return path
import os, shutil, subprocess
def untar(tarball_path, parent_path, base):
path = os.path.join(parent_path, base)
try:
shutil.rmtree(path)
except FileNotFoundError:
pass
os.makedirs(parent_path, exist_ok=True)
subprocess.check_call(['/bin/tar', 'xfC', tarball_path, parent_path])
return path
import hashlib
def feed_file(h, f):
"""Feed data read from an open file into the hashlib instance."""
while True:
data = f.read(65536)
if len(data) == 0:
# end of file
break
h.update(data)
def feed_file_path(h, path):
"""Feed data read from a file (to be opened by this function) into the hashlib instance."""
with open(path, 'rb') as f:
feed_file(h, f)
def file_digest(algorithm, path):
"""Calculate the digest of a file and return it in hexadecimal notation."""
h = algorithm()
feed_file_path(h, path)
return h.hexdigest()
def guess_digest_algorithm(digest):
l = len(digest)
if l == 32:
return hashlib.md5
elif l == 40:
return hashlib.sha1
elif l == 64:
return hashlib.sha256
else:
return None
def verify_file_digest(path, expected_digest):
"""Verify the digest of a file, and return True if the digest matches with the given expected digest."""
algorithm = guess_digest_algorithm(expected_digest)
assert(algorithm is not None)
return file_digest(algorithm, path) == expected_digest
import os.path, subprocess
from build.project import Project
class ZlibProject(Project):
def __init__(self, url, md5, installed,
**kwargs):
Project.__init__(self, url, md5, installed, **kwargs)
def build(self, toolchain):
src = self.unpack(toolchain, out_of_tree=False)
subprocess.check_call(['/usr/bin/make', '--quiet',
'-f', 'win32/Makefile.gcc',
'PREFIX=' + toolchain.arch + '-',
'-j12',
'install',
'INCLUDE_PATH='+ os.path.join(toolchain.install_prefix, 'include'),
'LIBRARY_PATH=' + os.path.join(toolchain.install_prefix, 'lib'),
'BINARY_PATH=' + os.path.join(toolchain.install_prefix, 'bin'),
'SHARED_MODE=1'],
cwd=src, env=toolchain.env)
#!/usr/bin/env ruby
#
# This script verifies that every source includes config.h first.
# This is very important for consistent Large File Support.
#
def check_file(file)
first = true
file.each_line do |line|
if line =~ /^\#include\s+(\S+)/ then
if $1 == '"config.h"'
unless first
puts "#{file.path}: config.h included too late"
end
else
if first
puts "#{file.path}: config.h missing"
end
end
first = false
end
end
end
def check_path(path)
File.open(path) do |file|
check_file(file)
end
end
if ARGV.empty?
Dir["src/*.c"].each do |path|
check_path(path)
end
Dir["src/*/*.c"].each do |path|
check_path(path)
end
Dir["test/*.c"].each do |path|
check_path(path)
end
else
ARGV.each do |path|
check_path(path)
end
end
/* compress.c
* Compressor logic
*
* (c)2007 busybee (http://beesbuzz.biz/
* Licensed under the terms of the LGPL. See the file COPYING for details.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "compress.h"
struct Compressor {
//! The compressor's preferences
struct CompressorConfig prefs;
//! History of the peak values
int *peaks;
//! History of the gain values
int *gain;
//! History of clip amounts
int *clipped;
unsigned int pos;
unsigned int bufsz;
};
struct Compressor *Compressor_new(unsigned int history)
{
struct Compressor *obj = malloc(sizeof(struct Compressor));
if (obj == NULL)
/* out of memory, not much we can do */
abort();
obj->prefs.target = TARGET;
obj->prefs.maxgain = GAINMAX;
obj->prefs.smooth = GAINSMOOTH;
obj->peaks = obj->gain = obj->clipped = NULL;
obj->bufsz = 0;
obj->pos = 0;
Compressor_setHistory(obj, history);
return obj;
}
void Compressor_delete(struct Compressor *obj)
{
if (obj->peaks)
free(obj->peaks);
if (obj->gain)
free(obj->gain);
if (obj->clipped)
free(obj->clipped);
free(obj);
}
static int *resizeArray(int *data, int newsz, int oldsz)
{
data = realloc(data, newsz*sizeof(int));
if (data == NULL)
/* out of memory, not much we can do */
abort();
if (newsz > oldsz)
memset(data + oldsz, 0, sizeof(int)*(newsz - oldsz));
return data;
}
void Compressor_setHistory(struct Compressor *obj, unsigned int history)
{
if (!history)
history = BUCKETS;
obj->peaks = resizeArray(obj->peaks, history, obj->bufsz);
obj->gain = resizeArray(obj->gain, history, obj->bufsz);
obj->clipped = resizeArray(obj->clipped, history, obj->bufsz);
obj->bufsz = history;
}
struct CompressorConfig *Compressor_getConfig(struct Compressor *obj)
{
return &obj->prefs;
}
void Compressor_Process_int16(struct Compressor *obj, int16_t *audio,
unsigned int count)
{
struct CompressorConfig *prefs = Compressor_getConfig(obj);
int16_t *ap;
unsigned int i;
int *peaks = obj->peaks;
int curGain = obj->gain[obj->pos];
int newGain;
int peakVal = 1;
int peakPos = 0;
int slot = (obj->pos + 1) % obj->bufsz;
int *clipped = obj->clipped + slot;
unsigned int ramp = count;
int delta;
ap = audio;
for (i = 0; i < count; i++)
{
int val = *ap++;
if (val < 0)
val = -val;
if (val > peakVal)
{
peakVal = val;
peakPos = i;
}
}
peaks[slot] = peakVal;
for (i = 0; i < obj->bufsz; i++)
{
if (peaks[i] > peakVal)
{
peakVal = peaks[i];
peakPos = 0;
}
}
//! Determine target gain
newGain = (1 << 10)*prefs->target/peakVal;
//! Adjust the gain with inertia from the previous gain value
newGain = (curGain*((1 << prefs->smooth) - 1) + newGain)
>> prefs->smooth;
//! Make sure it's no more than the maximum gain value
if (newGain > (prefs->maxgain << 10))
newGain = prefs->maxgain << 10;
//! Make sure it's no less than 1:1
if (newGain < (1 << 10))
newGain = 1 << 10;
//! Make sure the adjusted gain won't cause clipping
if ((peakVal*newGain >> 10) > 32767)
{
newGain = (32767 << 10)/peakVal;
//! Truncate the ramp time
ramp = peakPos;
}
//! Record the new gain
obj->gain[slot] = newGain;
if (!ramp)
ramp = 1;
if (!curGain)
curGain = 1 << 10;
delta = (newGain - curGain) / (int)ramp;
ap = audio;
*clipped = 0;
for (i = 0; i < count; i++)
{
int sample;
//! Amplify the sample
sample = *ap*curGain >> 10;
if (sample < -32768)
{
*clipped += -32768 - sample;
sample = -32768;
} else if (sample > 32767)
{
*clipped += sample - 32767;
sample = 32767;
}
*ap++ = sample;
//! Adjust the gain
if (i < ramp)
curGain += delta;
else
curGain = newGain;
}
obj->pos = slot;
}
/*! compress.h
* interface to audio compression
*
* (c)2007 busybee (http://beesbuzz.biz/)
* Licensed under the terms of the LGPL. See the file COPYING for details.
*/
#ifndef COMPRESS_H
#define COMPRESS_H
#include <stdint.h>
//! Configuration values for the compressor object
struct CompressorConfig {
int target;
int maxgain;
int smooth;
};
struct Compressor;
#ifdef __cplusplus
extern "C" {
#endif
//! Create a new compressor (use history value of 0 for default)
struct Compressor *Compressor_new(unsigned int history);
//! Delete a compressor
void Compressor_delete(struct Compressor *);
//! Set the history length
void Compressor_setHistory(struct Compressor *, unsigned int history);
//! Get the configuration for a compressor
struct CompressorConfig *Compressor_getConfig(struct Compressor *);
//! Process 16-bit signed data
void Compressor_Process_int16(struct Compressor *, int16_t *data, unsigned int count);
#ifdef __cplusplus
}
#endif
//! TODO: Compressor_Process_int32, Compressor_Process_float, others as needed
//! TODO: functions for getting at the peak/gain/clip history buffers (for monitoring)
#endif
/* config.h
** Default values for the configuration, and also a few random debug things
*/
#ifndef AC_CONFIG_H
#define AC_CONFIG_H
/*** Version information ***/
#define ACVERSION "2.0"
/*** Default configuration stuff ***/
#define TARGET 16384 /*!< Target level (on a scale of 0-32767) */
#define GAINMAX 32 /*!< The maximum amount to amplify by */
#define GAINSMOOTH 8 /*!< How much inertia ramping has*/
#define BUCKETS 400 /*!< How long of a history to use by default */
#endif
/*
* Copyright 2003-2017 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.
*/
#include "AudioFormat.hxx"
#include "util/StringBuffer.hxx"
#include <assert.h>
#include <stdio.h>
void
AudioFormat::ApplyMask(AudioFormat mask) noexcept
{
assert(IsValid());
assert(mask.IsMaskValid());
if (mask.sample_rate != 0)
sample_rate = mask.sample_rate;
if (mask.format != SampleFormat::UNDEFINED)
format = mask.format;
if (mask.channels != 0)
channels = mask.channels;
assert(IsValid());
}
StringBuffer<24>
ToString(const AudioFormat af) noexcept
{
StringBuffer<24> buffer;
if (af.format == SampleFormat::DSD && af.sample_rate > 0 &&
af.sample_rate % 44100 == 0) {
/* use shortcuts such as "dsd64" which implies the
sample rate */
snprintf(buffer.data(), buffer.capacity(), "dsd%u:%u",
af.sample_rate * 8 / 44100,
af.channels);
return buffer;
}
snprintf(buffer.data(), buffer.capacity(), "%u:%s:%u",
af.sample_rate, sample_format_to_string(af.format),
af.channels);
return buffer;
}
/*
* Copyright 2003-2017 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_AUDIO_FORMAT_HXX
#define MPD_AUDIO_FORMAT_HXX
#include "pcm/SampleFormat.hxx"
#include "Compiler.h"
#include <assert.h>
#include <stdint.h>
#include <stddef.h>
template<size_t CAPACITY> class StringBuffer;
static constexpr unsigned MAX_CHANNELS = 8;
/**
* This structure describes the format of a raw PCM stream.
*/
struct AudioFormat {
/**
* The sample rate in Hz. A better name for this attribute is
* "frame rate", because technically, you have two samples per
* frame in stereo sound.
*/
uint32_t sample_rate;
/**
* The format samples are stored in. See the #sample_format
* enum for valid values.
*/
SampleFormat format;
/**
* The number of channels.
*
* Channel order follows the FLAC convention
* (https://xiph.org/flac/format.html):
*
* - 1 channel: mono
* - 2 channels: left, right
* - 3 channels: left, right, center
* - 4 channels: front left, front right, back left, back right
* - 5 channels: front left, front right, front center, back/surround left, back/surround right
* - 6 channels: front left, front right, front center, LFE, back/surround left, back/surround right
* - 7 channels: front left, front right, front center, LFE, back center, side left, side right
* - 8 channels: front left, front right, front center, LFE, back left, back right, side left, side right
*/
uint8_t channels;
AudioFormat() = default;
constexpr AudioFormat(uint32_t _sample_rate,
SampleFormat _format, uint8_t _channels)
:sample_rate(_sample_rate),
format(_format), channels(_channels) {}
static constexpr AudioFormat Undefined() {
return AudioFormat(0, SampleFormat::UNDEFINED,0);
}
/**
* Clears the object, i.e. sets all attributes to an undefined
* (invalid) value.
*/
void Clear() {
sample_rate = 0;
format = SampleFormat::UNDEFINED;
channels = 0;
}
/**
* Checks whether the object has a defined value.
*/
constexpr bool IsDefined() const {
return sample_rate != 0;
}
/**
* Checks whether the object is full, i.e. all attributes are
* defined. This is more complete than IsDefined(), but
* slower.
*/
constexpr bool IsFullyDefined() const {
return sample_rate != 0 && format != SampleFormat::UNDEFINED &&
channels != 0;
}
/**
* Checks whether the object has at least one defined value.
*/
constexpr bool IsMaskDefined() const {
return sample_rate != 0 || format != SampleFormat::UNDEFINED ||
channels != 0;
}
bool IsValid() const;
bool IsMaskValid() const;
constexpr bool operator==(const AudioFormat other) const {
return sample_rate == other.sample_rate &&
format == other.format &&
channels == other.channels;
}
constexpr bool operator!=(const AudioFormat other) const {
return !(*this == other);
}
void ApplyMask(AudioFormat mask) noexcept;
gcc_pure
AudioFormat WithMask(AudioFormat mask) const noexcept {
AudioFormat result = *this;
result.ApplyMask(mask);
return result;
}
/**
* Returns the size of each (mono) sample in bytes.
*/
unsigned GetSampleSize() const;
/**
* Returns the size of each full frame in bytes.
*/
unsigned GetFrameSize() const;
/**
* Returns the floating point factor which converts a time
* span to a storage size in bytes.
*/
double GetTimeToSize() const;
};
/**
* Checks whether the sample rate is valid.
*
* @param sample_rate the sample rate in Hz
*/
static constexpr inline bool
audio_valid_sample_rate(unsigned sample_rate)
{
return sample_rate > 0 && sample_rate < (1 << 30);
}
/**
* Checks whether the number of channels is valid.
*/
static constexpr inline bool
audio_valid_channel_count(unsigned channels)
{
return channels >= 1 && channels <= MAX_CHANNELS;
}
/**
* Returns false if the format is not valid for playback with MPD.
* This function performs some basic validity checks.
*/
inline bool
AudioFormat::IsValid() const
{
return audio_valid_sample_rate(sample_rate) &&
audio_valid_sample_format(format) &&
audio_valid_channel_count(channels);
}
/**
* Returns false if the format mask is not valid for playback with
* MPD. This function performs some basic validity checks.
*/
inline bool
AudioFormat::IsMaskValid() const
{
return (sample_rate == 0 ||
audio_valid_sample_rate(sample_rate)) &&
(format == SampleFormat::UNDEFINED ||
audio_valid_sample_format(format)) &&
(channels == 0 || audio_valid_channel_count(channels));
}
inline unsigned
AudioFormat::GetSampleSize() const
{
return sample_format_size(format);
}
inline unsigned
AudioFormat::GetFrameSize() const
{
return GetSampleSize() * channels;
}
inline double
AudioFormat::GetTimeToSize() const
{
return sample_rate * GetFrameSize();
}
/**
* Renders the #AudioFormat object into a string, e.g. for printing
* it in a log file.
*
* @param af the #AudioFormat object
* @return the string buffer
*/
gcc_const
StringBuffer<24>
ToString(AudioFormat af) noexcept;
#endif
/*
* Copyright 2003-2017 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.
*/
/*
* Parser functions for audio related objects.
*
*/
#include "config.h"
#include "AudioParser.hxx"
#include "AudioFormat.hxx"
#include "util/RuntimeError.hxx"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
static uint32_t
ParseSampleRate(const char *src, bool mask, const char **endptr_r)
{
unsigned long value;
char *endptr;
if (mask && *src == '*') {
*endptr_r = src + 1;
return 0;
}
value = strtoul(src, &endptr, 10);
if (endptr == src) {
throw std::runtime_error("Failed to parse the sample rate");
} else if (!audio_valid_sample_rate(value))
throw FormatRuntimeError("Invalid sample rate: %lu",
value);
*endptr_r = endptr;
return value;
}
static SampleFormat
ParseSampleFormat(const char *src, bool mask, const char **endptr_r)
{
unsigned long value;
char *endptr;
SampleFormat sample_format;
if (mask && *src == '*') {
*endptr_r = src + 1;
return SampleFormat::UNDEFINED;
}
if (*src == 'f') {
*endptr_r = src + 1;
return SampleFormat::FLOAT;
}
if (memcmp(src, "dsd", 3) == 0) {
*endptr_r = src + 3;
return SampleFormat::DSD;
}
value = strtoul(src, &endptr, 10);
if (endptr == src)
throw std::runtime_error("Failed to parse the sample format");
switch (value) {
case 8:
sample_format = SampleFormat::S8;
break;
case 16:
sample_format = SampleFormat::S16;
break;
case 24:
if (memcmp(endptr, "_3", 2) == 0)
/* for backwards compatibility */
endptr += 2;
sample_format = SampleFormat::S24_P32;
break;
case 32:
sample_format = SampleFormat::S32;
break;
default:
throw FormatRuntimeError("Invalid sample format: %lu", value);
}
assert(audio_valid_sample_format(sample_format));
*endptr_r = endptr;
return sample_format;
}
static uint8_t
ParseChannelCount(const char *src, bool mask, const char **endptr_r)
{
unsigned long value;
char *endptr;
if (mask && *src == '*') {
*endptr_r = src + 1;
return 0;
}
value = strtoul(src, &endptr, 10);
if (endptr == src)
throw std::runtime_error("Failed to parse the channel count");
else if (!audio_valid_channel_count(value))
throw FormatRuntimeError("Invalid channel count: %u", value);
*endptr_r = endptr;
return value;
}
AudioFormat
ParseAudioFormat(const char *src, bool mask)
{
AudioFormat dest;
dest.Clear();
if (strncmp(src, "dsd", 3) == 0) {
/* allow format specifications such as "dsd64" which
implies the sample rate */
char *endptr;
auto dsd = strtoul(src + 3, &endptr, 10);
if (endptr > src + 3 && *endptr == ':' &&
dsd >= 32 && dsd <= 4096 && dsd % 2 == 0) {
dest.sample_rate = dsd * 44100 / 8;
dest.format = SampleFormat::DSD;
src = endptr + 1;
dest.channels = ParseChannelCount(src, mask, &src);
if (*src != 0)
throw FormatRuntimeError("Extra data after channel count: %s", src);
return dest;
}
}
/* parse sample rate */
dest.sample_rate = ParseSampleRate(src, mask, &src);
if (*src++ != ':')
throw std::runtime_error("Sample format missing");
/* parse sample format */
dest.format = ParseSampleFormat(src, mask, &src);
if (*src++ != ':')
throw std::runtime_error("Channel count missing");
/* parse channel count */
dest.channels = ParseChannelCount(src, mask, &src);
if (*src != 0)
throw FormatRuntimeError("Extra data after channel count: %s", src);
assert(mask
? dest.IsMaskValid()
: dest.IsValid());
return dest;
}
/*
* Copyright 2003-2017 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.
*/
/** \file
*
* Parser functions for audio related objects.
*/
#ifndef MPD_AUDIO_PARSER_HXX
#define MPD_AUDIO_PARSER_HXX
struct AudioFormat;
/**
* Parses a string in the form "SAMPLE_RATE:BITS:CHANNELS" into an
* #AudioFormat.
*
* Throws #std::runtime_error on error.
*
* @param src the input string
* @param mask if true, then "*" is allowed for any number of items
*/
AudioFormat
ParseAudioFormat(const char *src, bool mask);
#endif
/*
* Copyright 2003-2017 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_BULK_EDIT_HXX
#define MPD_BULK_EDIT_HXX
#include "Partition.hxx"
/**
* Begin a "bulk edit" and commit it automatically.
*/
class ScopeBulkEdit {
Partition &partition;
public:
ScopeBulkEdit(Partition &_partition):partition(_partition) {
partition.playlist.BeginBulk();
}
~ScopeBulkEdit() {
partition.playlist.CommitBulk(partition.pc);
}
};
#endif
/*
* Copyright 2003-2017 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.
*/
#include "config.h"
#include "CheckAudioFormat.hxx"
#include "AudioFormat.hxx"
#include "util/RuntimeError.hxx"
#include <stdexcept>
#include <assert.h>
void
CheckSampleRate(unsigned long sample_rate)
{
if (!audio_valid_sample_rate(sample_rate))
throw FormatRuntimeError("Invalid sample rate: %lu",
sample_rate);
}
void
CheckSampleFormat(SampleFormat sample_format)
{
if (!audio_valid_sample_format(sample_format))
throw FormatRuntimeError("Invalid sample format: %u",
unsigned(sample_format));
}
void
CheckChannelCount(unsigned channels)
{
if (!audio_valid_channel_count(channels))
throw FormatRuntimeError("Invalid channel count: %u",
channels);
}
AudioFormat
CheckAudioFormat(unsigned long sample_rate,
SampleFormat sample_format, unsigned channels)
{
CheckSampleRate(sample_rate);
CheckSampleFormat(sample_format);
CheckChannelCount(channels);
return AudioFormat(sample_rate, sample_format, channels);
}
/*
* Copyright 2003-2017 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_CHECK_AUDIO_FORMAT_HXX
#define MPD_CHECK_AUDIO_FORMAT_HXX
#include "AudioFormat.hxx"
void
CheckSampleRate(unsigned long sample_rate);
void
CheckSampleFormat(SampleFormat sample_format);
void
CheckChannelCount(unsigned sample_format);
/**
* Check #AudioFormat attributes and construct an #AudioFormat
* instance.
*
* Throws #std::runtime_error on error.
*/
AudioFormat
CheckAudioFormat(unsigned long sample_rate,
SampleFormat sample_format, unsigned channels);
#endif
/*
* Copyright 2003-2017 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_CHRONO_HXX
#define MPD_CHRONO_HXX
#include <chrono>
#include <utility>
#include <cstdint>
/**
* A time stamp within a song. Granularity is 1 millisecond and the
* maximum value is about 49 days.
*/
class SongTime : public std::chrono::duration<std::uint32_t, std::milli> {
typedef std::chrono::duration<std::uint32_t, std::milli> Base;
typedef Base::rep rep;
public:
SongTime() = default;
template<typename T>
explicit constexpr SongTime(T t):Base(t) {}
static constexpr SongTime zero() {
return SongTime(Base::zero());
}
static constexpr SongTime FromS(unsigned s) {
return SongTime(rep(s) * 1000);
}
static constexpr SongTime FromS(float s) {
return SongTime(rep(s * 1000));
}
static constexpr SongTime FromS(double s) {
return SongTime(rep(s * 1000));
}
static constexpr SongTime FromMS(rep ms) {
return SongTime(ms);
}
constexpr rep ToS() const {
return count() / rep(1000);
}
constexpr rep RoundS() const {
return (count() + 500) / rep(1000);
}
constexpr rep ToMS() const {
return count();
}
template<typename T=rep>
constexpr T ToScale(unsigned scale) const {
return count() * T(scale) / 1000;
}
/**
* Convert a scalar value with the given scale to a #SongTime
* instance.
*
* @param value the input value
* @param scale the value's scale in Hz
*/
template<typename T=rep>
static constexpr SongTime FromScale(T value, unsigned scale) {
return SongTime(value * T(1000) / T(scale));
}
constexpr double ToDoubleS() const {
return double(count()) / 1000.;
};
constexpr bool IsZero() const {
return count() == 0;
}
constexpr bool IsPositive() const {
return count() > 0;
}
constexpr SongTime operator+(const SongTime &other) const {
return SongTime(*(const Base *)this + (const Base &)other);
}
constexpr SongTime operator-(const SongTime &other) const {
return SongTime(*(const Base *)this - (const Base &)other);
}
};
/**
* A variant of #SongTime that is based on a signed integer. It can
* be used for relative values.
*/
class SignedSongTime : public std::chrono::duration<std::int32_t, std::milli> {
typedef std::chrono::duration<std::int32_t, std::milli> Base;
typedef Base::rep rep;
public:
SignedSongTime() = default;
template<typename T>
explicit constexpr SignedSongTime(T t):Base(t) {}
/**
* Allow implicit conversion from SongTime to SignedSongTime.
*/
constexpr SignedSongTime(SongTime t):Base(t) {}
static constexpr SignedSongTime zero() {
return SignedSongTime(Base::zero());
}
/**
* Generate a negative value.
*/
static constexpr SignedSongTime Negative() {
return SignedSongTime(-1);
}
static constexpr SignedSongTime FromS(int s) {
return SignedSongTime(rep(s) * 1000);
}
static constexpr SignedSongTime FromS(unsigned s) {
return SignedSongTime(rep(s) * 1000);
}
static constexpr SignedSongTime FromS(float s) {
return SignedSongTime(rep(s * 1000));
}
static constexpr SignedSongTime FromS(double s) {
return SignedSongTime(rep(s * 1000));
}
static constexpr SignedSongTime FromMS(rep ms) {
return SignedSongTime(ms);
}
constexpr rep ToS() const {
return count() / rep(1000);
}
constexpr rep RoundS() const {
return (count() + 500) / rep(1000);
}
constexpr rep ToMS() const {
return count();
}
template<typename T=rep>
constexpr T ToScale(unsigned scale) const {
return count() * T(scale) / 1000;
}
/**
* Convert a scalar value with the given scale to a
* #SignedSongTime instance.
*
* @param value the input value
* @param scale the value's scale in Hz
*/
template<typename T=rep>
static constexpr SignedSongTime FromScale(T value, unsigned scale) {
return SignedSongTime(value * T(1000) / T(scale));
}
constexpr double ToDoubleS() const {
return double(count()) / 1000.;
};
constexpr bool IsZero() const {
return count() == 0;
}
constexpr bool IsPositive() const {
return count() > 0;
}
constexpr bool IsNegative() const {
return count() < 0;
}
constexpr SignedSongTime operator+(const SignedSongTime &other) const {
return SignedSongTime(*(const Base *)this + (const Base &)other);
}
constexpr SignedSongTime operator-(const SignedSongTime &other) const {
return SignedSongTime(*(const Base *)this - (const Base &)other);
}
};
#endif
/*
* Copyright 2003-2017 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_COMMAND_LINE_HXX
#define MPD_COMMAND_LINE_HXX
struct options {
bool kill;
bool daemon;
bool log_stderr;
bool verbose;
};
void
ParseCommandLine(int argc, char **argv, struct options *options);
#endif
/*
* Copyright 2003-2017 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 COMPILER_H
#define COMPILER_H
#define GCC_MAKE_VERSION(major, minor, patchlevel) ((major) * 10000 + (minor) * 100 + patchlevel)
#ifdef __GNUC__
#define GCC_VERSION GCC_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#else
#define GCC_VERSION 0
#endif
#ifdef __clang__
# define CLANG_VERSION GCC_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
#elif defined(__GNUC__)
# define CLANG_VERSION 0
#endif
/**
* Are we building with the specified version of gcc (not clang or any
* other compiler) or newer?
*/
#define GCC_CHECK_VERSION(major, minor) \
(CLANG_VERSION == 0 && \
GCC_VERSION >= GCC_MAKE_VERSION(major, minor, 0))
/**
* Are we building with clang (any version) or at least the specified
* gcc version?
*/
#define CLANG_OR_GCC_VERSION(major, minor) \
(CLANG_VERSION > 0 || GCC_CHECK_VERSION(major, minor))
/**
* Are we building with gcc (not clang or any other compiler) and a
* version older than the specified one?
*/
#define GCC_OLDER_THAN(major, minor) \
(GCC_VERSION > 0 && CLANG_VERSION == 0 && \
GCC_VERSION < GCC_MAKE_VERSION(major, minor, 0))
#ifdef __clang__
# if __clang_major__ < 3
# error Sorry, your clang version is too old. You need at least version 3.1.
# endif
#elif defined(__GNUC__)
# if GCC_OLDER_THAN(4,9)
# error Sorry, your gcc version is too old. You need at least version 4.9.
# endif
#else
# warning Untested compiler. Use at your own risk!
#endif
/**
* Are we building with the specified version of clang or newer?
*/
#define CLANG_CHECK_VERSION(major, minor) \
(CLANG_VERSION >= GCC_MAKE_VERSION(major, minor, 0))
#if CLANG_OR_GCC_VERSION(4,0)
/* GCC 4.x */
#define gcc_const __attribute__((const))
#define gcc_deprecated __attribute__((deprecated))
#define gcc_may_alias __attribute__((may_alias))
#define gcc_malloc __attribute__((malloc))
#define gcc_noreturn __attribute__((noreturn))
#define gcc_packed __attribute__((packed))
#define gcc_printf(a,b) __attribute__((format(printf, a, b)))
#define gcc_pure __attribute__((pure))
#define gcc_sentinel __attribute__((sentinel))
#define gcc_unused __attribute__((unused))
#define gcc_warn_unused_result __attribute__((warn_unused_result))
#define gcc_nonnull(...) __attribute__((nonnull(__VA_ARGS__)))
#define gcc_nonnull_all __attribute__((nonnull))
#define gcc_likely(x) __builtin_expect (!!(x), 1)
#define gcc_unlikely(x) __builtin_expect (!!(x), 0)
#define gcc_visibility_hidden __attribute__((visibility("hidden")))
#define gcc_visibility_default __attribute__((visibility("default")))
#define gcc_always_inline __attribute__((always_inline))
#else
/* generic C compiler */
#define gcc_const
#define gcc_deprecated
#define gcc_may_alias
#define gcc_malloc
#define gcc_noreturn
#define gcc_packed
#define gcc_printf(a,b)
#define gcc_pure
#define gcc_sentinel
#define gcc_unused
#define gcc_warn_unused_result
#define gcc_nonnull(...)
#define gcc_nonnull_all
#define gcc_likely(x) (x)
#define gcc_unlikely(x) (x)
#define gcc_visibility_hidden
#define gcc_visibility_default
#define gcc_always_inline inline
#endif
#if CLANG_OR_GCC_VERSION(4,3)
#define gcc_hot __attribute__((hot))
#define gcc_cold __attribute__((cold))
#else /* ! GCC_UNUSED >= 40300 */
#define gcc_hot
#define gcc_cold
#endif /* ! GCC_UNUSED >= 40300 */
#if GCC_CHECK_VERSION(4,6)
#define gcc_flatten __attribute__((flatten))
#else
#define gcc_flatten
#endif
#ifndef __cplusplus
/* plain C99 has "restrict" */
#define gcc_restrict restrict
#elif CLANG_OR_GCC_VERSION(4,0)
/* "__restrict__" is a GCC extension for C++ */
#define gcc_restrict __restrict__
#else
/* disable it on other compilers */
#define gcc_restrict
#endif
#ifndef __has_feature
// define dummy macro for non-clang compilers
#define __has_feature(x) 0
#endif
#if __has_feature(attribute_unused_on_fields)
#define gcc_unused_field gcc_unused
#else
#define gcc_unused_field
#endif
#if defined(__GNUC__) || defined(__clang__)
#define gcc_unreachable() __builtin_unreachable()
#else
#define gcc_unreachable()
#endif
#endif
/*
* Copyright 2003-2017 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.
*/
#include "config.h"
#include "DetachedSong.hxx"
#include "db/LightSong.hxx"
#include "util/UriUtil.hxx"
#include "fs/Traits.hxx"
DetachedSong::DetachedSong(const LightSong &other)
:uri(other.GetURI().c_str()),
real_uri(other.real_uri != nullptr ? other.real_uri : ""),
tag(*other.tag),
mtime(other.mtime),
start_time(other.start_time),
end_time(other.end_time) {}
DetachedSong::~DetachedSong()
{
/* this destructor exists here just so it won't inlined */
}
bool
DetachedSong::IsRemote() const noexcept
{
return uri_has_scheme(GetRealURI());
}
bool
DetachedSong::IsAbsoluteFile() const noexcept
{
return PathTraitsUTF8::IsAbsolute(GetRealURI());
}
bool
DetachedSong::IsInDatabase() const noexcept
{
/* here, we use GetURI() and not GetRealURI() because
GetRealURI() is never relative */
const char *_uri = GetURI();
return !uri_has_scheme(_uri) && !PathTraitsUTF8::IsAbsolute(_uri);
}
SignedSongTime
DetachedSong::GetDuration() const noexcept
{
SongTime a = start_time, b = end_time;
if (!b.IsPositive()) {
if (tag.duration.IsNegative())
return tag.duration;
b = SongTime(tag.duration);
}
return SignedSongTime(b - a);
}
/*
* Copyright 2003-2017 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_DETACHED_SONG_HXX
#define MPD_DETACHED_SONG_HXX
#include "check.h"
#include "tag/Tag.hxx"
#include "Chrono.hxx"
#include "Compiler.h"
#include <string>
#include <utility>
#include <time.h>
struct LightSong;
class Storage;
class Path;
class DetachedSong {
friend DetachedSong DatabaseDetachSong(const Storage &db,
const LightSong &song);
/**
* An UTF-8-encoded URI referring to the song file. This can
* be one of:
*
* - an absolute URL with a scheme
* (e.g. "http://example.com/foo.mp3")
*
* - an absolute file name
*
* - a file name relative to the music directory
*/
std::string uri;
/**
* The "real" URI, the one to be used for opening the
* resource. If this attribute is empty, then #uri shall be
* used.
*
* This attribute is used for songs from the database which
* have a relative URI.
*/
std::string real_uri;
Tag tag;
time_t mtime = 0;
/**
* Start of this sub-song within the file.
*/
SongTime start_time = SongTime::zero();
/**
* End of this sub-song within the file.
* Unused if zero.
*/
SongTime end_time = SongTime::zero();
explicit DetachedSong(const LightSong &other);
public:
explicit DetachedSong(const DetachedSong &) = default;
explicit DetachedSong(const char *_uri)
:uri(_uri) {}
explicit DetachedSong(const std::string &_uri)
:uri(_uri) {}
explicit DetachedSong(std::string &&_uri)
:uri(std::move(_uri)) {}
template<typename U>
DetachedSong(U &&_uri, Tag &&_tag)
:uri(std::forward<U>(_uri)),
tag(std::move(_tag)) {}
DetachedSong(DetachedSong &&) = default;
~DetachedSong();
gcc_pure
const char *GetURI() const noexcept {
return uri.c_str();
}
template<typename T>
void SetURI(T &&_uri) {
uri = std::forward<T>(_uri);
}
/**
* Does this object have a "real" URI different from the
* displayed URI?
*/
gcc_pure
bool HasRealURI() const noexcept {
return !real_uri.empty();
}
/**
* Returns "real" URI (#real_uri) and falls back to just
* GetURI().
*/
gcc_pure
const char *GetRealURI() const noexcept {
return (HasRealURI() ? real_uri : uri).c_str();
}
template<typename T>
void SetRealURI(T &&_uri) {
real_uri = std::forward<T>(_uri);
}
/**
* Returns true if both objects refer to the same physical
* song.
*/
gcc_pure
bool IsSame(const DetachedSong &other) const noexcept {
return uri == other.uri &&
start_time == other.start_time &&
end_time == other.end_time;
}
gcc_pure gcc_nonnull_all
bool IsURI(const char *other_uri) const noexcept {
return uri == other_uri;
}
gcc_pure
bool IsRemote() const noexcept;
gcc_pure
bool IsFile() const noexcept {
return !IsRemote();
}
gcc_pure
bool IsAbsoluteFile() const noexcept;
gcc_pure
bool IsInDatabase() const noexcept;
const Tag &GetTag() const noexcept {
return tag;
}
Tag &WritableTag() noexcept {
return tag;
}
void SetTag(const Tag &_tag) {
tag = Tag(_tag);
}
void SetTag(Tag &&_tag) {
tag = std::move(_tag);
}
void MoveTagFrom(DetachedSong &&other) {
tag = std::move(other.tag);
}
/**
* Similar to the MoveTagFrom(), but move only the #TagItem
* array.
*/
void MoveTagItemsFrom(DetachedSong &&other) {
tag.MoveItemsFrom(std::move(other.tag));
}
time_t GetLastModified() const {
return mtime;
}
void SetLastModified(time_t _value) {
mtime = _value;
}
SongTime GetStartTime() const {
return start_time;
}
void SetStartTime(SongTime _value) {
start_time = _value;
}
SongTime GetEndTime() const {
return end_time;
}
void SetEndTime(SongTime _value) {
end_time = _value;
}
gcc_pure
SignedSongTime GetDuration() const noexcept;
/**
* Update the #tag and #mtime.
*
* @return true on success
*/
bool Update();
/**
* Load #tag and #mtime from a local file.
*/
bool LoadFile(Path path);
};
#endif
/*
* Copyright 2003-2017 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.
*/
#include "config.h"
#include "IOThread.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "thread/Thread.hxx"
#include "thread/Name.hxx"
#include "event/Loop.hxx"
#include <assert.h>
static struct {
Mutex mutex;
Cond cond;
EventLoop *loop;
Thread thread;
} io;
void
io_thread_run(void)
{
assert(io_thread_inside());
assert(io.loop != nullptr);
io.loop->Run();
}
static void
io_thread_func(gcc_unused void *arg)
{
SetThreadName("io");
/* lock+unlock to synchronize with io_thread_start(), to be
sure that io.thread is set */
io.mutex.lock();
io.mutex.unlock();
io_thread_run();
}
void
io_thread_init(void)
{
assert(io.loop == nullptr);
assert(!io.thread.IsDefined());
io.loop = new EventLoop();
}
void
io_thread_start()
{
assert(io.loop != nullptr);
assert(!io.thread.IsDefined());
const std::lock_guard<Mutex> protect(io.mutex);
io.thread.Start(io_thread_func, nullptr);
}
void
io_thread_quit(void)
{
assert(io.loop != nullptr);
io.loop->Break();
}
void
io_thread_deinit(void)
{
if (io.thread.IsDefined()) {
io_thread_quit();
io.thread.Join();
}
delete io.loop;
}
EventLoop &
io_thread_get() noexcept
{
assert(io.loop != nullptr);
return *io.loop;
}
bool
io_thread_inside() noexcept
{
return io.thread.IsInside();
}
/*
* Copyright 2003-2017 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_IO_THREAD_HXX
#define MPD_IO_THREAD_HXX
#include "Compiler.h"
class EventLoop;
void
io_thread_init();
void
io_thread_start();
/**
* Run the I/O event loop synchronously in the current thread. This
* can be called instead of io_thread_start(). For testing purposes
* only.
*/
void
io_thread_run();
/**
* Ask the I/O thread to quit, but does not wait for it. Usually, you
* don't need to call this function, because io_thread_deinit()
* includes this.
*/
void
io_thread_quit();
void
io_thread_deinit();
gcc_const
EventLoop &
io_thread_get() noexcept;
/**
* Is the current thread the I/O thread?
*/
gcc_pure
bool
io_thread_inside() noexcept;
#endif
/*
* Copyright 2003-2017 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.
*/
#include "config.h"
#include "IcyMetaDataParser.hxx"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
#include "util/Domain.hxx"
#include "util/StringView.hxx"
#include "Log.hxx"
#include <assert.h>
#include <string.h>
static constexpr Domain icy_metadata_domain("icy_metadata");
void
IcyMetaDataParser::Reset()
{
if (!IsDefined())
return;
if (data_rest == 0 && meta_size > 0)
delete[] meta_data;
delete tag;
data_rest = data_size;
meta_size = 0;
}
size_t
IcyMetaDataParser::Data(size_t length)
{
assert(length > 0);
if (!IsDefined())
return length;
if (data_rest == 0)
return 0;
if (length >= data_rest) {
length = data_rest;
data_rest = 0;
} else
data_rest -= length;
return length;
}
static void
icy_add_item(TagBuilder &tag, TagType type, const char *value)
{
size_t length = strlen(value);
if (length >= 2 && value[0] == '\'' && value[length - 1] == '\'') {
/* strip the single quotes */
++value;
length -= 2;
}
if (length > 0)
tag.AddItem(type, {value, length});
}
static void
icy_parse_tag_item(TagBuilder &tag, const char *name, const char *value)
{
if (strcmp(name, "StreamTitle") == 0)
icy_add_item(tag, TAG_TITLE, value);
else
FormatDebug(icy_metadata_domain,
"unknown icy-tag: '%s'", name);
}
/**
* Find a single quote that is followed by a semicolon (or by the end
* of the string). If that fails, return the first single quote. If
* that also fails, return #end.
*/
static char *
find_end_quote(char *p, char *const end)
{
char *fallback = std::find(p, end, '\'');
if (fallback >= end - 1 || fallback[1] == ';')
return fallback;
p = fallback + 1;
while (true) {
p = std::find(p, end, '\'');
if (p == end)
return fallback;
if (p == end - 1 || p[1] == ';')
return p;
++p;
}
}
static Tag *
icy_parse_tag(char *p, char *const end)
{
assert(p != nullptr);
assert(end != nullptr);
assert(p <= end);
TagBuilder tag;
while (p != end) {
const char *const name = p;
char *eq = std::find(p, end, '=');
if (eq == end)
break;
*eq = 0;
p = eq + 1;
if (*p != '\'') {
/* syntax error; skip to the next semicolon,
try to recover */
char *semicolon = std::find(p, end, ';');
if (semicolon == end)
break;
p = semicolon + 1;
continue;
}
++p;
const char *const value = p;
char *quote = find_end_quote(p, end);
if (quote == end)
break;
*quote = 0;
p = quote + 1;
icy_parse_tag_item(tag, name, value);
char *semicolon = std::find(p, end, ';');
if (semicolon == end)
break;
p = semicolon + 1;
}
return tag.CommitNew();
}
size_t
IcyMetaDataParser::Meta(const void *data, size_t length)
{
const unsigned char *p = (const unsigned char *)data;
assert(IsDefined());
assert(data_rest == 0);
assert(length > 0);
if (meta_size == 0) {
/* read meta_size from the first byte of a meta
block */
meta_size = *p++ * 16;
if (meta_size == 0) {
/* special case: no metadata */
data_rest = data_size;
return 1;
}
/* 1 byte was consumed (must be re-added later for the
return value */
--length;
/* initialize metadata reader, allocate enough
memory (+1 for the null terminator) */
meta_position = 0;
meta_data = new char[meta_size + 1];
}
assert(meta_position < meta_size);
if (length > meta_size - meta_position)
length = meta_size - meta_position;
memcpy(meta_data + meta_position, p, length);
meta_position += length;
if (p != data)
/* re-add the first byte (which contained meta_size) */
++length;
if (meta_position == meta_size) {
/* parse */
delete tag;
tag = icy_parse_tag(meta_data, meta_data + meta_size);
delete[] meta_data;
/* change back to normal data mode */
meta_size = 0;
data_rest = data_size;
}
return length;
}
size_t
IcyMetaDataParser::ParseInPlace(void *data, size_t length)
{
uint8_t *const dest0 = (uint8_t *)data;
uint8_t *dest = dest0;
const uint8_t *src = dest0;
while (length > 0) {
size_t chunk = Data(length);
if (chunk > 0) {
memmove(dest, src, chunk);
dest += chunk;
src += chunk;
length -= chunk;
if (length == 0)
break;
}
chunk = Meta(src, length);
if (chunk > 0) {
src += chunk;
length -= chunk;
}
}
return dest - dest0;
}
/*
* Copyright 2003-2017 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_ICY_META_DATA_PARSER_HXX
#define MPD_ICY_META_DATA_PARSER_HXX
#include <stddef.h>
struct Tag;
class IcyMetaDataParser {
size_t data_size, data_rest;
size_t meta_size, meta_position;
char *meta_data;
Tag *tag;
public:
IcyMetaDataParser():data_size(0) {}
~IcyMetaDataParser() {
Reset();
}
/**
* Initialize an enabled icy_metadata object with the specified
* data_size (from the icy-metaint HTTP response header).
*/
void Start(size_t _data_size) {
data_size = data_rest = _data_size;
meta_size = 0;
tag = nullptr;
}
/**
* Resets the icy_metadata. Call this after rewinding the stream.
*/
void Reset();
/**
* Checks whether the icy_metadata object is enabled.
*/
bool IsDefined() const {
return data_size > 0;
}
/**
* Evaluates data. Returns the number of bytes of normal data which
* can be read by the caller, but not more than "length". If the
* return value is smaller than "length", the caller should invoke
* icy_meta().
*/
size_t Data(size_t length);
/**
* Reads metadata from the stream. Returns the number of bytes
* consumed. If the return value is smaller than "length", the caller
* should invoke icy_data().
*/
size_t Meta(const void *data, size_t length);
/**
* Parse data and eliminate metadata.
*
* @return the number of data bytes remaining in the buffer
*/
size_t ParseInPlace(void *data, size_t length);
Tag *ReadTag() {
Tag *result = tag;
tag = nullptr;
return result;
}
};
#endif
/*
* Copyright 2003-2017 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.
*/
/*
* Support library for the "idle" command.
*
*/
#include "config.h"
#include "Idle.hxx"
#include "Main.hxx"
#include "Instance.hxx"
#include <assert.h>
void
idle_add(unsigned flags)
{
assert(flags != 0);
instance->EmitIdle(flags);
}
/*
* Copyright 2003-2017 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.
*/
/*
* Support library for the "idle" command.
*
*/
#ifndef MPD_IDLE_HXX
#define MPD_IDLE_HXX
#include "IdleFlags.hxx"
/**
* Adds idle flag (with bitwise "or") and queues notifications to all
* clients.
*/
void
idle_add(unsigned flags);
#endif
/*
* Copyright 2003-2017 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.
*/
/*
* Support library for the "idle" command.
*
*/
#include "config.h"
#include "IdleFlags.hxx"
#include "util/ASCII.hxx"
#include <assert.h>
static const char *const idle_names[] = {
"database",
"stored_playlist",
"playlist",
"player",
"mixer",
"output",
"options",
"sticker",
"update",
"subscription",
"message",
"neighbor",
"mount",
nullptr
};
const char*const*
idle_get_names() noexcept
{
return idle_names;
}
unsigned
idle_parse_name(const char *name) noexcept
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(name != nullptr);
#endif
for (unsigned i = 0; idle_names[i] != nullptr; ++i)
if (StringEqualsCaseASCII(name, idle_names[i]))
return 1 << i;
return 0;
}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment