summaryrefslogtreecommitdiffstats
path: root/vrplayer/playaudio.cpp
diff options
context:
space:
mode:
authorLaxmikant Rashinkar <lk@maya-vm-64.(none)>2012-12-26 18:48:17 -0800
committerLaxmikant Rashinkar <lk@maya-vm-64.(none)>2012-12-26 18:48:17 -0800
commitcae2adb75e2b339017746436c63f7d2b8c35fb63 (patch)
tree7fa8fc022ef3a52f069332642dc0e9c428c9c94c /vrplayer/playaudio.cpp
parentd1fc67102a273a8e0b170d0c613cf0d611cfa7f8 (diff)
downloadxrdp-proprietary-cae2adb75e2b339017746436c63f7d2b8c35fb63.tar.gz
xrdp-proprietary-cae2adb75e2b339017746436c63f7d2b8c35fb63.zip
o developer checkin
o modified vrplayer to use threads
Diffstat (limited to 'vrplayer/playaudio.cpp')
-rw-r--r--vrplayer/playaudio.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/vrplayer/playaudio.cpp b/vrplayer/playaudio.cpp
new file mode 100644
index 00000000..0e4ad4ae
--- /dev/null
+++ b/vrplayer/playaudio.cpp
@@ -0,0 +1,87 @@
+#include "playaudio.h"
+#include <QDebug>
+
+PlayAudio::PlayAudio(QObject *parent,
+ QQueue<MediaPacket *> *audioQueue,
+ QMutex *sendMutex,
+ void *channel,
+ int stream_id) :
+ QObject(parent)
+{
+ this->audioQueue = audioQueue;
+ this->sendMutex = sendMutex;
+ this->channel = channel;
+ this->stream_id = stream_id;
+ this->vcrFlag = 0;
+}
+
+void PlayAudio::play()
+{
+ MediaPacket *pkt;
+
+ while (1)
+ {
+ vcrMutex.lock();
+ switch (vcrFlag)
+ {
+ case VCR_PLAY:
+ vcrFlag = 0;
+ vcrMutex.unlock();
+ continue;
+ break;
+
+ case VCR_PAUSE:
+ vcrMutex.unlock();
+ usleep(1000 * 100);
+ continue;
+ break;
+
+ case VCR_STOP:
+ vcrMutex.unlock();
+ clearAudioQ();
+ usleep(1000 * 100);
+ continue;
+ break;
+
+ default:
+ vcrMutex.unlock();
+ goto label1;
+ break;
+ }
+
+label1:
+
+ if (audioQueue->isEmpty())
+ {
+ qDebug() << "PlayAudio::play: GOT EMPTY";
+ usleep(1000 * 100);
+ continue;
+ }
+
+ pkt = audioQueue->dequeue();
+ sendMutex->lock();
+ send_audio_pkt(channel, stream_id, pkt->av_pkt);
+ sendMutex->unlock();
+ delete pkt;
+ usleep(pkt->delay_in_us);
+ }
+}
+
+void PlayAudio::setVcrOp(int op)
+{
+ vcrMutex.lock();
+ this->vcrFlag = op;
+ vcrMutex.unlock();
+}
+
+void PlayAudio::clearAudioQ()
+{
+ MediaPacket *pkt;
+
+ while (!audioQueue->isEmpty())
+ {
+ pkt = audioQueue->dequeue();
+ av_free_packet((AVPacket *) pkt->av_pkt);
+ delete pkt;
+ }
+}