Commit 3454cf1b authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Render is now stopped when end of media is reached

This has only be tester with a Clip end date, not with an "unset" Clip
end.
Removed debug.
parent ccd6a8b3
......@@ -26,7 +26,7 @@
#include "Clip.h"
Clip::Clip( Media* parent ) : m_parent( parent ), m_begin( 0.5f ), m_end( Clip::UntilEndOfMedia )
Clip::Clip( Media* parent ) : m_parent( parent ), m_begin( 0.0f ), m_end( Clip::UntilEndOfMedia )
{
init();
}
......
......@@ -120,7 +120,6 @@ void MediaPlayer::play()
void MediaPlayer::pause()
{
qDebug() << "Pausing media";
libvlc_media_player_pause( m_internalPtr, m_ex );
CheckVlcppException( m_ex );
}
......
......@@ -31,11 +31,13 @@ ClipWorkflow::ClipWorkflow( Clip::Clip* clip, QMutex* condMutex, QWaitCondition*
m_condMutex( condMutex ),
m_waitCond( waitCond ),
m_mediaPlayer(NULL),
m_isReady( false )
m_isReady( false ),
m_endReached( false )
{
m_mutex = new QReadWriteLock();
m_buffer = new unsigned char[VIDEOHEIGHT * VIDEOWIDTH * 4];
m_initMutex = new QReadWriteLock();
m_endReachedLock = new QReadWriteLock();
}
ClipWorkflow::~ClipWorkflow()
......@@ -43,6 +45,7 @@ ClipWorkflow::~ClipWorkflow()
delete[] m_buffer;
delete m_mutex;
delete m_initMutex;
delete m_endReachedLock;
}
bool ClipWorkflow::renderComplete() const
......@@ -72,17 +75,28 @@ void ClipWorkflow::unlock( ClipWorkflow* clipWorkflow )
{
if ( clipWorkflow->m_isReady == true )
{
// qDebug() << "Outputing debug image";
QMutexLocker lock( clipWorkflow->m_condMutex );
{
QWriteLocker lock2( clipWorkflow->m_mutex );
clipWorkflow->m_renderComplete = true;
}
// qDebug() << "Frame rendered, sleeping mode";
if ( clipWorkflow->m_clip->getEnd() != Clip::UntilEndOfMedia
&& clipWorkflow->m_mediaPlayer->getPosition() > clipWorkflow->m_clip->getEnd() )
{
QWriteLocker lock2( clipWorkflow->m_endReachedLock );
clipWorkflow->m_endReached = true;
}
clipWorkflow->m_waitCond->wait( clipWorkflow->m_condMutex );
}
}
void ClipWorkflow::setRenderComplete()
{
}
void ClipWorkflow::initialize()
{
char buffer[32];
......@@ -138,8 +152,14 @@ void ClipWorkflow::positionChanged()
m_isReady = true;
}
bool ClipWorkflow::isReady()
bool ClipWorkflow::isReady() const
{
QReadLocker lock( m_initMutex );
return m_isReady;
}
bool ClipWorkflow::isEndReached() const
{
QReadLocker lock( m_endReachedLock );
return m_endReached;
}
......@@ -48,11 +48,14 @@ class ClipWorkflow : public QObject
bool renderComplete() const;
unsigned char* getOutput();
void startRender( LibVLCpp::MediaPlayer* mediaPlayer );
bool isReady();
bool isReady() const;
bool isEndReached() const;
private:
static void lock( ClipWorkflow* clipWorkflow, void** pp_ret );
static void unlock( ClipWorkflow* clipWorkflow );
void initialize();
void setRenderComplete();
private:
Clip* m_clip;
......@@ -64,6 +67,8 @@ class ClipWorkflow : public QObject
LibVLCpp::MediaPlayer* m_mediaPlayer;
QReadWriteLock* m_initMutex;
bool m_isReady;
bool m_endReached;
QReadWriteLock* m_endReachedLock;
public slots:
void playbackStarted();
......
......@@ -53,5 +53,7 @@ unsigned char* TrackWorkflow::getOutput()
// usleep( 1000 );
}
// qDebug() << "Frame rendered";
if ( m_currentClipWorkflow->isEndReached() == true )
return NULL;
return m_currentClipWorkflow->getOutput();
}
......@@ -59,7 +59,10 @@ void* RenderPreviewWidget::lock( void* datas )
{
// qDebug() << "Locking invmem";
RenderPreviewWidget* self = reinterpret_cast<RenderPreviewWidget*>( datas);
return self->m_mainWorkflow->getOutput();
void* ret = self->m_mainWorkflow->getOutput();
if ( ret == NULL )
self->m_mediaPlayer->stop();
return ret;
}
void RenderPreviewWidget::unlock( void* )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment