Make Input honor should_stop even when it is not connected to an encoder.
[cubemap] / input.cpp
index f9f879b6c2a393f6671b42fb25e4462854e04711..a1b71d618f4beeee42a7ec3431a89991901125ad 100644 (file)
--- a/input.cpp
+++ b/input.cpp
@@ -61,10 +61,15 @@ void *Input::do_work_thunk(void *arg)
 void Input::do_work()
 {
        CURL *curl = curl_easy_init();
-       curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
-       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Input::curl_callback_thunk);
-       curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
-       curl_easy_perform(curl);
+
+       while (!should_stop) {
+               curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+               curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Input::curl_callback_thunk);
+               curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
+               curl_easy_perform(curl);
+               printf("Transfer ended, waiting 0.2 seconds and restarting...\n");
+               usleep(200000);
+       }
 }
 
 size_t Input::curl_callback_thunk(char *ptr, size_t size, size_t nmemb, void *userdata)