From 89383cff1ba5d8a928262fcb4c40382a981c78c8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 11 Jun 2021 04:51:03 +0200 Subject: Remove dependency on youtube-dl for streaming youtube, resulting in faster video startup --- include/AsyncImageLoader.hpp | 6 +++--- include/MessageQueue.hpp | 1 + include/Program.hpp | 1 + include/StringUtils.hpp | 1 + include/VideoPlayer.hpp | 5 +++-- 5 files changed, 9 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/AsyncImageLoader.hpp b/include/AsyncImageLoader.hpp index 7fe7c07..689ec5f 100644 --- a/include/AsyncImageLoader.hpp +++ b/include/AsyncImageLoader.hpp @@ -3,12 +3,12 @@ #include "../include/Storage.hpp" #include "../include/MessageQueue.hpp" #include "../include/FileAnalyzer.hpp" +#include "../include/AsyncTask.hpp" #include #include #include #include #include -#include #include namespace QuickMedia { @@ -67,8 +67,8 @@ namespace QuickMedia { private: bool loading_image[NUM_IMAGE_LOAD_THREADS]; // TODO: Use curl single-threaded multi-download feature instead - std::thread download_image_thread[NUM_IMAGE_LOAD_THREADS]; - std::thread load_image_thread; + AsyncTask download_image_thread[NUM_IMAGE_LOAD_THREADS]; + AsyncTask load_image_thread; MessageQueue image_load_queue; std::unordered_map> thumbnails; size_t counter = 0; diff --git a/include/MessageQueue.hpp b/include/MessageQueue.hpp index 3f38ca2..30826f4 100644 --- a/include/MessageQueue.hpp +++ b/include/MessageQueue.hpp @@ -44,6 +44,7 @@ namespace QuickMedia { void close() { std::unique_lock lock(mutex); running = false; + data_queue.clear(); cv.notify_one(); } diff --git a/include/Program.hpp b/include/Program.hpp index 82c912a..f164180 100644 --- a/include/Program.hpp +++ b/include/Program.hpp @@ -41,5 +41,6 @@ int exec_program_async(const char **args, pid_t *result_process_id); void program_clear_current_thread(); void program_kill_in_thread(const std::thread::id &thread_id); +bool program_is_dead_in_current_thread(); #endif /* QUICKMEDIA_PROGRAM_HPP */ diff --git a/include/StringUtils.hpp b/include/StringUtils.hpp index 8a94d2f..cd18366 100644 --- a/include/StringUtils.hpp +++ b/include/StringUtils.hpp @@ -7,6 +7,7 @@ namespace QuickMedia { // Return false to stop iterating using StringSplitCallback = std::function; + void string_split(const std::string &str, const std::string &delimiter, StringSplitCallback callback_func); void string_split(const std::string &str, char delimiter, StringSplitCallback callback_func); // Returns the number of replaced substrings size_t string_replace_all(std::string &str, char old_char, char new_char); diff --git a/include/VideoPlayer.hpp b/include/VideoPlayer.hpp index 1d15aff..341c686 100644 --- a/include/VideoPlayer.hpp +++ b/include/VideoPlayer.hpp @@ -40,7 +40,8 @@ namespace QuickMedia { VideoPlayer(const VideoPlayer&) = delete; VideoPlayer& operator=(const VideoPlayer&) = delete; - Error load_video(const char *path, sf::WindowHandle parent_window, const std::string &plugin_name, const std::string &title); + // |audio_path| is only set when video and audio are separate files/urls + Error load_video(const char *path, const char *audio_path, sf::WindowHandle parent_window, const std::string &plugin_name, const std::string &title); // Should be called every update frame Error update(); @@ -55,7 +56,7 @@ namespace QuickMedia { int exit_status; private: Error send_command(const char *cmd, size_t size); - Error launch_video_process(const char *path, sf::WindowHandle parent_window, const std::string &plugin_name, const std::string &title); + Error launch_video_process(const char *path, const char *audio_path, sf::WindowHandle parent_window, const std::string &plugin_name, const std::string &title); VideoPlayer::Error read_ipc_func(); private: bool no_video; -- cgit v1.2.3