Comments (16)
What function is returning this hresult?
from directxtk.
Resume()
i ended up changing the soundeffect class in my project so that it doesn't have ownership of the wav data, because the problem is that if some other program takes exclusive control of the audio device and audioengine bombs out, after the other program does its thing and you go to reinitialize audioengine, you don't really want to load all the wav files over again when only the instances need to be recreated--not the actual wav bytes
so i basically have to look for the lost device HRESULT, reset all my directxtk soundeffect instances, and then reinitalize audio engine using the wav data that i've stored elsewhere
from directxtk.
There's already support for 'silent' mode that should avoid the need to load all the wave data again.
Do you have an example of software that grabs the exclusive ownership?
from directxtk.
Note the bug here is that Resume assumes the device is still there. That's not necessarily true as you've noted.
from directxtk.
Foobar, MAME with port audio in exclusive/low latency mode, any WASAPI software using exclusive mode, etc.
I had the understanding that if you created the audio engine in silent mode that you wouldn't get any sounds. Are you saying if you start it in silent mode, then you can reset it, and then on future failures it will be able to reset itself without reloading the data?
from directxtk.
After more testing, this also impacts initializing as well as resume. If you already started a program that is taking exclusive control of an audio device, the instantiation bombs out. I worked around it by adding this:
else if (hr == AUDCLNT_E_DEVICE_IN_USE)
{
DebugTrace("ERROR: AudioEngine failed (%08X) to initialize using device [%ls] because it was already in use.");
}
from directxtk.
Makes sense. Thanks for digging. I'll add both the explicit checking of AUDCLNT_E_DEVICE_IN_USE
as well as improving the Resume method later this week.
from directxtk.
If you can, please try out the code in the PR for DX11 or DX12 and let me know if it works for you. I'll do some testing as well.
from directxtk.
Seems to work okay. This is unrelated, but I'm wondering why you're guessing 16 on the bit depth on line 1332. Couldn't you get the PKEY_AudioEngine_DeviceFormat property and get the actual wBitsPerSample? You're already accessing the properties to get the device name on Windows.
from directxtk.
The PKEY_AudioEngine_DeviceFormat
doesn't seem entirely reliable. On my system it reports "32" which I know isn't right--I have basic on-board motherboard audio.
If I use PKEY_AudioEngine_OEMFormat
I get "16".
What values are you seeing for your audio part?
from directxtk.
It looks like PKEY_AudioEngine_DeviceFormat
just reports the information set in the Sound Settings dialog for the end-point. It was set to '32' for my speakers, but that's not at all what the DAC actually supports.
Is that information useful?
from directxtk.
Please open a new issue for the reporting of the bit-depth, and I'll look into it.
from directxtk.
For the bit-depth issue, see:
from directxtk.
Thanks. Is it useful to get WAVEFORMATEXTENSIBLE instead of WAVEFORMATEX?
The WAVEFORMATEXTENSIBLE structure defines the format of waveform-audio data for formats having more than two channels or higher sample resolutions than allowed by WAVEFORMATEX. It can also be used to define any format that can be defined by WAVEFORMATEX.
Also, would it make sense to also get the sample rate from the waveformat returned from this property, too?
from directxtk.
This was what I was doing in my hacked up version:
if (SUCCEEDED(props->GetValue(PKEY_AudioEngine_DeviceFormat, &var)))
{
if (var.vt == VT_BLOB && var.blob.cbSize >= sizeof(WAVEFORMATEX))
{
const WAVEFORMATEXTENSIBLE* deviceFormatProperties = reinterpret_cast<const WAVEFORMATEXTENSIBLE*>(var.blob.pBlobData);
device.sampleRate = deviceFormatProperties->Format.nSamplesPerSec;
device.bitDepth = deviceFormatProperties->Format.wBitsPerSample;
PropVariantClear(&var);
return true;
}
PropVariantClear(&var);
}
from directxtk.
There's no difference at all between:
auto deviceFormatProperties = reinterpret_cast<const WAVEFORMATEXTENSIBLE*>(var.blob.pBlobData);
device.sampleRate = deviceFormatProperties->Format.nSamplesPerSec;
device.bitDepth = deviceFormatProperties->Format.wBitsPerSample;
and
auto deviceFormatProperties = reinterpret_cast<const WAVEFORMATEX*>(var.blob.pBlobData);
device.sampleRate = deviceFormatProperties->nSamplesPerSec;
device.bitDepth = deviceFormatProperties->wBitsPerSample;
from directxtk.
Related Issues (20)
- Retire legacy Xbox One XDK support
- NonPremultiplied has to be used in the Begin() function. HOT 1
- App.cpp and App.h for UWP DeviceResources HOT 1
- Make use of C++/WinRT when building for C++17
- ARM64 version of xwbtool HOT 3
- `MapGuard` undefined behavior after move HOT 3
- DirectX Tool Kit for DX9
- DrawLine line thickness HOT 1
- Mesh Outline Effect HOT 2
- Point Light Shader HOT 2
- Clarify required WinSDK version HOT 2
- Hard fps lock to refresh rate value in fullscreen games - Win11 22H2 (DX11) HOT 2
- XWBtool makes all wav files the same name after repackaging HOT 5
- Audio: how to set distance attenuation/fall-off? HOT 4
- darker images loading HOT 1
- Request/question: Add a Vector4/floating point overload for the spritebatch's draw function
- undefined data type in PostProcess method HOT 3
- Aa
- Should Mouse use WM_MOUSELEAVE for Win32 raw input
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from directxtk.