aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/Application.cpp58
-rw-r--r--xbmc/Application.h4
-rw-r--r--xbmc/GUIInfoManager.cpp2
-rw-r--r--xbmc/dialogs/GUIDialogMuteBug.cpp2
-rw-r--r--xbmc/interfaces/Builtins.cpp2
-rw-r--r--xbmc/interfaces/http-api/XBMChttp.cpp4
-rw-r--r--xbmc/interfaces/json-rpc/ApplicationOperations.cpp2
-rw-r--r--xbmc/network/AirPlayServer.cpp2
-rw-r--r--xbmc/network/UPnP.cpp2
-rw-r--r--xbmc/peripherals/devices/PeripheralCecAdapter.cpp2
-rw-r--r--xbmc/settings/Settings.cpp6
-rw-r--r--xbmc/settings/Settings.h8
-rw-r--r--xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp10
13 files changed, 50 insertions, 54 deletions
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
index 3ccfb0a761..1577bf050e 100644
--- a/xbmc/Application.cpp
+++ b/xbmc/Application.cpp
@@ -31,6 +31,7 @@
#include "pictures/Picture.h"
#include "guilib/TextureManager.h"
#include "cores/dvdplayer/DVDFileInfo.h"
+#include "cores/AudioEngine/Utils/AEUtil.h"
#include "PlayListPlayer.h"
#include "Autorun.h"
#include "video/Bookmark.h"
@@ -732,6 +733,8 @@ bool CApplication::Create()
if (!g_localizeStrings.Load(strLanguagePath))
FatalErrorHandler(false, false, true);
+ SetHardwareVolume(g_settings.m_fVolumeLevel);
+
// start-up Addons Framework
// currently bails out if either cpluff Dll is unavailable or system dir can not be scanned
if (!CAddonMgr::Get().Init())
@@ -1254,7 +1257,6 @@ bool CApplication::Initialize()
// Restore volume
if (g_settings.m_bMute)
Mute();
- SetVolume(g_settings.m_nVolumeLevel, false);
// if the user shutoff the xbox during music scan
// restore the settings
@@ -2622,21 +2624,17 @@ bool CApplication::OnAction(const CAction &action)
{
if (g_settings.m_bMute)
UnMute();
- int volume = g_settings.m_nVolumeLevel + g_settings.m_dynamicRangeCompressionLevel;
-
- // calculate speed so that a full press will equal 1 second from min to max
- float speed = float(VOLUME_MAXIMUM - VOLUME_MINIMUM);
+ float volume = g_settings.m_fVolumeLevel;
+ float step = (VOLUME_MAXIMUM - VOLUME_MINIMUM) / VOLUME_CONTROL_STEPS;
if (action.GetRepeat())
- speed *= action.GetRepeat();
- else
- speed /= 50; //50 fps
+ step *= action.GetRepeat() * 50; // 50 fps
if (action.GetID() == ACTION_VOLUME_UP)
- volume += (int)((float)fabs(action.GetAmount()) * action.GetAmount() * speed);
+ volume += (float)fabs(action.GetAmount()) * action.GetAmount() * step;
else
- volume -= (int)((float)fabs(action.GetAmount()) * action.GetAmount() * speed);
+ volume -= (float)fabs(action.GetAmount()) * action.GetAmount() * step;
- SetVolume(volume, false);
+ SetHardwareVolume(volume);
}
// show visual feedback of volume change...
ShowVolumeBar(&action);
@@ -5129,44 +5127,40 @@ void CApplication::UnMute()
g_settings.m_bMute = false;
}
-void CApplication::SetVolume(long iValue, bool isPercentage /* = true */)
+void CApplication::SetVolume(float iValue, bool isPercentage/*=true*/)
{
- // convert the percentage to a mB (milliBell) value (*100 for dB)
- if (isPercentage)
- iValue = (long)((float)iValue * 0.01f * (VOLUME_MAXIMUM - VOLUME_MINIMUM) + VOLUME_MINIMUM);
+ float hardwareVolume = iValue;
- SetHardwareVolume(iValue);
- g_audioManager.SetVolume((int)(128.f * (g_settings.m_nVolumeLevel - VOLUME_MINIMUM) / (float)(VOLUME_MAXIMUM - VOLUME_MINIMUM)));
+ if(isPercentage)
+ hardwareVolume /= 100.0f;
+
+ SetHardwareVolume(hardwareVolume);
+ g_audioManager.SetVolume((int)(128.f * g_settings.m_fVolumeLevel));
CVariant data(CVariant::VariantTypeObject);
- data["volume"] = (int)(((float)(g_settings.m_nVolumeLevel - VOLUME_MINIMUM)) / (VOLUME_MAXIMUM - VOLUME_MINIMUM) * 100.0f + 0.5f);
+ data["volume"] = (int)(hardwareVolume * 100.0f + 0.5f);
data["muted"] = g_settings.m_bMute;
CAnnouncementManager::Announce(Application, "xbmc", "OnVolumeChanged", data);
}
-void CApplication::SetHardwareVolume(long hardwareVolume)
+void CApplication::SetHardwareVolume(float hardwareVolume)
{
- // TODO DRC
- if (hardwareVolume >= VOLUME_MAXIMUM) // + VOLUME_DRC_MAXIMUM
- hardwareVolume = VOLUME_MAXIMUM;// + VOLUME_DRC_MAXIMUM;
- if (hardwareVolume <= VOLUME_MINIMUM)
- hardwareVolume = VOLUME_MINIMUM;
+ hardwareVolume = std::max(VOLUME_MINIMUM, std::min(VOLUME_MAXIMUM, hardwareVolume));
+ g_settings.m_fVolumeLevel = hardwareVolume;
- // update our settings
- if (hardwareVolume > VOLUME_MAXIMUM)
- g_settings.m_nVolumeLevel = VOLUME_MAXIMUM;
- else
- g_settings.m_nVolumeLevel = hardwareVolume;
+ float value = 0.0f;
+ if (hardwareVolume > VOLUME_MINIMUM)
+ value = CAEUtil::LinToLog(VOLUME_DYNAMIC_RANGE, hardwareVolume);
// and tell our player to update the volume
if (m_pPlayer)
- m_pPlayer->SetVolume(g_settings.m_nVolumeLevel);
+ m_pPlayer->SetVolume(value);
}
int CApplication::GetVolume() const
{
// converts the hardware volume (in mB) to a percentage
- return int(((float)(g_settings.m_nVolumeLevel - VOLUME_MINIMUM)) / (VOLUME_MAXIMUM - VOLUME_MINIMUM)*100.0f + 0.5f);
+ return g_settings.m_fVolumeLevel * 100.0f;
}
int CApplication::GetSubtitleDelay() const
@@ -5205,7 +5199,7 @@ void CApplication::SetPlaySpeed(int iSpeed)
m_pPlayer->ToFFRW(m_iPlaySpeed);
if (m_iPlaySpeed == 1)
{ // restore volume
- m_pPlayer->SetVolume(g_settings.m_nVolumeLevel);
+ m_pPlayer->SetVolume(VOLUME_MAXIMUM);
}
else
{ // mute volume
diff --git a/xbmc/Application.h b/xbmc/Application.h
index edc8dfc4a4..26798342de 100644
--- a/xbmc/Application.h
+++ b/xbmc/Application.h
@@ -188,7 +188,7 @@ public:
void ProcessSlow();
void ResetScreenSaver();
int GetVolume() const;
- void SetVolume(long iValue, bool isPercentage = true);
+ void SetVolume(float iValue, bool isPercentage = true);
bool IsMuted() const;
void ToggleMute(void);
void ShowVolumeBar(const CAction *action = NULL);
@@ -399,7 +399,7 @@ protected:
void Mute();
void UnMute();
- void SetHardwareVolume(long hardwareVolume);
+ void SetHardwareVolume(float hardwareVolume);
void UpdateLCD();
void FatalErrorHandler(bool WindowSystemInitialized, bool MapDrives, bool InitNetwork);
diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp
index 73a9875280..16f9b28b42 100644
--- a/xbmc/GUIInfoManager.cpp
+++ b/xbmc/GUIInfoManager.cpp
@@ -1146,7 +1146,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
strLabel.Format("%02.2f", m_fps);
break;
case PLAYER_VOLUME:
- strLabel.Format("%2.1f dB", (float)(g_settings.m_nVolumeLevel + g_settings.m_dynamicRangeCompressionLevel) * 0.01f);
+ strLabel.Format("%2.1f dB", g_settings.m_fVolumeLevel);
break;
case PLAYER_SUBTITLE_DELAY:
strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_SubtitleDelay);
diff --git a/xbmc/dialogs/GUIDialogMuteBug.cpp b/xbmc/dialogs/GUIDialogMuteBug.cpp
index a54ec0a5f3..df4fde9305 100644
--- a/xbmc/dialogs/GUIDialogMuteBug.cpp
+++ b/xbmc/dialogs/GUIDialogMuteBug.cpp
@@ -36,7 +36,7 @@ CGUIDialogMuteBug::~CGUIDialogMuteBug(void)
void CGUIDialogMuteBug::UpdateVisibility()
{
- if (g_settings.m_bMute || g_settings.m_nVolumeLevel == VOLUME_MINIMUM)
+ if (g_settings.m_bMute || g_settings.m_fVolumeLevel == VOLUME_MINIMUM)
Show();
else
Close();
diff --git a/xbmc/interfaces/Builtins.cpp b/xbmc/interfaces/Builtins.cpp
index 409fdf585f..fa49de71ef 100644
--- a/xbmc/interfaces/Builtins.cpp
+++ b/xbmc/interfaces/Builtins.cpp
@@ -827,7 +827,7 @@ int CBuiltins::Execute(const CStdString& execString)
int oldVolume = g_application.GetVolume();
int volume = atoi(parameter.c_str());
- g_application.SetVolume(volume);
+ g_application.SetVolume((float)volume);
if(oldVolume != volume)
{
if(params.size() > 1 && params[1].Equals("showVolumeBar"))
diff --git a/xbmc/interfaces/http-api/XBMChttp.cpp b/xbmc/interfaces/http-api/XBMChttp.cpp
index fc6e2fcb1c..c3db3f2d51 100644
--- a/xbmc/interfaces/http-api/XBMChttp.cpp
+++ b/xbmc/interfaces/http-api/XBMChttp.cpp
@@ -1597,7 +1597,7 @@ int CXbmcHttp::xbmcSetVolume(int numParas, CStdString paras[])
else
{
int iPercent = atoi(paras[0].c_str());
- g_application.SetVolume(iPercent);
+ g_application.SetVolume((float)iPercent, true);
return SetResponse(openTag+"OK");
}
}
@@ -2612,7 +2612,7 @@ int CXbmcHttp::xbmcSTSetting(int numParas, CStdString paras[])
else if (paras[i]=="httpapibroadcastlevel")
tmp.Format("%i",g_settings.m_HttpApiBroadcastLevel);
else if (paras[i]=="volumelevel")
- tmp.Format("%i",g_settings.m_nVolumeLevel);
+ tmp.Format("%i",g_application.GetVolume());
else if (paras[i]=="systemtimetotalup")
tmp.Format("%i",g_settings.m_iSystemTimeTotalUp);
else if (paras[i]=="mute")
diff --git a/xbmc/interfaces/json-rpc/ApplicationOperations.cpp b/xbmc/interfaces/json-rpc/ApplicationOperations.cpp
index 8b17ef8b10..3f8110f592 100644
--- a/xbmc/interfaces/json-rpc/ApplicationOperations.cpp
+++ b/xbmc/interfaces/json-rpc/ApplicationOperations.cpp
@@ -58,7 +58,7 @@ JSONRPC_STATUS CApplicationOperations::SetVolume(const CStdString &method, ITran
int oldVolume = g_application.GetVolume();
int volume = (int)parameterObject["volume"].asInteger();
- g_application.SetVolume(volume);
+ g_application.SetVolume((float)volume, true);
up = oldVolume < volume;
}
diff --git a/xbmc/network/AirPlayServer.cpp b/xbmc/network/AirPlayServer.cpp
index e8da0e51f0..5cf254b27c 100644
--- a/xbmc/network/AirPlayServer.cpp
+++ b/xbmc/network/AirPlayServer.cpp
@@ -688,7 +688,7 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
else if (uri == "/volume")
{
const char* found = strstr(queryString.c_str(), "volume=");
- double volume = found ? (double)(atof(found + strlen("volume="))) : 0;
+ float volume = found ? (float)strtod(found + strlen("volume="), NULL) : 0;
CLog::Log(LOGDEBUG, "AIRPLAY: got request %s with volume %f", uri.c_str(), volume);
diff --git a/xbmc/network/UPnP.cpp b/xbmc/network/UPnP.cpp
index 55d077b2f3..912aa75f4b 100644
--- a/xbmc/network/UPnP.cpp
+++ b/xbmc/network/UPnP.cpp
@@ -1990,7 +1990,7 @@ CUPnPRenderer::OnSetVolume(PLT_ActionReference& action)
{
NPT_String volume;
NPT_CHECK_SEVERE(action->GetArgumentValue("DesiredVolume", volume));
- g_application.SetVolume(atoi((const char*)volume));
+ g_application.SetVolume((float)strtod((const char*)volume, NULL));
return NPT_SUCCESS;
}
diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
index b1a3416bea..f8db18bcac 100644
--- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
+++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
@@ -1188,7 +1188,7 @@ bool CPeripheralCecAdapterUpdateThread::SetInitialConfiguration(void)
// set amp present
m_adapter->SetAudioSystemConnected(true);
g_settings.m_bMute = false;
- g_settings.m_nVolumeLevel = VOLUME_MAXIMUM;
+ g_settings.m_fVolumeLevel = VOLUME_MAXIMUM;
}
m_adapter->m_bIsReady = true;
diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp
index 912cb4b0a9..e1263101c6 100644
--- a/xbmc/settings/Settings.cpp
+++ b/xbmc/settings/Settings.cpp
@@ -93,7 +93,7 @@ void CSettings::Initialize()
m_bAddonNotifications = true;
m_bAddonForeignFilter = false;
- m_nVolumeLevel = 0;
+ m_fVolumeLevel = 1.0f;
m_bMute = false;
m_fZoomAmount = 1.0f;
m_fPixelRatio = 1.0f;
@@ -722,7 +722,7 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile)
if (pElement)
{
XMLUtils::GetBoolean(pElement, "mute", m_bMute);
- GetInteger(pElement, "volumelevel", m_nVolumeLevel, VOLUME_MAXIMUM, VOLUME_MINIMUM, VOLUME_MAXIMUM);
+ GetFloat(pElement, "fvolumelevel", m_fVolumeLevel, VOLUME_MAXIMUM, VOLUME_MINIMUM, VOLUME_MAXIMUM);
}
LoadCalibration(pRootElement, strSettingsFile);
@@ -899,7 +899,7 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo
pNode = pRoot->InsertEndChild(volumeNode);
if (!pNode) return false;
XMLUtils::SetBoolean(pNode, "mute", m_bMute);
- XMLUtils::SetInt(pNode, "volumelevel", m_nVolumeLevel);
+ XMLUtils::SetFloat(pNode, "fvolumelevel", m_fVolumeLevel);
SaveCalibration(pRoot);
diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h
index 5b3d64bbd6..38c168e185 100644
--- a/xbmc/settings/Settings.h
+++ b/xbmc/settings/Settings.h
@@ -60,8 +60,10 @@
#define CACHE_VIDEO 1
#define CACHE_VOB 2
-#define VOLUME_MINIMUM -6000 // -60dB
-#define VOLUME_MAXIMUM 0 // 0dB
+#define VOLUME_MINIMUM 0.0f // -60dB
+#define VOLUME_MAXIMUM 1.0f // 0dB
+#define VOLUME_DYNAMIC_RANGE 90.0f // 60dB
+#define VOLUME_CONTROL_STEPS 90 // 90 steps
#define VOLUME_DRC_MINIMUM 0 // 0dB
#define VOLUME_DRC_MAXIMUM 6000 // 60dB
@@ -218,7 +220,7 @@ public:
int m_HttpApiBroadcastPort;
int m_HttpApiBroadcastLevel;
- int m_nVolumeLevel; // measured in milliBels -60dB -> 0dB range.
+ float m_fVolumeLevel; // float 0.0 - 1.0 range
bool m_bMute;
int m_iSystemTimeTotalUp; // Uptime in minutes!
diff --git a/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp b/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp
index 66eee83ead..3d707a7d88 100644
--- a/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp
+++ b/xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp
@@ -75,8 +75,8 @@ void CGUIDialogAudioSubtitleSettings::CreateSettings()
// clear out any old settings
m_settings.clear();
// create our settings
- m_volume = g_settings.m_nVolumeLevel * 0.01f;
- AddSlider(AUDIO_SETTINGS_VOLUME, 13376, &m_volume, VOLUME_MINIMUM * 0.01f, (VOLUME_MAXIMUM - VOLUME_MINIMUM) * 0.0001f, VOLUME_MAXIMUM * 0.01f, FormatDecibel, false);
+ m_volume = g_settings.m_fVolumeLevel;
+ AddSlider(AUDIO_SETTINGS_VOLUME, 13376, &m_volume, VOLUME_MINIMUM, VOLUME_MAXIMUM / 100.0f, VOLUME_MAXIMUM, FormatDecibel, false);
AddSlider(AUDIO_SETTINGS_VOLUME_AMPLIFICATION, 660, &g_settings.m_currentVideoSettings.m_VolumeAmplification, VOLUME_DRC_MINIMUM * 0.01f, (VOLUME_DRC_MAXIMUM - VOLUME_DRC_MINIMUM) / 6000.0f, VOLUME_DRC_MAXIMUM * 0.01f, FormatDecibel, false);
if (g_application.m_pPlayer && g_application.m_pPlayer->IsPassthrough())
{
@@ -214,8 +214,8 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting)
// check and update anything that needs it
if (setting.id == AUDIO_SETTINGS_VOLUME)
{
- g_settings.m_nVolumeLevel = (long)(m_volume * 100.0f);
- g_application.SetVolume(int(((float)(g_settings.m_nVolumeLevel - VOLUME_MINIMUM)) / (VOLUME_MAXIMUM - VOLUME_MINIMUM)*100.0f + 0.5f));
+ g_settings.m_fVolumeLevel = m_volume;
+ g_application.SetVolume(m_volume, false);//false - value is not in percent
}
else if (setting.id == AUDIO_SETTINGS_VOLUME_AMPLIFICATION)
{
@@ -352,7 +352,7 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting)
void CGUIDialogAudioSubtitleSettings::FrameMove()
{
- m_volume = g_settings.m_nVolumeLevel * 0.01f;
+ m_volume = g_settings.m_fVolumeLevel;
UpdateSetting(AUDIO_SETTINGS_VOLUME);
if (g_application.m_pPlayer)
{