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
952df71d
Commit
952df71d
authored
Feb 16, 2011
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sout_select: fix race conditions.
parent
ec37907e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
modules/stream_out/select.c
modules/stream_out/select.c
+14
-15
No files found.
modules/stream_out/select.c
View file @
952df71d
...
@@ -69,7 +69,7 @@ static sout_stream_id_t *Add (sout_stream_t *, es_format_t *);
...
@@ -69,7 +69,7 @@ static sout_stream_id_t *Add (sout_stream_t *, es_format_t *);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Del
(
sout_stream_t
*
,
sout_stream_id_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block_t
*
);
static
int
Send
(
sout_stream_t
*
,
sout_stream_id_t
*
,
block_t
*
);
static
void
*
Command
(
v
lc_object_t
*
);
static
void
*
Command
(
v
oid
*
);
struct
sout_stream_id_t
struct
sout_stream_id_t
{
{
...
@@ -85,6 +85,8 @@ struct sout_stream_sys_t
...
@@ -85,6 +85,8 @@ struct sout_stream_sys_t
int
i_es_num
;
int
i_es_num
;
vlc_mutex_t
es_lock
;
vlc_mutex_t
es_lock
;
vlc_thread_t
thread
;
int
i_fd
;
int
i_fd
;
int
i_id_disable
;
int
i_id_disable
;
};
};
...
@@ -135,7 +137,7 @@ static int Open(vlc_object_t *p_this)
...
@@ -135,7 +137,7 @@ static int Open(vlc_object_t *p_this)
vlc_mutex_init
(
&
p_sys
->
es_lock
);
vlc_mutex_init
(
&
p_sys
->
es_lock
);
if
(
vlc_thread_create
(
p_stream
,
Command
,
VLC_THREAD_PRIORITY_LOW
))
if
(
vlc_clone
(
&
p_sys
->
thread
,
Command
,
p_stream
,
VLC_THREAD_PRIORITY_LOW
))
{
{
vlc_mutex_destroy
(
&
p_sys
->
es_lock
);
vlc_mutex_destroy
(
&
p_sys
->
es_lock
);
free
(
p_sys
);
free
(
p_sys
);
...
@@ -156,11 +158,12 @@ static void Close (vlc_object_t * p_this)
...
@@ -156,11 +158,12 @@ static void Close (vlc_object_t * p_this)
sout_stream_t
*
p_stream
=
(
sout_stream_t
*
)
p_this
;
sout_stream_t
*
p_stream
=
(
sout_stream_t
*
)
p_this
;
sout_stream_sys_t
*
p_sys
=
(
sout_stream_sys_t
*
)
p_stream
->
p_sys
;
sout_stream_sys_t
*
p_sys
=
(
sout_stream_sys_t
*
)
p_stream
->
p_sys
;
net_Close
(
p_sys
->
i_fd
);
/* Stop the thread */
p_sys
->
i_fd
=
-
1
;
vlc_cancel
(
p_sys
->
thread
);
vlc_join
(
p_sys
->
thread
,
NULL
);
vlc_thread_join
(
p_stream
);
/* Free the ressources */
net_Close
(
p_sys
->
i_fd
);
vlc_mutex_destroy
(
&
p_sys
->
es_lock
);
vlc_mutex_destroy
(
&
p_sys
->
es_lock
);
p_stream
->
p_sout
->
i_out_pace_nocontrol
--
;
p_stream
->
p_sout
->
i_out_pace_nocontrol
--
;
...
@@ -171,18 +174,13 @@ static void Close (vlc_object_t * p_this)
...
@@ -171,18 +174,13 @@ static void Close (vlc_object_t * p_this)
/****************************************************************************
/****************************************************************************
* Command Thread:
* Command Thread:
****************************************************************************/
****************************************************************************/
static
void
*
Command
(
v
lc_object_t
*
p_this
)
static
void
*
Command
(
v
oid
*
p_this
)
{
{
sout_stream_t
*
p_stream
=
(
sout_stream_t
*
)
p_this
;
sout_stream_t
*
p_stream
=
(
sout_stream_t
*
)
p_this
;
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
int
canc
=
vlc_savecancel
();
while
(
vlc_object_alive
(
p_stream
))
while
(
vlc_object_alive
(
p_stream
))
{
{
if
(
p_sys
->
i_fd
<
0
)
break
;
char
psz_buffer
[
20
];
char
psz_buffer
[
20
];
int
i_len
=
recv
(
p_sys
->
i_fd
,
psz_buffer
,
sizeof
(
psz_buffer
)
-
1
,
0
);
int
i_len
=
recv
(
p_sys
->
i_fd
,
psz_buffer
,
sizeof
(
psz_buffer
)
-
1
,
0
);
...
@@ -195,6 +193,7 @@ static void* Command(vlc_object_t *p_this)
...
@@ -195,6 +193,7 @@ static void* Command(vlc_object_t *p_this)
if
(
strncmp
(
psz_buffer
,
"show"
,
4
)
==
0
)
if
(
strncmp
(
psz_buffer
,
"show"
,
4
)
==
0
)
{
{
vlc_mutex_lock
(
&
p_sys
->
es_lock
);
vlc_mutex_lock
(
&
p_sys
->
es_lock
);
mutex_cleanup_push
(
&
p_sys
->
es_lock
);
for
(
int
i
=
0
;
i
<
p_sys
->
i_es_num
;
i
++
)
for
(
int
i
=
0
;
i
<
p_sys
->
i_es_num
;
i
++
)
{
{
i_len
=
snprintf
(
psz_buffer
,
sizeof
(
psz_buffer
),
"%.4s : %d"
,
i_len
=
snprintf
(
psz_buffer
,
sizeof
(
psz_buffer
),
"%.4s : %d"
,
...
@@ -203,7 +202,7 @@ static void* Command(vlc_object_t *p_this)
...
@@ -203,7 +202,7 @@ static void* Command(vlc_object_t *p_this)
psz_buffer
[
i_len
]
=
'\0'
;
psz_buffer
[
i_len
]
=
'\0'
;
msg_Info
(
p_stream
,
psz_buffer
);
msg_Info
(
p_stream
,
psz_buffer
);
}
}
vlc_
mutex_unlock
(
&
p_sys
->
es_lock
);
vlc_
cleanup_pop
(
);
}
}
else
else
{
{
...
@@ -226,6 +225,7 @@ static void* Command(vlc_object_t *p_this)
...
@@ -226,6 +225,7 @@ static void* Command(vlc_object_t *p_this)
if
(
b_apply
)
if
(
b_apply
)
{
{
vlc_mutex_lock
(
&
p_sys
->
es_lock
);
vlc_mutex_lock
(
&
p_sys
->
es_lock
);
mutex_cleanup_push
(
&
p_sys
->
es_lock
);
for
(
int
i
=
0
;
i
<
p_sys
->
i_es_num
;
i
++
)
for
(
int
i
=
0
;
i
<
p_sys
->
i_es_num
;
i
++
)
{
{
msg_Info
(
p_stream
,
"elementary stream pid %d"
,
msg_Info
(
p_stream
,
"elementary stream pid %d"
,
...
@@ -236,12 +236,11 @@ static void* Command(vlc_object_t *p_this)
...
@@ -236,12 +236,11 @@ static void* Command(vlc_object_t *p_this)
msg_Info
(
p_stream
,
"%s: %d"
,
b_select
?
"enable"
:
"disable"
,
i_pid
);
msg_Info
(
p_stream
,
"%s: %d"
,
b_select
?
"enable"
:
"disable"
,
i_pid
);
}
}
}
}
vlc_
mutex_unlock
(
&
p_sys
->
es_lock
);
vlc_
cleanup_pop
(
);
}
}
}
}
}
}
vlc_restorecancel
(
canc
);
return
NULL
;
return
NULL
;
}
}
...
...
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