Skip to content

Commit

Permalink
AESinkPULSE: Make CacheTotal dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta authored and fritsch committed Nov 12, 2019
1 parent b7adfc6 commit d0c9c0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ CAESinkPULSE::CAESinkPULSE()
m_BytesPerSecond = 0;
m_BufferSize = 0;
m_Channels = 0;
m_maxLatency = 0.0;
m_Stream = NULL;
m_Context = NULL;
m_IsStreamPaused = false;
Expand All @@ -746,6 +747,7 @@ bool CAESinkPULSE::Initialize(AEAudioFormat &format, std::string &device)
m_BytesPerSecond = 0;
m_BufferSize = 0;
m_Channels = 0;
m_maxLatency = 0.0;
m_Stream = NULL;
m_Context = NULL;
m_periodSize = 0;
Expand Down Expand Up @@ -989,6 +991,7 @@ bool CAESinkPULSE::Initialize(AEAudioFormat &format, std::string &device)
m_periodSize = a->minreq;

format.m_frames = packetSize / frameSize;
m_maxLatency = static_cast<double>(m_BufferSize) / m_BytesPerSecond;
}

{
Expand Down Expand Up @@ -1029,6 +1032,7 @@ void CAESinkPULSE::Deinitialize()
m_passthrough = false;
m_periodSize = 0;
m_requestedBytes = 0;
m_maxLatency = 0.0;

if (m_Stream)
Drain();
Expand Down Expand Up @@ -1076,13 +1080,17 @@ void CAESinkPULSE::GetDelay(AEDelayStatus& status)
if (pa_stream_get_latency(m_Stream, &r_usec, &negative) < 0)
r_usec = 0;

double delay = r_usec / 1000000.0;
if (delay > m_maxLatency)
m_maxLatency = delay;

pa_threaded_mainloop_unlock(m_MainLoop);
status.SetDelay(r_usec / 1000000.0);
status.SetDelay(delay);
}

double CAESinkPULSE::GetCacheTotal()
{
return (float)m_BufferSize / (float)m_BytesPerSecond;
return m_maxLatency;
}

unsigned int CAESinkPULSE::AddPackets(uint8_t **data, unsigned int frames, unsigned int offset)
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/AudioEngine/Sinks/AESinkPULSE.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class CAESinkPULSE : public IAESink
unsigned int m_BytesPerSecond;
unsigned int m_BufferSize;
unsigned int m_Channels;
double m_maxLatency;

pa_stream *m_Stream;
pa_cvolume m_Volume;
Expand Down

0 comments on commit d0c9c0a

Please sign in to comment.