#include <oleidl.h>
#include <objidl.h>
#else
- #ifndef WIN32_WINRT
typedef struct _BYTE_BLOB
{
unsigned long clSize;
typedef /* [unique] */ __RPC_unique_pointer BYTE_BLOB *UP_BYTE_BLOB;
typedef LONGLONG REFERENCE_TIME;
#define NONAMELESSUNION
- #endif
#endif
#ifndef WAVE_FORMAT_IEEE_FLOAT
// Missing declarations for WinRT
#ifdef WIN32_WINRT
+ #define DEVICE_STATE_ACTIVE 0x00000001
+
typedef enum _EDataFlow
{
eRender = 0,
REFERENCE_TIME DefaultDevicePeriod;
REFERENCE_TIME MinimumDevicePeriod;
- // from GetMixFormat
- // WAVEFORMATEX *MixFormat;//needs to be CoTaskMemFree'd after use!
-
// Default format (setup through Control Panel by user)
WAVEFORMATEXTENSIBLE DefaultFormat;
long frame_bytes = nFrames * nBlockAlign;
long packets;
+ (void)nSamplesPerSec;
// align to packet size
frame_bytes = pAlignFunc(frame_bytes, HDA_PACKET_SIZE); // use ALIGN_FWD if bigger but safer period is more desired
// ------------------------------------------------------------------------------------------
#ifdef WIN32_WINRT
-typedef struct _CActivateAudioInterfaceCompletionHandler
+typedef struct PaActivateAudioInterfaceCompletionHandler
{
IActivateAudioInterfaceCompletionHandler parent;
ULONG refs;
}
out;
}
-CActivateAudioInterfaceCompletionHandler;
+PaActivateAudioInterfaceCompletionHandler;
-static HRESULT ( STDMETHODCALLTYPE CActivateAudioInterfaceCompletionHandler_QueryInterface )(
+static HRESULT ( STDMETHODCALLTYPE PaActivateAudioInterfaceCompletionHandler_QueryInterface )(
IActivateAudioInterfaceCompletionHandler * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject)
{
- CActivateAudioInterfaceCompletionHandler *handler = (CActivateAudioInterfaceCompletionHandler *)This;
+ PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
// From MSDN:
// "The IAgileObject interface is a marker interface that indicates that an object
return S_FALSE;
}
-static ULONG ( STDMETHODCALLTYPE CActivateAudioInterfaceCompletionHandler_AddRef )(
+static ULONG ( STDMETHODCALLTYPE PaActivateAudioInterfaceCompletionHandler_AddRef )(
IActivateAudioInterfaceCompletionHandler * This)
{
- CActivateAudioInterfaceCompletionHandler *handler = (CActivateAudioInterfaceCompletionHandler *)This;
+ PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
return ++ handler->refs;
}
-static ULONG ( STDMETHODCALLTYPE CActivateAudioInterfaceCompletionHandler_Release )(
+static ULONG ( STDMETHODCALLTYPE PaActivateAudioInterfaceCompletionHandler_Release )(
IActivateAudioInterfaceCompletionHandler * This)
{
- CActivateAudioInterfaceCompletionHandler *handler = (CActivateAudioInterfaceCompletionHandler *)This;
+ PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
if (handler->refs == 0)
{
PaUtil_FreeMemory(handler->parent.lpVtbl);
return -- handler->refs;
}
-static HRESULT ( STDMETHODCALLTYPE CActivateAudioInterfaceCompletionHandler_ActivateCompleted )(
+static HRESULT ( STDMETHODCALLTYPE PaActivateAudioInterfaceCompletionHandler_ActivateCompleted )(
IActivateAudioInterfaceCompletionHandler * This,
/* [annotation][in] */
_In_ IActivateAudioInterfaceAsyncOperation *activateOperation)
{
- CActivateAudioInterfaceCompletionHandler *handler = (CActivateAudioInterfaceCompletionHandler *)This;
+ PaActivateAudioInterfaceCompletionHandler *handler = (PaActivateAudioInterfaceCompletionHandler *)This;
HRESULT hr = S_OK;
HRESULT hrActivateResult = S_OK;
static IActivateAudioInterfaceCompletionHandler *CreateActivateAudioInterfaceCompletionHandler()
{
- CActivateAudioInterfaceCompletionHandler *handler = PaUtil_AllocateMemory(sizeof(CActivateAudioInterfaceCompletionHandler));
+ PaActivateAudioInterfaceCompletionHandler *handler = PaUtil_AllocateMemory(sizeof(PaActivateAudioInterfaceCompletionHandler));
ZeroMemory(handler, sizeof(*handler));
handler->parent.lpVtbl = PaUtil_AllocateMemory(sizeof(*handler->parent.lpVtbl));
- handler->parent.lpVtbl->QueryInterface = &CActivateAudioInterfaceCompletionHandler_QueryInterface;
- handler->parent.lpVtbl->AddRef = &CActivateAudioInterfaceCompletionHandler_AddRef;
- handler->parent.lpVtbl->Release = &CActivateAudioInterfaceCompletionHandler_Release;
- handler->parent.lpVtbl->ActivateCompleted = &CActivateAudioInterfaceCompletionHandler_ActivateCompleted;
+ handler->parent.lpVtbl->QueryInterface = &PaActivateAudioInterfaceCompletionHandler_QueryInterface;
+ handler->parent.lpVtbl->AddRef = &PaActivateAudioInterfaceCompletionHandler_AddRef;
+ handler->parent.lpVtbl->Release = &PaActivateAudioInterfaceCompletionHandler_Release;
+ handler->parent.lpVtbl->ActivateCompleted = &PaActivateAudioInterfaceCompletionHandler_ActivateCompleted;
return (IActivateAudioInterfaceCompletionHandler *)handler;
}
#endif
#ifdef WIN32_WINRT
static HRESULT ActivateAudioInterface_WINRT(const PaWasapiDeviceInfo *deviceInfo, IAudioClient **client)
{
+#define PA_WASAPI_DEVICE_PATH_LEN 64
+
PaError result = paNoError;
HRESULT hr = S_OK;
- HRESULT activateResult = S_OK;
IActivateAudioInterfaceAsyncOperation *asyncOp = NULL;
IActivateAudioInterfaceCompletionHandler *handler = CreateActivateAudioInterfaceCompletionHandler();
- CActivateAudioInterfaceCompletionHandler *ñhandler = (CActivateAudioInterfaceCompletionHandler *)handler;
- OLECHAR devicePath[64] = { 0 };
+ PaActivateAudioInterfaceCompletionHandler *handlerImpl = (PaActivateAudioInterfaceCompletionHandler *)handler;
+ OLECHAR devicePath[PA_WASAPI_DEVICE_PATH_LEN] = { 0 };
// Get device path in form L"{DEVICE_GUID}"
switch (deviceInfo->flow)
{
case eRender:
- StringFromGUID2(&DEVINTERFACE_AUDIO_RENDER, devicePath, 63);
+ StringFromGUID2(&DEVINTERFACE_AUDIO_RENDER, devicePath, PA_WASAPI_DEVICE_PATH_LEN - 1);
break;
case eCapture:
- StringFromGUID2(&DEVINTERFACE_AUDIO_CAPTURE, devicePath, 63);
+ StringFromGUID2(&DEVINTERFACE_AUDIO_CAPTURE, devicePath, PA_WASAPI_DEVICE_PATH_LEN - 1);
break;
default:
return S_FALSE;
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
// Wait in busy loop for async operation to complete
- while (SUCCEEDED(hr) && !ñhandler->done)
+ while (SUCCEEDED(hr) && !handlerImpl->done)
{
Pa_Sleep(1);
}
- (*client) = ñhandler->out.client;
- hr = ñhandler->out.hr;
+ (*client) = handlerImpl->out.client;
+ hr = handlerImpl->out.hr;
error:
SAFE_RELEASE(handler);
return hr;
+
+#undef PA_WASAPI_DEVICE_PATH_LEN
}
#endif
PaWasapiHostApiRepresentation *paWasapi;
PaDeviceInfo *deviceInfoArray;
HRESULT hr = S_OK;
+ UINT i;
#ifndef WIN32_WINRT
IMMDeviceCollection* pEndPoints = NULL;
-#endif
- UINT i;
+#else
WAVEFORMATEX *mixFormat;
+#endif
#ifndef WIN32_WINRT
if (!SetupAVRT())
for (i = 0; i < paWasapi->deviceCount; ++i)
{
- DWORD state = 0;
PaDeviceInfo *deviceInfo = &deviceInfoArray[i];
deviceInfo->structVersion = 2;
deviceInfo->hostApi = hostApiIndex;
if (paWasapi->devInfo[i].state != DEVICE_STATE_ACTIVE)
{
- PRINT(("WASAPI device: %d is not currently available (state:%d)\n",i,state));
+ PRINT(("WASAPI device: %d is not currently available (state:%d)\n", i, paWasapi->devInfo[i].state));
}
{
goto error;
}
if (value.pwszVal)
- WideCharToMultiByte(CP_UTF8, 0, value.pwszVal, (int)wcslen(value.pwszVal), deviceName, MAX_STR_LEN-1, 0, 0);
+ WideCharToMultiByte(CP_UTF8, 0, value.pwszVal, (int)wcslen(value.pwszVal), deviceName, MAX_STR_LEN - 1, 0, 0);
else
- _snprintf(deviceName, MAX_STR_LEN-1, "baddev%d", i);
+ _snprintf(deviceName, MAX_STR_LEN - 1, "baddev%d", i);
deviceInfo->name = deviceName;
PropVariantClear(&value);
PA_DEBUG(("WASAPI:%d| name[%s]\n", i, deviceInfo->name));
// Create temp Audio Client instance to query additional details
IAudioClient *tmpClient = NULL;
hr = ActivateAudioInterface(&paWasapi->devInfo[i], &tmpClient);
+ // We need to set the result to a value otherwise we will return paNoError
+ // [IF_FAILED_JUMP(hResult, error);]
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
// Get latency
(*hostApi)->info.defaultInputDevice = (*hostApi)->info.deviceCount;
// State
- paWasapi->devInfo[i].state = 1; // DEVICE_STATE_ACTIVE
+ paWasapi->devInfo[i].state = DEVICE_STATE_ACTIVE;
// Default format
memcpy(&paWasapi->devInfo[i].DefaultFormat, mixFormat, min(sizeof(paWasapi->devInfo[i].DefaultFormat), sizeof(*mixFormat)));
paWasapi->devInfo[i].formFactor = UnknownFormFactor;
// Name
- deviceInfo->name = PaUtil_GroupAllocateMemory(paWasapi->allocations, MAX_STR_LEN + 1);
+ deviceInfo->name = (char *)PaUtil_GroupAllocateMemory(paWasapi->allocations, MAX_STR_LEN + 1);
if (deviceInfo->name == NULL)
{
SAFE_RELEASE(tmpClient);
result = paInsufficientMemory;
goto error;
}
- _snprintf(deviceInfo->name, MAX_STR_LEN - 1, "WASAPI_%s:%d", (i == 0 ? "Output" : "Input"), i);
+ _snprintf((char *)deviceInfo->name, MAX_STR_LEN - 1, "WASAPI_%s:%d", (i == 0 ? "Output" : "Input"), i);
PA_DEBUG(("WASAPI:%d| name[%s]\n", i, deviceInfo->name));
}
#endif
SAFE_RELEASE(paWasapi->enumerator);
#endif
+ // Release device info bound objects and device info itself
for (i = 0; i < paWasapi->deviceCount; ++i)
{
PaWasapiDeviceInfo *info = &paWasapi->devInfo[i];
#ifndef WIN32_WINRT
SAFE_RELEASE(info->device);
+ #else
+ (void)info;
#endif
-
- //if (info->MixFormat)
- // CoTaskMemFree(info->MixFormat);
}
PaUtil_FreeMemory(paWasapi->devInfo);
WAVEFORMATEX *sharedClosestMatch = NULL;
HRESULT hr = !S_OK;
PaStreamParameters params = (*_params);
+ (void)output;
/* It was not noticed that 24-bit Input producing no output while device accepts this format.
To fix this issue let's ask for 32-bits and let PA converters convert host 32-bit data
const PaStreamParameters *params = &pSub->params.stream_params;
UINT32 framesPerLatency = pSub->params.frames_per_buffer;
double sampleRate = pSub->params.sample_rate;
- BOOL blocking = pSub->params.blocking;
+ //BOOL blocking = pSub->params.blocking;
BOOL fullDuplex = pSub->params.full_duplex;
const UINT32 userFramesPerBuffer = framesPerLatency;
return hFirstBadResult;
#else
+ (void)substream;
return S_OK;
#endif
}
ReleaseUnmarshaledSubComPointers(substream);
return hResult;
#else
+ (void)substream;
return S_OK;
#endif
}
ReleaseUnmarshaledComPointers(stream);
return hResult;
#else
+ (void)stream;
return S_OK;
#endif
}
return hTask;
#else
+ (void)name;
return NULL;
#endif
}
LogHostError(hr);
return paNoError;
#else
+ (void)nDevice;
+ (void)jcount;
return paUnanticipatedHostError;
#endif
}
return ret;
#else
+ (void)nDevice;
+ (void)jindex;
+ (void)pJackDescription;
return paUnanticipatedHostError;
#endif
}
if (FAILED(hr) && (hr != RPC_E_CHANGED_MODE))
{
PRINT(("WASAPI: failed ProcThreadEvent CoInitialize"));
- return paUnanticipatedHostError;
+ return (UINT32)paUnanticipatedHostError;
}
if (hr != RPC_E_CHANGED_MODE)
bThreadComInitialized = TRUE;
if (FAILED(hr) && (hr != RPC_E_CHANGED_MODE))
{
PRINT(("WASAPI: failed ProcThreadPoll CoInitialize"));
- return paUnanticipatedHostError;
+ return (UINT32)paUnanticipatedHostError;
}
if (hr != RPC_E_CHANGED_MODE)
bThreadComInitialized = TRUE;