source: roaraudio/roard/container_framework.c @ 2662:799dcdba973b

Last change on this file since 2662:799dcdba973b was 2662:799dcdba973b, checked in by phi, 15 years ago

added cont_fw_init_vio()

File size: 2.5 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
37int     cont_fw_init_vio(struct roar_vio_calls * vio, void * inst) {
38 if ( vio == NULL )
39  return -1;
40
41 memset(vio, 0, sizeof(struct roar_vio_calls));
42 vio->inst = inst;
43
44 vio->read  = cont_fw_read;
45 vio->write = cont_fw_write;
46 vio->sync  = cont_fw_sync;
47 vio->close = cont_fw_close;
48
49 return 0;
50}
51
52ssize_t cont_fw_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
53 _BASIC();
54
55 if ( inst->parent->cb.read != NULL )
56  return inst->parent->cb.read(inst->parent, inst->inst, buf, count);
57
58 return -1;
59}
60
61ssize_t cont_fw_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
62 _BASIC();
63
64 if ( inst->parent->cb.write != NULL )
65  return inst->parent->cb.write(inst->parent, inst->inst, buf, count);
66
67 return -1;
68}
69
70off_t   cont_fw_lseek   (struct roar_vio_calls * vio, off_t offset, int whence);
71int     cont_fw_nonblock(struct roar_vio_calls * vio, int state);
72
73int     cont_fw_sync    (struct roar_vio_calls * vio) {
74 _BASIC();
75
76 if ( inst->parent->cb.flush != NULL )
77  return inst->parent->cb.flush(inst->parent, inst->inst);
78
79 return 0;
80}
81
82int     cont_fw_close   (struct roar_vio_calls * vio) {
83 _DECL();
84 int r = 0;
85
86 _PREP();
87
88 if ( cont_fw_sync(vio) == -1 )
89  r = -1;
90
91 return -1;
92 return  r;
93}
94
95int     cont_fw_ctl     (struct roar_vio_calls * vio, int cmd, void * data);
96
97//ll
Note: See TracBrowser for help on using the repository browser.