Skip to content

Commit

Permalink
changed: drain audio device then flush instead of adding silence
Browse files Browse the repository at this point in the history
This is a revert of adding silence in case of timeouts on input queue.
  • Loading branch information
elupus committed Nov 26, 2011
1 parent eac52fe commit 8649a2d
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
Expand Up @@ -386,18 +386,12 @@ int CDVDPlayerAudio::DecodeFrame(DVDAudioFrame &audioframe, bool bDropPacket)


CDVDMsg* pMsg; CDVDMsg* pMsg;
int priority = (m_speed == DVD_PLAYSPEED_PAUSE && m_started) ? 1 : 0; int priority = (m_speed == DVD_PLAYSPEED_PAUSE && m_started) ? 1 : 0;
int timeout;


double cached = m_dvdAudio.GetCacheTime(); int timeout;
if(cached > 0.0 && m_speed == DVD_PLAYSPEED_NORMAL) if(m_duration > 0)
{ timeout = (int)(1000 * (m_duration / DVD_TIME_BASE + m_dvdAudio.GetCacheTime()));
if(cached > 0.2)
timeout = (int)(1000 * (cached - 0.2));
else
timeout = 0; /* in a hurry, try to fill with something as soon as possible */
}
else else
timeout = 1000; /* if nothing cached, we can just as well wait for a while */ timeout = 1000;


// read next packet and return -1 on error // read next packet and return -1 on error
MsgQueueReturnCode ret = m_messageQueue.Get(&pMsg, timeout, priority); MsgQueueReturnCode ret = m_messageQueue.Get(&pMsg, timeout, priority);
Expand Down Expand Up @@ -556,9 +550,12 @@ void CDVDPlayerAudio::Process()
{ {
m_stalled = true; m_stalled = true;


// Add some silence to keep renderer from draining // Flush as the audio output may keep looping if we don't
if(m_speed == DVD_PLAYSPEED_NORMAL) if(m_speed == DVD_PLAYSPEED_NORMAL)
m_dvdAudio.AddSilence(0.5); {
m_dvdAudio.Drain();
m_dvdAudio.Flush();
}


continue; continue;
} }
Expand Down

4 comments on commit 8649a2d

@arnova
Copy link
Member

@arnova arnova commented on 8649a2d Nov 28, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we're not going to fix this in Windows's DirectSound renderer after all?

And are we keeping CDVDAudio::AddSilence() as an unused function for now?

@elupus
Copy link
Contributor

@elupus elupus commented on 8649a2d Nov 28, 2011 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elupus
Copy link
Contributor

@elupus elupus commented on 8649a2d Nov 28, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a look and it surly wasn't easy to fix. We'd need another thread to handle the under-run situation. I think the add silence approach technically is better. But i think the AE stuff will change that anyway (even if i think the AE branch is a bit of using a sledge hammer to hit a tiny nail)

@arnova
Copy link
Member

@arnova arnova commented on 8649a2d Jan 16, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elupus: FYI there's also still another related issue on Windows (I hardly ever use Windows but I noticed it at a friend's place, and reproduced it at home). When a movie finishes the audio also momentarily loops (probably due to a/v inter-delay) which sounds rather nasty. Maybe there's a quick fix for this too?

Please sign in to comment.