summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vrplayer/mainwindow.cpp2
-rw-r--r--vrplayer/mediapacket.cpp3
-rw-r--r--vrplayer/playaudio.cpp2
-rw-r--r--vrplayer/playvideo.cpp99
4 files changed, 58 insertions, 48 deletions
diff --git a/vrplayer/mainwindow.cpp b/vrplayer/mainwindow.cpp
index 2d9baa34..43060746 100644
--- a/vrplayer/mainwindow.cpp
+++ b/vrplayer/mainwindow.cpp
@@ -312,6 +312,8 @@ void MainWindow::onMediaDurationInSeconds(int duration)
int secs = 0;
char buf[20];
+//return;
+
/* setup progress bar */
slider->setMinimum(0);
slider->setMaximum(duration * 100); /* in hundredth of a sec */
diff --git a/vrplayer/mediapacket.cpp b/vrplayer/mediapacket.cpp
index c9c2b128..c2828145 100644
--- a/vrplayer/mediapacket.cpp
+++ b/vrplayer/mediapacket.cpp
@@ -2,4 +2,7 @@
MediaPacket::MediaPacket()
{
+ av_pkt = 0;
+ delay_in_us = 0;
+ seq = 0;
}
diff --git a/vrplayer/playaudio.cpp b/vrplayer/playaudio.cpp
index 0e4ad4ae..bab7d38b 100644
--- a/vrplayer/playaudio.cpp
+++ b/vrplayer/playaudio.cpp
@@ -62,8 +62,8 @@ label1:
sendMutex->lock();
send_audio_pkt(channel, stream_id, pkt->av_pkt);
sendMutex->unlock();
- delete pkt;
usleep(pkt->delay_in_us);
+ delete pkt;
}
}
diff --git a/vrplayer/playvideo.cpp b/vrplayer/playvideo.cpp
index afb70c71..40ddbf29 100644
--- a/vrplayer/playvideo.cpp
+++ b/vrplayer/playvideo.cpp
@@ -22,76 +22,81 @@ PlayVideo::PlayVideo(QObject *parent,
void PlayVideo::play()
{
MediaPacket *pkt;
+ int usl;
while (1)
{
vcrMutex.lock();
switch (vcrFlag)
{
- case VCR_PLAY:
- vcrFlag = 0;
- vcrMutex.unlock();
- if (pausedTime)
- {
- elapsedTime = av_gettime() - pausedTime;
- pausedTime = 0;
- }
- isStopped = false;
- continue;
- break;
-
- case VCR_PAUSE:
- vcrMutex.unlock();
- if (!pausedTime)
- {
- /* save amount of video played so far */
- pausedTime = av_gettime() - elapsedTime;
- }
- usleep(1000 * 100);
- isStopped = false;
- continue;
- break;
-
- case VCR_STOP:
- vcrMutex.unlock();
- if (isStopped)
- {
+ case VCR_PLAY:
+ vcrFlag = 0;
+ vcrMutex.unlock();
+ if (pausedTime)
+ {
+ elapsedTime = av_gettime() - pausedTime;
+ pausedTime = 0;
+ }
+ isStopped = false;
+ continue;
+ break;
+
+ case VCR_PAUSE:
+ vcrMutex.unlock();
+ if (!pausedTime)
+ {
+ /* save amount of video played so far */
+ pausedTime = av_gettime() - elapsedTime;
+ }
usleep(1000 * 100);
+ isStopped = false;
continue;
- }
- clearVideoQ();
- elapsedTime = 0;
- pausedTime = 0;
- la_seekPos = -1;
- xrdpvr_seek_media(0, 0);
- isStopped = true;
- continue;
- break;
+ break;
+
+ case VCR_STOP:
+ vcrMutex.unlock();
+ if (isStopped)
+ {
+ usleep(1000 * 100);
+ continue;
+ }
+ clearVideoQ();
+ elapsedTime = 0;
+ pausedTime = 0;
+ la_seekPos = -1;
+ xrdpvr_seek_media(0, 0);
+ isStopped = true;
+ continue;
+ break;
- default:
- vcrMutex.unlock();
- goto label1;
- break;
+ default:
+ vcrMutex.unlock();
+ goto label1;
+ break;
}
label1:
if (videoQueue->isEmpty())
{
- qDebug() << "PlayVideo::play: GOT EMPTY";
- usleep(1000 * 100);
continue;
}
-
pkt = videoQueue->dequeue();
sendMutex->lock();
send_video_pkt(channel, stream_id, pkt->av_pkt);
sendMutex->unlock();
+ usl = pkt->delay_in_us;
+ if (usl < 0)
+ {
+ usl = 0;
+ }
+ if (usl > 100 * 1000)
+ {
+ usl = 100 * 1000;
+ }
+ usleep(usl);
delete pkt;
- usleep(pkt->delay_in_us);
-
updateMediaPos();
-
if (elapsedTime == 0)
elapsedTime = av_gettime();