aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS. Davilla <davilla@4pi.com>2013-01-15 13:49:14 -0500
committerS. Davilla <davilla@4pi.com>2013-01-19 16:52:40 -0500
commitc2cd6ee3d2df6a055220b1c5cc750d8b8018d0c7 (patch)
treef2443876114b894b1bac5d343758707e6b8526b8
parent195b7651084e69d5f20c399fd478d42863e0c323 (diff)
[aml] fixed mute and volume control
-rw-r--r--xbmc/cores/amlplayer/AMLPlayer.cpp39
-rw-r--r--xbmc/cores/amlplayer/AMLPlayer.h2
2 files changed, 36 insertions, 5 deletions
diff --git a/xbmc/cores/amlplayer/AMLPlayer.cpp b/xbmc/cores/amlplayer/AMLPlayer.cpp
index 0aee9a901f..ebf8f1c75f 100644
--- a/xbmc/cores/amlplayer/AMLPlayer.cpp
+++ b/xbmc/cores/amlplayer/AMLPlayer.cpp
@@ -779,17 +779,34 @@ float CAMLPlayer::GetPercentage()
void CAMLPlayer::SetMute(bool bOnOff)
{
- // TODO: set mute
+ m_audio_mute = bOnOff;
+#if !defined(TARGET_ANDROID)
+ CSingleLock lock(m_aml_csection);
+ if (m_dll->check_pid_valid(m_pid))
+ {
+ if (m_audio_mute)
+ m_dll->audio_set_volume(m_pid, 0.0);
+ else
+ m_dll->audio_set_volume(m_pid, m_audio_volume);
+ }
+#endif
}
void CAMLPlayer::SetVolume(float volume)
{
- CLog::Log(LOGDEBUG, "CAMLPlayer::SetVolume(%f)", volume);
+ m_audio_volume = 0.0f;
+ if (volume > VOLUME_MINIMUM)
+ {
+ float dB = CAEUtil::PercentToGain(volume);
+ m_audio_volume = CAEUtil::GainToScale(dB);
+ }
+ if (m_audio_volume >= 0.99f)
+ m_audio_volume = 1.0f;
+
#if !defined(TARGET_ANDROID)
CSingleLock lock(m_aml_csection);
- // volume is a float percent from 0.0 to 1.0
- if (m_dll->check_pid_valid(m_pid))
- m_dll->audio_set_volume(m_pid, volume);
+ if (!m_audio_mute && m_dll->check_pid_valid(m_pid))
+ m_dll->audio_set_volume(m_pid, m_audio_volume);
#endif
}
@@ -1095,6 +1112,8 @@ void CAMLPlayer::SeekTime(__int64 seek_ms)
m_dll->player_timesearch(m_pid, (float)seek_ms/1000.0);
WaitForSearchOK(5000);
WaitForPlaying(5000);
+ // restore system volume setting.
+ SetVolume(m_audio_volume);
}
}
@@ -1445,6 +1464,9 @@ void CAMLPlayer::Process()
// get our initial status.
GetStatus();
+ // restore mute setting.
+ SetMute(g_settings.m_bMute);
+
// restore system volume setting.
SetVolume(g_settings.m_fVolumeLevel);
@@ -1820,8 +1842,15 @@ bool CAMLPlayer::WaitForSearchOK(int timeout_ms)
bool CAMLPlayer::WaitForPlaying(int timeout_ms)
{
+ // force the volume off in case we are starting muted
+ m_audio_mute = true;
while (!m_bAbortRequest && (timeout_ms > 0))
{
+#if !defined(TARGET_ANDROID)
+ // anoying that we have to hammer audio_set_volume
+ // but have to catch it before any audio comes out.
+ m_dll->audio_set_volume(m_pid, 0.0);
+#endif
player_status pstatus = (player_status)GetPlayerSerializedState();
if (m_log_level > 5)
CLog::Log(LOGDEBUG, "CAMLPlayer::WaitForPlaying: %s", m_dll->player_status2str(pstatus));
diff --git a/xbmc/cores/amlplayer/AMLPlayer.h b/xbmc/cores/amlplayer/AMLPlayer.h
index 39c8913286..2624b61efe 100644
--- a/xbmc/cores/amlplayer/AMLPlayer.h
+++ b/xbmc/cores/amlplayer/AMLPlayer.h
@@ -225,6 +225,8 @@ private:
int m_audio_delay;
bool m_audio_passthrough_ac3;
bool m_audio_passthrough_dts;
+ bool m_audio_mute;
+ float m_audio_volume;
int m_video_index;
int m_video_count;