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
757ce256
Commit
757ce256
authored
Mar 17, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block: rewrite block_Fifo(Empty,Get,Put) with the new functions
parent
26d23afc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
80 deletions
+25
-80
include/vlc_block.h
include/vlc_block.h
+1
-1
src/misc/fifo.c
src/misc/fifo.c
+24
-79
No files found.
include/vlc_block.h
View file @
757ce256
...
...
@@ -313,7 +313,7 @@ VLC_API block_fifo_t *block_FifoNew( void ) VLC_USED VLC_MALLOC;
VLC_API
void
block_FifoRelease
(
block_fifo_t
*
);
VLC_API
void
block_FifoPace
(
block_fifo_t
*
fifo
,
size_t
max_depth
,
size_t
max_size
);
VLC_API
void
block_FifoEmpty
(
block_fifo_t
*
);
VLC_API
size_t
block_FifoPut
(
block_fifo_t
*
,
block_t
*
);
VLC_API
void
block_FifoPut
(
block_fifo_t
*
,
block_t
*
);
VLC_API
void
block_FifoWake
(
block_fifo_t
*
);
VLC_API
block_t
*
block_FifoGet
(
block_fifo_t
*
)
VLC_USED
;
VLC_API
block_t
*
block_FifoShow
(
block_fifo_t
*
);
...
...
src/misc/fifo.c
View file @
757ce256
...
...
@@ -276,29 +276,17 @@ void block_FifoRelease( block_fifo_t *p_fifo )
free
(
p_fifo
);
}
void
block_FifoEmpty
(
block_fifo_t
*
p_fifo
)
/**
* Clears all blocks in a FIFO.
*/
void
block_FifoEmpty
(
block_fifo_t
*
fifo
)
{
block_t
*
block
;
vlc_mutex_lock
(
&
p_fifo
->
lock
);
block
=
p_fifo
->
p_first
;
if
(
block
!=
NULL
)
{
p_fifo
->
i_depth
=
p_fifo
->
i_size
=
0
;
p_fifo
->
p_first
=
NULL
;
p_fifo
->
pp_last
=
&
p_fifo
->
p_first
;
}
vlc_cond_broadcast
(
&
p_fifo
->
wait_room
);
vlc_mutex_unlock
(
&
p_fifo
->
lock
);
while
(
block
!=
NULL
)
{
block_t
*
buf
;
buf
=
block
->
p_next
;
block_Release
(
block
);
block
=
buf
;
}
vlc_fifo_Lock
(
fifo
);
block
=
vlc_fifo_DequeueAllUnlocked
(
fifo
);
vlc_fifo_Unlock
(
fifo
);
block_ChainRelease
(
block
);
}
/**
...
...
@@ -336,33 +324,12 @@ void block_FifoPace (block_fifo_t *fifo, size_t max_depth, size_t max_size)
* Immediately queue one block at the end of a FIFO.
* @param fifo queue
* @param block head of a block list to queue (may be NULL)
* @return total number of bytes appended to the queue
*/
size_t
block_FifoPut
(
block_fifo_t
*
p_fifo
,
block_t
*
p_block
)
void
block_FifoPut
(
block_fifo_t
*
fifo
,
block_t
*
block
)
{
size_t
i_size
=
0
,
i_depth
=
0
;
block_t
*
p_last
;
if
(
p_block
==
NULL
)
return
0
;
for
(
p_last
=
p_block
;
;
p_last
=
p_last
->
p_next
)
{
i_size
+=
p_last
->
i_buffer
;
i_depth
++
;
if
(
!
p_last
->
p_next
)
break
;
}
vlc_mutex_lock
(
&
p_fifo
->
lock
);
*
p_fifo
->
pp_last
=
p_block
;
p_fifo
->
pp_last
=
&
p_last
->
p_next
;
p_fifo
->
i_depth
+=
i_depth
;
p_fifo
->
i_size
+=
i_size
;
/* We queued at least one block: wake up one read-waiting thread */
vlc_cond_signal
(
&
p_fifo
->
wait
);
vlc_mutex_unlock
(
&
p_fifo
->
lock
);
return
i_size
;
vlc_fifo_Lock
(
fifo
);
vlc_fifo_QueueUnlocked
(
fifo
,
block
);
vlc_fifo_Unlock
(
fifo
);
}
void
block_FifoWake
(
block_fifo_t
*
p_fifo
)
...
...
@@ -380,46 +347,24 @@ void block_FifoWake( block_fifo_t *p_fifo )
*
* @return a valid block, or NULL if block_FifoWake() was called.
*/
block_t
*
block_FifoGet
(
block_fifo_t
*
p_fifo
)
block_t
*
block_FifoGet
(
block_fifo_t
*
fifo
)
{
block_t
*
b
;
vlc_testcancel
(
);
vlc_mutex_lock
(
&
p_fifo
->
lock
);
mutex_cleanup_push
(
&
p_fifo
->
lock
);
/* 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
);
vlc_cleanup_pop
();
b
=
p_fifo
->
p_first
;
p_fifo
->
b_force_wake
=
false
;
if
(
b
==
NULL
)
{
/* Forced wakeup */
vlc_mutex_unlock
(
&
p_fifo
->
lock
);
return
NULL
;
}
block_t
*
block
;
p_fifo
->
p_first
=
b
->
p_next
;
p_fifo
->
i_depth
--
;
p_fifo
->
i_size
-=
b
->
i_buffer
;
vlc_testcancel
();
if
(
p_fifo
->
p_first
==
NULL
)
vlc_fifo_Lock
(
fifo
);
while
(
vlc_fifo_IsEmpty
(
fifo
)
&&
!
fifo
->
b_force_wake
)
{
p_fifo
->
pp_last
=
&
p_fifo
->
p_first
;
vlc_fifo_CleanupPush
(
fifo
);
vlc_fifo_Wait
(
fifo
);
vlc_cleanup_pop
();
}
fifo
->
b_force_wake
=
false
;
block
=
vlc_fifo_DequeueUnlocked
(
fifo
);
vlc_fifo_Unlock
(
fifo
);
/* We don't know how many threads can queue new packets now. */
vlc_cond_broadcast
(
&
p_fifo
->
wait_room
);
vlc_mutex_unlock
(
&
p_fifo
->
lock
);
b
->
p_next
=
NULL
;
return
b
;
return
block
;
}
/**
...
...
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