Added getter to get output pcm params
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Emeric Poupon
|
||||
*
|
||||
* This file is part of LMS.
|
||||
*
|
||||
* LMS 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.
|
||||
*
|
||||
* LMS 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 LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "audio/PcmTypes.hpp"
|
||||
#include "audio/Exception.hpp"
|
||||
|
||||
namespace lms::audio
|
||||
{
|
||||
std::size_t getSampleSize(PcmSampleType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case PcmSampleType::Signed16:
|
||||
return 2;
|
||||
case PcmSampleType::Signed32:
|
||||
case PcmSampleType::Float32:
|
||||
return 4;
|
||||
case PcmSampleType::Float64:
|
||||
return 8;
|
||||
};
|
||||
|
||||
throw Exception{ "Unhandled sample type" };
|
||||
}
|
||||
|
||||
} // namespace lms::audio
|
||||
@@ -167,6 +167,11 @@ namespace lms::audio::ffmpeg
|
||||
|
||||
PcmDecoder::~PcmDecoder() = default;
|
||||
|
||||
const PcmParameters& PcmDecoder::getParameters() const
|
||||
{
|
||||
return _parameters;
|
||||
}
|
||||
|
||||
std::size_t PcmDecoder::readSamples(std::span<WritableBuffer> outputChannelBuffers)
|
||||
{
|
||||
if (_finished)
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace lms::audio::ffmpeg
|
||||
PcmDecoder& operator=(const PcmDecoder&) = delete;
|
||||
|
||||
private:
|
||||
const PcmParameters& getParameters() const;
|
||||
|
||||
std::size_t readSamples(std::span<WritableBuffer> outputChannelBuffers) override;
|
||||
bool finished() const override;
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace lms::audio
|
||||
|
||||
using WritableBuffer = std::span<std::byte>;
|
||||
|
||||
virtual const PcmParameters& getParameters() const = 0;
|
||||
|
||||
// Returns the number of samples written per channel. Returns 0 only once all remaining samples are drained.
|
||||
// Provide one buffer per channel if planar, or a single buffer containing all channels interleaved
|
||||
// Each buffer must be sized to hold an integer number of samples according to the requested sample type.
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace lms::audio
|
||||
Float64,
|
||||
};
|
||||
|
||||
std::size_t getSampleSize(PcmSampleType type);
|
||||
|
||||
struct PcmParameters
|
||||
{
|
||||
unsigned channelCount;
|
||||
|
||||
Reference in New Issue
Block a user