C++/VB - DirectSound default device changes
Asked By dmorri
25-Nov-08 08:13 PM
I'm using DirectSound for capture and playback in an application, and I
always open the default capture and playback devices by passing 0 to
DirectSoundCreateFullDuplex. This works fine, but I find that if I change
the default devices (through the Windows control panel) while my app is
running and re-create my DirectSound handle, the device I'm playing through
_doesn't_ change. It's maintaining some state somewhere about what the
default device was when I started my app. Does anyone know how to over-ride
this, and open the _true_ current default devices?
This seems to happen whether I pass 0, GUID_NULL, or
DSDEVID_DefaultPlayback/DSDEVID_DefaultCapture as my requested device handles.
Thanks...
-Dan
WPF
(1)
WaveOutGetDevCaps
(1)
DirectSoundEnumerator
(1)
DefaultPlayback
(1)
DefaultCapture
(1)
FreeLibrary
(1)
DirectSound
(1)
LoadLibrary
(1)
Chris P. replied...
Hi Dan,
Your application should be seeing the changes with the exception of handles
that are already open. At least that is the way that I remember it and is
the way that waveIn/waveOut work. The application's top level window
receives a device change notify message which is automatically processed,
are you perhaps running in a console?
As a test can you inject the code from my DirectSoundEnumerator sample? It
would be interesting to see the enumeration and the associated wave device
Id's with each device both before and after.
--
http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]
dmorri replied...
Interesting... I'm not running in a pure console application, but to be
honest the message-handling loop in this app is somewhat complex and I'm not
sure if I could be doing anything that causes messages to get eaten
inappropriately. It's a WPF app with a large managed layer on top of
unmanaged DirectSound... I will take a look at whether I'm preventing
messages from getting to DSound.
Any idea what "automatically processed" means? Does DSound explicitly
inject a custom message handler into the app?
Thanks!
-Dan
Chris P. replied...
Actually I think the message is purely informational. The application can
choose to process it if it wished to close and reopen it's audio device for
example. It shouldn't matter whether you receive messages or not AFAICT.
However something appears to be funky with DirectSound. As a test I ran my
DirectSoundEnumerator app, which allows you to re-enumerate at will with
the click of a button. The DirectSound enumeration information is getting
cached and is the same for each iteration. On the other hand, inserting a
call to waveOutGetDevCaps() returned the correct (up to date) results for
each iteration.
I will check whether unloading the DSound.DLL changes this behavior. But
that's a little more difficult as you can't bind at link time.
--
http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]
Chris P. replied...
Unloading the DSound.dll works, however there seems to be a bug in the
DSound.dll reference counting as if you call LoadLibrary() (and only
LoadLibrary) you must call FreeLibrary() twice to get the DLL to actually
unload. When I do this I get the correct enumeration on the reload.
--
http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]

