October 29, 2013
On Tuesday, 29 October 2013 at 14:13:40 UTC, Benjamin Thaut wrote:
>
> As I'm not familiar with xaudio2 I will not be able to help you unless you present a example which actually crashes. I don't think this is a COM issue. Does a C++ program which does the same work?

C++ example works fine(link to original in xaudio example comments). thats just D port issues.

October 29, 2013
On Tuesday, 29 October 2013 at 14:13:40 UTC, Benjamin Thaut wrote:
>
> I also found that for all pp members which take pointers to COM interfaces. For example the "CreateMasteringVoice" "IXAudio2MasteringVoice** ppMasteringVoice" member. In D interfaces are already reference types. So it should read "IXAudio2MasteringVoice* ppMasteringVoice". Then you can also avoid the ugly casting you do in your examples. When fixing this it still doesn't work however.
>
i have removed unneeded ptr-to-ptr in args, still doesn't works. but, maybe you can tell something about this code?


//----------------------------
class XACallbacks : ComObject, IXAudio2EngineCallback
{
extern(Windows):
void OnProcessingPassStart() {}
void OnProcessingPassEnd () {}
void OnCriticalError (HRESULT Error) { writeln(Error); }
}

...
XACallbacks xcb = new XACallbacks ();
XAudio2Create( g_engine, XAUDIO2_DEBUG_ENGINE );

g_engine.RegisterForCallbacks(xcb); // <- after setting this callback crashes on any call later, probably stack corruption
...

//----------------------------
October 29, 2013
I have the exact same problem with XAudio2 in my own code. Code
compiles and run but doesn't output any sound. I tried your code
but it's the same as mine, runs but doesn't sound.

I'm using in my code the bindings from
http://www.dsource.org/projects/bindings/wiki/DirectX

Can't really understand what's going on with XAudio/COM in D2.
October 29, 2013
So I found it. Its actually your fault.

IXAudio2Voice isn't a COM interface. That means it should _not_ inherit from IUnkown. But if it isn't a COM interface it can't be a regular D interface either, because if it is a regular D-Interface it will not have a v-table layout that conforms with C++. That means you have to put "extern(C++)" in front of IXAudio2Voice to make it work.

So to make stuff work you should change

interface IXAudio2Voice : IUnknown

to

extern(C++) interface IXAudio2Voice

Then everything works fine.

Tip for the future: Using the "Microsoft Symbol Server" and the Visual Studio Debugger you can easily verify if your COM interfaces call the correct methods or if you messed up the declarations.

Kind Regards
Benjamin Thaut
October 29, 2013
On Tuesday, 29 October 2013 at 19:40:40 UTC, Benjamin Thaut wrote:
> So I found it. Its actually your fault.
>
> IXAudio2Voice isn't a COM interface. That means it should _not_ inherit from IUnkown. But if it isn't a COM interface it can't be a regular D interface either, because if it is a regular D-Interface it will not have a v-table layout that conforms with C++. That means you have to put "extern(C++)" in front of IXAudio2Voice to make it work.
>
> So to make stuff work you should change
>
> interface IXAudio2Voice : IUnknown
>
> to
>
> extern(C++) interface IXAudio2Voice
>
> Then everything works fine.
>
> Tip for the future: Using the "Microsoft Symbol Server" and the Visual Studio Debugger you can easily verify if your COM interfaces call the correct methods or if you messed up the declarations.
>
> Kind Regards
> Benjamin Thaut

Whoa! This did the trick with XAudio2! Thank you very much. I'll have the C++ linkage in mind for the rest of the DirectX APIs. One question: Should the other interfaces like IXAudio2 for example use extern(C++) whether they are COM interfaces or not?

I'll also take your tip. I got the link for the symbol server. Do you have a link for a tutorial or something for the Visual Studio Debugger? I'd like more info about it. I assume the debug information from DMD is compatible with this debugger, right?

Thank you again for your help and time.
October 29, 2013
Am 29.10.2013 21:26, schrieb Heinz:
> On Tuesday, 29 October 2013 at 19:40:40 UTC, Benjamin Thaut wrote:
>> So I found it. Its actually your fault.
>>
>> IXAudio2Voice isn't a COM interface. That means it should _not_
>> inherit from IUnkown. But if it isn't a COM interface it can't be a
>> regular D interface either, because if it is a regular D-Interface it
>> will not have a v-table layout that conforms with C++. That means you
>> have to put "extern(C++)" in front of IXAudio2Voice to make it work.
>>
>> So to make stuff work you should change
>>
>> interface IXAudio2Voice : IUnknown
>>
>> to
>>
>> extern(C++) interface IXAudio2Voice
>>
>> Then everything works fine.
>>
>> Tip for the future: Using the "Microsoft Symbol Server" and the Visual
>> Studio Debugger you can easily verify if your COM interfaces call the
>> correct methods or if you messed up the declarations.
>>
>> Kind Regards
>> Benjamin Thaut
>
> Whoa! This did the trick with XAudio2! Thank you very much. I'll have
> the C++ linkage in mind for the rest of the DirectX APIs. One question:
> Should the other interfaces like IXAudio2 for example use extern(C++)
> whether they are COM interfaces or not?
>
> I'll also take your tip. I got the link for the symbol server. Do you
> have a link for a tutorial or something for the Visual Studio Debugger?
> I'd like more info about it. I assume the debug information from DMD is
> compatible with this debugger, right?
>
> Thank you again for your help and time.

