Handmade Hero»Forums»Code
Andrew Chronister
194 posts / 2 projects
Developer, administrator, and style wrangler
DirectSound HRESULT --- SUCCEDED() vs == DS_OK
So previously when we were working with DirectSound (intial setup) we used the SUCCEEDED() macro to check if an operation (setting up the sound buffers) had worked.

In days 19 and 20, we instead check if the HRESULT == DS_OK. From what I can tell from the MSDN entries, the difference is that SUCCEEDED will be true for positive result values other than DS_OK, which would theoretically indicate success still.

Is this correct? Is this what we want to be doing? Based on the table of constant values, it looks like the other positive ones still indicate failure (DSERR_OUTOFMEMORY, DSERR_NOINTERFACE, etc). So do we want to be checking for DS_OK in the buffer initialization? Or do we not expect to see these return values from the functions used in that part?
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
DirectSound HRESULT --- SUCCEDED() vs == DS_OK
These are exactly the kinds of questions that I have no idea how to answer because it involves the magic of, nay, perhaps one might even say majesty of, the Windows SDK.

I think I just checked the docs quickly and the particular function said that it returned DS_OK on success. But that's all. I have no special knowledge of what they may or may not return, so we may want to change to use SUCCEEDED to be safe, but I honestly don't know if that will catch any additional cases in practice.

If someone out there from Microsoft wants to check the source and let us know, that would definitely be educational.

- Casey