Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
56ec18e7
Commit
56ec18e7
authored
Sep 16, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block_FifoWake: force the block_FifoGet()'ing thread to wakeup without
queuing any data - this is mostly useful when quitting
parent
9a38681d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
6 deletions
+27
-6
include/vlc_block.h
include/vlc_block.h
+3
-0
src/misc/block.c
src/misc/block.c
+24
-6
No files found.
include/vlc_block.h
View file @
56ec18e7
...
...
@@ -262,6 +262,8 @@ static inline block_t *block_ChainGather( block_t *p_list )
* only one getting data from the fifo.
* - block_FifoCount : how many packets are waiting in the fifo
* - block_FifoSize : how many cumulated bytes are waiting in the fifo
* - block_FifoWake : wake ups a thread with block_FifoGet() = NULL
* (this is used to wakeup a thread when there is no data to queue)
****************************************************************************/
#define block_FifoNew( a ) __block_FifoNew( VLC_OBJECT(a) )
...
...
@@ -269,6 +271,7 @@ VLC_EXPORT( block_fifo_t *, __block_FifoNew, ( vlc_object_t * ) );
VLC_EXPORT
(
void
,
block_FifoRelease
,
(
block_fifo_t
*
)
);
VLC_EXPORT
(
void
,
block_FifoEmpty
,
(
block_fifo_t
*
)
);
VLC_EXPORT
(
int
,
block_FifoPut
,
(
block_fifo_t
*
,
block_t
*
)
);
VLC_EXPORT
(
void
,
block_FifoWake
,
(
block_fifo_t
*
)
);
VLC_EXPORT
(
block_t
*
,
block_FifoGet
,
(
block_fifo_t
*
)
);
VLC_EXPORT
(
block_t
*
,
block_FifoShow
,
(
block_fifo_t
*
)
);
VLC_EXPORT
(
size_t
,
block_FifoSize
,
(
const
block_fifo_t
*
p_fifo
)
);
...
...
src/misc/block.c
View file @
56ec18e7
...
...
@@ -160,10 +160,11 @@ struct block_fifo_t
vlc_mutex_t
lock
;
/* fifo data lock */
vlc_cond_t
wait
;
/* fifo data conditional variable */
size_t
i_depth
;
block_t
*
p_first
;
block_t
**
pp_last
;
size_t
i_depth
;
size_t
i_size
;
vlc_bool_t
b_force_wake
;
};
block_fifo_t
*
__block_FifoNew
(
vlc_object_t
*
p_obj
)
...
...
@@ -173,9 +174,10 @@ block_fifo_t *__block_FifoNew( vlc_object_t *p_obj )
p_fifo
=
malloc
(
sizeof
(
block_fifo_t
)
);
vlc_mutex_init
(
p_obj
,
&
p_fifo
->
lock
);
vlc_cond_init
(
p_obj
,
&
p_fifo
->
wait
);
p_fifo
->
i_depth
=
p_fifo
->
i_size
=
0
;
p_fifo
->
p_first
=
NULL
;
p_fifo
->
pp_last
=
&
p_fifo
->
p_first
;
p_fifo
->
i_depth
=
p_fifo
->
i_size
=
0
;
p_fifo
->
b_force_wake
=
VLC_FALSE
;
return
p_fifo
;
}
...
...
@@ -233,22 +235,38 @@ int block_FifoPut( block_fifo_t *p_fifo, block_t *p_block )
return
i_size
;
}
void
block_FifoWake
(
block_fifo_t
*
p_fifo
)
{
vlc_mutex_lock
(
&
p_fifo
->
lock
);
if
(
p_fifo
->
p_first
==
NULL
)
p_fifo
->
b_force_wake
=
VLC_TRUE
;
vlc_cond_signal
(
&
p_fifo
->
wait
);
vlc_mutex_unlock
(
&
p_fifo
->
lock
);
}
block_t
*
block_FifoGet
(
block_fifo_t
*
p_fifo
)
{
block_t
*
b
;
vlc_mutex_lock
(
&
p_fifo
->
lock
);
/* We do a while here because there is a race condition in the
* win32 implementation of vlc_cond_wait() (We can't be sure the fifo
* hasn't been emptied again since we were signaled). */
while
(
p_fifo
->
p_first
==
NULL
)
/* Remember vlc_cond_wait() may cause spurious wakeups
* (on both Win32 and POSIX) */
while
(
(
p_fifo
->
p_first
==
NULL
)
&&
!
p_fifo
->
b_force_wake
)
{
vlc_cond_wait
(
&
p_fifo
->
wait
,
&
p_fifo
->
lock
);
}
b
=
p_fifo
->
p_first
;
p_fifo
->
b_force_wake
=
VLC_FALSE
;
if
(
b
==
NULL
)
{
/* Forced wakeup */
vlc_mutex_unlock
(
&
p_fifo
->
lock
);
return
NULL
;
}
p_fifo
->
p_first
=
b
->
p_next
;
p_fifo
->
i_depth
--
;
p_fifo
->
i_size
-=
b
->
i_buffer
;
...
...
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