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_mixer.h" |
---|
26 |
|
---|
27 |
#include <netinet/in.h> |
---|
28 |
#include <iostream> |
---|
29 |
|
---|
30 |
using namespace std; |
---|
31 |
|
---|
32 |
namespace FireWorks { |
---|
33 |
|
---|
34 |
const char *eMixerTargetToString(const enum eMixerTarget target) { |
---|
35 |
switch (target) { |
---|
36 |
case eMT_PhysicalOutputMix: |
---|
37 |
return "eMT_PhysicalOutputMix"; |
---|
38 |
case eMT_PhysicalInputMix: |
---|
39 |
return "eMT_PhysicalInputMix"; |
---|
40 |
case eMT_PlaybackMix: |
---|
41 |
return "eMT_PlaybackMix"; |
---|
42 |
case eMT_RecordMix: |
---|
43 |
return "eMT_RecordMix"; |
---|
44 |
default: |
---|
45 |
return "invalid"; |
---|
46 |
} |
---|
47 |
} |
---|
48 |
|
---|
49 |
const char *eMixerCommandToString(const enum eMixerCommand command) { |
---|
50 |
switch (command) { |
---|
51 |
case eMC_Gain: |
---|
52 |
return "eMC_Gain"; |
---|
53 |
case eMC_Solo: |
---|
54 |
return "eMC_Solo"; |
---|
55 |
case eMC_Mute: |
---|
56 |
return "eMC_Mute"; |
---|
57 |
case eMC_Pan: |
---|
58 |
return "eMC_Pan"; |
---|
59 |
case eMC_Nominal: |
---|
60 |
return "eMC_Nominal"; |
---|
61 |
default: |
---|
62 |
return "invalid"; |
---|
63 |
} |
---|
64 |
} |
---|
65 |
|
---|
66 |
EfcGenericMixerCmd::EfcGenericMixerCmd(enum eCmdType type, |
---|
67 |
enum eMixerTarget target, |
---|
68 |
enum eMixerCommand command) |
---|
69 |
: EfcCmd() |
---|
70 |
, m_channel ( -1 ) |
---|
71 |
, m_value ( 0 ) |
---|
72 |
, m_type ( type ) |
---|
73 |
, m_target ( target ) |
---|
74 |
, m_command ( command ) |
---|
75 |
{ |
---|
76 |
switch (target) { |
---|
77 |
case eMT_PhysicalOutputMix: |
---|
78 |
m_category_id=EFC_CAT_PHYSICAL_OUTPUT_MIX; |
---|
79 |
break; |
---|
80 |
case eMT_PhysicalInputMix: |
---|
81 |
m_category_id=EFC_CAT_PHYSICAL_INPUT_MIX; |
---|
82 |
break; |
---|
83 |
case eMT_PlaybackMix: |
---|
84 |
m_category_id=EFC_CAT_PLAYBACK_MIX; |
---|
85 |
break; |
---|
86 |
case eMT_RecordMix: |
---|
87 |
m_category_id=EFC_CAT_RECORD_MIX; |
---|
88 |
break; |
---|
89 |
default: |
---|
90 |
debugError("Invalid mixer target: %d\n", target); |
---|
91 |
} |
---|
92 |
|
---|
93 |
if (type == eCT_Get) { |
---|
94 |
switch (command) { |
---|
95 |
case eMC_Gain: |
---|
96 |
m_command_id=EFC_CMD_MIXER_GET_GAIN; |
---|
97 |
break; |
---|
98 |
case eMC_Solo: |
---|
99 |
m_command_id=EFC_CMD_MIXER_GET_SOLO; |
---|
100 |
break; |
---|
101 |
case eMC_Mute: |
---|
102 |
m_command_id=EFC_CMD_MIXER_GET_MUTE; |
---|
103 |
break; |
---|
104 |
case eMC_Pan: |
---|
105 |
m_command_id=EFC_CMD_MIXER_GET_PAN; |
---|
106 |
break; |
---|
107 |
case eMC_Nominal: |
---|
108 |
m_command_id=EFC_CMD_MIXER_GET_NOMINAL; |
---|
109 |
break; |
---|
110 |
default: |
---|
111 |
debugError("Invalid mixer get command: %d\n", command); |
---|
112 |
} |
---|
113 |
} else { |
---|
114 |
switch (command) { |
---|
115 |
case eMC_Gain: |
---|
116 |
m_command_id=EFC_CMD_MIXER_SET_GAIN; |
---|
117 |
break; |
---|
118 |
case eMC_Solo: |
---|
119 |
m_command_id=EFC_CMD_MIXER_SET_SOLO; |
---|
120 |
break; |
---|
121 |
case eMC_Mute: |
---|
122 |
m_command_id=EFC_CMD_MIXER_SET_MUTE; |
---|
123 |
break; |
---|
124 |
case eMC_Pan: |
---|
125 |
m_command_id=EFC_CMD_MIXER_SET_PAN; |
---|
126 |
break; |
---|
127 |
case eMC_Nominal: |
---|
128 |
m_command_id=EFC_CMD_MIXER_SET_NOMINAL; |
---|
129 |
break; |
---|
130 |
default: |
---|
131 |
debugError("Invalid mixer set command: %d\n", command); |
---|
132 |
} |
---|
133 |
} |
---|
134 |
} |
---|
135 |
|
---|
136 |
bool |
---|
137 |
EfcGenericMixerCmd::serialize( Util::IOSSerialize& se ) |
---|
138 |
{ |
---|
139 |
bool result=true; |
---|
140 |
|
---|
141 |
if (m_type == eCT_Get) { |
---|
142 |
// the length should be specified before |
---|
143 |
// the header is serialized |
---|
144 |
m_length=EFC_HEADER_LENGTH_QUADLETS+1; |
---|
145 |
|
---|
146 |
result &= EfcCmd::serialize ( se ); |
---|
147 |
|
---|
148 |
result &= se.write(htonl(m_channel), "Channel" ); |
---|
149 |
|
---|
150 |
} else { |
---|
151 |
// the length should be specified before |
---|
152 |
// the header is serialized |
---|
153 |
m_length=EFC_HEADER_LENGTH_QUADLETS+2; |
---|
154 |
|
---|
155 |
result &= EfcCmd::serialize ( se ); |
---|
156 |
|
---|
157 |
result &= se.write(htonl(m_channel), "Channel" ); |
---|
158 |
result &= se.write(htonl(m_value), "Value" ); |
---|
159 |
} |
---|
160 |
return result; |
---|
161 |
} |
---|
162 |
|
---|
163 |
bool |
---|
164 |
EfcGenericMixerCmd::deserialize( Util::IISDeserialize& de ) |
---|
165 |
{ |
---|
166 |
bool result=true; |
---|
167 |
|
---|
168 |
result &= EfcCmd::deserialize ( de ); |
---|
169 |
|
---|
170 |
EFC_DESERIALIZE_AND_SWAP(de, (quadlet_t *)&m_channel, result); |
---|
171 |
EFC_DESERIALIZE_AND_SWAP(de, &m_value, result); |
---|
172 |
|
---|
173 |
return result; |
---|
174 |
} |
---|
175 |
|
---|
176 |
void |
---|
177 |
EfcGenericMixerCmd::showEfcCmd() |
---|
178 |
{ |
---|
179 |
EfcCmd::showEfcCmd(); |
---|
180 |
debugOutput(DEBUG_LEVEL_NORMAL, "EFC %s %s %s:\n", |
---|
181 |
(m_type==eCT_Get?"GET":"SET"), |
---|
182 |
eMixerTargetToString(m_target), |
---|
183 |
eMixerCommandToString(m_command)); |
---|
184 |
debugOutput(DEBUG_LEVEL_NORMAL, " Channel : %ld\n", m_channel); |
---|
185 |
debugOutput(DEBUG_LEVEL_NORMAL, " Value : %lu\n", m_value); |
---|
186 |
} |
---|
187 |
|
---|
188 |
// --- The specific commands |
---|
189 |
|
---|
190 |
|
---|
191 |
|
---|
192 |
} // namespace FireWorks |
---|