The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Siekmanski on May 26, 2009, 03:02:13 PM

Title: Enumerating soundcards in DirectSound
Post by: Siekmanski on May 26, 2009, 03:02:13 PM
Hello

I have a problem enumerating soundcards in DirectSound.
I get the strings and guids of the soundcards but when I try open it with the DirectSoundCreate function, I get an error. (DSERR_NODRIVER)


   lea         esi,SoundCardGuids
   mov         eax,SoundCardNr
   shl         eax,4
   add         eax,esi

   invoke      DirectSoundCreate,eax,addr g_pDS,NULL

Who can tell me to do it the right way ?

Here are the sources:




[attachment deleted by admin]
Title: Re: Enumerating soundcards in DirectSound
Post by: BogdanOntanu on May 26, 2009, 04:14:16 PM
Have you tried with NULL instead of the enumerated GUID to check if it works?

DirectSoundCreate can fail IF another application is using the sound device and in this case you must ask the user to close that application and/or continue your application with no sound.
Title: Re: Enumerating soundcards in DirectSound
Post by: Siekmanski on May 26, 2009, 04:41:14 PM
Yes I did

invoke      DirectSoundCreate,NULL,addr g_pDS,NULL   ; open default device

I bought a second sound device, till now I never bothered to enumerate the devices because I allways used the default device.

Title: Re: Enumerating soundcards in DirectSound
Post by: Siekmanski on May 27, 2009, 10:40:56 AM
Solved !!!!!

Thanks to farrier
My approach was wrong.......

Here's the working version


[attachment deleted by admin]
Title: Re: Enumerating soundcards in DirectSound
Post by: UtillMasm on May 27, 2009, 10:59:02 AM
 :U
very cool!c:\china>\masm32\bin\rc.exe EnumSoundcards.rc
EnumSoundcards.rc (15): warning RC2182 : duplicate dialog control ID 10

c:\china>\masm32\bin\ml.exe /c /coff EnumSoundcards.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: EnumSoundcards.asm

c:\china>\masm32\bin\link.exe /subsystem:windows EnumSoundcards.res EnumSoundcards.obj
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LINK : warning LNK4068: /MACHINE not specified; defaulting to IX86

c:\china>
Title: Re: Enumerating soundcards in DirectSound
Post by: Siekmanski on May 27, 2009, 12:02:37 PM
Hi UtillMasm

code changed, removed duplicate dialog control ID 10 to -1
Title: Re: Enumerating soundcards in DirectSound
Post by: UtillMasm on May 27, 2009, 12:23:40 PM
 :U
very cool again!@echo off
\masm32\bin\rc.exe /foEnumSoundcards.res EnumSoundcards.rc
\masm32\bin\ml.exe /c /coff /FoEnumSoundcards.obj /nologo EnumSoundcards.asm
\masm32\bin\link.exe /subsystem:windows EnumSoundcards.obj EnumSoundcards.res /nologo
pause

SoundCards:
Primary Sound Driver
Speakers (Realtek High Definition Audio)
Speakers (VMware VMaudio (VMAUDIO) (WDM))
Realtek Digital Output (Realtek High Definition Audio)
Title: Re: Enumerating soundcards in DirectSound
Post by: farrier on May 27, 2009, 02:33:41 PM
Siekmanski,

Glad I could help!

The code I recommended can be found at:

http://board.flatassembler.net/topic.php?t=6990

Share with us when you get something great put together.

farrier
Title: Re: Enumerating soundcards in DirectSound
Post by: PBrennick on May 28, 2009, 12:41:10 AM
I vaguely remember there is an older version of this that was released a few years ago or is it that this just has the same look and feel? Still, as always, nice work.

Paul
Title: Re: Enumerating soundcards in DirectSound
Post by: Siekmanski on May 28, 2009, 06:55:32 AM
Hi Paul

Yes, this is the old version I released in 2004.
I used this old source to show my bad enumeration routine.
Title: Re: Enumerating soundcards in DirectSound
Post by: PBrennick on May 28, 2009, 01:50:11 PM
Your funny. Why do you say 'bad' when it works so well?

Paul
Title: Re: Enumerating soundcards in DirectSound
Post by: Siekmanski on May 28, 2009, 02:41:57 PM
 :bg

Yes, now it does....