1 | //codecfilter_roardmx.c: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2013 |
---|
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_LIGHT |
---|
29 | |
---|
30 | int cf_light_roardmx_read(int id, struct roar_stream_server * ss) { |
---|
31 | struct roar_roardmx_message mes; |
---|
32 | int i, c; |
---|
33 | uint16_t channel; |
---|
34 | uint8_t value; |
---|
35 | |
---|
36 | if ( roar_roardmx_message_recv(&mes, &(ss->vio)) == -1 ) { |
---|
37 | return -1; |
---|
38 | } |
---|
39 | |
---|
40 | // we ignore errors here at the moment as 0 not < -1 |
---|
41 | c = roar_roardmx_message_numchannels(&mes); |
---|
42 | ROAR_DBG("light_check_stream(id=%i): Number of subframes: %u", id, c); |
---|
43 | |
---|
44 | for (i = 0; i < c; i++) { |
---|
45 | if ( roar_roardmx_message_get_chanval(&mes, &channel, &value, i) == -1 ) |
---|
46 | return -1; |
---|
47 | |
---|
48 | if ( g_light_state.channels < channel ) { |
---|
49 | ROAR_WARN("light_check_stream(id=%i): Writing on non extisting DMX channel %u", id, channel); |
---|
50 | continue; |
---|
51 | } else { |
---|
52 | g_light_state.state[channel] = value; |
---|
53 | g_light_state.changes[channel] = 0xFF; // the channel changed |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | return 0; |
---|
58 | } |
---|
59 | |
---|
60 | int cf_light_roardmx_write(int id, struct roar_stream_server * ss) { |
---|
61 | struct roar_roardmx_message mes; |
---|
62 | int have_message = 0; |
---|
63 | int i; |
---|
64 | |
---|
65 | for (i = 0; i < g_light_state.channels; i++) { |
---|
66 | if ( g_light_state.changes[i] ) { |
---|
67 | if ( !have_message ) |
---|
68 | if ( roar_roardmx_message_new_sset(&mes) == -1 ) |
---|
69 | return -1; |
---|
70 | |
---|
71 | have_message = 2; |
---|
72 | |
---|
73 | if ( roar_roardmx_message_add_chanval(&mes, i, g_light_state.state[i]) == -1 ) { |
---|
74 | if ( roar_roardmx_message_send(&mes, &(ss->vio)) == -1 ) |
---|
75 | return -1; |
---|
76 | |
---|
77 | if ( roar_roardmx_message_new_sset(&mes) == -1 ) |
---|
78 | return -1; |
---|
79 | |
---|
80 | have_message = 1; |
---|
81 | } |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | if ( have_message == 2 ) |
---|
86 | if ( roar_roardmx_message_send(&mes, &(ss->vio)) == -1 ) |
---|
87 | return -1; |
---|
88 | |
---|
89 | return 0; |
---|
90 | } |
---|
91 | |
---|
92 | #endif |
---|
93 | |
---|
94 | //ll |
---|