diff --git a/include/FFmpegReader.h b/include/FFmpegReader.h index b92daffa..71b6750a 100644 --- a/include/FFmpegReader.h +++ b/include/FFmpegReader.h @@ -29,6 +29,7 @@ extern "C" { #include "Magick++.h" #include "Cache.h" #include "Exceptions.h" +#include "Sleep.h" using namespace std; diff --git a/include/FFmpegWriter.h b/include/FFmpegWriter.h index d3ea5f62..628d24e3 100644 --- a/include/FFmpegWriter.h +++ b/include/FFmpegWriter.h @@ -38,6 +38,7 @@ extern "C" { #include "Magick++.h" #include "Cache.h" #include "Exceptions.h" +#include "Sleep.h" using namespace std; diff --git a/include/Frame.h b/include/Frame.h index acd3a4fa..6daa8c69 100644 --- a/include/Frame.h +++ b/include/Frame.h @@ -22,6 +22,7 @@ #include "AudioBufferSource.h" #include "AudioResampler.h" #include "Fraction.h" +#include "Sleep.h" using namespace std; diff --git a/include/OpenShot.h b/include/OpenShot.h index 743cc314..f3a49679 100644 --- a/include/OpenShot.h +++ b/include/OpenShot.h @@ -48,6 +48,7 @@ #include "KeyFrame.h" #include "Player.h" #include "Point.h" +#include "Sleep.h" #include "TextReader.h" #include "Timeline.h" diff --git a/include/Sleep.h b/include/Sleep.h new file mode 100644 index 00000000..bf886e52 --- /dev/null +++ b/include/Sleep.h @@ -0,0 +1,11 @@ +#ifndef OPENSHOT_SLEEP_H +#define OPENSHOT_SLEEP_H + + #ifdef _WINDOWS + #include + #else + #include + #define Sleep(x) usleep((x)*1000) + #endif + +#endif diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index c5c5cc54..7f3764a2 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -382,7 +382,7 @@ tr1::shared_ptr FFmpegReader::ReadStream(int requested_frame) // Wait if too many frames are being processed while (processing_video_frames.size() + processing_audio_frames.size() >= minimum_packets) - usleep(1000 * 1); + Sleep(1); // Get the next packet (if any) if (packet_error < 0) diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 91b2affe..310df6d2 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -304,7 +304,7 @@ void FFmpegWriter::WriteFrame(tr1::shared_ptr frame) { // YES, WRITING... so wait until it finishes, before writing again while (is_writing) - usleep(250 * 1000); // sleep for 250 milliseconds + Sleep(1); // sleep for 250 milliseconds // Write frames to video file write_queued_frames(); diff --git a/src/Frame.cpp b/src/Frame.cpp index dc79383f..5f8ccdf8 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -680,7 +680,7 @@ void Frame::Play() while (transport1.isPlaying()) { cout << "playing" << endl; - sleep(1); + Sleep(1); } cout << "DONE!!!" << endl;