mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 23:35:55 +00:00
Add SLAudio renderer for Steam Link
This commit is contained in:
parent
2bf3f1b94b
commit
b7116657d9
30
app/app.pro
30
app/app.pro
@ -60,15 +60,21 @@ macx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unix:!macx {
|
unix:!macx {
|
||||||
CONFIG += link_pkgconfig soundio
|
CONFIG += link_pkgconfig
|
||||||
PKGCONFIG += openssl sdl2 SDL2_ttf opus
|
PKGCONFIG += openssl sdl2 SDL2_ttf opus
|
||||||
|
|
||||||
# For libsoundio
|
# SLAudio is used on Steam Link
|
||||||
packagesExist(libpulse) {
|
!config_SL {
|
||||||
PKGCONFIG += libpulse
|
CONFIG += soundio
|
||||||
}
|
}
|
||||||
packagesExist(alsa) {
|
|
||||||
PKGCONFIG += alsa
|
soundio {
|
||||||
|
packagesExist(libpulse) {
|
||||||
|
PKGCONFIG += libpulse
|
||||||
|
}
|
||||||
|
packagesExist(alsa) {
|
||||||
|
PKGCONFIG += alsa
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
packagesExist(libavcodec) {
|
packagesExist(libavcodec) {
|
||||||
@ -208,13 +214,15 @@ libvdpau {
|
|||||||
config_SL {
|
config_SL {
|
||||||
message(Steam Link build configuration selected)
|
message(Steam Link build configuration selected)
|
||||||
|
|
||||||
DEFINES += STEAM_LINK HAVE_SLVIDEO
|
DEFINES += STEAM_LINK HAVE_SLVIDEO HAVE_SLAUDIO
|
||||||
LIBS += -lSLVideo
|
LIBS += -lSLVideo -lSLAudio
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
streaming/video/slvid.cpp
|
streaming/video/slvid.cpp \
|
||||||
|
streaming/audio/renderers/slaud.cpp
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
streaming/video/slvid.h
|
streaming/video/slvid.h \
|
||||||
|
streaming/audio/renderers/slaud.h
|
||||||
}
|
}
|
||||||
win32:!winrt {
|
win32:!winrt {
|
||||||
message(DXVA2 renderer selected)
|
message(DXVA2 renderer selected)
|
||||||
@ -270,7 +278,7 @@ else:unix: LIBS += -L$$OUT_PWD/../qmdnsengine/ -lqmdnsengine
|
|||||||
INCLUDEPATH += $$PWD/../qmdnsengine/qmdnsengine/src/include $$PWD/../qmdnsengine
|
INCLUDEPATH += $$PWD/../qmdnsengine/qmdnsengine/src/include $$PWD/../qmdnsengine
|
||||||
DEPENDPATH += $$PWD/../qmdnsengine/qmdnsengine/src/include $$PWD/../qmdnsengine
|
DEPENDPATH += $$PWD/../qmdnsengine/qmdnsengine/src/include $$PWD/../qmdnsengine
|
||||||
|
|
||||||
!winrt {
|
soundio {
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../soundio/release/ -lsoundio
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../soundio/release/ -lsoundio
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../soundio/debug/ -lsoundio
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../soundio/debug/ -lsoundio
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../soundio/ -lsoundio
|
else:unix: LIBS += -L$$OUT_PWD/../soundio/ -lsoundio
|
||||||
|
@ -5,18 +5,24 @@
|
|||||||
#include "renderers/soundioaudiorenderer.h"
|
#include "renderers/soundioaudiorenderer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SLAUDIO
|
||||||
|
#include "renderers/slaud.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "renderers/sdl.h"
|
#include "renderers/sdl.h"
|
||||||
|
|
||||||
#include <Limelight.h>
|
#include <Limelight.h>
|
||||||
|
|
||||||
IAudioRenderer* Session::createAudioRenderer()
|
IAudioRenderer* Session::createAudioRenderer()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOUNDIO
|
#if defined(HAVE_SOUNDIO)
|
||||||
if (qgetenv("ML_AUDIO") == "SDL") {
|
if (qgetenv("ML_AUDIO") == "SDL") {
|
||||||
return new SdlAudioRenderer();
|
return new SdlAudioRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SoundIoAudioRenderer();
|
return new SoundIoAudioRenderer();
|
||||||
|
#elif defined(HAVE_SLAUDIO)
|
||||||
|
return new SLAudioRenderer();
|
||||||
#else
|
#else
|
||||||
return new SdlAudioRenderer();
|
return new SdlAudioRenderer();
|
||||||
#endif
|
#endif
|
||||||
|
58
app/streaming/audio/renderers/slaud.cpp
Normal file
58
app/streaming/audio/renderers/slaud.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#include "slaud.h"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
SLAudioRenderer::SLAudioRenderer()
|
||||||
|
: m_AudioContext(nullptr),
|
||||||
|
m_AudioStream(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SLAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* opusConfig)
|
||||||
|
{
|
||||||
|
m_AudioContext = SLAudio_CreateContext();
|
||||||
|
if (m_AudioContext == nullptr) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"SLAudio_CreateContext() failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_AudioStream = SLAudio_CreateStream(m_AudioContext,
|
||||||
|
opusConfig->sampleRate,
|
||||||
|
opusConfig->channelCount,
|
||||||
|
SAMPLES_PER_FRAME * sizeof(short) * opusConfig->channelCount,
|
||||||
|
1);
|
||||||
|
if (m_AudioStream == nullptr) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"SLAudio_CreateStream() failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Using SLAudio renderer");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SLAudioRenderer::~SLAudioRenderer()
|
||||||
|
{
|
||||||
|
if (m_AudioStream != nullptr) {
|
||||||
|
SLAudio_FreeStream(m_AudioStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_AudioContext != nullptr) {
|
||||||
|
SLAudio_FreeContext(m_AudioContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SLAudioRenderer::submitAudio(short* audioBuffer, int audioSize)
|
||||||
|
{
|
||||||
|
void* outputBuffer = SLAudio_BeginFrame(m_AudioStream);
|
||||||
|
|
||||||
|
if (outputBuffer != nullptr) {
|
||||||
|
memcpy(outputBuffer, audioBuffer, audioSize);
|
||||||
|
SLAudio_SubmitFrame(m_AudioStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
20
app/streaming/audio/renderers/slaud.h
Normal file
20
app/streaming/audio/renderers/slaud.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "renderer.h"
|
||||||
|
#include <SLAudio.h>
|
||||||
|
|
||||||
|
class SLAudioRenderer : public IAudioRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SLAudioRenderer();
|
||||||
|
|
||||||
|
virtual ~SLAudioRenderer();
|
||||||
|
|
||||||
|
virtual bool prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* opusConfig);
|
||||||
|
|
||||||
|
virtual bool submitAudio(short* audioBuffer, int audioSize);
|
||||||
|
|
||||||
|
private:
|
||||||
|
CSLAudioContext* m_AudioContext;
|
||||||
|
CSLAudioStream* m_AudioStream;
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user