source: roaraudio/roard/codecfilter_raum.c @ 5823:f9f70dbaa376

Last change on this file since 5823:f9f70dbaa376 was 5823:f9f70dbaa376, checked in by phi, 11 years ago

updated copyright

File size: 4.0 KB
Line 
1//codecfilter_raum.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2013
5 *
6 *  This file is part of roard 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 *  RoarAudio 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 "roard.h"
27
28#ifdef ROAR_HAVE_LIBRAUM
29#include <raum.h>
30
31// PCBs:
32int cf_raum_pcb_open  (struct cont_fw_parent_inst * self,
33                       int                          codec,
34                       struct roar_stream_server  * stream,
35                       struct roar_codecfilter    * filter) {
36 struct roar_stream * s = ROAR_STREAM(stream);
37 RAUMState * state;
38 int flags = 0;
39
40 ROAR_DBG("cf_raum_pcb_open(*) = ?");
41
42 if ( stream == NULL )
43  return -1;
44
45 switch (s->dir) {
46  case ROAR_DIR_COMPLEX_IN:
47  case ROAR_DIR_PLAY:
48    flags = O_RDONLY;
49   break;
50  case ROAR_DIR_COMPLEX_OUT:
51  case ROAR_DIR_MONITOR:
52  case ROAR_DIR_OUTPUT:
53    flags = O_WRONLY;
54   break;
55  default:
56    return -1;
57 }
58
59 state = RAUMOpenVIO(&(self->vio), flags);
60
61 if ( state == NULL )
62  return -1;
63
64 cont_fw_set_uinst(self, state);
65
66 ROAR_DBG("cf_raum_pcb_open(*) = 0");
67 return 0;
68}
69
70int cf_raum_pcb_close (struct cont_fw_parent_inst * self) {
71 void * state;
72
73 ROAR_DBG("cf_raum_pcb_close(*) = ?");
74
75 if ( cont_fw_get_uinst(self, &state) == -1 )
76  return -1;
77
78 ROAR_DBG("cf_raum_pcb_close(*) = ?");
79 return RAUMClose(state);
80}
81
82int cf_raum_pcb_new_child(struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child) {
83 struct roar_stream_server * ss;
84 struct roar_stream        *  s;
85 void                      * ps;
86 RAUMStream * stream;
87 int dir = ROAR_DIR_PLAY;
88
89 ROAR_DBG("cf_raum_pcb_new_child(self=%p, child=%p) = ?", self, child);
90
91 if ( streams_get(child->child, &ss) == -1 )
92  return -1;
93
94 if ( (s = ROAR_STREAM(ss)) == NULL )
95  return -1;
96
97 if ( cont_fw_get_uinst(self, &ps) == -1 )
98  return -1;
99
100 if ( ps == NULL )
101  return -1;
102
103 if ( (stream = RAUMStreamNewSimple(s->info.rate, s->info.channels, s->info.bits, s->info.codec, dir)) == NULL )
104  return -1;
105
106 if ( RAUMAddStream(ps, stream) == -1 ) {
107  RAUMStreamClose(stream);
108  return -1;
109 }
110
111 child->u_inst = stream;
112
113 ROAR_DBG("cf_raum_pcb_new_child(self=%p, child=%p) = 0", self, child);
114 return 0;
115}
116
117// CCBs:
118ssize_t cf_raum_ccb_read (struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child, void *buf, size_t len) {
119 ROAR_DBG("cf_raum_ccb_read(self=%p, child=%p, buf=%p, len=%lu) = ?", self, child, buf, (unsigned long)len);
120 return RAUMStreamRead(child->u_inst, buf, len);
121}
122ssize_t cf_raum_ccb_write(struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child, void *buf, size_t len) {
123 ROAR_DBG("cf_raum_ccb_write(self=%p, child=%p, buf=%p, len=%lu) = ?", self, child, buf, (unsigned long)len);
124 return RAUMStreamWrite(child->u_inst, buf, len);
125}
126int     cf_raum_ccb_close(struct cont_fw_parent_inst * self, struct cont_fw_child_vio_inst * child) {
127 ROAR_DBG("cf_raum_ccb_close(self=%p, child=%p) = ?", self, child);
128 return RAUMStreamClose(child->u_inst);
129}
130
131// SETUP:
132CONT_FW_SETUP_TYPE(cf_raum_setup) {
133 ROAR_DBG("cf_raum_setup(*) = ?");
134
135 // PCBs:
136 self->pcb.open      = cf_raum_pcb_open;
137 self->pcb.close     = cf_raum_pcb_close;
138 self->pcb.new_child = cf_raum_pcb_new_child;
139
140 // CCBs:
141 self->ccb.read      = cf_raum_ccb_read;
142 self->ccb.write     = cf_raum_ccb_write;
143 self->ccb.close     = cf_raum_ccb_close;
144
145 ROAR_DBG("cf_raum_setup(*) = 0");
146 return 0;
147}
148
149#endif
150
151//ll
Note: See TracBrowser for help on using the repository browser.