pcm/Volume: move silence pattern to Silence.cxx
This commit is contained in:
parent
5eb0cbc887
commit
b8097eaf2e
|
@ -467,6 +467,7 @@ libpcm_a_SOURCES = \
|
||||||
src/pcm/PcmConvert.cxx src/pcm/PcmConvert.hxx \
|
src/pcm/PcmConvert.cxx src/pcm/PcmConvert.hxx \
|
||||||
src/pcm/PcmDop.cxx src/pcm/PcmDop.hxx \
|
src/pcm/PcmDop.cxx src/pcm/PcmDop.hxx \
|
||||||
src/pcm/Volume.cxx src/pcm/Volume.hxx \
|
src/pcm/Volume.cxx src/pcm/Volume.hxx \
|
||||||
|
src/pcm/Silence.cxx src/pcm/Silence.hxx \
|
||||||
src/pcm/PcmMix.cxx src/pcm/PcmMix.hxx \
|
src/pcm/PcmMix.cxx src/pcm/PcmMix.hxx \
|
||||||
src/pcm/PcmChannels.cxx src/pcm/PcmChannels.hxx \
|
src/pcm/PcmChannels.cxx src/pcm/PcmChannels.hxx \
|
||||||
src/pcm/PcmPack.cxx src/pcm/PcmPack.hxx \
|
src/pcm/PcmPack.cxx src/pcm/PcmPack.hxx \
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-2016 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 "Silence.hxx"
|
||||||
|
#include "AudioFormat.hxx"
|
||||||
|
#include "util/WritableBuffer.hxx"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
PcmSilence(WritableBuffer<void> dest, SampleFormat format)
|
||||||
|
{
|
||||||
|
uint8_t pattern = 0;
|
||||||
|
if (format == SampleFormat::DSD)
|
||||||
|
pattern = 0x69;
|
||||||
|
|
||||||
|
memset(dest.data, pattern, dest.size);
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-2016 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_SILENCE_HXX
|
||||||
|
#define MPD_PCM_SILENCE_HXX
|
||||||
|
|
||||||
|
#include "check.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
template<typename T> struct WritableBuffer;
|
||||||
|
enum class SampleFormat : uint8_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill the given buffer with the format-specific silence pattern.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
PcmSilence(WritableBuffer<void> dest, SampleFormat format);
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,10 +19,12 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "Volume.hxx"
|
#include "Volume.hxx"
|
||||||
|
#include "Silence.hxx"
|
||||||
#include "Domain.hxx"
|
#include "Domain.hxx"
|
||||||
#include "PcmUtils.hxx"
|
#include "PcmUtils.hxx"
|
||||||
#include "Traits.hxx"
|
#include "Traits.hxx"
|
||||||
#include "util/ConstBuffer.hxx"
|
#include "util/ConstBuffer.hxx"
|
||||||
|
#include "util/WritableBuffer.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
|
|
||||||
#include "PcmDither.cxx" // including the .cxx file to get inlined templates
|
#include "PcmDither.cxx" // including the .cxx file to get inlined templates
|
||||||
|
@ -134,11 +136,7 @@ PcmVolume::Apply(ConstBuffer<void> src)
|
||||||
|
|
||||||
if (volume == 0) {
|
if (volume == 0) {
|
||||||
/* optimized special case: 0% volume = memset(0) */
|
/* optimized special case: 0% volume = memset(0) */
|
||||||
uint8_t pattern = 0;
|
PcmSilence({data, src.size}, format);
|
||||||
if (format == SampleFormat::DSD)
|
|
||||||
pattern = 0x69;
|
|
||||||
|
|
||||||
memset(data, pattern, src.size);
|
|
||||||
return { data, src.size };
|
return { data, src.size };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue