Skip to content
This repository
Browse code

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

…d in players
  • Loading branch information...
commit 78a424d3d6c98542cadf867c3e550c047831a1b3 1 parent d76a9af
authored July 07, 2012
2  xbmc/cores/AudioEngine/Engines/SoftAE/SoftAE.cpp
@@ -809,7 +809,7 @@ double CSoftAE::GetCacheTime()
809 809
   CSharedLock sinkLock(m_sinkLock);
810 810
 
811 811
   double time;
812  
-  time  = (double)m_buffer.Free() * m_sinkFormatFrameSizeMul * m_sinkFormatSampleRateMul;
  812
+  time  = (double)m_buffer.Used() * m_sinkFormatFrameSizeMul * m_sinkFormatSampleRateMul;
813 813
   time += m_sink->GetCacheTime();
814 814
 
815 815
   return time;
4  xbmc/cores/AudioEngine/Engines/SoftAE/SoftAEStream.cpp
@@ -489,8 +489,8 @@ double CSoftAEStream::GetCacheTime()
489 489
     return 0.0;
490 490
 
491 491
   double time;
492  
-  time  = (double)(m_inputBuffer.Free() / m_format.m_frameSize) / (double)m_format.m_sampleRate;
493  
-  time += (double)(m_waterLevel - m_refillBuffer)               / (double)AE.GetSampleRate();
  492
+  time  = (double)(m_inputBuffer.Used() / m_format.m_frameSize) / (double)m_format.m_sampleRate;
  493
+  time += (double)(m_waterLevel - m_framesBuffered)             / (double)AE.GetSampleRate();
494 494
   time += AE.GetCacheTime();
495 495
   return time;
496 496
 }
10  xbmc/cores/AudioEngine/Interfaces/AESink.h
@@ -53,22 +53,24 @@ class IAESink
53 53
   virtual bool IsCompatible(const AEAudioFormat format, const std::string device) = 0;
54 54
 
55 55
   /*
56  
-    This method must return the delay in seconds till new data will be sent out
  56
+    This method returns the time in seconds that it will take
  57
+    for the next added packet to be heard from the speakers.
57 58
   */
58 59
   virtual double GetDelay() = 0;
59 60
 
60 61
   /*
61  
-    This method returns the time in seconds till the sink's cache is full
  62
+    This method returns the time in seconds that it will take
  63
+    to underrun the cache if no sample is added.
62 64
   */
63 65
   virtual double GetCacheTime() = 0;
64 66
 
65 67
   /*
66  
-    This method returns the total length of the cache in seconds
  68
+    This method returns the total time in seconds of the cache.
67 69
   */
68 70
   virtual double GetCacheTotal() = 0;
69 71
 
70 72
   /*
71  
-    Adds packets to be sent out, must block after at-least one block is being rendered
  73
+    Adds packets to be sent out, this routine MUST block or sleep.
72 74
   */
73 75
   virtual unsigned int AddPackets(uint8_t *data, unsigned int frames) = 0;
74 76
 
14  xbmc/cores/AudioEngine/Interfaces/AEStream.h
@@ -59,8 +59,9 @@ class IAEStream
59 59
   virtual unsigned int AddData(void *data, unsigned int size) = 0;
60 60
 
61 61
   /**
62  
-   * Returns how long until new data will be played
63  
-   * @return The delay in seconds
  62
+   * Returns the time in seconds that it will take
  63
+   * for the next added packet to be heard from the speakers.
  64
+   * @return seconds
64 65
    */
65 66
   virtual double GetDelay() = 0;
66 67
 
@@ -71,14 +72,15 @@ class IAEStream
71 72
   virtual bool IsBuffering() = 0;
72 73
 
73 74
   /**
74  
-   * Returns how long until playback will start
75  
-   * @return The delay in seconds
  75
+   * Returns the time in seconds that it will take
  76
+   * to underrun the cache if no sample is added.
  77
+   * @return seconds
76 78
    */
77 79
   virtual double GetCacheTime() = 0;
78 80
 
79 81
   /**
80  
-   * Returns the total length of the cache before playback will start
81  
-   * @return The delay in seconds
  82
+   * Returns the total time in seconds of the cache
  83
+   * @return seconds
82 84
    */
83 85
   virtual double GetCacheTotal() = 0;
84 86
 
27  xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp
@@ -332,19 +332,7 @@ bool CAESinkWASAPI::IsCompatible(const AEAudioFormat format, const std::string d
332 332
 
333 333
 double CAESinkWASAPI::GetDelay()
334 334
 {
335  
-  HRESULT hr;
336  
-  if (!m_initialized)
337  
-    return 0.0;
338  
-
339  
-  hr = m_pAudioClient->GetBufferSize(&m_uiBufferLen);
340  
-  if (FAILED(hr))
341  
-  {
342  
-    #ifdef _DEBUG
343  
-    CLog::Log(LOGERROR, __FUNCTION__": GetBufferSize Failed : %s", WASAPIErrToStr(hr));
344  
-    #endif
345  
-    return 0.0;
346  
-  }
347  
-  return (double)m_uiBufferLen / (double)m_format.m_sampleRate;
  335
+  return GetCacheTime();
348 336
 }
349 337
 
350 338
 double CAESinkWASAPI::GetCacheTime()
@@ -352,11 +340,14 @@ double CAESinkWASAPI::GetCacheTime()
352 340
   if (!m_initialized)
353 341
     return 0.0;
354 342
 
355  
-  REFERENCE_TIME hnsLatency;
356  
-  HRESULT hr = m_pAudioClient->GetStreamLatency(&hnsLatency);
357  
-
358  
-  /** returns buffer duration in seconds */
359  
-  return hnsLatency / 10.0;
  343
+  unsigned int numPaddingFrames;
  344
+  HRESULT hr = m_pAudioClient->GetCurrentPadding(&numPaddingFrames);
  345
+  if (FAILED(hr))
  346
+  {
  347
+    CLog::Log(LOGERROR, __FUNCTION__": GetCurrentPadding Failed : %s", WASAPIErrToStr(hr));
  348
+    return 0.0;
  349
+  }
  350
+  return (double)numPaddingFrames / (double)m_format.m_sampleRate;
360 351
 }
361 352
 
362 353
 double CAESinkWASAPI::GetCacheTotal()

0 notes on commit 78a424d

arnova

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

davilla

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.

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