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 @@ ...@@ -26,7 +26,7 @@
#include "Clip.h" #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(); init();
} }
......
...@@ -120,7 +120,6 @@ void MediaPlayer::play() ...@@ -120,7 +120,6 @@ void MediaPlayer::play()
void MediaPlayer::pause() void MediaPlayer::pause()
{ {
qDebug() << "Pausing media";
libvlc_media_player_pause( m_internalPtr, m_ex ); libvlc_media_player_pause( m_internalPtr, m_ex );
CheckVlcppException( m_ex ); CheckVlcppException( m_ex );
} }
......
...@@ -31,11 +31,13 @@ ClipWorkflow::ClipWorkflow( Clip::Clip* clip, QMutex* condMutex, QWaitCondition* ...@@ -31,11 +31,13 @@ ClipWorkflow::ClipWorkflow( Clip::Clip* clip, QMutex* condMutex, QWaitCondition*
m_condMutex( condMutex ), m_condMutex( condMutex ),
m_waitCond( waitCond ), m_waitCond( waitCond ),
m_mediaPlayer(NULL), m_mediaPlayer(NULL),
m_isReady( false ) m_isReady( false ),
m_endReached( false )
{ {
m_mutex = new QReadWriteLock(); m_mutex = new QReadWriteLock();
m_buffer = new unsigned char[VIDEOHEIGHT * VIDEOWIDTH * 4]; m_buffer = new unsigned char[VIDEOHEIGHT * VIDEOWIDTH * 4];
m_initMutex = new QReadWriteLock(); m_initMutex = new QReadWriteLock();
m_endReachedLock = new QReadWriteLock();
} }
ClipWorkflow::~ClipWorkflow() ClipWorkflow::~ClipWorkflow()
...@@ -43,6 +45,7 @@ ClipWorkflow::~ClipWorkflow() ...@@ -43,6 +45,7 @@ ClipWorkflow::~ClipWorkflow()
delete[] m_buffer; delete[] m_buffer;
delete m_mutex; delete m_mutex;
delete m_initMutex; delete m_initMutex;
delete m_endReachedLock;
} }
bool ClipWorkflow::renderComplete() const bool ClipWorkflow::renderComplete() const
...@@ -72,17 +75,28 @@ void ClipWorkflow::unlock( ClipWorkflow* clipWorkflow ) ...@@ -72,17 +75,28 @@ void ClipWorkflow::unlock( ClipWorkflow* clipWorkflow )
{ {
if ( clipWorkflow->m_isReady == true ) if ( clipWorkflow->m_isReady == true )
{ {
// qDebug() << "Outputing debug image";
QMutexLocker lock( clipWorkflow->m_condMutex ); QMutexLocker lock( clipWorkflow->m_condMutex );
{ {
QWriteLocker lock2( clipWorkflow->m_mutex ); QWriteLocker lock2( clipWorkflow->m_mutex );
clipWorkflow->m_renderComplete = true; 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 ); clipWorkflow->m_waitCond->wait( clipWorkflow->m_condMutex );
} }
} }
void ClipWorkflow::setRenderComplete()
{
}
void ClipWorkflow::initialize() void ClipWorkflow::initialize()
{ {
char buffer[32]; char buffer[32];
...@@ -138,8 +152,14 @@ void ClipWorkflow::positionChanged() ...@@ -138,8 +152,14 @@ void ClipWorkflow::positionChanged()
m_isReady = true; m_isReady = true;
} }
bool ClipWorkflow::isReady() bool ClipWorkflow::isReady() const
{ {
QReadLocker lock( m_initMutex ); QReadLocker lock( m_initMutex );
return m_isReady; return m_isReady;
} }
bool ClipWorkflow::isEndReached() const
{
QReadLocker lock( m_endReachedLock );
return m_endReached;
}
...@@ -48,11 +48,14 @@ class ClipWorkflow : public QObject ...@@ -48,11 +48,14 @@ class ClipWorkflow : public QObject
bool renderComplete() const; bool renderComplete() const;
unsigned char* getOutput(); unsigned char* getOutput();
void startRender( LibVLCpp::MediaPlayer* mediaPlayer ); void startRender( LibVLCpp::MediaPlayer* mediaPlayer );
bool isReady(); bool isReady() const;
bool isEndReached() const;
private: private:
static void lock( ClipWorkflow* clipWorkflow, void** pp_ret ); static void lock( ClipWorkflow* clipWorkflow, void** pp_ret );
static void unlock( ClipWorkflow* clipWorkflow ); static void unlock( ClipWorkflow* clipWorkflow );
void initialize(); void initialize();
void setRenderComplete();
private: private:
Clip* m_clip; Clip* m_clip;
...@@ -64,6 +67,8 @@ class ClipWorkflow : public QObject ...@@ -64,6 +67,8 @@ class ClipWorkflow : public QObject
LibVLCpp::MediaPlayer* m_mediaPlayer; LibVLCpp::MediaPlayer* m_mediaPlayer;
QReadWriteLock* m_initMutex; QReadWriteLock* m_initMutex;
bool m_isReady; bool m_isReady;
bool m_endReached;
QReadWriteLock* m_endReachedLock;
public slots: public slots:
void playbackStarted(); void playbackStarted();
......
...@@ -53,5 +53,7 @@ unsigned char* TrackWorkflow::getOutput() ...@@ -53,5 +53,7 @@ unsigned char* TrackWorkflow::getOutput()
// usleep( 1000 ); // usleep( 1000 );
} }
// qDebug() << "Frame rendered"; // qDebug() << "Frame rendered";
if ( m_currentClipWorkflow->isEndReached() == true )
return NULL;
return m_currentClipWorkflow->getOutput(); return m_currentClipWorkflow->getOutput();
} }
...@@ -59,7 +59,10 @@ void* RenderPreviewWidget::lock( void* datas ) ...@@ -59,7 +59,10 @@ void* RenderPreviewWidget::lock( void* datas )
{ {
// qDebug() << "Locking invmem"; // qDebug() << "Locking invmem";
RenderPreviewWidget* self = reinterpret_cast<RenderPreviewWidget*>( datas); 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* ) 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