Commit f1f76c8f authored by Ghislain MARY's avatar Ghislain MARY

Fix build on systems prior to Windows 8.

parent a2ba5df1
......@@ -29,11 +29,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mswasapi_writer.h"
const IID IID_IAudioClient2 = __uuidof(IAudioClient2);
const IID IID_IAudioCaptureClient = __uuidof(IAudioCaptureClient);
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
#if !BUILD_FOR_WINDOWS_PHONE
#if BUILD_FOR_WINDOWS_PHONE
const IID IID_IAudioClient2 = __uuidof(IAudioClient2);
#else
const IID IID_IAudioClient = __uuidof(IAudioClient);
const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
#endif
......
......@@ -67,9 +67,9 @@ void MSWASAPIReader::init(LPCWSTR id)
{
HRESULT result;
WAVEFORMATEX *pWfx = NULL;
AudioClientProperties properties;
#if BUILD_FOR_WINDOWS_PHONE
AudioClientProperties properties;
mCaptureId = GetDefaultAudioCaptureId(Communications);
if (mCaptureId == NULL) {
ms_error("Could not get the CaptureId of the MSWASAPI audio input interface");
......@@ -83,6 +83,11 @@ void MSWASAPIReader::init(LPCWSTR id)
result = ActivateAudioInterface(mCaptureId, IID_IAudioClient2, (void **)&mAudioClient);
REPORT_ERROR("Could not activate the MSWASAPI audio input interface [%x]", result);
properties.cbSize = sizeof AudioClientProperties;
properties.bIsOffload = false;
properties.eCategory = AudioCategory_Communications;
result = mAudioClient->SetClientProperties(&properties);
REPORT_ERROR("Could not set properties of the MSWASAPI audio output interface [%x]", result);
#else
IMMDeviceEnumerator *pEnumerator = NULL;
IMMDevice *pDevice = NULL;
......@@ -93,15 +98,10 @@ void MSWASAPIReader::init(LPCWSTR id)
result = pEnumerator->GetDevice(mCaptureId, &pDevice);
SAFE_RELEASE(pEnumerator);
REPORT_ERROR("mswasapi: Could not get the capture device", result);
result = pDevice->Activate(IID_IAudioClient2, CLSCTX_ALL, NULL, (void **)&mAudioClient);
result = pDevice->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&mAudioClient);
SAFE_RELEASE(pDevice);
REPORT_ERROR("mswasapi: Could not activate the capture device", result);
#endif
properties.cbSize = sizeof AudioClientProperties;
properties.bIsOffload = false;
properties.eCategory = AudioCategory_Communications;
result = mAudioClient->SetClientProperties(&properties);
REPORT_ERROR("Could not set properties of the MSWASAPI audio output interface [%x]", result);
result = mAudioClient->GetMixFormat(&pWfx);
REPORT_ERROR("Could not get the mix format of the MSWASAPI audio input interface [%x]", result);
mRate = pWfx->nSamplesPerSec;
......
......@@ -50,7 +50,11 @@ private:
static bool smInstantiated;
LPCWSTR mCaptureId;
#if BUILD_FOR_WINDOWS_PHONE
IAudioClient2 *mAudioClient;
#else
IAudioClient *mAudioClient;
#endif
IAudioCaptureClient *mAudioCaptureClient;
UINT32 mBufferFrameCount;
bool mIsInitialized;
......
......@@ -65,9 +65,9 @@ MSWASAPIWriter::~MSWASAPIWriter()
void MSWASAPIWriter::init(LPCWSTR id) {
HRESULT result;
WAVEFORMATEX *pWfx = NULL;
AudioClientProperties properties;
#if BUILD_FOR_WINDOWS_PHONE
AudioClientProperties properties;
mRenderId = GetDefaultAudioRenderId(Communications);
if (mRenderId == NULL) {
ms_error("Could not get the RenderId of the MSWASAPI audio output interface");
......@@ -81,6 +81,11 @@ void MSWASAPIWriter::init(LPCWSTR id) {
result = ActivateAudioInterface(mRenderId, IID_IAudioClient2, (void **)&mAudioClient);
REPORT_ERROR("Could not activate the MSWASAPI audio output interface [%i]", result);
properties.cbSize = sizeof AudioClientProperties;
properties.bIsOffload = false;
properties.eCategory = AudioCategory_Communications;
result = mAudioClient->SetClientProperties(&properties);
REPORT_ERROR("Could not set properties of the MSWASAPI audio output interface [%x]", result);
#else
IMMDeviceEnumerator *pEnumerator = NULL;
IMMDevice *pDevice = NULL;
......@@ -91,15 +96,10 @@ void MSWASAPIWriter::init(LPCWSTR id) {
result = pEnumerator->GetDevice(mRenderId, &pDevice);
SAFE_RELEASE(pEnumerator);
REPORT_ERROR("mswasapi: Could not get the rendering device", result);
result = pDevice->Activate(IID_IAudioClient2, CLSCTX_ALL, NULL, (void **)&mAudioClient);
result = pDevice->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&mAudioClient);
SAFE_RELEASE(pDevice);
REPORT_ERROR("mswasapi: Could not activate the rendering device", result);
#endif
properties.cbSize = sizeof AudioClientProperties;
properties.bIsOffload = false;
properties.eCategory = AudioCategory_Communications;
result = mAudioClient->SetClientProperties(&properties);
REPORT_ERROR("Could not set properties of the MSWASAPI audio output interface [%x]", result);
result = mAudioClient->GetMixFormat(&pWfx);
REPORT_ERROR("Could not get the mix format of the MSWASAPI audio output interface [%x]", result);
mRate = pWfx->nSamplesPerSec;
......
......@@ -50,7 +50,11 @@ private:
static bool smInstantiated;
LPCWSTR mRenderId;
#if BUILD_FOR_WINDOWS_PHONE
IAudioClient2 *mAudioClient;
#else
IAudioClient *mAudioClient;
#endif
IAudioRenderClient *mAudioRenderClient;
UINT32 mBufferFrameCount;
bool mIsInitialized;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment