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

Can't open stream on macOS 11.x #395

Closed
maxvalle opened this issue Dec 26, 2020 · 6 comments
Closed

Can't open stream on macOS 11.x #395

maxvalle opened this issue Dec 26, 2020 · 6 comments
Labels
src-coreaudio Apple Core Audio Host API src/hostapi/coreaudio

Comments

@maxvalle
Copy link

Describe the bug

Trying to use Pa_OpenDefaultStream() or Pa_OpenStream() to open a stream, an error occur.
This is happening on macOS 11.1 (Big Sur) but not on a previous macOS version like 10.13.6 (High Sierra) where it works as intended

The error: ||PaMacCore (AUHAL)|| Error on line 1277: err='-66748', msg=Unknown Error

To Reproduce
A simple snippet of code to show the problem:

#include <stdio.h>
#include "portaudio.h"

int main( int argc, char **argv );
int main( int argc, char **argv )
{

	PaStream *stream;

	printf("Initialize\n");
	PaError err = Pa_Initialize();
	if(err!=paNoError) {
		printf("Error initializing portaudio: %s\n", Pa_GetErrorText(err));
		return 1;
	}

	printf("Get default input device\n");
	PaDeviceIndex default_input = Pa_GetDefaultInputDevice();
	if(default_input == paNoDevice) {
		printf("No default audio input device found\n");
		return 1;
	}
	
	printf("Get device input channels\n");
	long channels = Pa_GetDeviceInfo(default_input)->maxInputChannels;
	if(channels == 0) {
		printf("Default audio device has no input channels\n");
		return 1;
	}
	
	/* following call to Pa_OpenDefaultStream will fail */
	printf("Open default stream\n");
	err = Pa_OpenDefaultStream(&stream,channels,0,paFloat32,44100,paFramesPerBufferUnspecified,NULL,NULL);
	if(err!=paNoError)
		printf("Error opening default stream: %s\n", Pa_GetErrorText(err));
		return 1;

	printf("Start stream\n");
	err = Pa_StartStream(stream);
	if(err!=paNoError) {
		printf("Error starting the stream: %s\n", Pa_GetErrorText(err));
		return 1;
	}

	return 0;
}

Expected behavior
open an input/output stream

Actual behavior
Error: ||PaMacCore (AUHAL)|| Error on line 1277: err='-66748', msg=Unknown Error

Desktop

  • OS: macOS
  • OS Version: 11.1
  • Portaudio version 19.6.0 (stable) installed via Homebrew.

Additional context
The mentioned API to open a stream work properly on past versions of macOS.

@fmaker
Copy link

fmaker commented Dec 26, 2020

This is a dupe of #218. You can workaroudn this by using the 12.1 version of XCode command line tools:

From: #218 (comment)

Just to clarify: portaudio fails in runtime on macOS 11 only if the program is built against macOS SDK 11.
Latest XCode 12.2 comes with macOS SDK 11.
I downgraded Xcode to version 12.1 which uses 10.15 SDK and then portaudio worked fine on Big Sur!

@maxvalle
Copy link
Author

I did not build portaudio, used Homebrew to install prebuilt binaries, as many people does for convenience.
It would be nice having portaudio fixed for macOS SDK 11.

Additionally, as also reported in the #218
#218 (comment)

I was wrong about this. GitHub Actions is now using the macOS 11.0 SDK and users have been having issues with it.

@maxvalle
Copy link
Author

I've tried installing portaudio 19.6.0 built under macOS Mojave (Xcode 11.3.1) and also built under macOS Catalina (Xcode 12.1) but I have the same problem running on macOS 11.1
Maybe this is related to hardened privacy introduced.

@RossBencina
Copy link
Collaborator

Assuming that the issue is indeed deprecated APIs, there is this fix: #356

@philburk
Copy link
Collaborator

I am seeing multiple bug related to Big Sur.
At first I thought it was all related to the deprecated audio calls.
But now I think that was only part of the problem.

I started an umbrella issue #468 for crashes related to building with the SDK 11.
I don't know if this bug is a DUP of #468 or if it was a deprecation problem fixed by #356.

@maxvalle - #356 has been merged so please try the latest PortAudio and building using an older SDK and then running on Big Sur. That works for me. If it works for you then we can close this.

@philburk
Copy link
Collaborator

I got the same error in #468 so I am closing this as a DUP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src-coreaudio Apple Core Audio Host API src/hostapi/coreaudio
Projects
None yet
Development

No branches or pull requests

4 participants