The debug information are only compatible for 64-bit. But for 64-bit you will run into other problems when debugging with the visual studio debugger which require patching dmd to make it work.

For 32-bit they are in a different format but can be converted using cv2pdb which is part of VisualD. You should really be using VisualD when doing anything on windows. So the best option is using 32-bit and converting the debug information (manually or using VisualD which does it automatically) if you don't want to patch the compiler. If you need 64-bit and patching the compiler is an option I might be able to put up a small how-to.

COM interfaces don't need to be declared as extern(C++). Only interfaces that do not inherit from IUnkown and are actually C++ interfaces need to be declared extern(C++)

Kind Regards
Benjamin Thaut
October 30, 2013
On Tuesday, 29 October 2013 at 19:40:40 UTC, Benjamin Thaut wrote:
> So I found it. Its actually your fault.
>
> IXAudio2Voice isn't a COM interface. That means it should _not_ inherit from IUnkown. But if it isn't a COM interface it can't be a regular D interface either, because if it is a regular D-Interface it will not have a v-table layout that conforms with C++. That means you have to put "extern(C++)" in front of IXAudio2Voice to make it work.
>
> So to make stuff work you should change
>
> interface IXAudio2Voice : IUnknown
>
> to
>
> extern(C++) interface IXAudio2Voice
>
> Then everything works fine.

omg! i can't believe this :(

i have tried this too first(http://www.dsource.org/projects/bindings/wiki/DirectX), and it was somewhat crappy, so i start my own tranlation, all was fine until xaudio2. i looked up what author of those bindings did, noticed that it doesn't exactly relates to xaudio2.h, and tried to make the same in my version. so it figures out i have just overlooked that its not a COM interfaces. big thanks to you, i feel stupid :(

now i need to fix my xaudio, and then i can clean d3d11 mess i made.
October 30, 2013
Am 30.10.2013 04:18, schrieb evilrat:
> On Tuesday, 29 October 2013 at 19:40:40 UTC, Benjamin Thaut wrote:
>
> omg! i can't believe this :(
>
> i have tried this too
> first(http://www.dsource.org/projects/bindings/wiki/DirectX), and it was
> somewhat crappy, so i start my own tranlation, all was fine until
> xaudio2. i looked up what author of those bindings did, noticed that it
> doesn't exactly relates to xaudio2.h, and tried to make the same in my
> version. so it figures out i have just overlooked that its not a COM
> interfaces. big thanks to you, i feel stupid :(
>
> now i need to fix my xaudio, and then i can clean d3d11 mess i made.

Well we all make problems. Give me a note when you are done with complete directx bindings as I'm also interrested in having minimal up to date directx bindings.

Also its always apperciated to thank you a person which invested multiple hours to track down _your_ problem.

-- 
Kind Regards
Benjamin Thaut
October 30, 2013
On Wednesday, 30 October 2013 at 15:18:57 UTC, Benjamin Thaut wrote:
>
> Well we all make problems. Give me a note when you are done with complete directx bindings as I'm also interrested in having minimal up to date directx bindings.
>
> Also its always apperciated to thank you a person which invested multiple hours to track down _your_ problem.

yes, thanks again. i just really do prefer to solve my problems without bothering people around.


what exactly parts of DirectX you are interested in? my plans was to provide bindings for d3d11, xaudio2, x3daudio, xinput), d3d11 shader compiler and stuff, and maybe d3d10.
(though i'm not sure about this, d3d11 is newer and cleaner and can utilize d3d 9-to-11 gpu's).

and at last directxmath.h, but i don't know if it's possible to hack just one layer of C++ namespace with current extern(C++). but if its not possible i wish to avoid asm sections with SIMD(or maybe i can use phobos SIMD instrinsics, never tried it before) to provide same API as DirectXMath.
October 30, 2013
Am 30.10.2013 17:53, schrieb evilrat:
> On Wednesday, 30 October 2013 at 15:18:57 UTC, Benjamin Thaut wrote:
>>
>> Well we all make problems. Give me a note when you are done with
>> complete directx bindings as I'm also interrested in having minimal up
>> to date directx bindings.
>>
>> Also its always apperciated to thank you a person which invested
>> multiple hours to track down _your_ problem.
>
> yes, thanks again. i just really do prefer to solve my problems without
> bothering people around.
>
>
> what exactly parts of DirectX you are interested in? my plans was to
> provide bindings for d3d11, xaudio2, x3daudio, xinput), d3d11 shader
> compiler and stuff, and maybe d3d10.
> (though i'm not sure about this, d3d11 is newer and cleaner and can
> utilize d3d 9-to-11 gpu's).
>
> and at last directxmath.h, but i don't know if it's possible to hack
> just one layer of C++ namespace with current extern(C++). but if its not
> possible i wish to avoid asm sections with SIMD(or maybe i can use
> phobos SIMD instrinsics, never tried it before) to provide same API as
> DirectXMath.

I'm mostly interrested in directx 11 and d3d11 shader compiler bindings.
I don't really need any other part of the directx api (maybe xaudio2 in the future, currently I'm using OpenAL for sound)

I already have my own math classes implemented in D so I don't really need DirectXMath. Also D compilers will not be able to inline stuff that comes in from C++. D's SIMD intrinsics (core.simd) are unusable at the momemnt, so I would avoid them. The simd intrinsics of LDC and GDC work however (__builtin_x stuff).

-- 
Kind Regards
Benjamin Thaut
1 2 3
Next ›   Last »