1 |
/* |
---|
2 |
* Copyright (C) 2007 by Pieter Palmers |
---|
3 |
* |
---|
4 |
* This file is part of FFADO |
---|
5 |
* FFADO = Free Firewire (pro-)audio drivers for linux |
---|
6 |
* |
---|
7 |
* FFADO is based upon FreeBoB |
---|
8 |
* |
---|
9 |
* This library is free software; you can redistribute it and/or |
---|
10 |
* modify it under the terms of the GNU Lesser General Public |
---|
11 |
* License version 2.1, as published by the Free Software Foundation; |
---|
12 |
* |
---|
13 |
* This library is distributed in the hope that it will be useful, |
---|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 |
* Lesser General Public License for more details. |
---|
17 |
* |
---|
18 |
* You should have received a copy of the GNU Lesser General Public |
---|
19 |
* License along with this library; if not, write to the Free Software |
---|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
---|
21 |
* MA 02110-1301 USA |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
#include "efc_cmd.h" |
---|
25 |
#include "efc_cmds_monitor.h" |
---|
26 |
|
---|
27 |
#include <netinet/in.h> |
---|
28 |
#include <iostream> |
---|
29 |
|
---|
30 |
using namespace std; |
---|
31 |
|
---|
32 |
namespace FireWorks { |
---|
33 |
|
---|
34 |
const char *eMonitorCommandToString(const enum eMonitorCommand command) { |
---|
35 |
switch (command) { |
---|
36 |
case eMoC_Gain: |
---|
37 |
return "eMC_Gain"; |
---|
38 |
case eMoC_Solo: |
---|
39 |
return "eMoC_Solo"; |
---|
40 |
case eMoC_Mute: |
---|
41 |
return "eMoC_Mute"; |
---|
42 |
case eMoC_Pan: |
---|
43 |
return "eMoC_Pan"; |
---|
44 |
default: |
---|
45 |
return "invalid"; |
---|
46 |
} |
---|
47 |
} |
---|
48 |
|
---|
49 |
EfcGenericMonitorCmd::EfcGenericMonitorCmd(enum eCmdType type, |
---|
50 |
enum eMonitorCommand command) |
---|
51 |
: EfcCmd() |
---|
52 |
, m_input ( -1 ) |
---|
53 |
, m_output ( -1 ) |
---|
54 |
, m_value ( 0 ) |
---|
55 |
, m_type ( type ) |
---|
56 |
, m_command ( command ) |
---|
57 |
{ |
---|
58 |
m_category_id=EFC_CAT_MONITOR_MIX; |
---|
59 |
if (type == eCT_Get) { |
---|
60 |
switch (command) { |
---|
61 |
case eMoC_Gain: |
---|
62 |
m_command_id=EFC_CMD_MIXER_GET_GAIN; |
---|
63 |
break; |
---|
64 |
case eMoC_Solo: |
---|
65 |
m_command_id=EFC_CMD_MIXER_GET_SOLO; |
---|
66 |
break; |
---|
67 |
case eMoC_Mute: |
---|
68 |
m_command_id=EFC_CMD_MIXER_GET_MUTE; |
---|
69 |
break; |
---|
70 |
case eMoC_Pan: |
---|
71 |
m_command_id=EFC_CMD_MIXER_GET_PAN; |
---|
72 |
break; |
---|
73 |
default: |
---|
74 |
debugError("Invalid mixer get command: %d\n", command); |
---|
75 |
} |
---|
76 |
} else { |
---|
77 |
switch (command) { |
---|
78 |
case eMoC_Gain: |
---|
79 |
m_command_id=EFC_CMD_MIXER_SET_GAIN; |
---|
80 |
break; |
---|
81 |
case eMoC_Solo: |
---|
82 |
m_command_id=EFC_CMD_MIXER_SET_SOLO; |
---|
83 |
break; |
---|
84 |
case eMoC_Mute: |
---|
85 |
m_command_id=EFC_CMD_MIXER_SET_MUTE; |
---|
86 |
break; |
---|
87 |
case eMoC_Pan: |
---|
88 |
m_command_id=EFC_CMD_MIXER_SET_PAN; |
---|
89 |
break; |
---|
90 |
default: |
---|
91 |
debugError("Invalid mixer set command: %d\n", command); |
---|
92 |
} |
---|
93 |
} |
---|
94 |
} |
---|
95 |
|
---|
96 |
bool |
---|
97 |
EfcGenericMonitorCmd::serialize( Util::IOSSerialize& se ) |
---|
98 |
{ |
---|
99 |
bool result=true; |
---|
100 |
|
---|
101 |
if (m_type == eCT_Get) { |
---|
102 |
// the length should be specified before |
---|
103 |
// the header is serialized |
---|
104 |
m_length=EFC_HEADER_LENGTH_QUADLETS+2; |
---|
105 |
|
---|
106 |
result &= EfcCmd::serialize ( se ); |
---|
107 |
|
---|
108 |
result &= se.write(htonl(m_input), "Input" ); |
---|
109 |
result &= se.write(htonl(m_output), "Output" ); |
---|
110 |
|
---|
111 |
} else { |
---|
112 |
// the length should be specified before |
---|
113 |
// the header is serialized |
---|
114 |
m_length=EFC_HEADER_LENGTH_QUADLETS+3; |
---|
115 |
|
---|
116 |
result &= EfcCmd::serialize ( se ); |
---|
117 |
|
---|
118 |
result &= se.write(htonl(m_input), "Input" ); |
---|
119 |
result &= se.write(htonl(m_output), "Output" ); |
---|
120 |
result &= se.write(htonl(m_value), "Value" ); |
---|
121 |
} |
---|
122 |
return result; |
---|
123 |
} |
---|
124 |
|
---|
125 |
bool |
---|
126 |
EfcGenericMonitorCmd::deserialize( Util::IISDeserialize& de ) |
---|
127 |
{ |
---|
128 |
bool result=true; |
---|
129 |
|
---|
130 |
result &= EfcCmd::deserialize ( de ); |
---|
131 |
|
---|
132 |
EFC_DESERIALIZE_AND_SWAP(de, (quadlet_t *)&m_input, result); |
---|
133 |
EFC_DESERIALIZE_AND_SWAP(de, (quadlet_t *)&m_output, result); |
---|
134 |
EFC_DESERIALIZE_AND_SWAP(de, &m_value, result); |
---|
135 |
|
---|
136 |
return result; |
---|
137 |
} |
---|
138 |
|
---|
139 |
void |
---|
140 |
EfcGenericMonitorCmd::showEfcCmd() |
---|
141 |
{ |
---|
142 |
EfcCmd::showEfcCmd(); |
---|
143 |
debugOutput(DEBUG_LEVEL_NORMAL, "EFC %s MONITOR %s:\n", |
---|
144 |
(m_type==eCT_Get?"GET":"SET"), |
---|
145 |
eMonitorCommandToString(m_command)); |
---|
146 |
debugOutput(DEBUG_LEVEL_NORMAL, " Input : %ld\n", m_input); |
---|
147 |
debugOutput(DEBUG_LEVEL_NORMAL, " Output : %ld\n", m_output); |
---|
148 |
debugOutput(DEBUG_LEVEL_NORMAL, " Value : %lu\n", m_value); |
---|
149 |
} |
---|
150 |
|
---|
151 |
// --- The specific commands |
---|
152 |
|
---|
153 |
|
---|
154 |
|
---|
155 |
} // namespace FireWorks |
---|