[1827] | 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 | |
---|
[2367] | 27 | 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] | 28 | |
---|
[1830] | 29 | if ( fh == -1 ) { |
---|
| 30 | if ( device == NULL ) |
---|
| 31 | device = getenv("DMX"); |
---|
[1827] | 32 | |
---|
[1830] | 33 | if ( device == NULL ) |
---|
| 34 | device = "/dev/dmx"; |
---|
| 35 | |
---|
[1827] | 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; |
---|
[1828] | 44 | inst->ctl = driver_dmx_ctl; |
---|
| 45 | |
---|
| 46 | info->codec = ROAR_CODEC_DMX512; |
---|
[1827] | 47 | |
---|
[2368] | 48 | if ( sstream != NULL ) |
---|
| 49 | driver_dmx_ctl(inst, ROAR_VIO_CTL_SET_SSTREAM, sstream); |
---|
| 50 | |
---|
[1827] | 51 | return 0; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | ssize_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 | |
---|
[1831] | 61 | if ( roar_vio_basic_lseek(vio, 0, SEEK_SET) == (off_t)-1 ) |
---|
[1827] | 62 | return -1; |
---|
| 63 | |
---|
[1831] | 64 | return roar_vio_basic_write(vio, buf, count); |
---|
[1827] | 65 | } |
---|
| 66 | |
---|
[1828] | 67 | int 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; |
---|
[1829] | 75 | ROAR_STREAM_SERVER(data)->codec_orgi = ROAR_CODEC_DMX512; |
---|
[1828] | 76 | break; |
---|
| 77 | default: |
---|
| 78 | return -1; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | return 0; |
---|
| 82 | } |
---|
| 83 | |
---|
[1827] | 84 | //ll |
---|