From 0883d7de4991ee3498a903baadb2a8d79f20d706 Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Sat, 19 Oct 2024 09:15:18 +0200 Subject: [cores] CInputStreamPVRBase: Optimize: Only close the stream if it is open. Only open the stream if it is not open. --- .../VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp | 13 +++++++++---- xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp index 1f1622318d..7b8be41763 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp @@ -40,8 +40,9 @@ bool CInputStreamPVRBase::IsEOF() bool CInputStreamPVRBase::Open() { - if (CDVDInputStream::Open() && OpenPVRStream()) + if (!m_isOpen && CDVDInputStream::Open() && OpenPVRStream()) { + m_isOpen = true; m_eof = false; m_StreamProps->iStreamCount = 0; return true; @@ -54,9 +55,13 @@ bool CInputStreamPVRBase::Open() void CInputStreamPVRBase::Close() { - ClosePVRStream(); - CDVDInputStream::Close(); - m_eof = true; + if (m_isOpen) + { + ClosePVRStream(); + CDVDInputStream::Close(); + m_eof = true; + m_isOpen = false; + } } int CInputStreamPVRBase::Read(uint8_t* buf, int buf_size) diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.h b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.h index 67b5d32d1c..7a2d336512 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.h +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.h @@ -80,4 +80,5 @@ protected: std::shared_ptr m_StreamProps; std::map> m_streamMap; std::shared_ptr m_client; + bool m_isOpen{false}; }; -- cgit v1.2.3