diff options
-rw-r--r-- | include/Utils.hpp | 1 | ||||
-rw-r--r-- | src/Utils.cpp | 11 | ||||
-rw-r--r-- | src/VideoPlayer.cpp | 17 | ||||
-rw-r--r-- | src/plugins/Matrix.cpp | 4 |
4 files changed, 25 insertions, 8 deletions
diff --git a/include/Utils.hpp b/include/Utils.hpp index 4a93109..206ee38 100644 --- a/include/Utils.hpp +++ b/include/Utils.hpp @@ -7,5 +7,6 @@ namespace QuickMedia { void show_virtual_keyboard(); void hide_virtual_keyboard(); bool is_touch_enabled(); + bool is_running_wayland(); time_t iso_utc_to_unix_time(const char *time_str); }
\ No newline at end of file diff --git a/src/Utils.cpp b/src/Utils.cpp index 7ed6574..3da045e 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -9,6 +9,8 @@ namespace QuickMedia { static bool scale_set = false; static bool qm_enable_touch = false; static bool qm_enable_touch_set = false; + static bool wayland_display_set = false; + static const char *wayland_display = nullptr; static const int XFT_DPI_DEFAULT = 96; // Returns 96 on error @@ -86,6 +88,15 @@ namespace QuickMedia { return qm_enable_touch; } + bool is_running_wayland() { + if(wayland_display_set) + return wayland_display; + + wayland_display = getenv("WAYLAND_DISPLAY"); + wayland_display_set = true; + return wayland_display; + } + time_t iso_utc_to_unix_time(const char *time_str) { int year = 0; int month = 0; diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index fd5ba79..9dbbe85 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -1,6 +1,7 @@ #include "../include/VideoPlayer.hpp" #include "../include/Storage.hpp" #include "../include/Program.hpp" +#include "../include/Utils.hpp" #include <string> #include <json/reader.h> #include <json/writer.h> @@ -97,9 +98,9 @@ namespace QuickMedia { wid_arg += parent_window_str; std::string input_conf = "--input-conf=" + resource_root + "input.conf"; - Path video_cache_dir = get_cache_dir().join("video"); - create_directory_recursive(video_cache_dir); - std::string cache_dir = "--cache-dir=" + video_cache_dir.data; + //Path video_cache_dir = get_cache_dir().join("video"); + //create_directory_recursive(video_cache_dir); + //std::string cache_dir = "--cache-dir=" + video_cache_dir.data; Path mpv_watch_later_dir = get_storage_dir().join("mpv").join("watch_later"); create_directory_recursive(mpv_watch_later_dir); @@ -121,19 +122,23 @@ namespace QuickMedia { "--no-terminal", "--save-position-on-quit=yes", "--profile=pseudo-gui", // For gui when playing audio, requires a version of mpv that isn't ancient - cache_dir.c_str(), + //cache_dir.c_str(), watch_later_dir.c_str(), - "--cache-on-disk=yes", + //"--cache-on-disk=yes", ytdl_format.c_str(), // TODO: Disable hr seek on low power devices? "--hr-seek=yes", - "--gpu-context=x11egl", "--cookies", cookies_file_arg.c_str(), input_conf.c_str(), wid_arg.c_str() }); + if(is_running_wayland()) { + args.push_back("--gpu-context=x11egl"); + fprintf(stderr, "Wayland detected. Launching mpv in x11egl mode\n"); + } + if(keep_open) args.push_back("--keep-open=yes"); diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 3144232..de50049 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -71,12 +71,12 @@ namespace QuickMedia { size_t index = result.find('\n'); if(index == std::string::npos) { if(result.size() > max_length) - return result.substr(0, max_length) + " ..."; + return result.substr(0, max_length) + "..."; return result; } else if(index == 0) { return ""; } else { - return result.substr(0, std::min(index, max_length)) + " ..."; + return result.substr(0, std::min(index, max_length)) + "..."; } } |