Skip to content

Commit

Permalink
Merge pull request xbmc#13243 from afedchin/win10-fix
Browse files Browse the repository at this point in the history
[win10] a set of fixes for uwp
  • Loading branch information
MartijnKaijser authored Dec 25, 2017
2 parents 4a0e42f + f3db993 commit 372ad11
Show file tree
Hide file tree
Showing 21 changed files with 149 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ openssl-1.0.2k-win10-ARM-v140.7z
pcre-8.40-win10-ARM-v140.7z
pillow-4.2.1-v1-win10-ARM-v140.7z
pycryptodome-3.4.7-v1-win10-ARM-v140.7z
python-2.7.13-v2-win10-ARM-v140.7z
python-2.7.13-v3-win10-ARM-v140.7z
rapidjson-1.1.0-win32.7z
shairplay-ce80e00-win10-ARM-v140.7z
sqlite-3170000-win10-ARM-v140.7z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ openssl-1.0.2k-win10-Win32-v140.7z
pcre-8.40-win10-Win32-v140.7z
pillow-4.2.1-v1-win10-Win32-v140.7z
pycryptodome-3.4.7-v1-win10-Win32-v140.7z
python-2.7.13-v2-win10-Win32-v140.7z
python-2.7.13-v3-win10-Win32-v140.7z
rapidjson-1.1.0-win32.7z
shairplay-ce80e00-win10-Win32-v140.7z
sqlite-3170000-win10-Win32-v140.7z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ openssl-1.0.2k-win10-x64-v140.7z
pcre-8.40-win10-x64-v140.7z
pillow-4.2.1-v1-win10-x64-v140.7z
pycryptodome-3.4.7-v1-win10-x64-v140.7z
python-2.7.13-v2-win10-x64-v140.7z
python-2.7.13-v4-win10-x64-v140.7z
rapidjson-1.1.0-win32.7z
shairplay-ce80e00-win10-x64-v140.7z
sqlite-3170000-win10-x64-v140.7z
Expand Down
1 change: 1 addition & 0 deletions tools/windows/packaging/uwp/package.appxmanifest.in
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="internetClientServer" />
<Capability Name="codeGeneration" />
<uap:Capability Name="musicLibrary" />
<uap:Capability Name="picturesLibrary" />
<uap:Capability Name="removableStorage" />
Expand Down
9 changes: 8 additions & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ void CAESinkWASAPI::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bool fo
goto failed;
}

IAudioClient *pClient;
IAudioClient *pClient = nullptr;
hr = pDevice->Activate(&pClient);
if (SUCCEEDED(hr))
{
Expand All @@ -430,6 +430,13 @@ void CAESinkWASAPI::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bool fo
wfxex.Format.nBlockAlign = wfxex.Format.nChannels * (wfxex.Format.wBitsPerSample >> 3);
wfxex.Format.nAvgBytesPerSec = wfxex.Format.nSamplesPerSec * wfxex.Format.nBlockAlign;
hr = pClient->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, &wfxex.Format, NULL);
if (hr == AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED)
{
CLog::Log(LOGNOTICE, __FUNCTION__": Exclusive mode is not allowed on device \"%s\", check device settings.", details.strDescription.c_str());
SAFE_RELEASE(pClient);
SAFE_RELEASE(pDevice);
continue;
}
if (SUCCEEDED(hr) || details.eDeviceType == AE_DEVTYPE_HDMI)
{
if(FAILED(hr))
Expand Down
4 changes: 2 additions & 2 deletions xbmc/filesystem/win10/WinLibraryDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ bool CWinLibraryDirectory::Remove(const CURL& url)
catch(Platform::Exception^ ex)
{
std::string error = FromW(std::wstring(ex->Message->Data()));
CLog::Log(LOGERROR, "CWinLibraryDirectory::Remove: unable remove folder '%s' with error", url.Get(), error.c_str());
CLog::LogF(LOGERROR, __FUNCTION__, "unable remove folder '%s' with error", url.Get(), error.c_str());
exists = false;
}
return exists;
Expand All @@ -195,7 +195,7 @@ StorageFolder^ CWinLibraryDirectory::GetFolder(const CURL& url)
catch (Platform::Exception^ ex)
{
std::string error = FromW(std::wstring(ex->Message->Data()));
CLog::Log(LOGERROR, "CWinLibraryDirectory::GetFolder: unable to get folder '%s' with error", folderPath, error.c_str());
CLog::LogF(LOGERROR, __FUNCTION__, "unable to get folder '%s' with error", folderPath.c_str(), error.c_str());
}
return nullptr;
}
Expand Down
76 changes: 69 additions & 7 deletions xbmc/filesystem/win10/WinLibraryFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
#include "WinLibraryDirectory.h"
#include "platform/win10/AsyncHelpers.h"
#include "platform/win32/CharsetConverter.h"
#include "platform/win32/WIN32Util.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "URL.h"

