mirror of
https://github.com/thinkonmay/sunshine-sdk.git
synced 2026-01-10 07:12:04 +00:00
build with audio
This commit is contained in:
parent
5fed2d6798
commit
f359cf178e
@ -43,6 +43,8 @@ set(SUNSHINE_TARGET_FILES
|
||||
src/dll.cpp
|
||||
src/video.cpp
|
||||
src/video.h
|
||||
src/audio.h
|
||||
src/audio.cpp
|
||||
src/video_colorspace.cpp
|
||||
src/video_colorspace.h
|
||||
src/platform/common.h
|
||||
|
||||
@ -202,6 +202,7 @@ list(APPEND PLATFORM_TARGET_FILES
|
||||
src/platform/linux/misc.cpp
|
||||
src/platform/linux/x11grab.h
|
||||
src/platform/linux/wayland.h
|
||||
src/platform/linux/audio.cpp
|
||||
third-party/glad/src/egl.c
|
||||
third-party/glad/src/gl.c
|
||||
third-party/glad/include/EGL/eglplatform.h
|
||||
|
||||
@ -23,6 +23,7 @@ configure_file(src/platform/windows/windows.rs.in windows.rc @ONLY)
|
||||
set(PLATFORM_TARGET_FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/windows.rc"
|
||||
src/platform/windows/misc.h
|
||||
src/platform/windows/audio.cpp
|
||||
src/platform/windows/misc.cpp
|
||||
src/platform/windows/display.h
|
||||
src/platform/windows/display_base.cpp
|
||||
|
||||
@ -93,8 +93,8 @@ namespace audio {
|
||||
auto control_shared = safe::make_shared<audio_ctx_t>(start_audio_control, stop_audio_control);
|
||||
|
||||
void
|
||||
encodeThread(sample_queue_t samples, config_t config, void *channel_data) {
|
||||
auto packets = mail::man->queue<packet_t>(mail::audio_packets);
|
||||
encodeThread(safe::mail_t mail, sample_queue_t samples, config_t config, void *channel_data) {
|
||||
auto packets = mail->queue<packet_t>(mail::audio_packets);
|
||||
auto stream = &stream_configs[map_stream(config.channels, config.flags[config_t::HIGH_QUALITY])];
|
||||
|
||||
// Encoding takes place on this thread
|
||||
@ -201,7 +201,7 @@ namespace audio {
|
||||
platf::adjust_thread_priority(platf::thread_priority_e::critical);
|
||||
|
||||
auto samples = std::make_shared<sample_queue_t::element_type>(30);
|
||||
std::thread thread { encodeThread, samples, config, channel_data };
|
||||
std::thread thread { encodeThread, mail , samples, config, channel_data };
|
||||
|
||||
auto fg = util::fail_guard([&]() {
|
||||
samples->stop();
|
||||
|
||||
18
src/dll.cpp
18
src/dll.cpp
@ -16,24 +16,23 @@
|
||||
#include "main.h"
|
||||
#include "platform/common.h"
|
||||
#include "video.h"
|
||||
#include "audio.h"
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
struct _VideoPipeline {
|
||||
std::chrono::steady_clock::time_point start;
|
||||
video::config_t monitor;
|
||||
audio::config_t soundcard;
|
||||
safe::mail_t mail;
|
||||
};
|
||||
|
||||
extern VideoPipeline *__cdecl StartQueue(int video_codec) {
|
||||
static bool init = false;
|
||||
if (!init) {
|
||||
// If any of the following fail, we log an error and continue event
|
||||
// though sunshine will not function correctly. This allows access to
|
||||
// the UI to fix configuration problems or view the logs.
|
||||
if (platf::init()) {
|
||||
auto deinit_guard = platf::init();
|
||||
if (!deinit_guard) {
|
||||
BOOST_LOG(error) << "Platform failed to initialize"sv;
|
||||
return NULL;
|
||||
} else if (video::probe_encoders()) {
|
||||
BOOST_LOG(error) << "Video failed to find working encoder"sv;
|
||||
return NULL;
|
||||
@ -44,6 +43,7 @@ extern VideoPipeline *__cdecl StartQueue(int video_codec) {
|
||||
static VideoPipeline pipeline = {};
|
||||
pipeline.mail = std::make_shared<safe::mail_raw_t>();
|
||||
pipeline.monitor = {1920, 1080, 60, 6000, 1, 0, 1, 0, 0};
|
||||
pipeline.soundcard = {5,2,audio::config_t::HIGH_QUALITY};
|
||||
pipeline.start = std::chrono::steady_clock::now();
|
||||
|
||||
switch (video_codec) {
|
||||
@ -67,9 +67,13 @@ extern VideoPipeline *__cdecl StartQueue(int video_codec) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto thread = std::thread{
|
||||
auto video = std::thread{
|
||||
[&]() { video::capture(pipeline.mail, pipeline.monitor, NULL); }};
|
||||
thread.detach();
|
||||
video.detach();
|
||||
|
||||
auto audio = std::thread{
|
||||
[&]() { audio::capture(pipeline.mail, pipeline.soundcard, NULL); }};
|
||||
audio.detach();
|
||||
|
||||
return &pipeline;
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ namespace mail {
|
||||
|
||||
// queue
|
||||
MAIL(video_packets);
|
||||
MAIL(audio_packets);
|
||||
|
||||
// event
|
||||
MAIL(shutdown);
|
||||
|
||||
@ -512,5 +512,5 @@ enum class qos_data_type_e : int { audio, video };
|
||||
|
||||
typedef deinit_t client_input_t;
|
||||
|
||||
bool init();
|
||||
std::unique_ptr<deinit_t> init();
|
||||
} // namespace platf
|
||||
|
||||
@ -421,10 +421,4 @@ std::chrono::nanoseconds qpc_time_difference(int64_t performance_counter1,
|
||||
return {};
|
||||
}
|
||||
|
||||
// It's not big enough to justify it's own source file :/
|
||||
namespace dxgi {
|
||||
int init();
|
||||
}
|
||||
|
||||
bool init() { return dxgi::init() != 0; }
|
||||
} // namespace platf
|
||||
|
||||
Loading…
Reference in New Issue
Block a user