Fix NV12 crash issue when recreate camera object
This commit is contained in:
@@ -39,22 +39,26 @@ namespace ANSCENTER {
|
||||
catch (...) {}
|
||||
}
|
||||
void ANSFILEPLAYER::Destroy() {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
try {
|
||||
_url = "";
|
||||
_imageRotateDeg = 0;
|
||||
_isPlaying = false;
|
||||
_lastJpegImage = "";
|
||||
_pLastFrame.release();
|
||||
if (_playerClient) {
|
||||
_playerClient->close();
|
||||
decltype(_playerClient) clientToClose;
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
try {
|
||||
_url = "";
|
||||
_imageRotateDeg = 0;
|
||||
_isPlaying = false;
|
||||
_lastJpegImage = "";
|
||||
_pLastFrame.release();
|
||||
clientToClose = std::move(_playerClient);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
_logger.LogError("ANSFILEPLAYER::Destroy. Exception:", e.what(), __FILE__, __LINE__);
|
||||
}
|
||||
catch (...) {
|
||||
_logger.LogError("ANSFILEPLAYER::Destroy.", "Unknown exception", __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
_logger.LogError("ANSFILEPLAYER::Destroy. Exception:", e.what(), __FILE__, __LINE__);
|
||||
}
|
||||
catch (...) {
|
||||
_logger.LogError("ANSFILEPLAYER::Destroy.", "Unknown exception", __FILE__, __LINE__);
|
||||
if (clientToClose) {
|
||||
clientToClose->close();
|
||||
}
|
||||
}
|
||||
void ANSFILEPLAYER::CheckLicense() {
|
||||
@@ -94,8 +98,12 @@ namespace ANSCENTER {
|
||||
return _playerClient->open(_url);
|
||||
}
|
||||
bool ANSFILEPLAYER::Reconnect() {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
_isPlaying = false;
|
||||
}
|
||||
_playerClient->close();
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
Setup();
|
||||
return Start();
|
||||
}
|
||||
@@ -105,14 +113,17 @@ namespace ANSCENTER {
|
||||
return _isPlaying;
|
||||
}
|
||||
bool ANSFILEPLAYER::Stop() {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
if (_playerClient->pause()) {
|
||||
decltype(_playerClient.get()) player = nullptr;
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
player = _playerClient.get();
|
||||
}
|
||||
if (player && player->pause()) {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
_isPlaying = false;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool ANSFILEPLAYER::IsPaused() {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
|
||||
Reference in New Issue
Block a user