Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Windows Core Audio API and CDT
Windows Core Audio API and CDT [message #1713096] Fri, 30 October 2015 21:44
Kh Dunk is currently offline Kh DunkFriend
Messages: 1
Registered: October 2015
Junior Member
been trying to compile and run a simple audio endpoint application in Eclipse CDT using the visual c++ toolchain.


#include <iostream>
#include <Audioclient.h>
#include <Audiopolicy.h>
#include <Mmdeviceapi.h>
#include <stdio.h>
#include <FunctionDiscoveryKeys_devpkey.h>
#include <initguid.h>
#include <objbase.h>


using namespace std;


#define EXIT_ON_ERROR(hres) \
if (FAILED(hres)) { goto Exit; }
#define SAFE_RELEASE(punk) \
if ((punk) != NULL) \
{ (punk)->Release(); (punk) = NULL; }

const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);




void PrintEndpointNames()
{
HRESULT hr = S_OK;
IMMDeviceEnumerator *pEnumerator = NULL;
IMMDeviceCollection *pCollection = NULL;
IMMDevice *pEndpoint = NULL;
IPropertyStore *pProps = NULL;
LPWSTR pwszID = NULL;
CoInitialize(NULL);

hr = CoCreateInstance(
CLSID_MMDeviceEnumerator, NULL,
CLSCTX_ALL, IID_IMMDeviceEnumerator,
(void**)&pEnumerator);
EXIT_ON_ERROR(hr)

hr = pEnumerator->EnumAudioEndpoints(
eRender, DEVICE_STATE_ACTIVE,
&pCollection);
EXIT_ON_ERROR(hr)

UINT count;
hr = pCollection->GetCount(&count);
EXIT_ON_ERROR(hr)

if (count == 0)
{
printf("No endpoints found.\n");
}

// Each loop prints the name of an endpoint device.
for (ULONG i = 0; i < count; i++)
{
// Get pointer to endpoint number i.
hr = pCollection->Item(i, &pEndpoint);
EXIT_ON_ERROR(hr)

// Get the endpoint ID string.
hr = pEndpoint->GetId(&pwszID);
EXIT_ON_ERROR(hr)

hr = pEndpoint->OpenPropertyStore(
STGM_READ, &pProps);
EXIT_ON_ERROR(hr)

PROPVARIANT varName;
// Initialize container for property value.
PropVariantInit(&varName);

// Get the endpoint's friendly-name property.
hr = pProps->GetValue(
PKEY_Device_FriendlyName, &varName);
EXIT_ON_ERROR(hr)

// Print endpoint friendly name and endpoint ID.
printf("Endpoint %d: \"%S\" (%S)\n",
i, varName.pwszVal, pwszID);

CoTaskMemFree(pwszID);
pwszID = NULL;
PropVariantClear(&varName);
SAFE_RELEASE(pProps)
SAFE_RELEASE(pEndpoint)
}
SAFE_RELEASE(pEnumerator)
SAFE_RELEASE(pCollection)
return;

Exit:
printf("Error!\n");
CoTaskMemFree(pwszID);
SAFE_RELEASE(pEnumerator)
SAFE_RELEASE(pCollection)
SAFE_RELEASE(pEndpoint)
SAFE_RELEASE(pProps)
}
int main (){

PrintEndpointNames();

return 0;
}

after building the project I get this errors :
LNK1120: 4 unresolved externals AudioRen line 0 C/C++ Problem
LNK2019: unresolved external symbol __imp__CoCreateInstance@20 referenced in function "void __cdecl PrintEndpointNames(void)" (?PrintEndpointNames@@YAXXZ) main.obj /AudioRen/Debug C/C++ Problem
LNK2019: unresolved external symbol __imp__CoInitialize@4 referenced in function "void __cdecl PrintEndpointNames(void)" (?PrintEndpointNames@@YAXXZ) main.obj /AudioRen/Debug C/C++ Problem
LNK2019: unresolved external symbol __imp__CoTaskMemFree@4 referenced in function "void __cdecl PrintEndpointNames(void)" (?PrintEndpointNames@@YAXXZ) main.obj /AudioRen/Debug C/C++ Problem
LNK2019: unresolved external symbol __imp__PropVariantClear@4 referenced in function "void __cdecl PrintEndpointNames(void)" (?PrintEndpointNames@@YAXXZ) main.obj /AudioRen/Debug C/C++ Problem


I think I have everything correct, the code works in visual studio 2015. the includes that I'm using are windows 10 sdk. if anyone is familiar with windows core audio and cdt your help would be appreciated.

thanks
Previous Topic:ASM in eclipse
Next Topic:CDT Installation on Luna - "cannot perform operation"
Goto Forum:
  


Current Time: Thu Sep 12 09:55:52 GMT 2024

Powered by FUDForum. Page generated in 0.03065 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top