source: roaraudio/roard/container_framework.c @ 2669:3b6eb870e562

Last change on this file since 2669:3b6eb870e562 was 2669:3b6eb870e562, checked in by phi, 15 years ago

deleted struct cont_fw_child

File size: 3.6 KB
Line 
1//container_framework.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009
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, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25#include "roard.h"
26
27#define _DECL()  struct cont_fw_child_vio_inst * inst
28#define _CHECK() if ( vio == NULL ) \
29                 return -1
30#define _CINST() if ( (inst = vio->inst) == NULL ) \
31                  return -1
32#define _PREP()  _CHECK(); \
33                 _CINST()
34#define _BASIC() _DECL();  \
35                 _PREP()
36
37// Parent:
38int     cont_fw_new     (struct cont_fw_parent_inst ** inst) {
39 struct cont_fw_parent_inst * self;
40
41 if ( inst == NULL )
42  return -1;
43
44 if ( (self = malloc(sizeof(struct cont_fw_parent_inst))) == NULL ) {
45  *inst = NULL;
46  return -1;
47 }
48
49 memset(self, 0, sizeof(struct cont_fw_parent_inst));
50
51 *inst = self;
52 return 0;
53}
54
55int     cont_fw_delete  (struct cont_fw_parent_inst  * inst) {
56 int i;
57
58 if ( inst == NULL )
59  return -1;
60
61 // check if there are streams to close...
62 for (i = 0; i < CONT_FW_MAX_CHILDS; i++) {
63  if ( inst->child[i] != NULL ) {
64   return -1;
65  }
66 }
67
68 free(inst);
69
70 return 0;
71}
72
73int     cont_fw_set_uinst(struct cont_fw_parent_inst  * inst, void  * u_inst) {
74 if ( inst == NULL )
75  return -1;
76
77 inst->u_inst = u_inst;
78
79 return 0;
80}
81
82int     cont_fw_get_uinst(struct cont_fw_parent_inst  * inst, void ** u_inst) {
83 if ( inst == NULL || u_inst == NULL )
84  return -1;
85
86 *u_inst = inst->u_inst;
87
88 return 0;
89}
90
91// VIOs:
92int     cont_fw_new_child(struct cont_fw_parent_inst  * inst, int id) {
93 if ( inst == NULL )
94  return -1;
95
96 return -1;
97}
98
99int     cont_fw_init_vio(struct roar_vio_calls * vio, void * inst) {
100 if ( vio == NULL )
101  return -1;
102
103 memset(vio, 0, sizeof(struct roar_vio_calls));
104 vio->inst = inst;
105
106 vio->read  = cont_fw_read;
107 vio->write = cont_fw_write;
108 vio->sync  = cont_fw_sync;
109 vio->close = cont_fw_close;
110
111 return 0;
112}
113
114ssize_t cont_fw_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
115 _BASIC();
116
117 if ( inst->parent->ccb.read != NULL )
118  return inst->parent->ccb.read(inst->parent, inst, buf, count);
119
120 return -1;
121}
122
123ssize_t cont_fw_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
124 _BASIC();
125
126 if ( inst->parent->ccb.write != NULL )
127  return inst->parent->ccb.write(inst->parent, inst, buf, count);
128
129 return -1;
130}
131
132off_t   cont_fw_lseek   (struct roar_vio_calls * vio, off_t offset, int whence);
133int     cont_fw_nonblock(struct roar_vio_calls * vio, int state);
134
135int     cont_fw_sync    (struct roar_vio_calls * vio) {
136 _BASIC();
137
138 if ( inst->parent->ccb.flush != NULL )
139  return inst->parent->ccb.flush(inst->parent, inst);
140
141 return 0;
142}
143
144int     cont_fw_close   (struct roar_vio_calls * vio) {
145 _DECL();
146 int r = 0;
147
148 _PREP();
149
150 if ( cont_fw_sync(vio) == -1 )
151  r = -1;
152
153 if ( inst->parent->ccb.close != NULL )
154  return inst->parent->ccb.close(inst->parent, inst);
155
156 return  r;
157}
158
159int     cont_fw_ctl     (struct roar_vio_calls * vio, int cmd, void * data);
160
161//ll
Note: See TracBrowser for help on using the repository browser.