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:
Jérôme Duval
2017-07-24 11:59:05 +02:00
parent 13dbf47109
commit dbad909b4e
3 changed files with 27 additions and 7 deletions
+3
View File
@@ -72,6 +72,9 @@ public:
status_t GetStreamMetaData(int32 stream, status_t GetStreamMetaData(int32 stream,
BMessage* _data) const; BMessage* _data) const;
void StopProcessing();
private: private:
void _Init(BDataIO* source, int32 flags); void _Init(BDataIO* source, int32 flags);
+18 -7
View File
@@ -147,13 +147,8 @@ MediaExtractor::~MediaExtractor()
{ {
CALLED(); CALLED();
#if !DISABLE_CHUNK_CACHE // stop the extractor thread, if still running
// terminate extractor thread StopProcessing();
delete_sem(fExtractorWaitSem);
status_t status;
wait_for_thread(fExtractorThread, &status);
#endif
// free all stream cookies // free all stream cookies
// and chunk caches // 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 void
MediaExtractor::_RecycleLastChunk(stream_info& info) MediaExtractor::_RecycleLastChunk(stream_info& info)
{ {
+6
View File
@@ -471,6 +471,12 @@ BMediaFile::_UnInit()
free(fTrackList); free(fTrackList);
fTrackList = NULL; fTrackList = NULL;
fTrackNum = 0; fTrackNum = 0;
// Tells the extractor to stop its asynchronous processing
// before deleting its source
if (fExtractor != NULL)
fExtractor->StopProcessing();
if (fDeleteSource) { if (fDeleteSource) {
delete fSource; delete fSource;
fSource = NULL; fSource = NULL;