Fix NV12 crash issue when recreate camera object
This commit is contained in:
@@ -46,13 +46,19 @@ namespace ANSCENTER {
|
||||
Destroy();
|
||||
}
|
||||
void ANSMJPEGClient::Destroy() {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
if (_playerClient) {
|
||||
if (_isPlaying) {
|
||||
_playerClient->stop();
|
||||
_isPlaying = false;
|
||||
decltype(_playerClient) clientToClose;
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
if (_playerClient) {
|
||||
if (_isPlaying) {
|
||||
_playerClient->stop();
|
||||
_isPlaying = false;
|
||||
}
|
||||
}
|
||||
_playerClient->close();
|
||||
clientToClose = std::move(_playerClient);
|
||||
}
|
||||
if (clientToClose) {
|
||||
clientToClose->close();
|
||||
}
|
||||
}
|
||||
static void VerifyGlobalANSMJPEGLicense(const std::string& licenseKey) {
|
||||
@@ -129,8 +135,12 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
bool ANSMJPEGClient::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();
|
||||
_isPlaying = _playerClient->play();
|
||||
return _isPlaying;
|
||||
@@ -143,10 +153,16 @@ namespace ANSCENTER {
|
||||
return _isPlaying;
|
||||
}
|
||||
bool ANSMJPEGClient::Stop() {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
if (_isPlaying) {
|
||||
_playerClient->stop();
|
||||
_isPlaying = false;
|
||||
decltype(_playerClient.get()) player = nullptr;
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
if (_isPlaying) {
|
||||
_isPlaying = false;
|
||||
player = _playerClient.get();
|
||||
}
|
||||
}
|
||||
if (player) {
|
||||
player->stop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user