Hi!
pls
any code sample of wasapi in MASM
http://masm32.com/board/index.php?topic=6291.msg67498#msg67498
Thank for your replay!
I,m not advanced in using COM object and audio API so I use to learn a lot of Siekmanski sample of directsound. So i want to go one step further and use WASAPI but I,m stack at begining. Microsoft is giving step by step explanation how to prepare your application to start working with WASAPI in c++ . First you need to obtain MMDeviceEnumerator interface ....something like these:
....
.code
invoke CoInitialize, 0 ; requested in order to initialize COM object
; now you need to obtain MMDeviceEnumerator interface and you need
; CLSID ----class identificator ----GUID predefined value ( 16 bytes)
; IID ----- interface identificator----- GUID predefined value ( 16 bytes)
; variable that will hold value which represent interface ( i name it MMDeviceEnumeratorInterface)
invoke CoCreateInstance, addr ClsIdMMDeviceEnumerator, 0, CLSCTX_ALL, addr IID_MMDeviceEnumerator, addr MMDeviceEnumeratorInterface
and I get an error code "Class not registered"(80040154h)
i.m supposed that i,m fail to load some library (MMDevApi.dll ...), and register server of that DLL-s . So i need steps what I need to do in COM fashion way, to get to the point where i,m invoking CoCreateInstance .
I dont understand c/c++ directives used in .H files so that cannot help me. Even i dont fully understand MASM directive used in include files but at list I can use .inc within my .asm source codes ( especially some macro definitions) and experiment with them to understand how is working.
I will appreciate some help in MASM code.
Thank,s!
Hi milan,
Where can I find the CLSID_MMDeviceEnumerator?
deleted
Thanks nidud.
Hi milan,
I made a start with the WASAPI interfaces.
Marinus
EXCELENT!!! :greenclp:
Siekmanski i,m filing like you are heated me with stone directly in my head! After two weeks of searching what i need to implement in my .inc files before I start to learn how to work with WASAPI, i already want to give up because my level of knowledge and my understanding how to work with COM object is to poor.
You have done everything what I need to start to work with Windows core audio APIs including WASAPI. Now, not only that I can work with WASAPI but studying your example ,I can improve my knowledge of COM object and understand some important preparation steps before implementing some API functions. For everybody that is reading these post and want to start learning or implement WASAPI in his on application, everything you need is Siekmanski "MASM audio core skeleton" that is attached in the post. I will give to you some hints:
// Siekmanski MASM audio core skeleton//
.686p
.model flat,stdcall
.xmm
option casemap:none
include \masm32\include\ole32.inc
includelib \masm32\lib\ole32.lib
include COM_macros.inc
include Wasapi.inc
.data
g_pEnumerator LPIMMDEVICEENUMERATOR NULL
:.....................................................................................
; put some variables that will hold pointer on interface which you will use
g_pEnumeAudioEndpoints dword 0
; put some variable if you did not include some .inc file that will hold these definition and declaration like static variable values, structures, etc....
eCapture dword 1 ;= ( eRender + 1 ) --- defined in mmdevaceapi.h
DEVICE_STATE_ACTIVE dword 1------- defined in mmdevaceapi.h
.code
include Consolestuff.Asm
start:
;// these are codes that initiate Windows audio core API
invoke StdOut,TEXT_(" WASAPI test.",13,10,13,10)
invoke CoInitialize,NULL
invoke CoCreateInstance,GUID_ADDR(CLSID_MMDeviceEnumerator),NULL,CLSCTX_ALL,GUID_ADDR(IID_IMMDeviceEnumerator),addr g_pEnumerator
;// now your CODE to use audio core API is starting from here
;//
;// I want to obtain only capture devices that is active in the system
;// so i want to use IMMDeviceEnumerator::EnumAudioEndpoints method
;// but with these method you can also obtain all audio capture devices even :// those that is not active
coinvoke g_pEnumerator, IMMDeviceEnumerator, EnumAudioEndpoints, eCapture, DEVICE_STATE_ACTIVE,addr g_pEnumeAudioEndpoints
;// you should visit Microsoft site to se how to continue... or use other tutorial
;//..........................................................................
;// after you finish job with any interface you should use SAFE_RELEASE
;// macro to release interface that is not of interest anymore
;// when your application want to exit be sure that all interface are already
;// closed and exit
exit:
SAFE_RELEASE g_pEnumeAudioEndpoints
SAFE_RELEASE g_pEnumerator
invoke CoUninitialize
invoke Wait_Key
invoke ExitProcess,0
end start
So, for all of us Siekmanski providing fast way to learn or implement audio core API (Multimedia Device API, DeviceTopology API and Windows Audio Session API so called WASAPI).Everything what we need to do in our application (apart to declare and define some variable and structures) is to call particular method function (using coinvoke macro) to get the result, and release any interface when we dont need him.
Siekmanski my on personal opinion about you is that you have brilliant mind, high pc knowledge and assembly language skill but most important thing is that you have angel heart because you are helping peoples to understand things in easy way.
Thank you !!!
Your on the right track. :t
Keep us posted when your making progress.