#include <collection.h>
#include <string>
#include <robuffer.h>

Expand Down Expand Up @@ -192,7 +195,7 @@ bool CWinLibraryFile::Rename(const CURL & urlCurrentName, const CURL & urlNewNam
return false;
}

bool CWinLibraryFile::SetHidden(const CURL & url, bool hidden)
bool CWinLibraryFile::SetHidden(const CURL& url, bool hidden)
{
return false;
}
Expand All @@ -202,16 +205,15 @@ bool CWinLibraryFile::Exists(const CURL& url)
return GetFile(url) != nullptr;
}

int CWinLibraryFile::Stat(const CURL & url, struct __stat64 * statData)
int CWinLibraryFile::Stat(const CURL& url, struct __stat64* statData)
{
auto file = GetFile(url);
// TODO get stats
return 0;
return Stat(file, statData);
}

int CWinLibraryFile::Stat(struct __stat64 * statData)
int CWinLibraryFile::Stat(struct __stat64* statData)
{
return 0;
return Stat(m_sFile, statData);
}

bool CWinLibraryFile::IsInAccessList(const CURL& url)
Expand Down Expand Up @@ -286,7 +288,8 @@ StorageFile^ CWinLibraryFile::GetFile(const CURL & url)
}
catch (Platform::Exception^ ex)
{
// TODO logging error
std::string error = FromW(std::wstring(ex->Message->Data()));
CLog::LogF(LOGERROR, __FUNCTION__, "unable to get file '%s' with error", filePath.c_str(), error.c_str());
}
}
else if (url.GetProtocol() == "file" || url.GetProtocol().empty())
Expand Down Expand Up @@ -336,3 +339,62 @@ Platform::String^ CWinLibraryFile::GetTokenFromList(const CURL& url, IStorageIte

return nullptr;
}

int CWinLibraryFile::Stat(Windows::Storage::StorageFile^ file, struct __stat64* statData)
{
if (!statData)
return -1;

if (!file)
return -1;

/* set st_gid */
statData->st_gid = 0; // UNIX group ID is always zero on Win32
/* set st_uid */
statData->st_uid = 0; // UNIX user ID is always zero on Win32
/* set st_ino */
statData->st_ino = 0; // inode number is not implemented on Win32

auto propertyList = ref new Platform::Collections::Vector<Platform::String^>();
propertyList->Append("System.DateAccessed");
propertyList->Append("System.DateCreated");
propertyList->Append("System.DateModified");
propertyList->Append("System.Size");

auto requestedProps = Wait(file->Properties->RetrievePropertiesAsync(propertyList));

auto dateAccessed = requestedProps->Lookup("System.DateAccessed");
if (dateAccessed)
{
statData->st_atime = CWIN32Util::fileTimeToTimeT(static_cast<Windows::Foundation::DateTime>(dateAccessed).UniversalTime);
}
auto dateCreated = requestedProps->Lookup("System.DateCreated");
if (dateCreated)
{
statData->st_ctime = CWIN32Util::fileTimeToTimeT(static_cast<Windows::Foundation::DateTime>(dateCreated).UniversalTime);
}
auto dateModified = requestedProps->Lookup("System.DateModified");
if (dateModified)
{
statData->st_mtime = CWIN32Util::fileTimeToTimeT(static_cast<Windows::Foundation::DateTime>(dateModified).UniversalTime);
}
auto fileSize = requestedProps->Lookup("System.Size");
if (fileSize)
{
/* set st_size */
statData->st_size = static_cast<unsigned long long>(fileSize);
}

statData->st_dev = 0;
statData->st_rdev = statData->st_dev;
/* set st_nlink */
statData->st_nlink = 1;
/* set st_mode */
statData->st_mode = _S_IREAD; // only read permission for file from library
// copy user RWX rights to group rights
statData->st_mode |= (statData->st_mode & (_S_IREAD | _S_IWRITE | _S_IEXEC)) >> 3;
// copy user RWX rights to other rights
statData->st_mode |= (statData->st_mode & (_S_IREAD | _S_IWRITE | _S_IEXEC)) >> 6;

return 0;
}
1 change: 1 addition & 0 deletions xbmc/filesystem/win10/WinLibraryFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace XFILE
Windows::Storage::StorageFile^ GetFile(const CURL& url);
static bool IsInList(const CURL& url, Windows::Storage::AccessCache::IStorageItemAccessList^ list);
static Platform::String^ GetTokenFromList(const CURL& url, Windows::Storage::AccessCache::IStorageItemAccessList^ list);
static int Stat(Windows::Storage::StorageFile^ file, struct __stat64* statData);

