after calling DirectSoundCreate which works correctly (eax returns 0) the applications does not really stop. (thread is still running)

the code is:
push byte 0
push dword ABS(lpDirectSound)
push byte 0
call dword

i have win2000 with dx5 installed. but all other dsound examples i have run correctly. but they are written in C so i donnot know if they call an additional constructor...

does anyone of you had a similair problem?
what is the solution?
Posted on 2002-09-12 08:41:45 by peci
I've ported some dsound stuff from C and it's quite straight forward.
I suggest you get up to date with DX8.

your post isn't clear..
post the c source and your translation so we could see what your doing...
Posted on 2002-09-12 16:21:06 by MArtial_Code
that is exactly the point, even if i do nothig - only creating the com structure with DirectSoundCreate the program hangs. if i comment it out it works fine and the task ends correctly.

maybe youre right and i should switch to direcx8.
i do not have a c - compiler on the computer, but all the demos work fine for directx 5.0.
(8 not installed yet - no admin rights :(( )

i thought that directX creates a thread and has to be called with an explicitly quit or release or something - but i couldnt find such a call in all of the c-sources as well as in theire disasembled versions.
Posted on 2002-09-13 05:12:35 by peci
here is the call to create the directsounf object...

invoke DirectSoundCreate,NULL,offset lpDS,NULL

lpDS is a global variable...
Posted on 2002-09-13 07:34:42 by MArtial_Code
that is what i did (if you look at the code)
and it works. i also get 0 in eax so i am sure it is ok...
but when the application quits the task is still listed in the taskmanager...

how should i quit the application. i tried directDraw and there it worked correctly.
Posted on 2002-09-13 07:37:18 by peci
In my code I use PostQuitMessage in the WM_DESTROY handler.
remember to release any buffers and the direct sound object.

like I said post some proper code so we can se wha your're aint TOPSECRET after all:tongue:
Posted on 2002-09-13 08:15:16 by MArtial_Code
that is what i thought. how do i release the directsound object?
i think this is done in c++ autmatically - right?
cause i have not seen any release call in the c-code...
Posted on 2002-09-13 08:17:14 by peci
to release the objects you need to call their Release method.

lpDSbuffer and lpDS are th pointers to the dsound buffer and dsound object respectively.
you must release the buffers before releasing the object...

DXINVOKE (pIDSB[(lpDSbuffer]).Release
;now release the directsound interface itself

btw...are you able to play any sounds with your version?
Posted on 2002-09-13 08:25:51 by MArtial_Code
not yet.

hmm. your macros look very strange. i dont like macros.
this is how it looks in my code:

calling the directsoundcreate:

push byte 0
push dword ABS(lpDirectSound)
push byte 0
call dword

ABS is a macro which adds 40000, which is the exe-adress of any pe exe file.
i dont use a linker, because its a big overhead. (especially for a 4k intro)
note that push byte 0 pushes a 0 dword on the stack! - but is 3 bytes smaller.

ok, here i read the COM table and do the release call.

mov edi,dword
mov dword edi,

push dword
call dword

ok now i release everything, but the thread is still running after the app terminates.
Posted on 2002-09-13 08:31:30 by peci
Just because we're using assembly doesn't mean we have to do things the hard way. Assembly is meant to empower you not hold you back...

what's wrong with using a linker? From what you say it's probable that your convoluted method of programming is the source of the error...

My macros (adapted from others) make it a snap to convert DX function calls from c/++ to assembly.
I guarantee if you send me the c source your using I can have it up and running in ten minutes....

here's a compiled example it' a port rom the book windows gane programming for dummies, it's an excellent book to learn the basics of directdraw/dsound/dinput

see if it runs on your computer..
Posted on 2002-09-13 08:51:50 by MArtial_Code
as i said i am trying to do a 4k. removing the linker reduced the size of my exe about 2.5k!!!!

i now have complete 3d opengl-engine, object generator, texture generator, 2 small testscenes... in about 2.5 k packed. now i am looking forward to play some generated music. for that its the best to use directSound....

but you are right, it has something todo with the way i call it...

i am going to ignore that problem and just try to play a sound out of the buffers...
well maybe it will work when i am using the buffers....

i would also prefer coding like in c, but think about the wasted space for all the pushes, leaves, enters..., all my functions have their parameters in the registers to save space...
Posted on 2002-09-13 09:02:10 by peci
If your functions do not take their arguments on the stack then there won't be any stack overhead. AFAIK masm is smart enough to know when to generate a stack. If the functions takes no arguments on th stack then none can be push it's simple...
the dsound functions and do take their args on the stack though...

Btw when I refer to coding like c i only mean from a readability viewpoint.
so my DXINVOKE macro only generate runtime code which you would have had to write anyway

well done on your progress so far...

do try my example and PLEASE post the c source...
Posted on 2002-09-13 09:19:07 by MArtial_Code
i have various code examples from the net here.
i know that they would work if you port them...

but i need it in my code, and in my code it has problems even when i call the create method..
look at the attached .zip. there is everything to produce my exe
you will see it quits correctly but is still in the task-list...

if you have win98 you will need to change the defines for win98
Posted on 2002-09-13 09:33:02 by peci

Is that how nasm code looks...It's giving me a headache already!!

I must admit it's interesting but for me I dont think coding like that could be anything more than an excercise in "hmm lets see if it's possible"

are you sure you want to code your stuff like that...damn it's very difficult to follow especially for some one who's never used nasm before!

What happens when the dlls change?

I've ran you program nd it does indeed stay in the control panel on exit...
I'm afraid I won't be much help to you, except to say, locate where you handle the various messages, also there's alot of uses of ebx,edi,esi windows will expect these to be preserved and of course you must balance the stack
perhaps you can try your luck on a nasm forum...
Posted on 2002-09-13 10:22:17 by MArtial_Code
headache? *hehe*

it has nothing to do with nasm. you can do beatiful code in nasm,
but i want it as short as possible. therefore i put the window-structure on the stack,
use the stack for all my memory storage (allocating memory can be done with a sub esp,... *gg*)

and the stragest thing is that i dont use a linker, just define the PE-header inside the exe.
and of course calling the dlls with their ordinals saved me another 350bytes.

i am sure i want to code the maximum which is possible in 4k.
i also thought it has something to do with the registers, thats why i do pushad and popad before and after the directSound calls. same result.

so i have to leave now, will be back on monday, maybe i have a solution at home..
i will inform you if the product is finished...
and thx for your help
Posted on 2002-09-13 10:29:26 by peci
i don't know if i understood you well, but if you're going to make a 4kB demo, then use windows' sound engine, not dsound
Posted on 2002-09-14 12:54:22 by ti_mo_n
i thought its better to use dsound, cause everyone uses it.
its faster, and should be less code when i understood it right...

how can i use windows-sound?
is there an example online, where i can see how to initialize the raw-buffers and how to fill it?
Posted on 2002-09-16 02:42:15 by peci
read platform sdk.

it's exactly: Multimedia.chm

it says everything

using dsound interface will waste a lot of mem. use window's internal stuff.
Posted on 2002-10-05 21:28:58 by ti_mo_n
I've got a little source code to show. This is how to use mme, with .. it's exactly the full source code of a very early version of Dreamer. Had written it in C++, but it sure will be ok. You create an event, wait for it, and when it is done, you swap headers. Ask if you have something not clear
Posted on 2002-10-07 12:06:14 by Ultrano

I've got a little source code to show. This is how to use mme, with .. it's exactly the full source code of a very early version of Dreamer. Had written it in C++, but it sure will be ok. You create an event, wait for it, and when it is done, you swap headers. Ask if you have something not clear

Hey Ultrano, can you direct me into a reading which will show me how to generade these sinusoudal, saw and triangle waves? I'm not sure on how its done, sounds awesome! :D
Posted on 2002-10-08 20:45:46 by x86asm