Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] Memory leak of the CLibcdio. Now using a boost::shared_ptr to t…

…rack.
  • Loading branch information...
commit c6037cd1b9186309426fb02583147afc3a58ed67 1 parent 7826a61
Jim Carroll authored
View
2  xbmc/filesystem/CDDAFile.h
@@ -53,7 +53,7 @@ class CFileCDDA : public IFile
lsn_t m_lsnStart; // Start of m_iTrack in logical sector number
lsn_t m_lsnCurrent; // Position inside the track in logical sector number
lsn_t m_lsnEnd; // End of m_iTrack in logical sector number
- MEDIA_DETECT::CLibcdio* m_cdio;
+ boost::shared_ptr<MEDIA_DETECT::CLibcdio> m_cdio;
};
}
View
3  xbmc/storage/DetectDVDType.h
@@ -36,6 +36,7 @@
#include "threads/Thread.h"
#include "utils/StdString.h"
+#include "boost/shared_ptr.hpp"
namespace MEDIA_DETECT
{
@@ -88,7 +89,7 @@ class CDetectDVDMedia : public CThread
static CStdString m_diskLabel;
static CStdString m_diskPath;
- CLibcdio* m_cdio;
+ boost::shared_ptr<CLibcdio> m_cdio;
};
}
#endif
View
2  xbmc/storage/MediaManager.cpp
@@ -638,7 +638,7 @@ void CMediaManager::EjectTray( const bool bEject, const char cDriveLetter )
#ifdef TARGET_WINDOWS
CWIN32Util::EjectTray(cDriveLetter);
#else
- CLibcdio *c_cdio = CLibcdio::GetInstance();
+ boost::shared_ptr<CLibcdio> c_cdio = CLibcdio::GetInstance();
char* dvdDevice = c_cdio->GetDeviceFileName();
m_isoReader.Reset();
int nRetries=3;
View
17 xbmc/storage/cdioSupport.cpp
@@ -36,8 +36,7 @@
using namespace MEDIA_DETECT;
-CLibcdio* CLibcdio::m_pInstance = NULL;
-char *CLibcdio::s_defaultDevice = NULL;
+boost::shared_ptr<CLibcdio> CLibcdio::m_pInstance;
/* Some interesting sector numbers stored in the above buffer. */
#define ISO_SUPERBLOCK_SECTOR 16 /* buffer[0] */
@@ -102,7 +101,7 @@ xbox_cdio_log_handler (cdio_log_level_t level, const char message[])
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
-CLibcdio::CLibcdio()
+CLibcdio::CLibcdio(): s_defaultDevice(NULL)
{
cdio_log_set_handler( xbox_cdio_log_handler );
}
@@ -113,20 +112,16 @@ CLibcdio::~CLibcdio()
s_defaultDevice = NULL;
}
-void CLibcdio::RemoveInstance()
+void CLibcdio::ReleaseInstance()
{
- if (m_pInstance)
- {
- delete m_pInstance;
- m_pInstance = NULL;
- }
+ m_pInstance.reset();
}
-CLibcdio* CLibcdio::GetInstance()
+boost::shared_ptr<CLibcdio> CLibcdio::GetInstance()
{
if (!m_pInstance)
{
- m_pInstance = new CLibcdio();
+ m_pInstance = boost::shared_ptr<CLibcdio>(new CLibcdio());
}
return m_pInstance;
}
View
11 xbmc/storage/cdioSupport.h
@@ -37,6 +37,7 @@
#include <cdio/cdio.h>
#include "threads/CriticalSection.h"
#include "utils/StdString.h"
+#include "boost/shared_ptr.hpp"
#include <map>
namespace MEDIA_DETECT
@@ -257,8 +258,8 @@ class CLibcdio : public CCriticalSection
public:
virtual ~CLibcdio();
- static void RemoveInstance();
- static CLibcdio* GetInstance();
+ static void ReleaseInstance();
+ static boost::shared_ptr<CLibcdio> GetInstance();
// libcdio is not thread safe so these are wrappers to libcdio routines
CdIo_t* cdio_open(const char *psz_source, driver_id_t driver_id);
@@ -275,9 +276,9 @@ class CLibcdio : public CCriticalSection
char* GetDeviceFileName();
private:
- static char* s_defaultDevice;
+ char* s_defaultDevice;
CCriticalSection m_critSection;
- static CLibcdio* m_pInstance;
+ static boost::shared_ptr<CLibcdio> m_pInstance;
};
class CCdIoSupport
@@ -340,7 +341,7 @@ class CCdIoSupport
int m_nFirstAudio; /* # of first audio track */
int m_nNumAudio; /* # of audio tracks */
- CLibcdio* m_cdio;
+ boost::shared_ptr<CLibcdio> m_cdio;
};
}
Please sign in to comment.
Something went wrong with that request. Please try again.