aboutsummaryrefslogtreecommitdiff
path: root/src/VideoPlayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VideoPlayer.cpp')
-rw-r--r--src/VideoPlayer.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index 1049bcf..c56981a 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -343,16 +343,9 @@ namespace QuickMedia {
VideoPlayer::Error VideoPlayer::update() {
const int max_retries_find_window = 1000;
- if(video_process_id != -1) {
- if(wait_program_non_blocking(video_process_id, &exit_status)) {
- fprintf(stderr, "The video player exited!, status: %d\n", exit_status);
- close(ipc_socket);
- video_process_id = -1;
- ipc_socket = -1;
- window_handle = None;
- return Error::EXITED;
- }
- }
+ check_if_exited();
+ if(video_process_id == -1)
+ return Error::EXITED;
if(ipc_socket == -1)
return Error::INIT_FAILED;
@@ -413,6 +406,10 @@ namespace QuickMedia {
std::unique_ptr<Json::CharReader> json_reader(json_builder.newCharReader());
std::string json_errors;
+ check_if_exited();
+ if(video_process_id == -1)
+ return Error::EXITED;
+
char buffer[2048];
ssize_t bytes_read = read_eintr(ipc_socket, buffer, sizeof(buffer));
if(bytes_read == -1) {
@@ -461,6 +458,19 @@ namespace QuickMedia {
return Error::OK;
}
+ void VideoPlayer::check_if_exited() {
+ if(video_process_id == -1)
+ return;
+
+ if(wait_program_non_blocking(video_process_id, &exit_status)) {
+ fprintf(stderr, "The video player exited!, status: %d\n", exit_status);
+ close(ipc_socket);
+ video_process_id = -1;
+ ipc_socket = -1;
+ window_handle = None;
+ }
+ }
+
VideoPlayer::Error VideoPlayer::get_time_in_file(double *result_seconds) {
Json::Value json_root(Json::objectValue);
json_root["command"] = "time-pos";