I am searching since weeks for a solution for my problem but i can t find anything. So I thought this is probably the biggest C#-Forum... I may ask here. The Question is quite difficult to explain so I just copy a link to stackoverflow where i asked before:
http://stackoverflow.com/questions/11382341/translate-c-code-com-interface-to-c-sharp
Again It would be sooooooo nice if someone could help me. I am really such anoyed by that interface but i really want to get i working :)
Loading
florianPosted Jul 15, 2012, 10:18 AM
It is not that way I would like to have it but it works. I've created a MTABackgroundthread.
Thanks a lot for your help :)
VulpesPosted Jul 15, 2012, 10:00 AM
Unless those Actions themselves create threads, then you wouldn't be able to mix Actions which require STA or MTA as the background thread itself would have to be one or the other.
I suppose you could have two background threads - one for Actions requiring STA and the other for Actions requiring MTA.
florianPosted Jul 15, 2012, 9:42 AM
And by the way whats about creating a background thread that works with something like a queue that contains Actions the thread has to call. And every time the thread gets a new action into to queue it gets pushed?
VulpesPosted Jul 15, 2012, 9:36 AM
Whilst starting a new thread may pose some problems of its own, I don't see what other option is open to you. However, you should be able to use the threadpool rather than creating your own thread manually if MTA is required, because that's what the threadpool uses and (to my knowledge) it can't be changed.
florianPosted Jul 15, 2012, 9:24 AM
But creating a new thread every time I call SetVolume is not that good solution because for example if the user creates a scrollbar that sets the volume. I would have to create new Threads thaaat often.
VulpesPosted Jul 15, 2012, 9:15 AM
If the apartment state is reported as 'Unknown', then that's effectively MTA.
Although you can change the apartment state of an existing thread in certain circumstances, that's probably not a good idea as you don't know what else the user may be doing on that thread.
florianPosted Jul 15, 2012, 5:45 AM
It doesn t seems like to be very common problem because nobody really knows a solution for this problem :(
VulpesPosted Jul 14, 2012, 7:11 PM
florianPosted Jul 14, 2012, 5:54 PM
It works on MTAThread config but not on STAThread. Does anyone know why?
florianPosted Jul 13, 2012, 1:01 PM
So I am searching and searching and searching. But I can find anything.
Another question: The Interface itself seems to be right. I mean all that marshalling stuff and so on...
VulpesPosted Jul 13, 2012, 12:59 PM
http://msdn.microsoft.com/en-us/library/windows/desktop/ee416963(v=vs.85).aspx
There are just three new ones : IDirectSound8, IDirectSoundBuffer8, and IDirectSoundCaptureBuffer8 and the rest have just been renamed.
I don't think that the new ones inherit, as such, from the corresponding IDirectSound interfaces, though they do have some members in common.
IUnknown is still there, of course :)
florianPosted Jul 13, 2012, 12:18 PM
EDIT
OK I just tried it on another Computer. Same Result. With the IUnknown Interface it works best. sound plays on volume change --> crash.
VulpesPosted Jul 12, 2012, 6:51 PM
florianPosted Jul 12, 2012, 1:17 PM
VulpesPosted Jul 10, 2012, 6:32 PM
https://www.google.co.uk/search?sugexp=chrome,mod=5&sourceid=chrome&ie=UTF-8&q=HRESULT+0x8878001E
My guess is that it's not a problem with your translation of the COM interface but a problem with something else such as the sound-card.
florianPosted Jul 10, 2012, 4:28 PM
EDIT: OK no its not same result. I get HRESULT 0x8878001E at primaryBuffer.Play... What means that CTRL is not supported but i don t have to control volume and so on on primarybuffer... really confusing.
VulpesPosted Jul 8, 2012, 7:25 PM
florianPosted Jul 8, 2012, 4:25 PM
EDIT: I can play now the primarybuffer but I still get an InvalidCastException when I try to call SetVolume because QueryInterface is not supported on the COM-Component. (E_NOINTERFACE)
VulpesPosted Jul 8, 2012, 4:03 PM