Skip to content

Commit

Permalink
FIX: [AT] simplify blocking loop
Browse files Browse the repository at this point in the history
  • Loading branch information
koying committed Jun 20, 2017
1 parent 9d4f66b commit 8060200
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ unsigned int CAESinkAUDIOTRACK::AddPackets(uint8_t **data, unsigned int frames,
if (m_at_jni->getPlayState() != CJNIAudioTrack::PLAYSTATE_PLAYING)
m_at_jni->play();

bool retried = false;
int size_left = size;
while (written < size)
{
Expand All @@ -697,31 +696,9 @@ unsigned int CAESinkAUDIOTRACK::AddPackets(uint8_t **data, unsigned int frames,
// if we could not add any data - sleep a bit and retry
if (loop_written == 0)
{
if (!retried)
{
retried = true;
double sleep_time = 0;
if (m_passthrough && !m_wantsIECPassthrough)
{
sleep_time = m_format.m_streamInfo.GetDuration();
usleep(sleep_time * 1000);
}
else
{
sleep_time = (double) m_format.m_frames / m_sink_frameSize / 2.0 / (double) m_format.m_sampleRate * 1000;
usleep(sleep_time * 1000);
}
bool playing = m_at_jni->getPlayState() == CJNIAudioTrack::PLAYSTATE_PLAYING;
CLog::Log(LOGDEBUG, "Retried to write onto the sink - slept: %lf playing: %s", sleep_time, playing ? "yes" : "no");
continue;
}
else
{
CLog::Log(LOGDEBUG, "Repeatedly tried to write onto the sink - giving up");
break;
}
CLog::Log(LOGDEBUG, "AudioTrack: Could not write to sink (%d / %d)", size_left, size);
break;
}
retried = false; // at least one time there was more than zero data written
if (m_passthrough && !m_wantsIECPassthrough)
{
if (written == size)
Expand Down

0 comments on commit 8060200

Please sign in to comment.