source: roaraudio/roard/driver_dmx.c @ 3811:49db840fb4f4

Last change on this file since 3811:49db840fb4f4 was 3811:49db840fb4f4, checked in by phi, 14 years ago

fixed some copyright statements

File size: 2.2 KB
Line 
1//driver_dmx.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2010
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
32 if ( fh == -1 ) {
33  if ( device == NULL )
34   device = getenv("DMX");
35
36  if ( device == NULL )
37   device = "/dev/dmx";
38
39  if ( roar_vio_open_file(inst, device, O_WRONLY, 0644) == -1 )
40   return -1;
41 } else {
42  if ( roar_vio_open_fh(inst, fh) == -1 )
43   return -1;
44 }
45
46 inst->write = driver_dmx_write;
47 inst->ctl   = driver_dmx_ctl;
48
49 info->codec = ROAR_CODEC_DMX512;
50
51 if ( sstream != NULL )
52  driver_dmx_ctl(inst, ROAR_VIO_CTL_SET_SSTREAM, sstream);
53
54 return 0;
55}
56
57ssize_t driver_dmx_write (struct roar_vio_calls * vio,  void *buf, size_t count) {
58 if ( vio == NULL || buf == NULL )
59  return -1;
60
61 if ( count != 512 )
62  return -1;
63
64 if ( roar_vio_basic_lseek(vio, 0, SEEK_SET) == (off_t)-1 )
65  return -1;
66
67 return roar_vio_basic_write(vio, buf, count);
68}
69
70int driver_dmx_ctl(struct roar_vio_calls * vio, int cmd, void * data) {
71
72 if ( vio == NULL )
73  return -1;
74
75 switch (cmd) {
76  case ROAR_VIO_CTL_SET_SSTREAM:
77    ROAR_STREAM(data)->dir = ROAR_DIR_LIGHT_OUT;
78    ROAR_STREAM_SERVER(data)->codec_orgi = ROAR_CODEC_DMX512;
79   break;
80  default:
81   return -1;
82 }
83
84 return 0;
85}
86
87#endif
88
89//ll
Note: See TracBrowser for help on using the repository browser.