Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change AE definition and usage of GetCacheTime to match how it is use…

…d in players
  • Loading branch information...
commit 78a424d3d6c98542cadf867c3e550c047831a1b3 1 parent d76a9af
@davilla davilla authored
View
2  xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp
@@ -809,7 +809,7 @@ double CSoftAE::GetCacheTime()
CSharedLock sinkLock(m_sinkLock);
double time;
- time = (double)m_buffer.Free() * m_sinkFormatFrameSizeMul * m_sinkFormatSampleRateMul;
+ time = (double)m_buffer.Used() * m_sinkFormatFrameSizeMul * m_sinkFormatSampleRateMul;
@arnova Collaborator
arnova added a note

Since this seems to change the behavior of GetCacheTime() shouldn't DVDPlayer & PAPlayer be updated accordingly?

@davilla
davilla added a note

DVDPlayer & PAPlayer use this def of GetCacheTime already, that was the whole point of changing AE, it did not match the usage in players which has never changed.

@elupus Collaborator
elupus added a note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
time += m_sink->GetCacheTime();
return time;
View
4 xbmc/cores/AudioEngine/Engines/SoftAE/SoftAEStream.cpp
@@ -489,8 +489,8 @@ double CSoftAEStream::GetCacheTime()
return 0.0;
double time;
- time = (double)(m_inputBuffer.Free() / m_format.m_frameSize) / (double)m_format.m_sampleRate;
- time += (double)(m_waterLevel - m_refillBuffer) / (double)AE.GetSampleRate();
+ time = (double)(m_inputBuffer.Used() / m_format.m_frameSize) / (double)m_format.m_sampleRate;
+ time += (double)(m_waterLevel - m_framesBuffered) / (double)AE.GetSampleRate();
time += AE.GetCacheTime();
return time;
}
View
10 xbmc/cores/AudioEngine/Interfaces/AESink.h
@@ -53,22 +53,24 @@ class IAESink
virtual bool IsCompatible(const AEAudioFormat format, const std::string device) = 0;
/*
- This method must return the delay in seconds till new data will be sent out
+ This method returns the time in seconds that it will take
+ for the next added packet to be heard from the speakers.
*/
virtual double GetDelay() = 0;
/*
- This method returns the time in seconds till the sink's cache is full
+ This method returns the time in seconds that it will take
+ to underrun the cache if no sample is added.
*/
virtual double GetCacheTime() = 0;
/*
- This method returns the total length of the cache in seconds
+ This method returns the total time in seconds of the cache.
*/
virtual double GetCacheTotal() = 0;
/*
- Adds packets to be sent out, must block after at-least one block is being rendered
+ Adds packets to be sent out, this routine MUST block or sleep.
*/
virtual unsigned int AddPackets(uint8_t *data, unsigned int frames) = 0;
View
14 xbmc/cores/AudioEngine/Interfaces/AEStream.h
@@ -59,8 +59,9 @@ class IAEStream
virtual unsigned int AddData(void *data, unsigned int size) = 0;
/**
- * Returns how long until new data will be played
- * @return The delay in seconds
+ * Returns the time in seconds that it will take
+ * for the next added packet to be heard from the speakers.
+ * @return seconds
*/
virtual double GetDelay() = 0;
@@ -71,14 +72,15 @@ class IAEStream
virtual bool IsBuffering() = 0;
/**
- * Returns how long until playback will start
- * @return The delay in seconds
+ * Returns the time in seconds that it will take
+ * to underrun the cache if no sample is added.
+ * @return seconds
*/
virtual double GetCacheTime() = 0;
/**
- * Returns the total length of the cache before playback will start
- * @return The delay in seconds
+ * Returns the total time in seconds of the cache
+ * @return seconds
*/
virtual double GetCacheTotal() = 0;
View
27 xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp
@@ -332,19 +332,7 @@ bool CAESinkWASAPI::IsCompatible(const AEAudioFormat format, const std::string d
double CAESinkWASAPI::GetDelay()
{
- HRESULT hr;
- if (!m_initialized)
- return 0.0;
-
- hr = m_pAudioClient->GetBufferSize(&m_uiBufferLen);
- if (FAILED(hr))
- {
- #ifdef _DEBUG
- CLog::Log(LOGERROR, __FUNCTION__": GetBufferSize Failed : %s", WASAPIErrToStr(hr));
- #endif
- return 0.0;
- }
- return (double)m_uiBufferLen / (double)m_format.m_sampleRate;
+ return GetCacheTime();
}
double CAESinkWASAPI::GetCacheTime()
@@ -352,11 +340,14 @@ double CAESinkWASAPI::GetCacheTime()
if (!m_initialized)
return 0.0;
- REFERENCE_TIME hnsLatency;
- HRESULT hr = m_pAudioClient->GetStreamLatency(&hnsLatency);
-
- /** returns buffer duration in seconds */
- return hnsLatency / 10.0;
+ unsigned int numPaddingFrames;
+ HRESULT hr = m_pAudioClient->GetCurrentPadding(&numPaddingFrames);
+ if (FAILED(hr))
+ {
+ CLog::Log(LOGERROR, __FUNCTION__": GetCurrentPadding Failed : %s", WASAPIErrToStr(hr));
+ return 0.0;
+ }
+ return (double)numPaddingFrames / (double)m_format.m_sampleRate;
}
double CAESinkWASAPI::GetCacheTotal()
Please sign in to comment.
Something went wrong with that request. Please try again.