midiOutOpen on Windows 10 using Microsoft GS Wavetable Synth fails
Asked Answered
D

3

12

I have an application that relies on the in built Microsoft GS Wavetable Synth. It has worked flawlessly on Windows XP, Vista, 7, 8 and 8.1. While the first call to midiOutOpen on Windows 10 works, subsequent calls result in error code 1, meaning 'Unspecified error'. The code is simple:

result = midiOutOpen(&_midiOutHandle, midiOutputDevice, NULL, 0, CALLBACK_NULL);

Any ideas regarding how to resolve this hugely appreciated.

Diaconate answered 31/7, 2015 at 18:27 Comment(0)
S
11

I see it. Tracing through the machine code, I see the modMessage() function fail and return MMSYSERR_ERROR. Exactly why isn't clear to me, it looks like a missing initialization problem.

What is strange about this mishap is that there are not a lot of complaints about it, you'd expect plenty of other programs fall over as well. Or for that matter for them to be tested before Win10 shipped. Next thing I tried is adding the one thing that happens in any non-trivial audio app that I skipped in my test program. Partly inspired by seeing "ATL" back in the symbols of modMessage, although it wasn't anywhere close. I added this as the first line in main():

   CoInitializeEx(NULL, COINIT_MULTITHREADED);

Badaboom, no more error. Use COINIT_APARTMENTTHREADED if you call this on the main thread of a UI thread. CoUninitialize() at the end to clean up.

Explaining it is difficult, initializing COM should not be necessary when you use MIDI. With it in place, calling midiOutOpen gets one more DLL loaded, clbcatq.dll. That's a COM+ support module. So sure looks like Win10 requires COM to be initialized.

Slipover answered 13/9, 2015 at 18:38 Comment(2)
Thanks for looking into this - your workaround worked for me!Nippy
Lots of programs do fall over. But lots of low-budget programmers didn't have an extra machine to use for Win10 testing before it was released... and they expected M$ to stay compatible............. VanBasco Karaoke player is one that falls over... unless you click the ? (help) icon which apparently uses/initializes COM.Cottar
T
1

I put a MessageBox (with nothing important to say) just before midiOutOpen, and IT WORKED! I'm using Visual Studio 2013 C++.

WASAPI doesn't work for me anymore in sharing mode, although I think I'll be able to make it work.

Tiling answered 6/8, 2015 at 19:17 Comment(1)
Thanks for your reply, I really appreciate your input. However I can't force my users to close an empty message box every time they press the start button. Do you have any idea as to why this works?Diaconate
D
1

When I use the CoInitializeEx(NULL, COINIT_MULTITHREADED), this helps for the midi open problem but has bad influence for using mciSendString with opening an MP3 song, which results always in error 266 in same program. Eg.:

open "d:\\music\\Fernando.mp3" type MPEGVideo alias Fernando.mp3 wait

(without the CoInitializeEx this open works and the mp3 song plays in Windows 10).

On some Windows 10 Systems the midi and mp3 open well without calling the CoInitializeEx, on others it does not play midi. It is not documented in MCI api that it must be called and causes indetermined problems. For me it is not clear when or why it must be called and when I should better not call it. The Windows 10 incompatibility relating MCI of Microsoft is intolerable. All Systems since XP are MCI compatible and only Windows 10 causes troubles.

Dianthe answered 10/4, 2016 at 8:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.