[2996] | 1 | //filter_speex_prep.c: |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009 |
---|
| 5 | * |
---|
| 6 | * This file is part of libroardsp a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * libroardsp is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
| 21 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 22 | * |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #include "libroardsp.h" |
---|
| 26 | |
---|
| 27 | #ifdef _SPEEX_TYPES_H |
---|
| 28 | // TODO: check parameters we allready know: |
---|
| 29 | int roardsp_speex_prep_init (struct roardsp_filter * filter, struct roar_stream * stream, int id) { |
---|
[2997] | 30 | struct roardsp_speex_prep * self; |
---|
| 31 | |
---|
| 32 | if ( filter->channels != 1 ) |
---|
| 33 | return -1; |
---|
| 34 | |
---|
| 35 | if ( filter->bits != 16 ) |
---|
| 36 | return -1; |
---|
| 37 | |
---|
| 38 | self = roar_mm_malloc(sizeof(struct roardsp_speex_prep)); |
---|
[2996] | 39 | |
---|
| 40 | if ( self == NULL ) |
---|
| 41 | return -1; |
---|
| 42 | |
---|
| 43 | memset(self, 0, sizeof(struct roardsp_speex_prep)); |
---|
| 44 | |
---|
| 45 | return 0; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | int roardsp_speex_prep_uninit (struct roardsp_filter * filter) { |
---|
| 49 | struct roardsp_speex_prep * self = filter->inst; |
---|
| 50 | |
---|
| 51 | if ( self->preprocess != NULL ) |
---|
| 52 | speex_preprocess_state_destroy(self->preprocess); |
---|
| 53 | |
---|
| 54 | roar_mm_free(self); |
---|
| 55 | |
---|
| 56 | return 0; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | int roardsp_speex_prep_ctl (struct roardsp_filter * filter, int cmd, void * data) { |
---|
| 60 | struct roardsp_speex_prep * self = filter->inst; |
---|
| 61 | size_t * val; |
---|
| 62 | |
---|
| 63 | switch (cmd) { |
---|
| 64 | case ROARDSP_FCTL_PACKET_SIZE: |
---|
| 65 | val = data; |
---|
| 66 | self->frame_size = *val; |
---|
| 67 | |
---|
| 68 | self->preprocess = speex_preprocess_state_init(self->frame_size, filter->rate); |
---|
| 69 | if ( self->preprocess == NULL ) |
---|
| 70 | return -1; |
---|
| 71 | |
---|
| 72 | return 0; |
---|
| 73 | break; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | return -1; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | int roardsp_speex_prep_reset (struct roardsp_filter * filter, int what) { |
---|
| 80 | if ( what == ROARDSP_RESET_NONE ) |
---|
| 81 | return 0; |
---|
| 82 | |
---|
| 83 | return -1; |
---|
| 84 | } |
---|
| 85 | #endif |
---|
| 86 | |
---|
| 87 | //ll |
---|