Skip to content

Commit

Permalink
Merge pull request #3148 from FernetMenta/aepause
Browse files Browse the repository at this point in the history
ActiveAE: flush engine on pause stream if only a single stream is playin...
  • Loading branch information
FernetMenta committed Aug 26, 2013
2 parents e4c9e8c + e6e0545 commit 5be7680
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
47 changes: 27 additions & 20 deletions xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ void CActiveAE::StateMachine(int signal, Protocol *port, Message *msg)
CActiveAEStream *stream;
stream = *(CActiveAEStream**)msg->data;
stream->m_paused = true;
if (m_streams.size() == 1)
FlushEngine();
return;
case CActiveAEControlProtocol::RESUMESTREAM:
stream = *(CActiveAEStream**)msg->data;
Expand Down Expand Up @@ -1110,31 +1112,36 @@ void CActiveAE::SFlushStream(CActiveAEStream *stream)
// flush the engine if we only have a single stream
if (m_streams.size() == 1)
{
if (m_sinkBuffers)
m_sinkBuffers->Flush();
if (m_vizBuffers)
m_vizBuffers->Flush();
FlushEngine();
}
}

// send message to sink
Message *reply;
if (m_sink.m_controlPort.SendOutMessageSync(CSinkControlProtocol::FLUSH,
&reply, 2000))
{
bool success = reply->signal == CSinkControlProtocol::ACC ? true : false;
if (!success)
{
CLog::Log(LOGERROR, "ActiveAE::%s - returned error on flush", __FUNCTION__);
m_extError = true;
}
reply->Release();
}
else
void CActiveAE::FlushEngine()
{
if (m_sinkBuffers)
m_sinkBuffers->Flush();
if (m_vizBuffers)
m_vizBuffers->Flush();

// send message to sink
Message *reply;
if (m_sink.m_controlPort.SendOutMessageSync(CSinkControlProtocol::FLUSH,
&reply, 2000))
{
bool success = reply->signal == CSinkControlProtocol::ACC ? true : false;
if (!success)
{
CLog::Log(LOGERROR, "ActiveAE::%s - failed to flush", __FUNCTION__);
CLog::Log(LOGERROR, "ActiveAE::%s - returned error on flush", __FUNCTION__);
m_extError = true;
}
m_stats.Reset(m_sinkFormat.m_sampleRate);
reply->Release();
}
else
{
CLog::Log(LOGERROR, "ActiveAE::%s - failed to flush", __FUNCTION__);
m_extError = true;
}
m_stats.Reset(m_sinkFormat.m_sampleRate);
}

void CActiveAE::ClearDiscardedBuffers()
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class CActiveAE : public IAE, private CThread
CActiveAEStream* CreateStream(MsgStreamNew *streamMsg);
void DiscardStream(CActiveAEStream *stream);
void SFlushStream(CActiveAEStream *stream);
void FlushEngine();
void ClearDiscardedBuffers();
void SStopSound(CActiveAESound *sound);
void DiscardSound(CActiveAESound *sound);
Expand Down

0 comments on commit 5be7680

Please sign in to comment.