[cf19b8a] | 1 | /* |
---|
| 2 | Copyright (C) 2016 Paul Brossier <piem@aubio.org> |
---|
| 3 | |
---|
| 4 | This file is part of aubio. |
---|
| 5 | |
---|
| 6 | aubio is free software: you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation, either version 3 of the License, or |
---|
| 9 | (at your option) any later version. |
---|
| 10 | |
---|
| 11 | aubio is distributed in the hope that it will be useful, |
---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | GNU General Public License for more details. |
---|
| 15 | |
---|
| 16 | You should have received a copy of the GNU General Public License |
---|
| 17 | along with aubio. If not, see <http://www.gnu.org/licenses/>. |
---|
| 18 | |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #include "config.h" |
---|
| 22 | #include "aubio_priv.h" |
---|
| 23 | |
---|
| 24 | uint_t |
---|
| 25 | aubio_io_validate_samplerate(const char_t *kind, const char_t *path, uint_t samplerate) |
---|
| 26 | { |
---|
| 27 | if ((sint_t)(samplerate) <= 0) { |
---|
| 28 | AUBIO_ERR("%s: failed creating %s, samplerate should be positive, not %d\n", |
---|
| 29 | kind, path, samplerate); |
---|
| 30 | return AUBIO_FAIL; |
---|
| 31 | } |
---|
| 32 | if ((sint_t)samplerate > AUBIO_MAX_SAMPLERATE) { |
---|
| 33 | AUBIO_ERR("%s: failed creating %s, samplerate %dHz is too large\n", |
---|
| 34 | kind, path, samplerate); |
---|
| 35 | return AUBIO_FAIL; |
---|
| 36 | } |
---|
| 37 | return AUBIO_OK; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | uint_t |
---|
| 41 | aubio_io_validate_channels(const char_t *kind, const char_t *path, uint_t channels) |
---|
| 42 | { |
---|
| 43 | if ((sint_t)(channels) <= 0) { |
---|
| 44 | AUBIO_ERR("sink_%s: failed creating %s, channels should be positive, not %d\n", |
---|
| 45 | kind, path, channels); |
---|
| 46 | return AUBIO_FAIL; |
---|
| 47 | } |
---|
| 48 | if (channels > AUBIO_MAX_CHANNELS) { |
---|
| 49 | AUBIO_ERR("sink_%s: failed creating %s, too many channels (%d but %d available)\n", |
---|
| 50 | kind, path, channels, AUBIO_MAX_CHANNELS); |
---|
| 51 | return AUBIO_FAIL; |
---|
| 52 | } |
---|
| 53 | return AUBIO_OK; |
---|
| 54 | } |
---|