source: roaraudio/roard/driver_dmx.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: 2.3 KB
Line 
1//driver_dmx.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_DMX
29
30int driver_dmx_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
31 struct roar_vio_defaults def;
32
33 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY, 0644) == -1 )
34  return -1;
35
36 if ( fh == -1 ) {
37  if ( device == NULL )
38   device = getenv("DMX");
39
40  if ( device == NULL )
41   device = "/dev/dmx";
42
43  if ( roar_vio_open_dstr(inst, device, &def, 1) == -1 )
44   return -1;
45 } else {
46  if ( roar_vio_open_fh(inst, fh) == -1 )
47   return -1;
48 }
49
50 inst->write = driver_dmx_write;
51 inst->ctl   = driver_dmx_ctl;
52
53 info->codec = ROAR_CODEC_DMX512;
54
55 if ( sstream != NULL )
56  driver_dmx_ctl(inst, ROAR_VIO_CTL_SET_SSTREAM, sstream);
57
58 return 0;
59}
60
61ssize_t driver_dmx_write (struct roar_vio_calls * vio,  void *buf, size_t count) {
62 if ( vio == NULL || buf == NULL )
63  return -1;
64
65 if ( count != 512 )
66  return -1;
67
68 if ( roar_vio_lseek(vio, 0, SEEK_SET) == (roar_off_t)-1 )
69  return -1;
70
71 return roar_vio_write(vio, buf, count);
72}
73
74int driver_dmx_ctl(struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) {
75
76 if ( vio == NULL )
77  return -1;
78
79 switch (cmd) {
80  case ROAR_VIO_CTL_SET_SSTREAM:
81    ROAR_STREAM(data)->dir = ROAR_DIR_LIGHT_OUT;
82    ROAR_STREAM_SERVER(data)->codec_orgi = ROAR_CODEC_DMX512;
83   break;
84  default:
85   return -1;
86 }
87
88 return 0;
89}
90
91#endif
92
93//ll
Note: See TracBrowser for help on using the repository browser.