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

MacOS: Bluetooth devices change channel count during usage. #394

Open
knell opened this issue Apr 12, 2023 · 2 comments
Open

MacOS: Bluetooth devices change channel count during usage. #394

knell opened this issue Apr 12, 2023 · 2 comments

Comments

@knell
Copy link

knell commented Apr 12, 2023

Hey guys, I'm not sure is it a real issue or my mistake but the situation is the following.
I'm using #define RTAUDIO_VERSION "6.0.0beta1"
I have pretty straitforward code which enumerates the audio devices on start, like:

for (auto i = 0u; i < _dac->getDeviceCount(); i++)
{
	const auto di = _dac->getDeviceInfo(i);
	if (di.probed && di.outputChannels > 0)
	{
		vec.emplace_back(std::make_tuple(i, di.name));
	}
}

next, I start playing incoming stream using the standard code:

const auto out_di = _dac->getDeviceInfo(_current_out_device);
out_params.deviceId     = _current_out_device;
out_params.nChannels    = 2;
out_params.firstChannel = 0;

if (ret = _dac->openStream(&out_params, nullptr, RTAUDIO_SINT16, sampleRate, &bufferFrames, cb, (void *)&uinfo, &opts);
	ret != RtAudioErrorType::RTAUDIO_NO_ERROR)
{ /* ... */ }

if (ret = _dac->startStream(); ret != RtAudioErrorType::RTAUDIO_NO_ERROR)
{
	if (_dac->isStreamOpen())
		_dac->closeStream();
	return false;
}

I'm using bluetooth Sony WH-1000XM3 on MacOS. Before the start the system shows me that the device is 2ch 48kHz, after start the device switches to the 1ch 48kHz after enumeration. When start the stream I have a pretty weird state then:

image

The RtAudio still thinks the we have 1ch 48kHz but in the system it's 1ch 16kHz and the sound is distorted. After I close the app the device gets back to 2ch 48kHz. The same situation is with AirPods, it changes channels count in runtime during using RtAudio. But after a couple of reconnecting of the device (on dis/connect I have a watcher wich makes the same procedure like enumerate and restart the stream) at somepoint it matches the proper channels/samplerate and sounds properly.

@garyscavone
Copy link
Contributor

I would try with the version 6.0.0 beta1. From my own experience, AirPods run at 16 kHz and they are reported that way on my OS-X system.

@darbyjohnston
Copy link

Hi, I'm having a similar issue, and can reproduce it with one of the RtAudio test apps:

  • Start the test app: playsaw 2 44100
  • Set audio output to Bluetooth headphones
  • Open the macOS Sound settings and change the "Output" tab to "Input"

When the tab changes the audio becomes very distorted. It also looks like the number of channels is changing. If I change back to the "Output" tab it seems to go back to normal after a bit. I tried this with RtAudio 5.2.0 and 6.0.1, on macOS Ventura.

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

No branches or pull requests

3 participants