source: roaraudio/roard/raw.c @ 5381:430b1d26e12d

Last change on this file since 5381:430b1d26e12d was 5381:430b1d26e12d, checked in by phi, 12 years ago

updated copyright years

File size: 1.9 KB
Line 
1//raw.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2012
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#ifndef ROAR_WITHOUT_DCOMP_RAW
29
30int raw_check_stream  (int id) {
31 struct roar_stream        *    s;
32 struct roar_stream_server *   ss;
33 struct roar_buffer        *  buf;
34 void                      * data;
35 ssize_t                     len;
36
37 if ( g_streams[id] == NULL )
38  return -1;
39
40 ROAR_DBG("raw_check_stream(id=%i) = ?", id);
41
42 s = ROAR_STREAM(ss = g_streams[id]);
43
44 if ( s->pos_rel_id == -1 )
45  return -1;
46
47 // TODO: do we really need a buffer object here? wouldn't space on stack be ok?
48 if ( roar_buffer_new_data(&buf, RAW_READ_LEN, &data) == -1 )
49  return -1;
50
51 if ( (len = stream_vio_s_read(ss, data, RAW_READ_LEN)) < 1 ) {
52  // this is len=0 -> eof OR len=-1 -> error
53  streams_delete(id);
54  roar_buffer_free(buf);
55  return -1;
56 }
57
58 if ( stream_vio_write(s->pos_rel_id, data, len) != len ) {
59  // we are hard here as this is needed to ensure data integrety
60  streams_delete(s->pos_rel_id);
61 }
62
63 roar_buffer_free(buf);
64
65 return 0;
66}
67
68#endif
69
70//ll
Note: See TracBrowser for help on using the repository browser.