source: roaraudio/libroardsp/filter_swap.c @ 3811:49db840fb4f4

Last change on this file since 3811:49db840fb4f4 was 3811:49db840fb4f4, checked in by phi, 14 years ago

fixed some copyright statements

File size: 2.5 KB
Line 
1//swap.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2010
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, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#include "libroardsp.h"
27
28int roardsp_swap_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id) {
29 struct roardsp_swap * inst = roar_mm_malloc(sizeof(struct roardsp_swap));
30
31 ROAR_DBG("roardsp_swap_init(*): inst=%p", inst);
32
33 if ( inst == NULL ) {
34  ROAR_ERR("roardsp_swap_init(*): Can not alloc memory for filter swap: %s", strerror(errno));
35  filter->inst = NULL;
36  return -1;
37 }
38
39 filter->inst = inst;
40
41 return roardsp_swap_reset(filter, ROARDSP_RESET_FULL);
42}
43
44int roardsp_swap_uninit (struct roardsp_filter * filter) {
45 if ( filter == NULL )
46  return -1;
47
48 if ( filter->inst == NULL )
49  return -1;
50
51 roar_mm_free(filter->inst);
52
53 return 0;
54}
55
56int roardsp_swap_calc162(struct roardsp_filter * filter, void * data, size_t samples) {
57 int16_t * d = data;
58 register int16_t s;
59 int i;
60
61 for (i = 0; i < samples; i += 2) {
62  ROAR_DBG("roardsp_swap_calc162(*): d[i]=%i, d[i+1]=%i", d[i], d[i+1]);
63  s      = d[i];
64  d[i]   = d[i+1];
65  d[i+1] = s;
66 }
67
68 return 0;
69}
70
71int roardsp_swap_ctl    (struct roardsp_filter * filter, int cmd, void * data) {
72 return -1;
73}
74
75int roardsp_swap_reset  (struct roardsp_filter * filter, int what) {
76 struct roardsp_swap * inst = NULL;
77 int i;
78
79 if ( filter == NULL )
80  return -1;
81
82 if ( (inst = filter->inst) == NULL )
83  return -1;
84
85 switch (what) {
86  case ROARDSP_RESET_NONE:
87  case ROARDSP_RESET_STATE:
88    return  0;
89   break;
90  case ROARDSP_RESET_FULL:
91    memset(inst, 0, sizeof(struct roardsp_swap));
92
93    for (i = 0; i < ROAR_MAX_CHANNELS; i++)
94     inst->map[i] = i;
95
96    inst->map[0] = 1;
97    inst->map[1] = 0;
98    return  0;
99   break;
100  default:
101    return -1;
102 }
103
104 return -1;
105}
106
107//ll
Note: See TracBrowser for help on using the repository browser.