Switch back from Qt Multimedia to SDL for audio configuration detection. Qt is also broken, but just broken in a way that always reports stereo
This commit is contained in:
parent
9f0617f6ee
commit
14ec0259df
3 changed files with 30 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
QT += core quick network quickcontrols2 svg multimedia
|
QT += core quick network quickcontrols2 svg
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
unix:!macx {
|
unix:!macx {
|
||||||
|
|
@ -96,7 +96,6 @@ SOURCES += \
|
||||||
streaming/session.cpp \
|
streaming/session.cpp \
|
||||||
streaming/audio/audio.cpp \
|
streaming/audio/audio.cpp \
|
||||||
streaming/audio/renderers/sdlaud.cpp \
|
streaming/audio/renderers/sdlaud.cpp \
|
||||||
streaming/audio/renderers/qtaud.cpp \
|
|
||||||
gui/computermodel.cpp \
|
gui/computermodel.cpp \
|
||||||
gui/appmodel.cpp \
|
gui/appmodel.cpp \
|
||||||
streaming/streamutils.cpp \
|
streaming/streamutils.cpp \
|
||||||
|
|
@ -115,7 +114,6 @@ HEADERS += \
|
||||||
streaming/session.hpp \
|
streaming/session.hpp \
|
||||||
streaming/audio/renderers/renderer.h \
|
streaming/audio/renderers/renderer.h \
|
||||||
streaming/audio/renderers/sdl.h \
|
streaming/audio/renderers/sdl.h \
|
||||||
streaming/audio/renderers/qtaud.h \
|
|
||||||
gui/computermodel.h \
|
gui/computermodel.h \
|
||||||
gui/appmodel.h \
|
gui/appmodel.h \
|
||||||
streaming/video/decoder.h \
|
streaming/video/decoder.h \
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#include "../session.hpp"
|
#include "../session.hpp"
|
||||||
#include "renderers/renderer.h"
|
#include "renderers/renderer.h"
|
||||||
#include "renderers/sdl.h"
|
#include "renderers/sdl.h"
|
||||||
#include "renderers/qtaud.h"
|
|
||||||
|
|
||||||
#include <Limelight.h>
|
#include <Limelight.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#include <Limelight.h>
|
#include <Limelight.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include <QAudioDeviceInfo>
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#define MIN_QUEUED_FRAMES 2
|
#define MIN_QUEUED_FRAMES 2
|
||||||
|
|
@ -11,20 +10,40 @@
|
||||||
#define STOP_THE_WORLD_LIMIT 20
|
#define STOP_THE_WORLD_LIMIT 20
|
||||||
#define DROP_RATIO_DENOM 32
|
#define DROP_RATIO_DENOM 32
|
||||||
|
|
||||||
// Detecting this with SDL is quite problematic, so we'll use Qt's
|
// This isn't accurate on macOS and Linux (PulseAudio),
|
||||||
// multimedia framework to do so. It appears to be actually
|
// since they both report supporting a large number of
|
||||||
// accurate on Linux and macOS, unlike using SDL and relying
|
// channels, regardless of the actual output device.
|
||||||
// on a channel change in the format received.
|
|
||||||
int SdlAudioRenderer::detectAudioConfiguration()
|
int SdlAudioRenderer::detectAudioConfiguration()
|
||||||
{
|
{
|
||||||
int preferredChannelCount = QAudioDeviceInfo::defaultOutputDevice().preferredFormat().channelCount();
|
SDL_AudioSpec want, have;
|
||||||
|
SDL_AudioDeviceID dev;
|
||||||
|
|
||||||
|
SDL_zero(want);
|
||||||
|
want.freq = 48000;
|
||||||
|
want.format = AUDIO_S16;
|
||||||
|
want.channels = 6;
|
||||||
|
want.samples = 1024;
|
||||||
|
|
||||||
|
// Try to open for 5.1 surround sound, but allow SDL to tell us that's
|
||||||
|
// not available.
|
||||||
|
dev = SDL_OpenAudioDevice(NULL, 0, &want, &have, SDL_AUDIO_ALLOW_CHANNELS_CHANGE);
|
||||||
|
if (dev == 0) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Failed to open audio device");
|
||||||
|
// We'll probably have issues during audio stream init, but we'll
|
||||||
|
// try anyway
|
||||||
|
return AUDIO_CONFIGURATION_STEREO;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_CloseAudioDevice(dev);
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Audio output device prefers %d channel configuration",
|
"Audio device has %d channels", have.channels);
|
||||||
preferredChannelCount);
|
|
||||||
|
|
||||||
// We can better downmix 5.1 to quad than we can upmix stereo
|
if (have.channels > 2) {
|
||||||
if (preferredChannelCount > 2) {
|
// We don't support quadraphonic or 7.1 surround, but SDL
|
||||||
|
// should be able to downmix or upmix better from 5.1 than
|
||||||
|
// from stereo, so use 5.1 in non-stereo cases.
|
||||||
return AUDIO_CONFIGURATION_51_SURROUND;
|
return AUDIO_CONFIGURATION_51_SURROUND;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue