Skip to content
Browse files

Merge pull request #4111 from FernetMenta/ticket

paplayer: fix hang in flac codec if read fails, fixes ticket 12056
  • Loading branch information...
2 parents fdc0421 + 78b8730 commit aea43f824bc5be947af6443f8967c0b906e1a1cd @t-nelson t-nelson committed Jan 30, 2014
Showing with 16 additions and 12 deletions.
  1. +4 −1 xbmc/cores/paplayer/FLACcodec.cpp
  2. +12 −11 xbmc/cores/paplayer/PAPlayer.cpp
View
5 xbmc/cores/paplayer/FLACcodec.cpp
@@ -208,7 +208,10 @@ FLAC__StreamDecoderReadStatus FLACCodec::DecoderReadCallback(const FLAC__StreamD
*bytes=pThis->m_file.Read(buffer, *bytes);
- return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
+ if (*bytes==0)
+ return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
+ else
+ return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}
FLAC__StreamDecoderSeekStatus FLACCodec::DecoderSeekCallback(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
View
23 xbmc/cores/paplayer/PAPlayer.cpp
@@ -520,6 +520,18 @@ bool PAPlayer::CloseFile(bool reopen)
/* wait for the thread to terminate */
StopThread(true);//true - wait for end of thread
+
+ // wait for any pending jobs to complete
+ {
+ CSharedLock lock(m_streamsLock);
+ while (m_jobCounter > 0)
+ {
+ lock.Leave();
+ m_jobEvent.WaitMSec(100);
+ lock.Enter();
+ }
+ }
+
return true;
}
@@ -553,17 +565,6 @@ void PAPlayer::Process()
GetTimeInternal(); //update for GUI
}
- // wait for any pending jobs to complete
- {
- CSharedLock lock(m_streamsLock);
- while (m_jobCounter > 0)
- {
- lock.Leave();
- m_jobEvent.WaitMSec(100);
- lock.Enter();
- }
- }
-
if(m_isFinished && !m_bStop)
m_callback.OnPlayBackEnded();
else

0 comments on commit aea43f8

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