mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-04-23 08:29:09 +00:00
Remove IAudioRenderer::testAudio() and just use IAudioRenderer::prepareForPlayback() instead
This commit is contained in:
@@ -109,69 +109,6 @@ void PortAudioRenderer::submitAudio(short* audioBuffer, int audioSize)
|
||||
}
|
||||
}
|
||||
|
||||
bool PortAudioRenderer::testAudio(int audioConfiguration) const
|
||||
{
|
||||
PaStreamParameters params = {};
|
||||
|
||||
PaDeviceIndex outputDeviceIndex = Pa_GetDefaultOutputDevice();
|
||||
if (outputDeviceIndex == paNoDevice) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"No output device available");
|
||||
return false;
|
||||
}
|
||||
|
||||
const PaDeviceInfo* deviceInfo = Pa_GetDeviceInfo(outputDeviceIndex);
|
||||
if (deviceInfo == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Pa_GetDeviceInfo() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (audioConfiguration)
|
||||
{
|
||||
case AUDIO_CONFIGURATION_STEREO:
|
||||
params.channelCount = 2;
|
||||
break;
|
||||
case AUDIO_CONFIGURATION_51_SURROUND:
|
||||
params.channelCount = 6;
|
||||
break;
|
||||
default:
|
||||
SDL_assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
params.sampleFormat = paInt16;
|
||||
params.device = outputDeviceIndex;
|
||||
params.suggestedLatency = deviceInfo->defaultLowOutputLatency;
|
||||
|
||||
// We used to just use Pa_IsFormatSupported() but there are cases
|
||||
// where Pa_IsFormatSupported() will fail but when we actually
|
||||
// call Pa_OpenStream(), it fails with device unavailable.
|
||||
PaStream* stream;
|
||||
PaError error = Pa_OpenStream(&stream, nullptr, ¶ms,
|
||||
48000,
|
||||
SAMPLES_PER_FRAME,
|
||||
paNoFlag,
|
||||
nullptr, nullptr);
|
||||
if (error != paNoError) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Pa_OpenStream() failed: %s",
|
||||
Pa_GetErrorText(error));
|
||||
return false;
|
||||
}
|
||||
|
||||
error = Pa_StartStream(stream);
|
||||
if (error != paNoError) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Pa_StartStream() failed: %s",
|
||||
Pa_GetErrorText(error));
|
||||
}
|
||||
|
||||
Pa_CloseStream(stream);
|
||||
|
||||
return error == paNoError;
|
||||
}
|
||||
|
||||
int PortAudioRenderer::detectAudioConfiguration() const
|
||||
{
|
||||
const PaDeviceInfo* deviceInfo = Pa_GetDeviceInfo(Pa_GetDefaultOutputDevice());
|
||||
|
||||
Reference in New Issue
Block a user