Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SC_PortAudioDriver: PortAudio failed at Pa_OpenStream with error: 'Unanticipated host error' could not initialize audio. RESULT = -1073740791 #3976

Closed
th1sthye7 opened this issue Aug 12, 2018 · 34 comments

Comments

@th1sthye7
Copy link

Environment

Windows 10 x64 Newest Update (1803?)
SuperCollider 3.9.0 and 3.9.3

Expected Behavior

audio

Current Behavior

no audio

Steps to reproduce (for bugs)

/

Error message (for bugs)

log:

compiling class library...
Found 695 primitives.
Compiling directory 'C:\Program Files\SuperCollider-3.9.0\SCClassLibrary'
Compiling directory 'C:\Users\x\AppData\Roaming\SuperCollider\Extensions'
Compiling directory 'C:\Users\x\AppData\Local\SuperCollider\Extensions'
numentries = 808750 / 11502548 = 0.07
5186 method selectors, 2218 classes
method table size 12343840 bytes, big table size 92020384
Number of Symbols 11733
Byte Code Size 358430
compiled 321 files in 3.19 seconds

Info: 2 methods are currently overwritten by extensions. To see which, execute:
MethodOverride.printAll

compile done
localhost : setting clientID to 0.
internal : setting clientID to 0.
Class tree inited in 0.02 seconds

*** Welcome to SuperCollider 3.9.0. *** For help press Ctrl-D.
SCDoc: Indexing help-files...
SCDoc: Indexed 1338 documents in 9.26 seconds
booting server 'localhost' on address: 127.0.0.1:57110

Device options:

