Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
f750252a
Commit
f750252a
authored
May 15, 2011
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Used vlc_clone instead of vlc_thread_create in goom.
parent
0a4005ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
34 deletions
+48
-34
modules/visualization/goom.c
modules/visualization/goom.c
+48
-34
No files found.
modules/visualization/goom.c
View file @
f750252a
...
@@ -78,13 +78,18 @@ vlc_module_end ()
...
@@ -78,13 +78,18 @@ vlc_module_end ()
typedef
struct
typedef
struct
{
{
VLC_COMMON_MEMBERS
vlc_thread_t
thread
;
int
i_width
;
int
i_height
;
vout_thread_t
*
p_vout
;
vout_thread_t
*
p_vout
;
int
i_speed
;
char
*
psz_title
;
char
*
psz_title
;
vlc_mutex_t
lock
;
vlc_mutex_t
lock
;
vlc_cond_t
wait
;
vlc_cond_t
wait
;
bool
b_exit
;
/* Audio properties */
/* Audio properties */
unsigned
i_channels
;
unsigned
i_channels
;
...
@@ -105,7 +110,7 @@ struct filter_sys_t
...
@@ -105,7 +110,7 @@ struct filter_sys_t
static
block_t
*
DoWork
(
filter_t
*
,
block_t
*
);
static
block_t
*
DoWork
(
filter_t
*
,
block_t
*
);
static
void
*
Thread
(
vlc_object_t
*
);
static
void
*
Thread
(
void
*
);
static
char
*
TitleGet
(
vlc_object_t
*
);
static
char
*
TitleGet
(
vlc_object_t
*
);
...
@@ -117,7 +122,6 @@ static int Open( vlc_object_t *p_this )
...
@@ -117,7 +122,6 @@ static int Open( vlc_object_t *p_this )
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
;
filter_sys_t
*
p_sys
;
goom_thread_t
*
p_thread
;
goom_thread_t
*
p_thread
;
int
width
,
height
;
video_format_t
fmt
;
video_format_t
fmt
;
...
@@ -139,12 +143,10 @@ static int Open( vlc_object_t *p_this )
...
@@ -139,12 +143,10 @@ static int Open( vlc_object_t *p_this )
p_sys
=
p_filter
->
p_sys
=
malloc
(
sizeof
(
filter_sys_t
)
);
p_sys
=
p_filter
->
p_sys
=
malloc
(
sizeof
(
filter_sys_t
)
);
/* Create goom thread */
/* Create goom thread */
p_sys
->
p_thread
=
p_thread
=
p_sys
->
p_thread
=
p_thread
=
calloc
(
1
,
sizeof
(
*
p_thread
)
);
vlc_object_create
(
p_filter
,
sizeof
(
goom_thread_t
)
);
vlc_object_attach
(
p_thread
,
p_this
);
width
=
var_CreateGetInteger
(
p_thread
,
"goom-width"
);
const
int
width
=
p_thread
->
i_width
=
var_InheritInteger
(
p_filter
,
"goom-width"
);
height
=
var_CreateGetInteger
(
p_thread
,
"goom-height"
);
const
int
height
=
p_thread
->
i_height
=
var_InheritInteger
(
p_filter
,
"goom-height"
);
memset
(
&
fmt
,
0
,
sizeof
(
video_format_t
)
);
memset
(
&
fmt
,
0
,
sizeof
(
video_format_t
)
);
...
@@ -157,10 +159,15 @@ static int Open( vlc_object_t *p_this )
...
@@ -157,10 +159,15 @@ static int Open( vlc_object_t *p_this )
if
(
p_thread
->
p_vout
==
NULL
)
if
(
p_thread
->
p_vout
==
NULL
)
{
{
msg_Err
(
p_filter
,
"no suitable vout module"
);
msg_Err
(
p_filter
,
"no suitable vout module"
);
vlc_object_releas
e
(
p_thread
);
fre
e
(
p_thread
);
free
(
p_sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
p_thread
->
i_speed
=
MAX_SPEED
-
var_InheritInteger
(
p_filter
,
"goom-speed"
);
if
(
p_thread
->
i_speed
<
0
)
p_thread
->
i_speed
=
0
;
vlc_mutex_init
(
&
p_thread
->
lock
);
vlc_mutex_init
(
&
p_thread
->
lock
);
vlc_cond_init
(
&
p_thread
->
wait
);
vlc_cond_init
(
&
p_thread
->
wait
);
...
@@ -171,15 +178,15 @@ static int Open( vlc_object_t *p_this )
...
@@ -171,15 +178,15 @@ static int Open( vlc_object_t *p_this )
p_thread
->
psz_title
=
TitleGet
(
VLC_OBJECT
(
p_filter
)
);
p_thread
->
psz_title
=
TitleGet
(
VLC_OBJECT
(
p_filter
)
);
if
(
vlc_
thread_create
(
p_thread
,
T
hread
,
if
(
vlc_
clone
(
&
p_thread
->
t
hread
,
VLC_THREAD_PRIORITY_LOW
)
)
Thread
,
p_thread
,
VLC_THREAD_PRIORITY_LOW
)
)
{
{
msg_Err
(
p_filter
,
"cannot lauch goom thread"
);
msg_Err
(
p_filter
,
"cannot lauch goom thread"
);
vlc_object_release
(
p_thread
->
p_vout
);
vlc_object_release
(
p_thread
->
p_vout
);
vlc_mutex_destroy
(
&
p_thread
->
lock
);
vlc_mutex_destroy
(
&
p_thread
->
lock
);
vlc_cond_destroy
(
&
p_thread
->
wait
);
vlc_cond_destroy
(
&
p_thread
->
wait
);
free
(
p_thread
->
psz_title
);
free
(
p_thread
->
psz_title
);
vlc_object_releas
e
(
p_thread
);
fre
e
(
p_thread
);
free
(
p_sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -295,39 +302,43 @@ static int FillBuffer( int16_t *p_data, int *pi_data,
...
@@ -295,39 +302,43 @@ static int FillBuffer( int16_t *p_data, int *pi_data,
/*****************************************************************************
/*****************************************************************************
* Thread:
* Thread:
*****************************************************************************/
*****************************************************************************/
static
void
*
Thread
(
vlc_object_t
*
p_this
)
static
void
*
Thread
(
void
*
p_thread_data
)
{
{
goom_thread_t
*
p_thread
=
(
goom_thread_t
*
)
p_this
;
goom_thread_t
*
p_thread
=
(
goom_thread_t
*
)
p_thread_data
;
int
width
,
height
,
speed
;
date_t
i_pts
;
date_t
i_pts
;
int16_t
p_data
[
2
][
512
];
int16_t
p_data
[
2
][
512
];
int
i_data
=
0
,
i_count
=
0
;
int
i_data
=
0
,
i_count
=
0
;
PluginInfo
*
p_plugin_info
;
PluginInfo
*
p_plugin_info
;
int
canc
=
vlc_savecancel
();
int
canc
=
vlc_savecancel
();
width
=
var_GetInteger
(
p_this
,
"goom-width"
);
p_plugin_info
=
goom_init
(
p_thread
->
i_width
,
p_thread
->
i_height
);
height
=
var_GetInteger
(
p_this
,
"goom-height"
);
speed
=
var_CreateGetInteger
(
p_thread
,
"goom-speed"
);
speed
=
MAX_SPEED
-
speed
;
if
(
speed
<
0
)
speed
=
0
;
p_plugin_info
=
goom_init
(
width
,
height
);
for
(
;;
)
while
(
vlc_object_alive
(
p_thread
)
)
{
{
uint32_t
*
plane
;
uint32_t
*
plane
;
picture_t
*
p_pic
;
picture_t
*
p_pic
;
/* FIXME the way the update is done is not really good.
* Supurious wake up from p_thread->wait will make it generates a frame
* without using new samples (probably rare as we should not be waiting
* samples).
* The frame rate at which the video is generated is not well controlled
* nor the time at which each frame is displayed (not smooth)
*/
/* goom_update is damn slow, so just copy data and release the lock */
/* goom_update is damn slow, so just copy data and release the lock */
vlc_mutex_lock
(
&
p_thread
->
lock
);
vlc_mutex_lock
(
&
p_thread
->
lock
);
if
(
FillBuffer
(
(
int16_t
*
)
p_data
,
&
i_data
,
&
i_pts
,
if
(
!
p_thread
->
b_exit
&&
&
p_thread
->
date
,
p_thread
)
!=
VLC_SUCCESS
)
FillBuffer
(
(
int16_t
*
)
p_data
,
&
i_data
,
&
i_pts
,
&
p_thread
->
date
,
p_thread
)
!=
VLC_SUCCESS
)
vlc_cond_wait
(
&
p_thread
->
wait
,
&
p_thread
->
lock
);
vlc_cond_wait
(
&
p_thread
->
wait
,
&
p_thread
->
lock
);
bool
b_exit
=
p_thread
->
b_exit
;
vlc_mutex_unlock
(
&
p_thread
->
lock
);
vlc_mutex_unlock
(
&
p_thread
->
lock
);
if
(
b_exit
)
break
;
/* Speed selection */
/* Speed selection */
if
(
speed
&&
(
++
i_count
%
(
speed
+
1
))
)
continue
;
if
(
p_thread
->
i_speed
&&
(
++
i_count
%
(
p_thread
->
i_
speed
+
1
))
)
continue
;
/* Frame dropping if necessary */
/* Frame dropping if necessary */
if
(
date_Get
(
&
i_pts
)
+
GOOM_DELAY
<=
mdate
()
)
continue
;
if
(
date_Get
(
&
i_pts
)
+
GOOM_DELAY
<=
mdate
()
)
continue
;
...
@@ -338,15 +349,19 @@ static void* Thread( vlc_object_t *p_this )
...
@@ -338,15 +349,19 @@ static void* Thread( vlc_object_t *p_this )
free
(
p_thread
->
psz_title
);
free
(
p_thread
->
psz_title
);
p_thread
->
psz_title
=
NULL
;
p_thread
->
psz_title
=
NULL
;
while
(
!
(
p_pic
=
vout_GetPicture
(
p_thread
->
p_vout
)
)
&&
while
(
!
(
p_pic
=
vout_GetPicture
(
p_thread
->
p_vout
)
)
)
vlc_object_alive
(
p_thread
)
)
{
{
vlc_mutex_lock
(
&
p_thread
->
lock
);
bool
b_exit
=
p_thread
->
b_exit
;
vlc_mutex_unlock
(
&
p_thread
->
lock
);
if
(
b_exit
)
break
;
msleep
(
VOUT_OUTMEM_SLEEP
);
msleep
(
VOUT_OUTMEM_SLEEP
);
}
}
if
(
p_pic
==
NULL
)
break
;
if
(
p_pic
==
NULL
)
break
;
memcpy
(
p_pic
->
p
[
0
].
p_pixels
,
plane
,
width
*
height
*
4
);
memcpy
(
p_pic
->
p
[
0
].
p_pixels
,
plane
,
p_thread
->
i_width
*
p_thread
->
i_
height
*
4
);
p_pic
->
date
=
date_Get
(
&
i_pts
)
+
GOOM_DELAY
;
p_pic
->
date
=
date_Get
(
&
i_pts
)
+
GOOM_DELAY
;
vout_PutPicture
(
p_thread
->
p_vout
,
p_pic
);
vout_PutPicture
(
p_thread
->
p_vout
,
p_pic
);
...
@@ -366,13 +381,12 @@ static void Close( vlc_object_t *p_this )
...
@@ -366,13 +381,12 @@ static void Close( vlc_object_t *p_this )
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
/* Stop Goom Thread */
/* Stop Goom Thread */
vlc_object_kill
(
p_sys
->
p_thread
);
vlc_mutex_lock
(
&
p_sys
->
p_thread
->
lock
);
vlc_mutex_lock
(
&
p_sys
->
p_thread
->
lock
);
p_sys
->
p_thread
->
b_exit
=
true
;
vlc_cond_signal
(
&
p_sys
->
p_thread
->
wait
);
vlc_cond_signal
(
&
p_sys
->
p_thread
->
wait
);
vlc_mutex_unlock
(
&
p_sys
->
p_thread
->
lock
);
vlc_mutex_unlock
(
&
p_sys
->
p_thread
->
lock
);
vlc_
thread_join
(
p_sys
->
p_thread
);
vlc_
join
(
p_sys
->
p_thread
->
thread
,
NULL
);
/* Free data */
/* Free data */
aout_filter_RequestVout
(
p_filter
,
p_sys
->
p_thread
->
p_vout
,
0
);
aout_filter_RequestVout
(
p_filter
,
p_sys
->
p_thread
->
p_vout
,
0
);
...
@@ -384,7 +398,7 @@ static void Close( vlc_object_t *p_this )
...
@@ -384,7 +398,7 @@ static void Close( vlc_object_t *p_this )
block_Release
(
p_sys
->
p_thread
->
pp_blocks
[
p_sys
->
p_thread
->
i_blocks
]
);
block_Release
(
p_sys
->
p_thread
->
pp_blocks
[
p_sys
->
p_thread
->
i_blocks
]
);
}
}
vlc_object_releas
e
(
p_sys
->
p_thread
);
fre
e
(
p_sys
->
p_thread
);
free
(
p_sys
);
free
(
p_sys
);
}
}
...
...
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