I just want to debug without seeing "no type information available in symbol file." I can not debug an application efficiently if I can not see the types I am working with when I am debugging.
Currently, if I build a new project and try to debug Win32 COM code, I get the annoying "no type information available in symbol file."
I have tried every single answer in the question below and nothing has worked! Why does a newly created project in an ide built for such project have this issue?
Visual Studio No Symbols have been loaded for this document
Here is the code with the error:
#include <InitGuid.h>
#include <Mmdeviceapi.h>
#include <Functiondiscoverykeys_devpkey.h>
#include <iostream>
#include <Windows.h>
#include <Audiopolicy.h>
#include <Audioclient.h>
#include <dshow.h>
#include <functional>
#include <random>
#define EXIT_ON_ERROR(hres) \
if (FAILED(hres)) \
{ std::cout << std::hex <<hres << "\n"; goto Exit; }
#define SAFE_RELEASE(punk) \
if ((punk) != NULL) \
{ (punk)->Release(); (punk) = NULL; }
class RandomDouble
{
public:
RandomDouble(double low, double high)
:r(std::bind(std::uniform_real_distribution<>(low, high), std::default_random_engine())) {}
double operator()() { return r(); }
private:
std::function<double()> r;
};
HRESULT getAudioEndpointRenderDevices(IMMDeviceCollection** ppMMDeviceCollection) {
HRESULT hr = S_OK;
const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
IMMDeviceEnumerator* pMMDeviceEnumerator = NULL;
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL,
CLSCTX_ALL, IID_IMMDeviceEnumerator, (void**)&pMMDeviceEnumerator);
if (hr != S_OK) {
goto EXITGAERD;
}
hr = pMMDeviceEnumerator->EnumAudioEndpoints(
EDataFlow::eRender, DEVICE_STATE_ACTIVE, ppMMDeviceCollection);
EXITGAERD:
SAFE_RELEASE(pMMDeviceEnumerator);
return hr;
}
HRESULT getAudioEndpointSpeakerIndices(IMMDeviceCollection** ppMMDeviceCollection,
std::vector<int> iSpeakers) {
HRESULT hr;
UINT nMMDevices;
IMMDevice* pMMDevice = NULL;
IPropertyStore* pPropertyStore = NULL;
PROPVARIANT property;
// Initialize container for property value.
PropVariantInit(&property);
hr = (*ppMMDeviceCollection)->GetCount(&nMMDevices);
if (hr != S_OK) {
goto EXITGAES;
}
for (ULONG i = 0; i < nMMDevices; i++) {
hr = (*ppMMDeviceCollection)->Item(i, &pMMDevice);
if (hr != S_OK) {
goto EXITGAES;
}
hr = pMMDevice->OpenPropertyStore(STGM_READ, &pPropertyStore);
if (hr != S_OK) {
goto EXITGAES;
}
hr = pPropertyStore->GetValue(PKEY_AudioEndpoint_FormFactor, &property);
if (hr != S_OK) {
goto EXITGAES;
}
if (property.uintVal == Speakers) {
iSpeakers.push_back(i);
}
}
EXITGAES:
SAFE_RELEASE(pMMDevice);
SAFE_RELEASE(pPropertyStore);
return hr;
}
int main()
{
IMMDeviceCollection* pMMDeviceCollection = NULL;
std::vector<int> iSpeakers{};
IMMDevice* pMMDevice = NULL;
IPropertyStore* pPropertyStore = NULL;
IAudioClient* pAudioClient = NULL;
REFERENCE_TIME bufferTime = 0;
WAVEFORMATEX* pWaveFormatEx = NULL;
WAVEFORMATEXTENSIBLE* pWaveFormatExtensible = NULL;
IAudioRenderClient* pAudioRenderClient = NULL;
RandomDouble* rd;
EXIT_ON_ERROR(CoInitialize(nullptr));
EXIT_ON_ERROR(getAudioEndpointRenderDevices(&pMMDeviceCollection));
EXIT_ON_ERROR(getAudioEndpointSpeakerIndices(&pMMDeviceCollection, iSpeakers));
// TODO make user pick device
EXIT_ON_ERROR(pMMDeviceCollection->Item(0, &pMMDevice));
EXIT_ON_ERROR(pMMDevice->Activate(__uuidof(IAudioClient), CLSCTX_ALL,
NULL, (void**)&pAudioClient));
EXIT_ON_ERROR(pMMDevice->OpenPropertyStore(STGM_READ, &pPropertyStore));
PROPVARIANT property;
// Initialize container for property value.
PropVariantInit(&property);
EXIT_ON_ERROR(pPropertyStore->GetValue(PKEY_AudioEngine_DeviceFormat, &property));
WORD formatTag;
WORD validBitsPerSample;
WORD samplesPerBlock;
GUID subFormat;
WORD nChannels;
DWORD nSamplesPerSec;
DWORD nAvgBytesPerSec;
WORD nBlockAlign;
WORD bitsPerSample;
WORD cbSize;
/*
pWaveFormatEx = (WAVEFORMATEX*)property.blob.pBlobData;
formatTag = pWaveFormatEx->wFormatTag;
bitsPerSample = pWaveFormatEx->wBitsPerSample;
if (formatTag == 0xFFFE) {
pWaveFormatExtensible = (WAVEFORMATEXTENSIBLE*)property.blob.pBlobData;
validBitsPerSample = pWaveFormatExtensible->Samples.wValidBitsPerSample;
samplesPerBlock = pWaveFormatExtensible->Samples.wSamplesPerBlock;
subFormat = pWaveFormatExtensible->SubFormat; }
else {
validBitsPerSample = bitsPerSample;
}
*/
pAudioClient->GetMixFormat(&pWaveFormatEx);
pWaveFormatExtensible = (WAVEFORMATEXTENSIBLE*)pWaveFormatEx;
validBitsPerSample = pWaveFormatExtensible->Samples.wValidBitsPerSample;
samplesPerBlock = pWaveFormatExtensible->Samples.wSamplesPerBlock;
double amplitude;
amplitude = std::pow(2.0, validBitsPerSample);
nChannels = pWaveFormatEx->nChannels;
nSamplesPerSec = pWaveFormatEx->nSamplesPerSec;
nAvgBytesPerSec = pWaveFormatEx->nAvgBytesPerSec;
nBlockAlign = pWaveFormatEx->nBlockAlign;
bitsPerSample = pWaveFormatEx->wBitsPerSample;
EXIT_ON_ERROR(pAudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED, 0,
bufferTime, 0, pWaveFormatEx, NULL));
UINT32 bufferSize;
EXIT_ON_ERROR(pAudioClient->GetBufferSize(&bufferSize));
EXIT_ON_ERROR(pAudioClient->GetService(__uuidof(IAudioRenderClient), (void**)&pAudioRenderClient));
EXIT_ON_ERROR(pAudioClient->Start());
rd = new RandomDouble(0, amplitude);
UINT32 currentPadding;
for (int i = 0; i < nSamplesPerSec / bufferSize; i++) {
EXIT_ON_ERROR(pAudioClient->GetCurrentPadding(¤tPadding));
//currentPadding *= bytesPerSample;
if (bufferSize - currentPadding != 0) {
long* pData;
pData = new long[bufferSize - currentPadding];
for (int i = 0; i < bufferSize - currentPadding; i++) {
pData[i] = (*rd)();
}
BYTE* pBuffer;
EXIT_ON_ERROR(pAudioRenderClient->GetBuffer(bufferSize - currentPadding, &pBuffer));
for (int j = 0; j < (bufferSize - currentPadding) / 8; j += 8) {
BYTE* bytePointer = reinterpret_cast<byte*>(&pData[j / 8]);
*((pBuffer)+j) = *bytePointer;
*((pBuffer)+j + 1) = *(bytePointer + 1);
*((pBuffer)+j + 2) = *(bytePointer + 2);
*((pBuffer)+j + 3) = *(bytePointer + 3);
*((pBuffer)+j + 4) = *bytePointer;
*((pBuffer)+j + 5) = *(bytePointer + 1);
*((pBuffer)+j + 6) = *(bytePointer + 2);
*((pBuffer)+j + 7) = *(bytePointer + 3);
}
EXIT_ON_ERROR(pAudioRenderClient->ReleaseBuffer(bufferSize - currentPadding, 0));
}
else {
i--;
}
}
return 0;
Exit:
printf("Error!\n");
SAFE_RELEASE(pMMDeviceCollection);
SAFE_RELEASE(pAudioClient);
SAFE_RELEASE(pPropertyStore);
CoUninitialize();
return 0;
}
pMMDeviceCollection in particular has no type information. Even with this line:
Loaded 'C:\Windows\System32\MMDevAPI.dll'. Symbols loaded.
and this:
SYMSRV: RESULT: 0x00000000
https://msdl.microsoft.com/download/symbols: Symbols downloaded from symbol server.
C:\Users\me\AppData\Local\Temp\SymbolCache\MMDevAPI.pdb\64A6E5290A7AFAE0E2C07DFC2B0252291\MMDevAPI.pdb: Symbols loaded.```