flat assembler
Message board for the users of flat assembler.
Index
> Windows > DirectSound problem |
Author |
|
farrier 06 May 2007, 15:29
ManOfSteel,
As vid would say: "Always check the return value of any Windows function"! What were the return values for the DirectSoundCreate and SetCooperativeLevel calls? That may give you your answer. Also, what is the return value from the CreateSoundBuffer call? hth, farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
06 May 2007, 15:29 |
|
madmatt 07 May 2007, 09:58
Everything looks good, except for:
1. should zero out 'dsbd' and 'WaveFormatEx' structures before using. 2. I use these flags for the buffer desc: DSBCAPS_STATIC or DSBCAPS_LOCSOFTWARE or DSBCAPS_CTRLFREQUENCY or DSBCAPS_CTRLPAN or DSBCAPS_CTRLVOLUME. 3. And as farrier quoted, Check ALL return values for errors. This helps in debugging also. |
|||
07 May 2007, 09:58 |
|
ManOfSteel 07 May 2007, 11:52
Hello Farrier,
Quote: As vid would say: "Always check the return value of any Windows function"! Actually, that's what I'm doing. I only removed the checks because those two functions are working fine. I always compare the returning eax with 0 (which is DS_OK) after each API. Quote: What were the return values for the DirectSoundCreate and SetCooperativeLevel calls? That may give you your answer. I'm getting 0 on both of them, so I guess CreateSoundBuffer must be the faulty one. Quote: Also, what is the return value from the CreateSoundBuffer call? 2147942487 in decimal, which is ... DSERR_INVALIDPARAM. Is it necessary to do a QueryInterface before CreateSoundBuffer? Could it be that? By the way, I read somewhere DirectSound can't play other than 22KHZ, 8-Bit, Mono at the NORMAL priority (SetCooperativeLevel,[hwnd],DSSCL_NORMAL). Is it true? I changed the code to: Code: mov [WaveFormatEx.nChannels],1 ;mono mov [WaveFormatEx.nSamplesPerSec],22050 ;22050 sample/s mov [WaveFormatEx.nAvgBytesPerSec],44100 ;nSamplesPerSec * nBlockAlign mov [WaveFormatEx.nBlockAlign],2 ;(nChannels * wBitsPerSample) / 8 mov [WaveFormatEx.wBitsPerSample],8 ;8 bits/sample Are these values above (1 for mono, etc) correct? Anyway, the result is still the same. madmatt, Thanks, I'll check all this later. I must go now. I'll be back soon. |
|||
07 May 2007, 11:52 |
|
vid 07 May 2007, 12:02
ManOfSteel wrote:
You really should leave those checks there. |
|||
07 May 2007, 12:02 |
|
ManOfSteel 07 May 2007, 13:55
madmatt,
I clean both structures with RtlZeroMemory and I also tried the flags you told me about, but it's still the same. vid, Quote:
Ok, I will. |
|||
07 May 2007, 13:55 |
|
vid 07 May 2007, 14:32
ManOfSteel:
look at MSDN reference of IDirectSound8::CreateSoundBuffer, and check description of "ppDSBuffer", there is the bug. I'll leave rest on you |
|||
07 May 2007, 14:32 |
|
farrier 07 May 2007, 14:37
ManOfSteel,
You can use GetCaps to find out exactly what your sound card is capable of. This will make sure you can use the parameters you have coded. hth, farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
07 May 2007, 14:37 |
|
ManOfSteel 08 May 2007, 05:54
vid,
I already read the MSDN. Are you suggesting that I write ppDSBuffer as a dword value in the .data section? Like that: Code: ppDSBuff dd ? ... cominvk ds,CreateSoundBuffer,dsbd,ppDSBuff,0 Well, I've seen some code doing that and I already thought about it, but it doesn't work any better. It still gives me the same invalid parameter error. In the DirectSound recording utility I talked about earlier, Farrier did it like me (dsb DirectSoundBuffer) and it worked fine. I'm really confused. farrier, Quote: You can use GetCaps to find out exactly what your sound card is capable of. This will make sure you can use the parameters you have coded. I'm using the same flags and settings as you did in your recording/playback utility (from the 'com_invoke' macro thread) and this utility is working fine. |
|||
08 May 2007, 05:54 |
|
farrier 08 May 2007, 06:46
ManOfSteel,
Just a wild guess: Try removing the flags: DSBCAPS_GLOBALFOCUS or DSBCAPS_CTRLPOSITIONNOTIFY and try again. The only other difference I can see is that I have been using the '8' functions, only because they are the ones recommended in the latest SDK. I use DirectSoundCreate8, you use DirectSoundCreate. Other than that, I can't see why yours is not working. hth, farrier _________________ Some Assembly Required It's a good day to code! U.S.Constitution; Bill of Rights; Amendment 1: ... the right of the people peaceably to assemble, ... The code is dark, and full of errors! |
|||
08 May 2007, 06:46 |
|
vid 08 May 2007, 09:27
Quote: I already read the MSDN. Are you suggesting that I write ppDSBuffer as a dword value in the .data section? Like that: Yes, that's how the function must be called. You don't pass pointer to structure (LPDIRECTSOUNDBUFFER = DIRECTSOUNDBUFFER *, LP = long pointer). You pass pointer to pointer to structure (LPDIRECTSOUNDBUFFER* = DIRECTSOUNDBUFFER**). In assembly terms, where every pointer is dword, you pass address of dword, which will on return hold address of filled structure. But naybe you also have some other errors there. |
|||
08 May 2007, 09:27 |
|
ManOfSteel 09 May 2007, 20:41
If what you say is correct, then I should do the same with DirectSoundCreate. Its second parameter is the "address of a variable to receive an IDirectSound8 interface pointer".
So when I call IDirectSound::SetCooperativeLevel, I will use the pointer that I just got from the first function. For that I can't use cominvk anymore. I will have to use comcall, right? Code: ds DirectSound dsbd DSBUFFERDESC ppDS dd ? ppDSBuff dd ? invoke DirectSoundCreate,0,ppDS,0 comcall [ppDS],ds,SetCooperativeLevel,[hwnd],DSSCL_NORMAL ... comcall [ppDS],ds,CreateSoundBuffer,dsbd,ppDSBuff,0 The problem is still there: the first two functions still work well, while CreateSoundBuffer doesn't. Anyway, the output of both codes is quite the same: the disassembly is almost identical. I think there's an explanation about the dword pointer in the manual: Quote:
|
|||
09 May 2007, 20:41 |
|
vid 09 May 2007, 21:42
sorry, you was right. I forgot that FASM's "DSBUFFERDESC" is C's "LPDSBUFFERDESC" etc...
|
|||
09 May 2007, 21:42 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.