|
a/upmpd/rendering.cxx |
|
b/upmpd/rendering.cxx |
|
... |
|
... |
173 |
|
173 |
|
174 |
return UPNP_E_SUCCESS;
|
174 |
return UPNP_E_SUCCESS;
|
175 |
}
|
175 |
}
|
176 |
#endif
|
176 |
#endif
|
177 |
|
177 |
|
178 |
int UpMpdRenderCtl::setMute(const SoapArgs& sc, SoapData& data)
|
178 |
int UpMpdRenderCtl::getvolume_i()
|
179 |
{
|
179 |
{
|
180 |
map<string, string>::const_iterator it;
|
180 |
return m_desiredvolume >= 0 ? m_desiredvolume :
|
|
|
181 |
m_dev->m_mpdcli->getVolume();
|
|
|
182 |
}
|
181 |
|
183 |
|
182 |
it = sc.args.find("Channel");
|
184 |
void UpMpdRenderCtl::setvolume_i(int volume)
|
183 |
if (it == sc.args.end() || it->second.compare("Master")) {
|
185 |
{
|
184 |
return UPNP_E_INVALID_PARAM;
|
186 |
int previous_volume = m_dev->m_mpdcli->getVolume();
|
185 |
}
|
187 |
int delta = previous_volume - volume;
|
186 |
|
188 |
if (delta < 0)
|
187 |
it = sc.args.find("DesiredMute");
|
189 |
delta = -delta;
|
188 |
if (it == sc.args.end() || it->second.empty()) {
|
190 |
LOGDEB("UpMpdRenderCtl::setVolume: volume " << volume << " delta " <<
|
189 |
return UPNP_E_INVALID_PARAM;
|
191 |
delta << endl);
|
190 |
}
|
192 |
if (delta >= 5) {
|
191 |
if (it->second[0] == 'F' || it->second[0] == '0') {
|
|
|
192 |
// Restore pre-mute
|
|
|
193 |
m_dev->m_mpdcli->setVolume(1, true);
|
193 |
m_dev->m_mpdcli->setVolume(volume);
|
194 |
} else if (it->second[0] == 'T' || it->second[0] == '1') {
|
194 |
m_desiredvolume = -1;
|
|
|
195 |
} else {
|
|
|
196 |
m_desiredvolume = volume;
|
|
|
197 |
}
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
void UpMpdRenderCtl::setmute_i(bool onoff)
|
|
|
201 |
{
|
|
|
202 |
if (onoff) {
|
195 |
if (m_desiredvolume >= 0) {
|
203 |
if (m_desiredvolume >= 0) {
|
196 |
m_dev->m_mpdcli->setVolume(m_desiredvolume);
|
204 |
m_dev->m_mpdcli->setVolume(m_desiredvolume);
|
197 |
m_desiredvolume = -1;
|
205 |
m_desiredvolume = -1;
|
198 |
}
|
206 |
}
|
199 |
m_dev->m_mpdcli->setVolume(0, true);
|
207 |
m_dev->m_mpdcli->setVolume(0, true);
|
200 |
} else {
|
208 |
} else {
|
|
|
209 |
// Restore pre-mute
|
|
|
210 |
m_dev->m_mpdcli->setVolume(1, true);
|
|
|
211 |
}
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
int UpMpdRenderCtl::setMute(const SoapArgs& sc, SoapData& data)
|
|
|
215 |
{
|
|
|
216 |
map<string, string>::const_iterator it;
|
|
|
217 |
|
|
|
218 |
it = sc.args.find("Channel");
|
|
|
219 |
if (it == sc.args.end() || it->second.compare("Master")) {
|
|
|
220 |
return UPNP_E_INVALID_PARAM;
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
it = sc.args.find("DesiredMute");
|
|
|
224 |
if (it == sc.args.end() || it->second.empty()) {
|
|
|
225 |
return UPNP_E_INVALID_PARAM;
|
|
|
226 |
}
|
|
|
227 |
if (it->second[0] == 'F' || it->second[0] == '0') {
|
|
|
228 |
setmute_i(false);
|
|
|
229 |
} else if (it->second[0] == 'T' || it->second[0] == '1') {
|
|
|
230 |
setmute_i(true);
|
|
|
231 |
} else {
|
201 |
return UPNP_E_INVALID_PARAM;
|
232 |
return UPNP_E_INVALID_PARAM;
|
202 |
}
|
233 |
}
|
203 |
m_dev->loopWakeup();
|
234 |
m_dev->loopWakeup();
|
204 |
return UPNP_E_SUCCESS;
|
235 |
return UPNP_E_SUCCESS;
|
205 |
}
|
236 |
}
|
|
... |
|
... |
236 |
}
|
267 |
}
|
237 |
if (volume < 0 || volume > 100) {
|
268 |
if (volume < 0 || volume > 100) {
|
238 |
return UPNP_E_INVALID_PARAM;
|
269 |
return UPNP_E_INVALID_PARAM;
|
239 |
}
|
270 |
}
|
240 |
|
271 |
|
241 |
int previous_volume = m_dev->m_mpdcli->getVolume();
|
272 |
setvolume_i(volume);
|
242 |
int delta = previous_volume - volume;
|
|
|
243 |
if (delta < 0)
|
|
|
244 |
delta = -delta;
|
|
|
245 |
LOGDEB("UpMpdRenderCtl::setVolume: volume " << volume << " delta " << delta << endl);
|
|
|
246 |
if (delta >= 5) {
|
|
|
247 |
m_dev->m_mpdcli->setVolume(volume);
|
|
|
248 |
m_desiredvolume = -1;
|
|
|
249 |
} else {
|
|
|
250 |
m_desiredvolume = volume;
|
|
|
251 |
}
|
|
|
252 |
|
273 |
|
253 |
m_dev->loopWakeup();
|
274 |
m_dev->loopWakeup();
|
254 |
return UPNP_E_SUCCESS;
|
275 |
return UPNP_E_SUCCESS;
|
255 |
}
|
276 |
}
|
256 |
|
277 |
|
|
... |
|
... |
262 |
it = sc.args.find("Channel");
|
283 |
it = sc.args.find("Channel");
|
263 |
if (it == sc.args.end() || it->second.compare("Master")) {
|
284 |
if (it == sc.args.end() || it->second.compare("Master")) {
|
264 |
return UPNP_E_INVALID_PARAM;
|
285 |
return UPNP_E_INVALID_PARAM;
|
265 |
}
|
286 |
}
|
266 |
|
287 |
|
267 |
int volume = m_dev->m_mpdcli->getVolume();
|
288 |
int volume = getvolume_i();
|
268 |
if (isDb) {
|
289 |
if (isDb) {
|
269 |
volume = percentodbvalue(volume);
|
290 |
volume = percentodbvalue(volume);
|
270 |
}
|
291 |
}
|
271 |
char svolume[30];
|
292 |
char svolume[30];
|
272 |
sprintf(svolume, "%d", volume);
|
293 |
sprintf(svolume, "%d", volume);
|