From 606c3e1c6ddef9f1ec15ca382acf41490931bf59 Mon Sep 17 00:00:00 2001 From: Duzy Chan Date: Tue, 11 Feb 2014 15:53:19 +0800 Subject: [PATCH] combine audio and video playback --- README | 2 +- src/AudioReaderSource.cpp | 2 +- src/Qt/AudioPlaybackThread.cpp | 6 ++---- src/Qt/PlayerPrivate.cpp | 17 +++++++++-------- src/Qt/PlayerPrivate.h | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/README b/README index 43f11f6c..1ead1390 100644 --- a/README +++ b/README @@ -42,4 +42,4 @@ Please see AUTHORS file for a full list of authors. www.openshot.org | www.openshotstudios.com #################################################################### - Copyright (c) 2008-2013 OpenShot Studios, LLC \ No newline at end of file + Copyright (c) 2008-2013 OpenShot Studios, LLC diff --git a/src/AudioReaderSource.cpp b/src/AudioReaderSource.cpp index 1d5e70d6..8ca29b5e 100644 --- a/src/AudioReaderSource.cpp +++ b/src/AudioReaderSource.cpp @@ -131,7 +131,7 @@ void AudioReaderSource::GetMoreSamplesFromReader() { // Get the next block of audio samples void AudioReaderSource::getNextAudioBlock (const AudioSourceChannelInfo& info) { - cout << "getNextAudioBlock" << endl; + //cout << "getNextAudioBlock" << endl; int buffer_samples = buffer->getNumSamples(); int buffer_channels = buffer->getNumChannels(); diff --git a/src/Qt/AudioPlaybackThread.cpp b/src/Qt/AudioPlaybackThread.cpp index 04dc3ce9..a30d6858 100644 --- a/src/Qt/AudioPlaybackThread.cpp +++ b/src/Qt/AudioPlaybackThread.cpp @@ -75,7 +75,7 @@ namespace openshot void AudioPlaybackThread::run() { - // Init audio device + // Init audio device audioDeviceManager.initialise ( 0, /* number of input channels */ numChannels, /* number of output channels */ @@ -106,9 +106,7 @@ namespace openshot cout << "starting transport" << endl; transport.start(); - //TODO: re-add this code !threadShouldExit() && - while (transport.isPlaying()) { - cout << "... still playing" << endl; + while (!threadShouldExit() && transport.isPlaying()) { sleep(1); } diff --git a/src/Qt/PlayerPrivate.cpp b/src/Qt/PlayerPrivate.cpp index 4564c32d..4feba06a 100644 --- a/src/Qt/PlayerPrivate.cpp +++ b/src/Qt/PlayerPrivate.cpp @@ -56,18 +56,18 @@ namespace openshot audioPlayback->setReader(reader); audioPlayback->startThread(1); - /* videoPlayback->startThread(2); - //tr1::shared_ptr frame = getFrame(); tr1::shared_ptr frame; while (!threadShouldExit()) { const Time t1 = Time::getCurrentTime(); - frame = audioPlayback->getFrame(); - if (!frame) { - sleep(1); continue; - //break; + if (!(frame = audioPlayback->getFrame())) { + if (true) { + sleep(1); continue; + } else { + break; + } } videoPlayback->frame = frame; @@ -80,14 +80,14 @@ namespace openshot int64 d = t2.toMilliseconds() - t1.toMilliseconds(); int st = int(ft - d + 0.5); if (0 < ft - d) sleep(st); - std::cout << "frametime: " << ft << " - " << d << " = " << st << std::endl; + //std::cout << "frametime: " << ft << " - " << d << " = " << st << std::endl; } if (videoPlayback->isThreadRunning()) videoPlayback->stopThread(-1); - */ if (audioPlayback->isThreadRunning()) audioPlayback->stopThread(-1); } + /* tr1::shared_ptr PlayerPrivate::getFrame() { try { @@ -101,6 +101,7 @@ namespace openshot } return tr1::shared_ptr(); } + */ bool PlayerPrivate::startPlayback() { diff --git a/src/Qt/PlayerPrivate.h b/src/Qt/PlayerPrivate.h index ef8e8390..c19cc8a2 100644 --- a/src/Qt/PlayerPrivate.h +++ b/src/Qt/PlayerPrivate.h @@ -49,7 +49,7 @@ namespace openshot bool startPlayback(); void stopPlayback(int timeOutMilliseconds = -1); - tr1::shared_ptr getFrame(); + //tr1::shared_ptr getFrame(); friend class QtPlayer; };