Skip to content

Commit 7c08a3a

Browse files
committed
Use GetVolume() and IsMuted() instead of control's implementation detail
These methods existed in the class yet in these places the code was still using the repeated code. The existing methods return the same value.
1 parent a044a1a commit 7c08a3a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/mpc-hc/MainFrm.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10033,16 +10033,16 @@ void CMainFrame::OnPlayVolume(UINT nID)
1003310033
m_pBA->put_Volume(m_wndToolBar.Volume);
1003410034

1003510035
//strVolume.Format (L"Vol : %d dB", m_wndToolBar.Volume / 100);
10036-
if (m_wndToolBar.Volume == -10000) {
10036+
if (IsMuted()) {
1003710037
strVolume.Format(IDS_VOLUME_OSD, 0);
1003810038
} else {
10039-
strVolume.Format(IDS_VOLUME_OSD, m_wndToolBar.m_volctrl.GetPos());
10039+
strVolume.Format(IDS_VOLUME_OSD, GetVolume());
1004010040
}
1004110041
m_OSD.DisplayMessage(OSD_TOPLEFT, strVolume);
1004210042
//SendStatusMessage(strVolume, 3000); // Now the volume is displayed in three places at once.
1004310043
}
1004410044

10045-
m_Lcd.SetVolume((m_wndToolBar.Volume > -10000 ? m_wndToolBar.m_volctrl.GetPos() : 1));
10045+
m_Lcd.SetVolume((!IsMuted() ? GetVolume() : 1));
1004610046

1004710047
SendCurrentVolumeToApi();
1004810048
}
@@ -20543,9 +20543,9 @@ void CMainFrame::SendCurrentVolumeToApi()
2054320543
}
2054420544

2054520545
CString buff, volumelevel, muted;
20546-
volumelevel.Format(_T("%d"), m_wndToolBar.m_volctrl.GetPos());
20547-
muted.Format(_T("%d"), m_wndToolBar.Volume == -10000 ? 1 : 0);
20548-
buff.Format(L"%s|%s", volumelevel, muted);
20546+
volumelevel.Format(_T("%d"), GetVolume());
20547+
muted.Format(_T("%d"), IsMuted() ? 1 : 0);
20548+
buff.Format(L"%s|%s", volumelevel.GetString(), muted.GetString());
2054920549

2055020550
SendAPICommand(CMD_CURRENTVOLUME, L"%s", static_cast<LPCWSTR>(buff));
2055120551
}

src/mpc-hc/WebClientSocket.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,8 @@ bool CWebClientSocket::OnControls(CStringA& hdr, CStringA& body, CStringA& mime)
681681
}
682682

683683
CString volumelevel, muted;
684-
volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
685-
muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
684+
volumelevel.Format(_T("%d"), m_pMainFrame->GetVolume());
685+
muted.Format(_T("%d"), m_pMainFrame->IsMuted() ? 1 : 0);
686686

687687
CString reloadtime(_T("0")); // TODO
688688

@@ -737,8 +737,8 @@ bool CWebClientSocket::OnVariables(CStringA& hdr, CStringA& body, CStringA& mime
737737
}
738738

739739
CString volumelevel, muted;
740-
volumelevel.Format(_T("%d"), m_pMainFrame->m_wndToolBar.m_volctrl.GetPos());
741-
muted.Format(_T("%d"), m_pMainFrame->m_wndToolBar.Volume == -10000 ? 1 : 0);
740+
volumelevel.Format(_T("%d"), m_pMainFrame->GetVolume());
741+
muted.Format(_T("%d"), m_pMainFrame->IsMuted() ? 1 : 0);
742742

743743
CString reloadtime(_T("0")); // TODO
744744

0 commit comments

Comments
 (0)