Permalink
Browse files

Merge pull request #651 from wsoltys/disc_detection_job

changed: do TMSG_OPTICAL_MOUNT in job to prevent XBMC from freezing
  • Loading branch information...
2 parents a9219be + fe7b8c7 commit 18cfc9a260535666d62759582c84d29cdaae3559 @wsoltys wsoltys committed Jan 25, 2012
@@ -743,6 +743,7 @@
<ClCompile Include="..\..\xbmc\SortFileItem.cpp" />
<ClCompile Include="..\..\xbmc\storage\AutorunMediaJob.cpp" />
<ClCompile Include="..\..\xbmc\storage\cdioSupport.cpp" />
+ <ClCompile Include="..\..\xbmc\storage\DetectDVDType.cpp" />
<ClCompile Include="..\..\xbmc\storage\IoSupport.cpp" />
<ClCompile Include="..\..\xbmc\storage\MediaManager.cpp" />
<ClCompile Include="..\..\xbmc\storage\windows\Win32StorageProvider.cpp" />
@@ -756,6 +757,7 @@
<ClCompile Include="..\..\xbmc\threads\platform\Implementation.cpp" />
<ClInclude Include="..\..\xbmc\cores\AudioRenderers\IAudioRenderer.h" />
<ClInclude Include="..\..\xbmc\filesystem\FileUPnP.h" />
+ <ClInclude Include="..\..\xbmc\storage\DetectDVDType.h" />
<ClInclude Include="..\..\xbmc\threads\platform\win\Implementation.cpp" />
<ClCompile Include="..\..\xbmc\threads\SystemClock.cpp" />
<ClCompile Include="..\..\xbmc\threads\Thread.cpp" />
@@ -2565,6 +2565,9 @@
<ClCompile Include="..\..\xbmc\filesystem\FileUPnP.cpp">
<Filter>filesystem</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\storage\DetectDVDType.cpp">
+ <Filter>storage</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\xbmc\win32\pch.h">
@@ -5151,6 +5154,9 @@
<Filter>filesystem</Filter>
</ClInclude>
<ClInclude Include="..\..\xbmc\cores\AudioRenderers\IAudioRenderer.h" />
+ <ClInclude Include="..\..\xbmc\storage\DetectDVDType.h">
+ <Filter>storage</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\xbmc\win32\XBMC_PC.rc">
View
@@ -266,9 +266,10 @@
#ifdef HAS_SDL_AUDIO
#include <SDL/SDL_mixer.h>
#endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
#include <shlobj.h>
#include "win32util.h"
+#include "storage/DetectDVDType.h"
#endif
#ifdef HAS_XRANDR
#include "windowing/X11/XRandR.h"
@@ -1032,7 +1033,10 @@ bool CApplication::InitDirectoriesWin32()
VECSOURCES::const_iterator it;
for(it=vShare.begin();it!=vShare.end();++it)
if(g_mediaManager.GetDriveStatus(it->strPath) == DRIVE_CLOSED_MEDIA_PRESENT)
- g_application.getApplicationMessenger().OpticalMount(it->strPath);
+ {
+ CDetectDisc* discdetection = new CDetectDisc(it->strPath, false);
+ CJobManager::GetInstance().AddJob(discdetection, NULL);
+ }
// remove end
return true;
@@ -68,6 +68,9 @@
#include "playlists/PlayList.h"
#include "FileItem.h"
+#include "utils/JobManager.h"
+#include "storage/DetectDVDType.h"
+
using namespace std;
CDelayedMessage::CDelayedMessage(ThreadMessage& msg, unsigned int delay)
@@ -726,31 +729,6 @@ case TMSG_POWERDOWN:
break;
#ifdef HAS_DVD_DRIVE
- case TMSG_OPTICAL_MOUNT:
- {
- CMediaSource share;
- share.strPath = pMsg->strParam;
- share.strStatus = g_mediaManager.GetDiskLabel(share.strPath);
- share.strDiskUniqueId = g_mediaManager.GetDiskUniqueId(share.strPath);
- if(g_mediaManager.IsAudio(share.strPath))
- share.strStatus = "Audio-CD";
- else if(share.strStatus == "")
- share.strStatus = g_localizeStrings.Get(446);
- share.strName = share.strPath;
- share.m_ignore = true;
- share.m_iDriveType = CMediaSource::SOURCE_TYPE_DVD;
- g_mediaManager.AddAutoSource(share, pMsg->dwParam1 != 0);
- }
- break;
-
- case TMSG_OPTICAL_UNMOUNT:
- {
- CMediaSource share;
- share.strPath = pMsg->strParam;
- share.strName = share.strPath;
- g_mediaManager.RemoveAutoSource(share);
- }
- break;
case TMSG_CALLBACK:
{
ThreadMessageCallback *callback = (ThreadMessageCallback*)pMsg->lpVoid;
@@ -1180,21 +1158,6 @@ vector<bool> CApplicationMessenger::GetInfoBooleans(const vector<CStdString> &pr
return infoLabels;
}
-void CApplicationMessenger::OpticalMount(CStdString device, bool bautorun)
-{
- ThreadMessage tMsg = {TMSG_OPTICAL_MOUNT};
- tMsg.strParam = device;
- tMsg.dwParam1 = (DWORD)bautorun;
- SendMessage(tMsg, false);
-}
-
-void CApplicationMessenger::OpticalUnMount(CStdString device)
-{
- ThreadMessage tMsg = {TMSG_OPTICAL_UNMOUNT};
- tMsg.strParam = device;
- SendMessage(tMsg, false);
-}
-
void CApplicationMessenger::ShowVolumeBar(bool up)
{
ThreadMessage tMsg = {TMSG_VOLUME_SHOW};
@@ -91,9 +91,6 @@ class CGUIWindow;
#define TMSG_GUI_INFOLABEL 608
#define TMSG_GUI_INFOBOOL 609
-#define TMSG_OPTICAL_MOUNT 700
-#define TMSG_OPTICAL_UNMOUNT 701
-
#define TMSG_CALLBACK 800
#define TMSG_VOLUME_SHOW 900
@@ -197,9 +194,6 @@ class CApplicationMessenger
std::vector<CStdString> GetInfoLabels(const std::vector<CStdString> &properties);
std::vector<bool> GetInfoBooleans(const std::vector<CStdString> &properties);
- void OpticalMount(CStdString device, bool bautorun=false);
- void OpticalUnMount(CStdString device);
-
void ShowVolumeBar(bool up);
void SetSplashMessage(const CStdString& message);
@@ -51,6 +51,7 @@
#include "Application.h"
#include "IoSupport.h"
#include "cdioSupport.h"
+#include "storage/MediaManager.h"
using namespace XFILE;
@@ -529,4 +530,27 @@ const CStdString &CDetectDVDMedia::GetDVDPath()
return m_diskPath;
}
+CDetectDisc::CDetectDisc(const CStdString &strPath, bool bautorun)
+{
+ m_strPath = strPath;
+ m_bautorun = bautorun;
+}
+
+bool CDetectDisc::DoWork()
+{
+ CMediaSource share;
+ share.strPath = m_strPath;
+ share.strStatus = g_mediaManager.GetDiskLabel(share.strPath);
+ share.strDiskUniqueId = g_mediaManager.GetDiskUniqueId(share.strPath);
+ if(g_mediaManager.IsAudio(share.strPath))
+ share.strStatus = "Audio-CD";
+ else if(share.strStatus == "")
+ share.strStatus = g_localizeStrings.Get(446);
+ share.strName = share.strPath;
+ share.m_ignore = true;
+ share.m_iDriveType = CMediaSource::SOURCE_TYPE_DVD;
+ g_mediaManager.AddAutoSource(share, m_bautorun);
+ return true;
+}
+
#endif
@@ -37,6 +37,7 @@
#include "threads/Thread.h"
#include "utils/StdString.h"
+#include "utils/Job.h"
namespace MEDIA_DETECT
{
@@ -93,4 +94,15 @@ class CDetectDVDMedia : public CThread
};
}
+class CDetectDisc : public CJob
+{
+public:
+ CDetectDisc(const CStdString &strPath, bool bautorun);
+ bool DoWork();
+
+private:
+ CStdString m_strPath;
+ bool m_bautorun;
+};
+
#endif
View
@@ -522,7 +522,10 @@ HRESULT CWIN32Util::ToggleTray(const char cDriveLetter)
if(dwReq == IOCTL_STORAGE_EJECT_MEDIA && bRet == 1)
{
strRootFormat.Format( _T("%c:"), cDL);
- g_application.getApplicationMessenger().OpticalUnMount(strRootFormat);
+ CMediaSource share;
+ share.strPath = strRootFormat;
+ share.strName = share.strPath;
+ g_mediaManager.RemoveAutoSource(share);
}
return bRet? S_OK : S_FALSE;
}
@@ -39,6 +39,8 @@
#include "settings/Settings.h"
#include "settings/AdvancedSettings.h"
#include "peripherals/Peripherals.h"
+#include "storage/DetectDVDType.h"
+#include "utils/JobManager.h"
#ifdef _WIN32
@@ -640,7 +642,10 @@ LRESULT CALLBACK CWinEventsWin32::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
case SHCNE_MEDIAINSERTED:
CLog::Log(LOGDEBUG, __FUNCTION__": Drive %s Media has arrived.", drivePath);
if (GetDriveType(drivePath) == DRIVE_CDROM)
- g_application.getApplicationMessenger().OpticalMount(drivePath, true);
+ {
+ CDetectDisc* discdetection = new CDetectDisc(drivePath, true);
+ CJobManager::GetInstance().AddJob(discdetection, NULL);
+ }
else
CWin32StorageProvider::SetEvent();
break;
@@ -649,7 +654,12 @@ LRESULT CALLBACK CWinEventsWin32::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
case SHCNE_MEDIAREMOVED:
CLog::Log(LOGDEBUG, __FUNCTION__": Drive %s Media was removed.", drivePath);
if (GetDriveType(drivePath) == DRIVE_CDROM)
- g_application.getApplicationMessenger().OpticalUnMount(drivePath);
+ {
+ CMediaSource share;
+ share.strPath = drivePath;
+ share.strName = share.strPath;
+ g_mediaManager.RemoveAutoSource(share);
+ }
else
CWin32StorageProvider::SetEvent();
break;

0 comments on commit 18cfc9a

Please sign in to comment.