1 | //vio_transcode.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 | int roar_vio_open_xcode (struct roar_vio_calls * calls, int encoder, struct roar_audio_info * info, |
---|
28 | struct roar_vio_calls * dst) { |
---|
29 | struct roar_xcoder * xcoder = malloc(sizeof(struct roar_xcoder)); |
---|
30 | |
---|
31 | if ( xcoder == NULL ) |
---|
32 | return -1; |
---|
33 | |
---|
34 | if ( calls == NULL || info == NULL || dst == NULL ) { |
---|
35 | free(xcoder); |
---|
36 | return -1; |
---|
37 | } |
---|
38 | |
---|
39 | if ( roar_xcoder_init(xcoder, encoder, info, dst) == -1 ) { |
---|
40 | free(xcoder); |
---|
41 | return -1; |
---|
42 | } |
---|
43 | |
---|
44 | memset(calls, 0, sizeof(struct roar_vio_calls)); |
---|
45 | |
---|
46 | calls->inst = (void*)xcoder; |
---|
47 | |
---|
48 | calls->close = roar_vio_xcode_close; |
---|
49 | |
---|
50 | if ( encoder ) { |
---|
51 | calls->write = roar_vio_xcode_proc; |
---|
52 | } else { |
---|
53 | calls->read = roar_vio_xcode_proc; |
---|
54 | } |
---|
55 | |
---|
56 | return 0; |
---|
57 | } |
---|
58 | |
---|
59 | ssize_t roar_vio_xcode_proc (struct roar_vio_calls * vio, void *buf, size_t count) { |
---|
60 | if ( vio == NULL ) |
---|
61 | return -1; |
---|
62 | |
---|
63 | if ( buf == NULL && count != 0 ) |
---|
64 | return -1; |
---|
65 | |
---|
66 | return roar_xcoder_proc(vio->inst, buf, count); |
---|
67 | } |
---|
68 | |
---|
69 | off_t roar_vio_xcode_lseek (struct roar_vio_calls * vio, off_t offset, int whence); |
---|
70 | int roar_vio_xcode_nonblock(struct roar_vio_calls * vio, int state); |
---|
71 | int roar_vio_xcode_sync (struct roar_vio_calls * vio); |
---|
72 | int roar_vio_xcode_ctl (struct roar_vio_calls * vio, int cmd, void * data); |
---|
73 | |
---|
74 | int roar_vio_xcode_close (struct roar_vio_calls * vio) { |
---|
75 | int ret = 0; |
---|
76 | |
---|
77 | if ( vio == NULL ) |
---|
78 | return -1; |
---|
79 | |
---|
80 | if ( roar_xcoder_close(vio->inst) == -1 ) |
---|
81 | ret = -1; |
---|
82 | |
---|
83 | if ( vio->inst != NULL ) |
---|
84 | free(vio->inst); |
---|
85 | |
---|
86 | return ret; |
---|
87 | } |
---|
88 | |
---|
89 | int roar_vio_open_bixcode (struct roar_vio_calls * calls, struct roar_audio_info * info, |
---|
90 | struct roar_vio_calls * dst); |
---|
91 | ssize_t roar_vio_bixcode_read (struct roar_vio_calls * vio, void *buf, size_t count); |
---|
92 | ssize_t roar_vio_bixcode_write (struct roar_vio_calls * vio, void *buf, size_t count); |
---|
93 | off_t roar_vio_bixcode_lseek (struct roar_vio_calls * vio, off_t offset, int whence); |
---|
94 | int roar_vio_bixcode_nonblock(struct roar_vio_calls * vio, int state); |
---|
95 | int roar_vio_bixcode_sync (struct roar_vio_calls * vio); |
---|
96 | int roar_vio_bixcode_ctl (struct roar_vio_calls * vio, int cmd, void * data); |
---|
97 | int roar_vio_bixcode_close (struct roar_vio_calls * vio); |
---|
98 | |
---|
99 | //ll |
---|