From 458a1beed99279898ca2f8e60c354c3bb5367098 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 17 Jun 2019 14:15:04 +0200 Subject: [PATCH] AudioFormat: move MAX_CHANNELS to pcm/ChannelDefs.hxx Reduce header dependencies. --- src/AudioFormat.hxx | 12 +----------- src/pcm/ChannelDefs.hxx | 34 ++++++++++++++++++++++++++++++++++ src/pcm/Dop.cxx | 2 +- src/pcm/PcmChannels.cxx | 2 +- src/pcm/PcmDsd.hxx | 2 +- 5 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 src/pcm/ChannelDefs.hxx diff --git a/src/AudioFormat.hxx b/src/AudioFormat.hxx index 8df83dade..2968d2584 100644 --- a/src/AudioFormat.hxx +++ b/src/AudioFormat.hxx @@ -21,6 +21,7 @@ #define MPD_AUDIO_FORMAT_HXX #include "pcm/SampleFormat.hxx" +#include "pcm/ChannelDefs.hxx" #include "util/Compiler.h" #include @@ -30,8 +31,6 @@ template class StringBuffer; -static constexpr unsigned MAX_CHANNELS = 8; - /** * This structure describes the format of a raw PCM stream. */ @@ -184,15 +183,6 @@ audio_valid_sample_rate(unsigned sample_rate) noexcept return sample_rate > 0 && sample_rate < (1 << 30); } -/** - * Checks whether the number of channels is valid. - */ -constexpr bool -audio_valid_channel_count(unsigned channels) noexcept -{ - 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. diff --git a/src/pcm/ChannelDefs.hxx b/src/pcm/ChannelDefs.hxx new file mode 100644 index 000000000..6425dafce --- /dev/null +++ b/src/pcm/ChannelDefs.hxx @@ -0,0 +1,34 @@ +/* + * Copyright 2003-2019 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_PCM_CHANNEL_DEFS_HXX +#define MPD_PCM_CHANNEL_DEFS_HXX + +static constexpr unsigned MAX_CHANNELS = 8; + +/** + * Checks whether the number of channels is valid. + */ +constexpr bool +audio_valid_channel_count(unsigned channels) noexcept +{ + return channels >= 1 && channels <= MAX_CHANNELS; +} + +#endif diff --git a/src/pcm/Dop.cxx b/src/pcm/Dop.cxx index 4d084c91b..8120e200c 100644 --- a/src/pcm/Dop.cxx +++ b/src/pcm/Dop.cxx @@ -19,7 +19,7 @@ #include "Dop.hxx" #include "Buffer.hxx" -#include "AudioFormat.hxx" +#include "ChannelDefs.hxx" #include "util/ConstBuffer.hxx" #include diff --git a/src/pcm/PcmChannels.cxx b/src/pcm/PcmChannels.cxx index 6c658e372..c620eabee 100644 --- a/src/pcm/PcmChannels.cxx +++ b/src/pcm/PcmChannels.cxx @@ -18,10 +18,10 @@ */ #include "PcmChannels.hxx" +#include "ChannelDefs.hxx" #include "Buffer.hxx" #include "Silence.hxx" #include "Traits.hxx" -#include "AudioFormat.hxx" #include "util/ConstBuffer.hxx" #include "util/WritableBuffer.hxx" diff --git a/src/pcm/PcmDsd.hxx b/src/pcm/PcmDsd.hxx index a754cd770..d91b9cbad 100644 --- a/src/pcm/PcmDsd.hxx +++ b/src/pcm/PcmDsd.hxx @@ -21,7 +21,7 @@ #define MPD_PCM_DSD_HXX #include "Buffer.hxx" -#include "AudioFormat.hxx" +#include "ChannelDefs.hxx" #include