2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
12 // Thread running in the background to detect a CD change and the filesystem
14 // by Bobbin007 in 2003
16 #include "PlatformDefs.h"
20 #include "storage/discs/IDiscDriveHandler.h"
21 #include "threads/CriticalSection.h"
22 #include "threads/Thread.h"
23 #include "utils/DiscsUtils.h"
28 namespace MEDIA_DETECT
33 class CDetectDVDMedia
: public CThread
37 ~CDetectDVDMedia() override
;
39 void OnStartup() override
;
40 void OnExit() override
;
41 void Process() override
;
43 static void WaitMediaReady();
44 static bool IsDiscInDrive();
45 static bool DriveReady();
46 static DriveState
GetDriveState();
47 static CCdInfo
* GetCdInfo();
48 static CEvent m_evAutorun
;
50 static const std::string
&GetDVDLabel();
51 static const std::string
&GetDVDPath();
53 static void UpdateState();
56 DriveState
PollDriveState();
59 void DetectMediaType();
60 void SetNewDVDShareUrl( const std::string
& strNewUrl
, bool bCDDA
, const std::string
& strDiscLabel
);
65 static CCriticalSection m_muReadingMedia
;
67 static DriveState m_DriveState
;
68 static time_t m_LastPoll
;
69 static CDetectDVDMedia
* m_pInstance
;
71 static CCdInfo
* m_pCdInfo
;
73 bool m_bStartup
= true; // Do not autorun on startup
74 bool m_bAutorun
= false;
75 TrayState m_TrayState
{TrayState::UNDEFINED
};
76 TrayState m_LastTrayState
{TrayState::UNDEFINED
};
77 DriveState m_LastDriveState
{DriveState::NONE
};
79 static std::string m_diskLabel
;
80 static std::string m_diskPath
;
82 std::shared_ptr
<CLibcdio
> m_cdio
;
84 /*! \brief Stores the DiscInfo of the current disk */
85 static UTILS::DISCS::DiscInfo m_discInfo
;