[1827] | 1 | //driver_dmx.c: |
---|
| 2 | |
---|
| 3 | /* |
---|
[4708] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2011 |
---|
[1827] | 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 |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[1827] | 23 | * |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | #include "roard.h" |
---|
| 27 | |
---|
[2503] | 28 | #ifndef ROAR_WITHOUT_DCOMP_DMX |
---|
| 29 | |
---|
[2367] | 30 | int driver_dmx_open_vio (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) { |
---|
[1827] | 31 | |
---|
[1830] | 32 | if ( fh == -1 ) { |
---|
| 33 | if ( device == NULL ) |
---|
| 34 | device = getenv("DMX"); |
---|
[1827] | 35 | |
---|
[1830] | 36 | if ( device == NULL ) |
---|
| 37 | device = "/dev/dmx"; |
---|
| 38 | |
---|
[1827] | 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; |
---|
[1828] | 47 | inst->ctl = driver_dmx_ctl; |
---|
| 48 | |
---|
| 49 | info->codec = ROAR_CODEC_DMX512; |
---|
[1827] | 50 | |
---|
[2368] | 51 | if ( sstream != NULL ) |
---|
| 52 | driver_dmx_ctl(inst, ROAR_VIO_CTL_SET_SSTREAM, sstream); |
---|
| 53 | |
---|
[1827] | 54 | return 0; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | ssize_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 | |
---|
[4918] | 64 | if ( roar_vio_lseek(vio, 0, SEEK_SET) == (off_t)-1 ) |
---|
[1827] | 65 | return -1; |
---|
| 66 | |
---|
[4918] | 67 | return roar_vio_write(vio, buf, count); |
---|
[1827] | 68 | } |
---|
| 69 | |
---|
[1828] | 70 | int 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; |
---|
[1829] | 78 | ROAR_STREAM_SERVER(data)->codec_orgi = ROAR_CODEC_DMX512; |
---|
[1828] | 79 | break; |
---|
| 80 | default: |
---|
| 81 | return -1; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | return 0; |
---|
| 85 | } |
---|
| 86 | |
---|
[2503] | 87 | #endif |
---|
| 88 | |
---|
[1827] | 89 | //ll |
---|