BMediaFile: fix MediaExtractor crash.
* stop the extractor processing before deleting the source. * crash happened in MediaPlayer FilePlaylistItem::_CalculateDuration(). * was a regression introduced in hrev50671. * fixes #13156.
This commit is contained in:
@@ -72,6 +72,9 @@ public:
|
||||
status_t GetStreamMetaData(int32 stream,
|
||||
BMessage* _data) const;
|
||||
|
||||
void StopProcessing();
|
||||
|
||||
|
||||
private:
|
||||
void _Init(BDataIO* source, int32 flags);
|
||||
|
||||
|
||||
@@ -147,13 +147,8 @@ MediaExtractor::~MediaExtractor()
|
||||
{
|
||||
CALLED();
|
||||
|
||||
#if !DISABLE_CHUNK_CACHE
|
||||
// terminate extractor thread
|
||||
delete_sem(fExtractorWaitSem);
|
||||
|
||||
status_t status;
|
||||
wait_for_thread(fExtractorThread, &status);
|
||||
#endif
|
||||
// stop the extractor thread, if still running
|
||||
StopProcessing();
|
||||
|
||||
// free all stream cookies
|
||||
// and chunk caches
|
||||
@@ -412,6 +407,22 @@ MediaExtractor::GetStreamMetaData(int32 stream, BMessage* _data) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MediaExtractor::StopProcessing()
|
||||
{
|
||||
#if !DISABLE_CHUNK_CACHE
|
||||
if (fExtractorWaitSem > -1) {
|
||||
// terminate extractor thread
|
||||
delete_sem(fExtractorWaitSem);
|
||||
fExtractorWaitSem = -1;
|
||||
|
||||
status_t status;
|
||||
wait_for_thread(fExtractorThread, &status);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MediaExtractor::_RecycleLastChunk(stream_info& info)
|
||||
{
|
||||
|
||||
@@ -471,6 +471,12 @@ BMediaFile::_UnInit()
|
||||
free(fTrackList);
|
||||
fTrackList = NULL;
|
||||
fTrackNum = 0;
|
||||
|
||||
// Tells the extractor to stop its asynchronous processing
|
||||
// before deleting its source
|
||||
if (fExtractor != NULL)
|
||||
fExtractor->StopProcessing();
|
||||
|
||||
if (fDeleteSource) {
|
||||
delete fSource;
|
||||
fSource = NULL;
|
||||
|
||||
Reference in New Issue
Block a user