| 1 |
/* |
| 2 |
* Copyright (C) 2022 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2022 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-runtime-lib |
| 6 |
* Created on: 23 окт. 2022 г. |
| 7 |
* |
| 8 |
* lsp-runtime-lib is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* lsp-runtime-lib is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License |
| 19 |
* along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include <lsp-plug.in/fmt/lspc/IAudioFormatSelector.h> |
| 23 |
|
| 24 |
namespace lsp |
| 25 |
{ |
| 26 |
namespace lspc |
| 27 |
{ |
| 28 |
IAudioFormatSelector::IAudioFormatSelector() |
| 29 |
{ |
| 30 |
} |
| 31 |
|
| 32 |
IAudioFormatSelector::~IAudioFormatSelector() |
| 33 |
{ |
| 34 |
} |
| 35 |
|
| 36 |
status_t IAudioFormatSelector::decide(lspc::audio_format_t *out, const mm::audio_stream_t *in) |
| 37 |
{ |
| 38 |
if ((out == NULL) || (in == NULL)) |
| 39 |
return STATUS_BAD_ARGUMENTS; |
| 40 |
|
| 41 |
switch (mm::sformat_format(in->format)) |
| 42 |
{ |
| 43 |
case mm::SFMT_U8: out->sample_format = lspc::SAMPLE_FMT_U8LE; break; |
| 44 |
case mm::SFMT_S8: out->sample_format = lspc::SAMPLE_FMT_S8LE; break; |
| 45 |
case mm::SFMT_U16: out->sample_format = lspc::SAMPLE_FMT_U16LE; break; |
| 46 |
case mm::SFMT_S16: out->sample_format = lspc::SAMPLE_FMT_S16LE; break; |
| 47 |
case mm::SFMT_U24: out->sample_format = lspc::SAMPLE_FMT_U24LE; break; |
| 48 |
case mm::SFMT_S24: out->sample_format = lspc::SAMPLE_FMT_S24LE; break; |
| 49 |
case mm::SFMT_U32: out->sample_format = lspc::SAMPLE_FMT_U32LE; break; |
| 50 |
case mm::SFMT_S32: out->sample_format = lspc::SAMPLE_FMT_S32LE; break; |
| 51 |
case mm::SFMT_F32: out->sample_format = lspc::SAMPLE_FMT_F32LE; break; |
| 52 |
case mm::SFMT_F64: out->sample_format = lspc::SAMPLE_FMT_F64LE; break; |
| 53 |
default: |
| 54 |
return STATUS_INCOMPATIBLE; |
| 55 |
} |
| 56 |
|
| 57 |
out->codec = lspc::CODEC_PCM; |
| 58 |
out->sample_rate = in->srate; |
| 59 |
|
| 60 |
return STATUS_OK; |
| 61 |
} |
| 62 |
} /* namespace lspc */ |
| 63 |
} /* namespace lsp */ |
| 64 |
|
| 65 |
|