the deeper questions and answers I see is what are the Thanks PS: What is WPF overall? A new GUI foundation? Do you recommend WPF over MFC? - - HLS VC MFC Discussions SQL Server (1) Visual Studio (1) Silverlight (1) Windows flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm WPF will take you away from managed world to .Net, which is managed. WinForms and now WPF are available in .Net and obviate the need to use MFC in .Net world. In want to migrate to .net). - - Ajay Thanks for the clear explanation. Whats the difference from WPF and WinForms. Would you say that MS is merging the .NET technologies anyway for MFC for a VS2010 recompiled MFC applet with no explicit action on my part to include WPF / WINFORM, will it still required some level of .NET to be installed on a end managed sub-system requirement when its recompiled under VS2010? - - HLS WinForms came originally with .Net. WPF is the newer framework. WinForms is now essentially not going to see enhancements(it will to run it. Build times are pretty quick. MFC is a GUI framework, requiring Windows. WPF is a GUI framework requiring .NET. WinForms is another GUI framework requiring .NET. WPF is
make it easier to localize. - - David Mihai: so I'm curious what your opinion of WPF is. I mean: it seems to me that you are very sober (in Italian I one font in dialog, no bold face, etc. So, are you against the style of WPF GUIs, that seems to me to be all kind of skinning, rich of colors, "Hollywood few that s*ck at i18n. I don't like it. The localization model for WPF (if there is such a thing :-) is not great. Another disaster is the autolayout: usless i18n API (with a messier localization story) That one propagates nicely all the way to WPF and Silverlight 2.0 But I think this is more of an exception to the rule, with MS getting somethign right from version 1.0 With WPF we are back to the old model: wait for version 3 :-) I think the trend net - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Replace _year_ with _ to get the real email I am almost postive the WPF grid layout can specify percentages. - - David Sure some is overblown. But you think 2-3 _year_ with _ to get the real email My bad. I was thinking Silverlight. The WPF grid has some thing with stars where you can say - - Mihai Nita [Microsoft MVP, Visual traditional MFC and .rc file is too moderate for modern appeal! - - David broadly used than WPF. - - David No argument here, Daniel. - - David Silverlight is in competition against Flash, and I think
open C++ / VB I would like to embed an IE browser into a Windows app (WPF or FormsApp doesn't matter). It basically works, but whenever one of the pages I can be changed with a setting somewhere ? thank you for your help Win32 UI Discussions WPF (1) WebBrowser (1) WindowsApp (1) FormsApp (1) Marchesoni (1) Windows (1) René (1) Javascript (1 01 / pain-of-cross-domain.html Regards, Rene Pilon Thank you René, I dropped the WPF way and use regular WindowsApp (Forms) where in the webbrowser control I can catch the allows me exactly to do what I want. This is apparently not available in the WPF webbrowser controls (unfortunately). Thank you for your reply I am not familiar with WPF very much so perhaps I misunderstand the problem using it. My guess though is that was however able to add it in code. Perhaps you could use something similar using WPF. ctly p ing a e is Yes Carlo I am also about to abandon WPF for exactly the same reason: you cannot capture the NewWindow2 event, so you lose control window.open description: I would like to embed an IE browser into a Windows app (WPF or FormsApp doesn't matter). It basically works, but whenever one of the pages I
WPF - Changing Radio Button to have Command Button Style??? C++ / VB Hello, I have a series of wpf radio buttons in a group that I would like to have the look and feel of regular wpf command buttons. For example, instead of a little circle with the label beside it, I use that will give this "command button" look and feel? Thanks Sam VC MFC Discussions WPF (1) Radiobutton (1) Sam, You'll get a better response if you post your question to a WPF newsgroup. Dave keywords: WPF, -, Changing, Radio, Button, to, have, Command, Button, Style??? description: Hello, I have a series of wpf radio buttons in a group that I would like to have the look and feel of regular wpf command buttons. For example, instead
Discussions Grade.SetTopIndex (1) Grade.SetCurSel (1) Silverlight (1) HWNDmbodthisingI (1) XAML (1) WCF (1) WPF (1) VB (1) Daum, The usual problem is that the combo list is only 1 we are more productive now but I do not like the way .NET is going. WPF / WCF / Silverlight / Linq are plain weird. I am sticking with WinForms just because it is sane. - - David . ust We are using WinForms but people want to go to WPF for reasons like, its new. I dont know any more than what I was told either. - - Ajay I am curious. What do *you* mean by "weird"? I am asked about WPF often by my clients, who think they may want to move some of their simple MVP Tips: http: / / www.flounder.com / mvp_tips.htm I did a 10 month contract with WPF, I was lucky, the client paid for my training. :-) The best part of WPF is it lets you have more freedom to design non-gray, more than one font the workaround was very low level involving some XAML hack, I think. All in all, WPF is not something an MFC programmer would fall in love with (at least I did nice for ASP programming. Tom We are using WinForms but people want to go to WPF for reasons like, its new. I dont know any more than what I was told