|
a/src/mpdcli.cxx |
|
b/src/mpdcli.cxx |
|
... |
|
... |
447 |
// LOGDEB1("MPDCli::mapSong: got mpdid " << upsong.mpdid << " " <<
|
447 |
// LOGDEB1("MPDCli::mapSong: got mpdid " << upsong.mpdid << " " <<
|
448 |
// upsong.dump() << endl);
|
448 |
// upsong.dump() << endl);
|
449 |
return upsong;
|
449 |
return upsong;
|
450 |
}
|
450 |
}
|
451 |
|
451 |
|
|
|
452 |
// All the nutty stuff about mute is due to the fact that MPD does not
|
|
|
453 |
// have such a function (they say that pause is good enough).
|
452 |
bool MPDCli::setVolume(int volume, bool isMute)
|
454 |
bool MPDCli::setVolume(int volume, bool isMute)
|
453 |
{
|
455 |
{
|
454 |
LOGDEB("MPDCli::setVolume. extvc " << m_externalvolumecontrol << endl);
|
456 |
LOGDEB("MPDCli::setVolume. extvc " << m_externalvolumecontrol << endl);
|
455 |
if (!ok()) {
|
457 |
if (!ok()) {
|
456 |
return false;
|
458 |
return false;
|
|
... |
|
... |
465 |
|
467 |
|
466 |
LOGDEB("MPDCli::setVolume: vol " << volume << " isMute " << isMute << endl);
|
468 |
LOGDEB("MPDCli::setVolume: vol " << volume << " isMute " << isMute << endl);
|
467 |
|
469 |
|
468 |
if (isMute) {
|
470 |
if (isMute) {
|
469 |
if (volume) {
|
471 |
if (volume) {
|
470 |
// If we're already not muted, do nothing
|
472 |
// volume 1, isMute true means that unmute is required
|
|
|
473 |
// Restore premute volume if it is set, else volume will
|
|
|
474 |
// be restored to 1 (ensuring that the user can increase
|
|
|
475 |
// it because we are out of the mute state).
|
471 |
if (m_premutevolume == 0)
|
476 |
if (m_premutevolume != 0) {
|
472 |
return true;
|
|
|
473 |
// Restore premute volume
|
|
|
474 |
LOGDEB("MPDCli::setVolume: restoring premute " << m_premutevolume
|
477 |
LOGDEB("MPDCli::setVolume: restoring premute " <<
|
475 |
<< endl);
|
478 |
m_premutevolume << endl);
|
476 |
volume = m_stat.volume = m_premutevolume;
|
479 |
volume = m_stat.volume = m_premutevolume;
|
|
|
480 |
}
|
477 |
m_premutevolume = 0;
|
481 |
m_premutevolume = 0;
|
478 |
} else {
|
482 |
} else {
|
|
|
483 |
// volume 0, isMute true: mute request
|
479 |
// If we're already muted, do nothing
|
484 |
// If we're already muted, do nothing
|
480 |
if (m_premutevolume > 0)
|
485 |
if (m_premutevolume > 0) {
|
481 |
return true;
|
486 |
return true;
|
|
|
487 |
}
|
482 |
if (m_cachedvolume > 0) {
|
488 |
if (m_cachedvolume > 0) {
|
483 |
m_premutevolume = m_cachedvolume;
|
489 |
m_premutevolume = m_cachedvolume;
|
|
|
490 |
} else {
|
|
|
491 |
// Never mute with a saved volume of 0, we get into
|
|
|
492 |
// trouble with some CPs
|
|
|
493 |
m_premutevolume = 1;
|
484 |
}
|
494 |
}
|
485 |
}
|
495 |
}
|
486 |
}
|
496 |
}
|
487 |
|
497 |
|
488 |
if (volume < 0)
|
498 |
if (volume < 0)
|
489 |
volume = 0;
|
499 |
volume = 0;
|
490 |
else if (volume > 100)
|
500 |
else if (volume > 100)
|
491 |
volume = 100;
|
501 |
volume = 100;
|
492 |
|
502 |
|
493 |
if (!(m_externalvolumecontrol)) {
|
503 |
if (!(m_externalvolumecontrol)) {
|
|
|
504 |
LOGDEB2("MPDCli::setVolume: setting mpd volume " << volume << endl);
|
494 |
RETRY_CMD(mpd_run_set_volume(M_CONN, volume));
|
505 |
RETRY_CMD(mpd_run_set_volume(M_CONN, volume));
|
495 |
}
|
506 |
}
|
496 |
if (!m_onvolumechange.empty()) {
|
507 |
if (!m_onvolumechange.empty()) {
|
497 |
ExecCmd ecmd;
|
508 |
ExecCmd ecmd;
|
498 |
vector<string> args = m_onvolumechange;
|
509 |
vector<string> args = m_onvolumechange;
|