Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
VLMC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
21
Issues
21
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VideoLAN
VLMC
Commits
844eb31a
Commit
844eb31a
authored
May 29, 2009
by
Hugo Beauzee-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Solved crash when moving after the current media
parent
bcda39c4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
26 deletions
+66
-26
src/Workflow/ClipWorkflow.cpp
src/Workflow/ClipWorkflow.cpp
+20
-6
src/Workflow/ClipWorkflow.h
src/Workflow/ClipWorkflow.h
+4
-0
src/Workflow/TrackWorkflow.cpp
src/Workflow/TrackWorkflow.cpp
+40
-20
src/Workflow/TrackWorkflow.h
src/Workflow/TrackWorkflow.h
+2
-0
No files found.
src/Workflow/ClipWorkflow.cpp
View file @
844eb31a
...
...
@@ -67,7 +67,7 @@ void ClipWorkflow::lock( ClipWorkflow* clipWorkflow, void** pp_ret )
//In any case, we give vlc a buffer to render in...
//If we don't, segmentation fault will catch us and eat our brain !! ahem...
//
qDebug() << "Locking in ClipWorkflow::lock";
qDebug
()
<<
"Locking in ClipWorkflow::lock"
;
*
pp_ret
=
clipWorkflow
->
m_buffer
;
}
...
...
@@ -75,8 +75,14 @@ void ClipWorkflow::unlock( ClipWorkflow* clipWorkflow )
{
if
(
clipWorkflow
->
m_isReady
==
true
)
{
QMutexLocker
lock
(
clipWorkflow
->
m_condMutex
);
{
QReadLocker
lock
(
clipWorkflow
->
m_endReachedLock
);
if
(
clipWorkflow
->
m_endReached
==
true
)
{
qDebug
()
<<
"UnLocking in ClipWorkflow::unlock"
;
return
;
}
}
{
QWriteLocker
lock2
(
clipWorkflow
->
m_mutex
);
clipWorkflow
->
m_renderComplete
=
true
;
...
...
@@ -87,9 +93,11 @@ void ClipWorkflow::unlock( ClipWorkflow* clipWorkflow )
QWriteLocker
lock2
(
clipWorkflow
->
m_endReachedLock
);
clipWorkflow
->
m_endReached
=
true
;
}
QMutexLocker
lock
(
clipWorkflow
->
m_condMutex
);
clipWorkflow
->
m_waitCond
->
wait
(
clipWorkflow
->
m_condMutex
);
}
//
qDebug() << "UnLocking in ClipWorkflow::unlock";
qDebug
()
<<
"UnLocking in ClipWorkflow::unlock"
;
}
void
ClipWorkflow
::
setRenderComplete
()
...
...
@@ -199,13 +207,14 @@ const Clip* ClipWorkflow::getClip() const
void
ClipWorkflow
::
stop
()
{
Q_ASSERT
(
m_mediaPlayer
!=
NULL
);
{
QWriteLocker
lock2
(
m_mutex
);
m_renderComplete
=
false
;
}
{
QWriteLocker
lock2
(
m_endReachedLock
);
m_endReached
=
fals
e
;
m_endReached
=
tru
e
;
}
{
QWriteLocker
lock
(
m_initMutex
);
...
...
@@ -213,10 +222,15 @@ void ClipWorkflow::stop()
}
m_mediaPlayer
->
stop
();
m_mediaPlayer
=
NULL
;
//
qDebug() << "Stoped ClipWorkflow";
qDebug
()
<<
"Stoped ClipWorkflow"
;
}
void
ClipWorkflow
::
setPosition
(
float
pos
)
{
m_mediaPlayer
->
setPosition
(
pos
);
}
bool
ClipWorkflow
::
isStopped
()
const
{
return
(
m_mediaPlayer
==
NULL
);
}
src/Workflow/ClipWorkflow.h
View file @
844eb31a
...
...
@@ -62,6 +62,10 @@ class ClipWorkflow : public QObject
*/
void
stop
();
void
setPosition
(
float
pos
);
/**
* \return true if the workflow has already been stopped.
*/
bool
isStopped
()
const
;
private:
static
void
lock
(
ClipWorkflow
*
clipWorkflow
,
void
**
pp_ret
);
...
...
src/Workflow/TrackWorkflow.cpp
View file @
844eb31a
...
...
@@ -34,11 +34,20 @@ TrackWorkflow::TrackWorkflow()
m_currentLock
=
new
QReadWriteLock
();
if
(
TrackWorkflow
::
blackOutput
==
NULL
)
{
//TODO: this ain't free !
TrackWorkflow
::
blackOutput
=
new
unsigned
char
[
VIDEOHEIGHT
*
VIDEOWIDTH
*
3
];
memset
(
TrackWorkflow
::
blackOutput
,
0
,
VIDEOHEIGHT
*
VIDEOWIDTH
*
3
);
}
}
TrackWorkflow
::~
TrackWorkflow
()
{
delete
m_condMutex
;
delete
m_waitCondition
;
delete
m_mediaPlayer
;
delete
m_currentLock
;
}
void
TrackWorkflow
::
addClip
(
Clip
*
clip
,
qint64
start
)
{
qDebug
()
<<
"Inserting clip at frame nb"
<<
start
;
...
...
@@ -141,23 +150,34 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
// qDebug() << "Stil no clip at this time, going to the next frame";
return
ret
;
}
m_waitCondition
->
wakeAll
();
// qDebug() << "All waked";
while
(
m_current
.
value
()
->
renderComplete
()
==
false
)
usleep
(
20
);
if
(
m_current
.
value
()
->
isEndReached
()
==
false
)
ret
=
m_current
.
value
()
->
getOutput
();
else
// qDebug() << "All waked"
if
(
m_current
.
value
()
->
isStopped
()
==
false
)
{
if
(
clipsRemaining
==
false
)
{
// qDebug() <<"End reached";
emit
endReached
();
}
m_waitCondition
->
wakeAll
();
while
(
m_current
.
value
()
->
renderComplete
()
==
false
)
usleep
(
20
);
if
(
m_current
.
value
()
->
isEndReached
()
==
false
)
ret
=
m_current
.
value
()
->
getOutput
();
return
ret
;
}
qDebug
()
<<
"End reached : stopping current clipworkflow"
;
stopCurrentClipWorkflow
();
if
(
clipsRemaining
==
false
)
{
qDebug
()
<<
"End reached"
;
emit
endReached
();
}
return
ret
;
}
void
TrackWorkflow
::
stopCurrentClipWorkflow
()
{
//Awaking renderer thread to avoid dead lock
if
(
m_current
.
value
()
->
isStopped
()
==
false
)
m_current
.
value
()
->
stop
();
}
void
TrackWorkflow
::
setPosition
(
float
pos
)
{
qint64
frame
=
(
float
)
m_length
*
pos
;
...
...
@@ -171,7 +191,7 @@ void TrackWorkflow::setPosition( float pos )
// qDebug() << "setting position after the end of this track";
if
(
m_current
!=
end
)
{
m_current
.
value
()
->
stop
();
stopCurrentClipWorkflow
();
m_current
=
end
;
return
;
}
...
...
@@ -183,7 +203,7 @@ void TrackWorkflow::setPosition( float pos )
if
(
it
.
key
()
<=
frame
&&
(
it
.
key
()
+
it
.
value
()
->
getClip
()
->
getLength
()
)
>
frame
)
{
//
qDebug() << "Found new current clip workflow";
qDebug
()
<<
"Found new current clip workflow"
;
break
;
}
else
if
(
next
==
m_clips
.
end
()
&&
it
.
key
()
>
frame
)
...
...
@@ -195,13 +215,13 @@ void TrackWorkflow::setPosition( float pos )
next
=
it
;
if
(
next
!=
m_clips
.
begin
()
)
{
//
qDebug() << "Next clip isn't the first one";
qDebug
()
<<
"Next clip isn't the first one"
;
next
=
next
-
1
;
//Since the iterator must point to the previous video
}
else
{
next
=
end
;
//
qDebug() << "Next clip is the first of the track";
qDebug
()
<<
"Next clip is the first of the track"
;
}
// in order to checkNextClip() to work.
it
=
end
;
...
...
@@ -214,13 +234,13 @@ void TrackWorkflow::setPosition( float pos )
{
if
(
m_current
!=
end
)
{
m_current
.
value
()
->
stop
();
stopCurrentClipWorkflow
();
}
m_current
=
next
;
}
else
if
(
it
==
m_current
)
{
//
qDebug() << "Changing the position of the current clip";
qDebug
()
<<
"Changing the position of the current clip"
;
//We're changing the position of the current clip
it
.
value
()
->
setPosition
(
(
float
)(
frame
-
it
.
key
()
)
/
(
float
)(
it
.
value
()
->
getClip
()
->
getLength
())
);
//Awaking renderers to avoid them to be stuck inside of the lock...
...
...
@@ -229,10 +249,10 @@ void TrackWorkflow::setPosition( float pos )
}
else
{
//
qDebug() << "Switching to other Clip";
qDebug
()
<<
"Switching to other Clip"
;
if
(
m_current
!=
end
)
{
m_current
.
value
()
->
stop
();
stopCurrentClipWorkflow
();
// m_waitCondition->wakeAll();
}
...
...
src/Workflow/TrackWorkflow.h
View file @
844eb31a
...
...
@@ -43,6 +43,7 @@ class TrackWorkflow : public QObject
public:
TrackWorkflow
();
~
TrackWorkflow
();
void
startRender
();
unsigned
char
*
getOutput
(
qint64
currentFrame
);
...
...
@@ -67,6 +68,7 @@ class TrackWorkflow : public QObject
*/
bool
checkNextClip
(
qint64
currentFrame
);
void
computeLength
();
void
stopCurrentClipWorkflow
();
private:
QMap
<
qint64
,
ClipWorkflow
*>
m_clips
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment