mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:03:00 +00:00
- Check if allocation succeeded
- Wait untill each audio service has been started - May now fix randomly playing logon sound svn path=/trunk/; revision=42611
This commit is contained in:
parent
ca039fbfa9
commit
fb04896e11
2 changed files with 73 additions and 32 deletions
|
@ -61,6 +61,12 @@ ProcessExistingDevices()
|
||||||
0,
|
0,
|
||||||
length);
|
length);
|
||||||
|
|
||||||
|
if ( ! detail_data )
|
||||||
|
{
|
||||||
|
logmsg("ProcessExistingDevices() failed to allocate detail_data\n");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
while (
|
while (
|
||||||
SetupDiEnumDeviceInterfaces(dev_info,
|
SetupDiEnumDeviceInterfaces(dev_info,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -17,51 +17,86 @@
|
||||||
#include <audiosrv/audiosrv.h>
|
#include <audiosrv/audiosrv.h>
|
||||||
#include "audiosrv.h"
|
#include "audiosrv.h"
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
WaitForService(
|
||||||
|
SC_HANDLE hService,
|
||||||
|
ULONG RetryCount)
|
||||||
|
{
|
||||||
|
ULONG Index = 0;
|
||||||
|
DWORD dwSize;
|
||||||
|
SERVICE_STATUS_PROCESS Info;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!QueryServiceStatusEx(hService, SC_STATUS_PROCESS_INFO, (LPBYTE)&Info, sizeof(SERVICE_STATUS_PROCESS), &dwSize))
|
||||||
|
{
|
||||||
|
logmsg("QueryServiceStatusEx failed %x\n", GetLastError());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Info.dwCurrentState == SERVICE_RUNNING)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
Sleep(1000);
|
||||||
|
|
||||||
|
}while(Index++ < RetryCount);
|
||||||
|
|
||||||
|
logmsg("Timeout while waiting for service to become ready %p\n", hService);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
StartAudioService(
|
||||||
|
SC_HANDLE hSCManager,
|
||||||
|
LPWSTR ServiceName,
|
||||||
|
ULONG RetryCount)
|
||||||
|
{
|
||||||
|
SC_HANDLE hService;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
hService = OpenService(hSCManager, ServiceName, SERVICE_ALL_ACCESS);
|
||||||
|
|
||||||
|
if (!hService)
|
||||||
|
{
|
||||||
|
logmsg("Failed to open service %S %x\n", ServiceName, GetLastError());
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StartService(hService, 0, NULL))
|
||||||
|
{
|
||||||
|
logmsg("Failed to start service %S %x\n", ServiceName, GetLastError());
|
||||||
|
CloseServiceHandle(hService);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = WaitForService(hService, RetryCount);
|
||||||
|
|
||||||
|
CloseServiceHandle(hService);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
StartSystemAudioServices()
|
StartSystemAudioServices()
|
||||||
{
|
{
|
||||||
SC_HANDLE hSCManager, hService;
|
SC_HANDLE hSCManager;
|
||||||
|
|
||||||
logmsg("Starting system audio services\n");
|
logmsg("Starting system audio services\n");
|
||||||
|
|
||||||
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
|
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
|
||||||
if (!hSCManager)
|
if (!hSCManager)
|
||||||
{
|
{
|
||||||
logmsg("Failed to open service manager\n");
|
logmsg("Failed to open service manager %x\n", GetLastError());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
hService = OpenService(hSCManager, L"sysaudio", SERVICE_ALL_ACCESS);
|
logmsg("Starting sysaudio service\n");
|
||||||
if (hService)
|
StartAudioService(hSCManager, L"sysaudio", 20);
|
||||||
{
|
logmsg("Starting wdmaud service\n");
|
||||||
if (!StartService(hService, 0, NULL))
|
StartAudioService(hSCManager, L"wdmaud", 20);
|
||||||
{
|
|
||||||
logmsg("Failed to start sysaudio service\n");
|
|
||||||
CloseServiceHandle(hService);
|
|
||||||
CloseServiceHandle(hSCManager);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
CloseServiceHandle(hService);
|
|
||||||
logmsg("Sysaudio service started\n");
|
|
||||||
// FIXME
|
|
||||||
// wait untill service is started
|
|
||||||
}
|
|
||||||
|
|
||||||
hService = OpenService(hSCManager, L"wdmaud", SERVICE_ALL_ACCESS);
|
|
||||||
if (hService)
|
|
||||||
{
|
|
||||||
if (!StartService(hService, 0, NULL))
|
|
||||||
{
|
|
||||||
logmsg("Failed to start sysaudio service\n");
|
|
||||||
CloseServiceHandle(hService);
|
|
||||||
CloseServiceHandle(hSCManager);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
CloseServiceHandle(hService);
|
|
||||||
logmsg("Wdmaud service started\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CloseServiceHandle(hSCManager);
|
CloseServiceHandle(hSCManager);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue