source: roaraudio/roard/driver_dmx.c @ 2368:4128bea7fc3e

Last change on this file since 2368:4128bea7fc3e was 2368:4128bea7fc3e, checked in by phi, 15 years ago

set sstream if we have one at open time

File size: 2.1 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, struct roar_stream_server * sstream) {
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 if ( sstream != NULL )
49  driver_dmx_ctl(inst, ROAR_VIO_CTL_SET_SSTREAM, sstream);
50
51 return 0;
52}
53
54ssize_t driver_dmx_write (struct roar_vio_calls * vio,  void *buf, size_t count) {
55 if ( vio == NULL || buf == NULL )
56  return -1;
57
58 if ( count != 512 )
59  return -1;
60
61 if ( roar_vio_basic_lseek(vio, 0, SEEK_SET) == (off_t)-1 )
62  return -1;
63
64 return roar_vio_basic_write(vio, buf, count);
65}
66
67int driver_dmx_ctl(struct roar_vio_calls * vio, int cmd, void * data) {
68
69 if ( vio == NULL )
70  return -1;
71
72 switch (cmd) {
73  case ROAR_VIO_CTL_SET_SSTREAM:
74    ROAR_STREAM(data)->dir = ROAR_DIR_LIGHT_OUT;
75    ROAR_STREAM_SERVER(data)->codec_orgi = ROAR_CODEC_DMX512;
76   break;
77  default:
78   return -1;
79 }
80
81 return 0;
82}
83
84//ll
Note: See TracBrowser for help on using the repository browser.