source: roaraudio/roard/driver_dmx.c @ 1830:3a678ce28438

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

added some default devices

File size: 2.0 KB
Line 
1//driver_dmx.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
27int driver_dmx_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh) {
28
29 if ( fh == -1 ) {
30  if ( device == NULL )
31   device = getenv("DMX");
32
33  if ( device == NULL )
34   device = "/dev/dmx";
35
36  if ( roar_vio_open_file(inst, device, O_WRONLY, 0644) == -1 )
37   return -1;
38 } else {
39  if ( roar_vio_open_fh(inst, fh) == -1 )
40   return -1;
41 }
42
43 inst->write = driver_dmx_write;
44 inst->ctl   = driver_dmx_ctl;
45
46 info->codec = ROAR_CODEC_DMX512;
47
48 return 0;
49}
50
51ssize_t driver_dmx_write (struct roar_vio_calls * vio,  void *buf, size_t count) {
52 if ( vio == NULL || buf == NULL )
53  return -1;
54
55 if ( count != 512 )
56  return -1;
57
58 if ( lseek(roar_vio_get_fh(vio), 0, SEEK_SET) == (off_t)-1 )
59  return -1;
60
61 return write(roar_vio_get_fh(vio), buf, count);
62}
63
64int driver_dmx_ctl(struct roar_vio_calls * vio, int cmd, void * data) {
65
66 if ( vio == NULL )
67  return -1;
68
69 switch (cmd) {
70  case ROAR_VIO_CTL_SET_SSTREAM:
71    ROAR_STREAM(data)->dir = ROAR_DIR_LIGHT_OUT;
72    ROAR_STREAM_SERVER(data)->codec_orgi = ROAR_CODEC_DMX512;
73   break;
74  default:
75   return -1;
76 }
77
78 return 0;
79}
80
81//ll
Note: See TracBrowser for help on using the repository browser.