Booting with:
In: MME : Mikrofon (High Definition Audio
Out: MME : Kopfhörer (High Definition Audi
SC_PortAudioDriver: PortAudio failed at Pa_OpenStream with error: 'Unanticipated host error'
could not initialize audio.
RESULT = -1073740791

@jamshark70
Copy link
Contributor

SC's audio engine, scsynth, in Windows uses a library called PortAudio to connect to the audio hardware driver. If something goes wrong during the connection, then you'll see PortAudio errors.

These errors are generally not bugs, but rather environmental factors in the system. (I feel I should emphasize that since this is logged as a bug report -- if the expectation is that a code fix in SC will resolve this, chances are that it won't.)

The helpful thing about PortAudio errors is that many other audio programs also use PortAudio -- so, web searching for the error text is likely to turn up useful advice.

https://answers.bitwig.com/questions/1317/engine-failed-to-connect

http://www.audiomulch.com/forums/bugs-and-issues/portaudio-error-9999-v203-when-enabling-audio-resolved

However, I can think of one possible bug within SC. Can you try something? After launching SC from scratch:

s.options.inDevice = "MME : Mikrofon (High Definition Audio";
s.options.inDevice = "MME : Microsoft Soundmapper - Output";
s.boot;

If this succeeds where Kopfhörer failed, it would point to a class of issues that I thought had been fixed, but maybe wasn't (or is maybe not fixed in 3.9.x).

My guess is that this is unlikely but it's worth testing.

@th1sthye7
Copy link
Author

th1sthye7 commented Aug 13, 2018

hey
bitwig does not has any issues with it's output..

and i guess your try would be to Change outDevice, not inDevice? Well I do try that…

very confusing, why does your s.options.inDevice = … changes the output? But anyway same result (= -1073740791) :-/

well i guess to installing another Driver for the OnBoard soundcard should Change something. hope so

@jamshark70
Copy link
Contributor

My fault (editing text on a phone), I meant:

s.options.inDevice = "MME : Mikrofon (High Definition Audio";
s.options.outDevice = "MME : Microsoft Soundmapper - Output";
s.boot;

@th1sthye7
Copy link
Author

th1sthye7 commented Aug 13, 2018

man even with a new driver it does not work, i am getting mad.

and a fancy 2-ugly-color-plus-grey-trayicon that is just criminal priceless.

the new Output:

-> localhost
booting server 'localhost' on address: 127.0.0.1:57110

Device options:

Booting with:
In: MME : Mikrofon (SoundMAX Integrated D
Out: MME : Lautsprecher (SoundMAX Integrat
SC_PortAudioDriver: PortAudio failed at Pa_OpenStream with error: 'Unanticipated host error'
could not initialize audio.
RESULT = -1073740791

edit…. now i know that Windows does no has any Sound anymore… new driver... dude...

@th1sthye7
Copy link
Author

th1sthye7 commented Aug 13, 2018

no way!!!!!!!!!!

TWO TRAY ICONs now!!! (and still no Sound)

@th1sthye7
Copy link
Author

might the fact that i plugged the Stereo in the headphone socket at Tower front be the reason of my Problem?

@th1sthye7
Copy link
Author

th1sthye7 commented Aug 13, 2018

3soundtrayicons

@th1sthye7
Copy link
Author

spare!!! i deinstalled that tray Icon program, now Windows Sound works again :)

buuut… s.options.outDevice = does not work anymore. Output: "-> a ServerOptions"

iirc mme never worked for any program… i mostly used wasapi what Always worked.

so just s.options.outDevice = wasapi would have to work eigh?

@jamshark70
Copy link
Contributor

s.options.outDevice = does not work anymore. Output: "-> a ServerOptions"

That's the correct output.

s.options.something = a_value only changes a setting in ServerOptions. It doesn't boot the server or do anything else.

@th1sthye7
Copy link
Author

mh… but it doesnt Change the device ?

@jamshark70
Copy link
Contributor

So then you might try:

s.options.outDevice = "Windows WASAPI : Lautsprecher (SoundMAX Integrated Digital HD Audio)";
s.options.inDevice = "Windows WASAPI : Mikrofon (SoundMAX Integrated Digital HD Audio)";
s.boot;

FWIW Windows audio is terribly fiddly.

@th1sthye7
Copy link
Author

th1sthye7 commented Aug 13, 2018

nope… still mme

--> Booting with:
In: MME : Mikrofon (High Definition Audio
Out: MME : Kopfhörer (High Definition Audi
SC_PortAudioDriver: PortAudio failed at Pa_OpenStream with error: 'Unanticipated host error'
could not initialize audio.
RESULT = -1073740791

@th1sthye7
Copy link
Author

i think with the Change to wasapi it would work… so please someone help me to find out how to switch the Output device. i am really too lazy to plug the saffire… so it's at you now! how to swith to wasapi here.

@jamshark70
Copy link
Contributor

Here, I need to ask other developers. I just noticed something weird in the SC code.

https://github.com/supercollider/supercollider/blob/develop/SCClassLibrary/Common/Control/Server.sc#L121-L127

o = o ++ " -H %".format(inDevice.quote);

In Windows, we often need to specify a separate input and output device, but it seems not to be supported?

Can anyone responsible for the Windows code elaborate? This seems wrong to me.

In the meantime, maybe this?

s.options.device = "Windows WASAPI : Lautsprecher (SoundMAX Integrated Digital HD Audio)";
s.boot;

@jamshark70
Copy link
Contributor

The last thing I can think of is to set the system's default audio devices (input and output) using the Windows control panel, and don't do anything with inDevice and outDevice. That's not an ideal solution IMO but it may be the best available at the moment.

@th1sthye7
Copy link
Author

no it always keeps being mme. sigh.

@th1sthye7
Copy link
Author

ERROR: Variable 'systemdefault' not defined.

@jamshark70
Copy link
Contributor

No, I said "set the system's default audio devices (input and output) using the Windows control panel".

@jamshark70
Copy link
Contributor

Sorry, I was answering on a phone, I emphatically did not mean to close it. It's only because "close and comment" is too close and my phone's accuracy is not good.

@jamshark70
Copy link
Contributor

@brianlheim is there any chance that the string encoding fixes for Windows might have broken audio device selection?

I'm pretty sure, in my old Windows environment, that I could use s.options.device and it always worked (even in a later build including the Unicode fixes).

In this issue, it appears that we are specifying a device, and scsynth is searching for the device but not finding it, and then reverting to some default which (to make matters worse) PortAudio refuses to connect to.

So there are two problems whose internals I don't understand and for which I have no more troubleshooting ideas.

  • If we copy/paste a device from scsynth's device list and plug it into s.options.device, it should match during server init. How do we get some visibility into the reason for failures here?

  • Why is our invocation of PortAudio failing here when the user reports that Bitwig is ok?

And a third, side issue: Looking at this user's device list, options for a single I/O device are limited. How, in SC, should the user choose a specific input and a specific output of a soundcard when the input's name and the output's name are different? Currently this appears unsupported. That might not be acceptable.

@jamshark70
Copy link
Contributor

@th1sthye7 Sorry, I know this is a pain (much more than it should be), but could you confirm the exact steps you're taking? I can sort of infer some of what you're doing based on your log output, but "inferring" is not enough to evaluate the issue.

Scenario 1: Using Windows system default audio.

  • Could you post a screenshot of your Windows audio control panel, showing the default device that is selected?

  • Then, launch SC, don't do anything with s.options, and boot the server. What's the log output?

Scenario 2: Using s.options.

  • Then, do:
    s.options.device = "Windows WASAPI : Kopfhörer (High Definition Audio-Gerät)";
    s.boot;
    
    What is the log output?

Background: SC has had problems before with characters outside of ASCII 0-127, including accented characters. Supposedly this was fixed, but it's possible a bug still lingers. (Here, SC has to read the device name from the code instruction, stick it into another string for the command to launch scsynth, and then scsynth has to compare that against device names -- at least three translations: code --> string, string --> scsynth commandline, scsynth CL argument --> device comparison. I believe the first two should be safe but I'm not sure about the third.)

But, to prove that this is the case, we need to be absolutely 100% certain of the instructions you're submitting.

I apologize again, but the more I see, it's looking like a serious problem. I don't want it to get lost because of insufficient detail.

@jamshark70
Copy link
Contributor

@th1sthye7 One more suggestion: an ASIO driver will probably work better, e.g. https://en.softonic.com/download/asio4all/windows -- this will present one interface name for input and output and avoid some of these problems.

Sorry this has been so irritating.

@th1sthye7
Copy link
Author

th1sthye7 commented Aug 14, 2018

systemsound

Out: MME : Kopfhörer (High Definition Audi
SC_PortAudioDriver: PortAudio failed at Pa_OpenStream with error: 'Unanticipated host error'
could not initialize audio.
RESULT = -1073740791

[...ah... i understand… for the Computer it's hard to know if the two dots over the o are 0's or 1's, right?]

ehm… okay that really might be a reason. let's see if there could be a workaround

@th1sthye7
Copy link
Author

asio4all had lot of Problems with it... did not work well. of Course that was in 2007 or '08... did it became better?

@th1sthye7
Copy link
Author

asio4alldriver

...that's not very promising

@jamshark70
Copy link
Contributor

@th1sthye7 Which site are you looking at? I have no way to evaluate whether you've downloaded from a good or bad source.

Your screenshot is showing asio4all v2.08 and 2.09... I'm finding sites for v2.14.

http://www.softpedia.com/get/Multimedia/Audio/Other-AUDIO-Tools/ASIO4ALL.shtml (I checked the site specifically -- it has 2.14 in English and 2.13 in German)

https://www.majorgeeks.com/files/details/asio4all.html

[...ah... i understand… for the Computer it's hard to know if the two dots over the o are 0's or 1's, right?]

ehm… okay that really might be a reason

(Unfortunately) Yes, it really could. If you want the backstory... strings in SC have always been encoded as 7-bit ASCII characters. If you think this is an icky problem, consider that in really old versions of SC, you couldn't even put "Kopfhörer" into a GUI view (but now you can). It was even worse for multibyte symbols like Chinese, Japanese or Korean characters. Then somebody figured out, we can treat an array of bytes as Unicode... but then there were issues in Windows where our strings are represented internally using one encoding but the Windows file system expects a different encoding. Most of those issues have been fixed. But, as I pointed out, there are a couple of key translations. Your code in the code window --> SC string should be OK. SC string containing non-ASCII characters --> Windows commandline, I'm not 100% sure. Windows commandline argument --> scsynth for checking against the device list, I'm not 100% sure (though I think, maybe, last year I had some students with Chinese characters in device names and it might have worked...? My memory is fuzzy).

Full Unicode support in SC has been discussed but it would mean massive changes to the language internals, so this hasn't happened.

@th1sthye7
Copy link
Author

Which site are you looking at?

your link i downloaded the .08

...mmmh i might look for a .14. OOOh surprise

Booting with:
Out: MME : Kopfhörer (High Definition Audi
Sample rate: 44100.000
Latency (in/out): 0.000 / 0.091 sec
SC_AudioDriver: sample rate = 44100.000000, driver's block size = 64
SuperCollider 3 server ready.
Requested notification messages from server 'localhost'
localhost: server process's maxLogins (1) matches with my options.
localhost: keeping clientID (0) as confirmed by server process.
Shared memory server interface initialized

okay let's see what to do now.

@th1sthye7
Copy link
Author

WOOPIE

@jamshark70
Copy link
Contributor

WOOPIE

Well, that troubleshooting datum is going to be the one that cracks the case, isn't it? 🤣

Joking aside...

Now you've installed a new audio driver. The server, as you've seen, prints a list of audio drivers when it boots. So we would expect to see something about asio4all in the list -- that is, the list should not be the same as it was at the beginning.

So the really relevant part of the log is not the part you posted, but the listing appearing right above it. Could you post that list?

If asio4all isn't on the list, then either the installation failed, or maybe you have to go to the asio4all control panel and set something up. I don't have a working Windows installation at the moment, so I'm afraid (unless someone else weighs in), you're on your own with that.

If it is, then you could try a couple of things:

  • Find the asio4all line (I guess it should look something like "ASIO : ..... (2 ins 2 outs)"). Copy and paste the part from "ASIO : " up to the parenthesis (not including the space). Then paste that inside the quote marks:

    s.options.device = "";  // <-- paste inside here
    
    // Example -- again, I DO NOT HAVE a Windows machine
    // "something something" will definitely not match your system
    s.options.device = "ASIO : ASIO4ALL something something";
    
    // Then boot:
    s.boot;
    
  • Or, go to the Windows sound control panel and choose asio4all as the default device. (Note, when I mentioned the sound control panel before, you posted a screenshot of the audio mixer. I'm pretty sure that's not the right dialog. Probably this one...)
    windows-10-choose-default-audio-device

@jamshark70
Copy link
Contributor

Oh, I'm silly, I saw MME and thought it was still broken 🤦 ok, I see it now, it booted last time.

I'd like to close this one, then, and make a clean enhancement request for better device selection in Windows.

@th1sthye7
Copy link
Author

yes it works now…

..what i did was to deactivate all other Outputs expect the front Panel, and all Inputs.

it does not look like it uses asio.

@jamshark70
Copy link
Contributor

Great!

Opened #3990, so I'll close this now. Thanks for your patience.

@mossheim
Copy link
Contributor

Thanks @jamshark70 and @th1sthye7 for triaging this so patiently :)

@lgvr123
Copy link

lgvr123 commented Apr 17, 2022

For anyone having this issue, I had the same. It appears when I disabled the microphone authorisations (but didn't realize immediately). Resetting it to "On" solved my issue.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants