4 * Copyright (C) 2005-2013 Team XBMC
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
23 // CDetectDVDMedia - Thread running in the background to detect a CD change
26 // by Bobbin007 in 2003
35 #include "threads/CriticalSection.h"
37 #include "threads/Thread.h"
38 #include "utils/StdString.h"
39 #include "boost/shared_ptr.hpp"
41 namespace MEDIA_DETECT
46 class CDetectDVDMedia : public CThread
50 virtual ~CDetectDVDMedia();
52 virtual void OnStartup();
53 virtual void OnExit();
54 virtual void Process();
56 static void WaitMediaReady();
57 static bool IsDiscInDrive();
58 static int DriveReady();
59 static CCdInfo* GetCdInfo();
60 static CEvent m_evAutorun;
62 static const CStdString &GetDVDLabel();
63 static const CStdString &GetDVDPath();
65 static void UpdateState();
71 void DetectMediaType();
72 void SetNewDVDShareUrl( const CStdString& strNewUrl, bool bCDDA, const CStdString& strDiscLabel );
75 static CCriticalSection m_muReadingMedia;
77 static int m_DriveState;
78 static time_t m_LastPoll;
79 static CDetectDVDMedia* m_pInstance;
81 static CCdInfo* m_pCdInfo;
87 DWORD m_dwLastTrayState;
89 static CStdString m_diskLabel;
90 static CStdString m_diskPath;
92 boost::shared_ptr<CLibcdio> m_cdio;