//
// Copyright (c) 2019-2021 Ryujinx
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
using System;
namespace Ryujinx.Audio.Renderer.Server.Upsampler
{
/// <summary>
/// Server state for a upsampling.
/// </summary>
public class UpsamplerState
/// The output buffer containing the target samples.
public Memory<float> OutputBuffer { get; }
/// The target sample count.
public uint SampleCount { get; }
/// The index of the <see cref="UpsamplerState"/>. (used to free it)
private int _index;
/// The <see cref="UpsamplerManager"/>.
private UpsamplerManager _manager;
/// The source sample count.
public uint SourceSampleCount;
/// The input buffer indices of the buffers holding the samples that need upsampling.
public ushort[] InputBufferIndices;
/// Create a new <see cref="UpsamplerState"/>.
/// <param name="manager">The upsampler manager.</param>
/// <param name="index">The index of the <see cref="UpsamplerState"/>. (used to free it)</param>
/// <param name="outputBuffer">The output buffer used to contain the target samples.</param>
/// <param name="sampleCount">The target sample count.</param>
public UpsamplerState(UpsamplerManager manager, int index, Memory<float> outputBuffer, uint sampleCount)
_manager = manager;
_index = index;
OutputBuffer = outputBuffer;
SampleCount = sampleCount;
}
/// Release the <see cref="UpsamplerState"/>.
public void Release()
_manager.Free(_index);