Skip to content

Commit

Permalink
Metal tvOS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Oct 29, 2024
1 parent f1eab4e commit 2885038
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 16 deletions.
6 changes: 4 additions & 2 deletions app/src/streaming/ffmpeg/FFmpegVideoDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ int FFmpegVideoDecoder::setup(int video_format, int width, int height,

if (Settings::instance().use_hw_decoding() && hwType != AV_HWDEVICE_TYPE_NONE) {
if ((err = av_hwdevice_ctx_create(&hw_device_ctx, hwType, NULL, NULL, 0)) < 0) {
brls::Logger::error("FFmpeg: Error initializing hardware decoder - {}", err);
char error[512];
av_strerror(err, error, sizeof(error));
brls::Logger::error("FFmpeg: Error initializing hardware decoder - {}", error);
return -1;
}
m_decoder_context->hw_device_ctx = av_buffer_ref(hw_device_ctx);
Expand Down Expand Up @@ -366,7 +368,7 @@ AVFrame* FFmpegVideoDecoder::get_frame(bool native_frame) {
}

if (hw_device_ctx) {
#if defined(BOREALIS_USE_DEKO3D) || defined(PLATFORM_ANDROID) || defined(PLATFORM_IOS)
#if defined(BOREALIS_USE_DEKO3D) || defined(PLATFORM_ANDROID) || defined(PLATFORM_APPLE)
// DEKO decoder will work with hardware frame
// Android already produce software Frame
resultFrame = decodeFrame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#ifdef BOREALIS_USE_DEKO3D
#include "DKVideoRenderer.hpp"
#elif defined(PLATFORM_IOS)
#elif defined(PLATFORM_APPLE)
#include "MetalVideoRenderer.hpp"
#else
#include "GLVideoRenderer.hpp"
Expand All @@ -24,7 +24,7 @@ IVideoRenderer*
SwitchMoonlightSessionDecoderAndRenderProvider::video_renderer() {
#ifdef BOREALIS_USE_DEKO3D
return new DKVideoRenderer();
#elif defined(PLATFORM_IOS)
#elif defined(PLATFORM_APPLE)
return new MetalVideoRenderer();
#else
return new GLVideoRenderer();
Expand Down
2 changes: 1 addition & 1 deletion app/src/streaming/video/Metal/MetalVideoRenderer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#if defined(PLATFORM_IOS)
#if defined(PLATFORM_APPLE)

#include "IVideoRenderer.hpp"
#include <SDL2/SDL.h>
Expand Down
4 changes: 3 additions & 1 deletion app/src/streaming/video/Metal/MetalVideoRenderer.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if defined(PLATFORM_IOS)
#if defined(PLATFORM_APPLE)

#define AVMediaType AVMediaType_FFmpeg
//#include <libavutil/pixdesc.h>
Expand Down Expand Up @@ -532,9 +532,11 @@ int getBitnessScaleFactor(AVFrame* frame) {
m_MetalLayer.device = device;

// Allow EDR content if we're streaming in a 10-bit format
#if defined(PLATFORM_IOS)
if (@available(iOS 16.0, *)) {
m_MetalLayer.wantsExtendedDynamicRangeContent = imageFormat & VIDEO_FORMAT_MASK_10BIT;
}
#endif

// Ideally, we don't actually want triple buffering due to increased
// display latency, since our render time is very short. However, we
Expand Down
8 changes: 4 additions & 4 deletions app/src/streaming_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ void setBottomBarStatus(const char *value) {
StreamingView::StreamingView(const Host& host, const AppInfo& app) : host(host), app(app) {
Application::getPlatform()->disableScreenDimming(true);

#ifdef PLATFORM_TVOS
updatePreferredDisplayMode(true);
#endif

setFocusable(true);
setHideHighlight(true);
loader = new LoadingOverlay(this);
Expand Down Expand Up @@ -67,6 +63,10 @@ StreamingView::StreamingView(const Host& host, const AppInfo& app) : host(host),
loader->setHidden(true);
if (!result.isSuccess()) {
showError(result.error(), [this]() { terminate(false); });
} else {
#ifdef PLATFORM_TVOS
updatePreferredDisplayMode(true);
#endif
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion extern/borealis
2 changes: 1 addition & 1 deletion extern/vcpkg
Submodule vcpkg updated 1 files
+1 −1 versions/f-/ffmpeg.json
4 changes: 2 additions & 2 deletions vcpkg-android.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
],
"overrides": [
{ "name": "ffmpeg", "version": "7.0.2" },
{ "name": "curl", "version": "8.7.1" }
{ "name": "ffmpeg", "version": "7.0.2" },
{ "name": "curl", "version": "8.7.1" }
]
}
4 changes: 2 additions & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "moonlight",
"builtin-baseline": "d89b9ba126a575ec4f8387188878fdd1b696288d",
"builtin-baseline": "2de6b07379e32daf149ae46c1e315fe180008d51",
"version": "1.0",
"dependencies": [
{
Expand All @@ -17,7 +17,7 @@
"mbedtls"
],
"overrides": [
{ "name": "ffmpeg", "version": "7.0.2" },
{"name": "mbedtls", "version": "2.28.8"},
{ "name": "curl", "version": "8.7.1" }
]
}

0 comments on commit 2885038

Please sign in to comment.