try to fix segfault on open/close

Origin commit data
------------------
Branch: master
Commit: c1c2a5fc2c
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2019-08-01 (Thu, 01 Aug 2019)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
Jacek Jendrzej
2019-08-01 15:43:58 +02:00
committed by vanhofen
parent 13ac6ab00a
commit b8f7140215
2 changed files with 30 additions and 11 deletions

View File

@@ -24,6 +24,7 @@ static Context_t *player = NULL;
extern cAudio *audioDecoder;
extern cVideo *videoDecoder;
OpenThreads::Mutex cPlayback::mutex;
//Used by Fileplay
bool cPlayback::Open(playmode_t PlayMode)
@@ -50,9 +51,13 @@ bool cPlayback::Open(playmode_t PlayMode)
nPlaybackSpeed = 0;
init_jump = -1;
mutex.lock();
if (player)
{
free(player);
player = NULL;
}
mutex.unlock();
player = (Context_t *) malloc(sizeof(Context_t));
@@ -82,8 +87,10 @@ void cPlayback::Close(void)
hal_info("%s\n", __func__);
//Dagobert: movieplayer does not call stop, it calls close ;)
mutex.lock();
if(playing)
Stop();
mutex.unlock();
if (decoders_closed)
{
@@ -765,27 +772,37 @@ cPlayback::~cPlayback()
{
hal_info("%s\n", __func__);
mutex.lock();
if (player)
{
free(player);
player = NULL;
}
mutex.unlock();
}
void cPlayback::RequestAbort()
{
if (player && player->playback && player->playback->isPlaying)
if (player && player->playback)
{
hal_info("%s\n", __func__);
mutex.lock();
if (player && player->playback && player->playback->isPlaying)
{
Stop();
//player->playback->abortRequested = 1;//why ?
while (player->playback->isPlaying)
usleep(100000);
player->playback->abortRequested = 1;
}
else if(player->playback->isHttp && !player->playback->isPlaying &&!player->playback->abortRequested)
{
hal_info("%s\n", __func__);
player->playback->abortRequested = 1;
}
mutex.unlock();
while (player->playback->isPlaying)
usleep(100000);
}
}
bool cPlayback::IsPlaying()

View File

@@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <OpenThreads/Mutex>
typedef enum
{
@@ -17,6 +18,7 @@ class cPlayback
friend class CStreamInfo2;
private:
static OpenThreads::Mutex mutex;
bool enabled;
bool playing, first;
bool no_probe;