bool m_allowWrite;
Windows::Storage::StorageFile^ m_sFile;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/network/TCPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ bool CTCPServer::Initialize()
#ifdef TARGET_WINDOWS_STORE
bool CTCPServer::InitializeBlue()
{
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
return true; // need to fake it for now
}

Expand Down
2 changes: 1 addition & 1 deletion xbmc/network/mdns/ZeroconfBrowserMDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CZeroconfBrowserMDNS::~CZeroconfBrowserMDNS()
WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, 0 );
#elif defined(TARGET_WINDOWS_STORE)
// need to modify this code to use WSAEventSelect since WSAAsyncSelect is not supported
CLog::Log(LOGERROR, "%s is not implemented for TARGET_WINDOWS_STORE", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented for TARGET_WINDOWS_STORE", __FUNCTION__);
#endif //TARGET_WINDOWS

if (m_browser)
Expand Down
4 changes: 2 additions & 2 deletions xbmc/peripherals/bus/win10/PeripheralBusUSB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ bool CPeripheralBusUSB::PerformDeviceScan(const GUID *guid, const PeripheralType
{
bool bReturn(false);

CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);

return bReturn;
}

bool GetProductAndVendorId(const PeripheralType type, const std::string &strDeviceLocation, int *iVendorId, int *iProductId)
{
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);

return false;
}
Expand Down
16 changes: 8 additions & 8 deletions xbmc/platform/win32/WIN32Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ CWIN32Util::~CWIN32Util(void)
int CWIN32Util::GetDriveStatus(const std::string &strPath, bool bStatusEx)
{
#ifdef TARGET_WINDOWS_STORE
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGERROR, __FUNCTION__": Could not determine tray status %d", GetLastError());
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, __FUNCTION__": Could not determine tray status %d", GetLastError());
return -1;
#else
using KODI::PLATFORM::WINDOWS::ToW;
Expand Down Expand Up @@ -302,7 +302,7 @@ int CWIN32Util::BatteryLevel()
bool CWIN32Util::XBMCShellExecute(const std::string &strPath, bool bWaitForScriptExit)
{
#ifdef TARGET_WINDOWS_STORE
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
return false;
#else
std::string strCommand = strPath;
Expand Down Expand Up @@ -440,7 +440,7 @@ std::string CWIN32Util::GetResInfoString()
int CWIN32Util::GetDesktopColorDepth()
{
#ifdef TARGET_WINDOWS_STORE
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
return 32;
#else
DEVMODE devmode;
Expand Down Expand Up @@ -641,7 +641,7 @@ __time64_t CWIN32Util::fileTimeToTimeT(const LARGE_INTEGER& ftimeli)
HRESULT CWIN32Util::ToggleTray(const char cDriveLetter)
{
#ifdef TARGET_WINDOWS_STORE
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
return false;
#else
using namespace KODI::PLATFORM::WINDOWS;
Expand Down Expand Up @@ -804,7 +804,7 @@ DEVINST CWIN32Util::GetDrivesDevInstByDiskNumber(long DiskNumber)
bool CWIN32Util::EjectDrive(const char cDriveLetter)
{
#ifdef TARGET_WINDOWS_STORE
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
return false;
#else
using KODI::PLATFORM::WINDOWS::ToW;
Expand Down Expand Up @@ -887,7 +887,7 @@ BOOL CWIN32Util::IsCurrentUserLocalAdministrator()
void CWIN32Util::GetDrivesByType(VECSOURCES &localDrives, Drive_Types eDriveType, bool bonlywithmedia)
{
#ifdef TARGET_WINDOWS_STORE
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
#else
WCHAR* pcBuffer= NULL;
DWORD dwStrLength= GetLogicalDriveStringsW( 0, pcBuffer );
Expand Down Expand Up @@ -1701,7 +1701,7 @@ std::string CWIN32Util::WUSysMsg(DWORD dwError)
bool CWIN32Util::SetThreadLocalLocale(bool enable /* = true */)
{
#ifdef TARGET_WINDOWS_STORE
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
return false;
#else
const int param = enable ? _ENABLE_PER_THREAD_LOCALE : _DISABLE_PER_THREAD_LOCALE;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/powermanagement/DPMSSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void DPMSSupport::PlatformSpecificInit()
bool DPMSSupport::PlatformSpecificEnablePowerSaving(PowerSavingMode mode)
{
#ifdef TARGET_WINDOWS_STORE
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
return false;
#else
if(!g_graphicsContext.IsFullScreenRoot())
Expand All @@ -224,7 +224,7 @@ bool DPMSSupport::PlatformSpecificEnablePowerSaving(PowerSavingMode mode)
bool DPMSSupport::PlatformSpecificDisablePowerSaving()
{
#ifdef TARGET_WINDOWS_STORE
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
return false;
#else
// Turn display on
Expand Down
2 changes: 1 addition & 1 deletion xbmc/storage/IoSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ INT CIoSupport::ReadSectorMode2(HANDLE hDevice, DWORD dwSector, LPSTR lpczBuffer
return -1;
}
#elif defined(TARGET_WINDOWS_STORE)
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
#else
DWORD dwBytesReturned;
RAW_READ_INFO rawRead = {0};
Expand Down
14 changes: 4 additions & 10 deletions xbmc/storage/windows/Win32StorageProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,22 @@ void CWin32StorageProvider::Initialize()

void CWin32StorageProvider::GetLocalDrives(VECSOURCES &localDrives)
{
#ifndef TARGET_WINDOWS_STORE
using namespace KODI::PLATFORM::WINDOWS;
CMediaSource share;
#ifndef TARGET_WINDOWS_STORE
wchar_t profilePath[MAX_PATH];
if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_PROFILE, nullptr, 0, profilePath)) ||
GetEnvironmentVariable(L"USERPROFILE", profilePath, MAX_PATH) > 0)
share.strPath = FromW(profilePath);
share.strPath = KODI::PLATFORM::WINDOWS::FromW(profilePath);
else
#endif
share.strPath = CSpecialProtocol::TranslatePath("special://home");
share.strName = g_localizeStrings.Get(21440);
share.m_ignore = true;
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
localDrives.push_back(share);

#ifndef TARGET_WINDOWS_STORE
CWIN32Util::GetDrivesByType(localDrives, LOCAL_DRIVES);
#else
CMediaSource share;
XFILE::CWinLibraryDirectory::GetStoragePath("documents", share.strPath);
share.strName = g_localizeStrings.Get(20249);
share.m_ignore = true;
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
localDrives.push_back(share);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion xbmc/utils/AliasShortcutUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void TranslateAliasShortcut(std::string& path)
// Linux does not use alias or shortcut methods
#elif defined(TARGET_WINDOWS_STORE)
// Win10 does not use alias or shortcut methods
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
#elif defined(TARGET_WINDOWS)
/* Needs testing under Windows platform so ignore shortcuts for now
CComPtr<IShellLink> ipShellLink;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/utils/CPUInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ CCPUInfo::CCPUInfo(void)
m_cores[core.m_id] = core;
}
#elif defined(TARGET_WINDOWS_STORE)
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
#elif defined(TARGET_WINDOWS_DESKTOP)
using KODI::PLATFORM::WINDOWS::FromW;

Expand Down Expand Up @@ -548,7 +548,7 @@ float CCPUInfo::getCPUFrequency()
return 0.f;
return hz / 1000000.0;
#elif defined(TARGET_WINDOWS_STORE)
CLog::Log(LOGERROR, "%s is not implemented", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s is not implemented", __FUNCTION__);
return 0.f;
#elif defined(TARGET_WINDOWS_DESKTOP)
if (m_cpuFreqCounter && PdhCollectQueryData(m_cpuQueryFreq) == ERROR_SUCCESS)
Expand Down
Loading

0 comments on commit 372ad11

Please sign in to comment.