Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1131 from davilla/fix-ae-getcachetime

change AE definition and usage of GetCacheTime to match how it is used in players
  • Loading branch information...
commit 8ac5a867c37764e736259aab6af889ab24a092eb 2 parents 0ed0f26 + 78a424d
@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;
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()

6 comments on commit 8ac5a86

@Memphiz
Owner

@davilla how sure are you that this wasapi change is not able to break AirTunes playback? (ending in freeze/deadlock). I don't have the stuff to reproduce - but at least a pointer to the important thread/post:

http://forum.xbmc.org/showthread.php?tid=136558&pid=1155539#pid1155539

@davilla
Collaborator

I'm not sure of anything with wasapi, it was acked in pull/req as what was needed.

@Memphiz
Owner

Well what is strange that GetDelay and GetCacheTime are equal now - which wasn't the case before. I don't know nothing about this windows crap. But if reverting this fixes AirTunes for Windows - i might do that...

@Memphiz
Owner

It also freezes on mp3 playback with paplayer and WASAPI as it seems

@Montellese
Owner

I can confirm that when using WASAPI mp3 playback freezes XBMC after a few seconds after starting playback. Using DirectSound does not result in any problems. Reverting this commit seems to get rid of the freeze with WASAPI. Unfortunately I can't test if it also solves AirTunes.

@Memphiz
Owner

I'm pretty sure it does. 0wing from the forum confirmed this already.

Please sign in to comment.
Something went wrong with that request. Please try again.