diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-06-11 04:51:03 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-06-11 04:51:03 +0200 |
commit | 89383cff1ba5d8a928262fcb4c40382a981c78c8 (patch) | |
tree | da8b6062cc6770fd37e7a6f7b8c09fb61f46f7b2 /include | |
parent | 5b3becc79461d4ecf015e33515871cc09e26e04e (diff) |
Remove dependency on youtube-dl for streaming youtube, resulting in faster video startup
Diffstat (limited to 'include')
-rw-r--r-- | include/AsyncImageLoader.hpp | 6 | ||||
-rw-r--r-- | include/MessageQueue.hpp | 1 | ||||
-rw-r--r-- | include/Program.hpp | 1 | ||||
-rw-r--r-- | include/StringUtils.hpp | 1 | ||||
-rw-r--r-- | include/VideoPlayer.hpp | 5 |
5 files changed, 9 insertions, 5 deletions
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 <SFML/System/Vector2.hpp> #include <SFML/Graphics/Texture.hpp> #include <SFML/System/Clock.hpp> #include <string> #include <memory> -#include <thread> #include <unordered_map> 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<void> download_image_thread[NUM_IMAGE_LOAD_THREADS]; + AsyncTask<void> load_image_thread; MessageQueue<ThumbnailLoadData> image_load_queue; std::unordered_map<std::string, std::shared_ptr<ThumbnailData>> 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<std::mutex> 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<bool(const char *str, size_t size)>; + 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; |