Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
2cf6b776
Commit
2cf6b776
authored
May 16, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/buffering: eliminate "idle" flag, automatically seek to next hole
parent
a5c09f4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
BufferingInputStream.cxx
src/input/BufferingInputStream.cxx
+17
-12
BufferingInputStream.hxx
src/input/BufferingInputStream.hxx
+1
-1
No files found.
src/input/BufferingInputStream.cxx
View file @
2cf6b776
...
...
@@ -105,7 +105,6 @@ BufferingInputStream::Read(std::unique_lock<Mutex> &lock, void *ptr, size_t s)
if
(
!
IsAvailable
())
{
/* wake up the sleeping thread */
idle
=
false
;
wake_cond
.
notify_one
();
}
...
...
@@ -117,12 +116,6 @@ BufferingInputStream::Read(std::unique_lock<Mutex> &lock, void *ptr, size_t s)
std
::
rethrow_exception
(
std
::
exchange
(
read_error
,
{}));
}
if
(
idle
)
{
/* wake up the sleeping thread */
idle
=
false
;
wake_cond
.
notify_one
();
}
client_cond
.
wait
(
lock
);
}
}
...
...
@@ -158,11 +151,10 @@ BufferingInputStream::RunThread() noexcept
seek_error
=
std
::
current_exception
();
}
idle
=
false
;
seek
=
false
;
read_error
=
{};
client_cond
.
notify_one
();
}
else
if
(
read_error
||
idle
)
{
}
else
if
(
read_error
)
{
/* wait for client to consume the read error */
wake_cond
.
wait
(
lock
);
}
else
if
(
offset
!=
input
->
GetOffset
()
&&
!
IsAvailable
())
{
...
...
@@ -214,9 +206,22 @@ BufferingInputStream::RunThread() noexcept
if
(
w
.
empty
())
{
if
(
IsAvailable
())
{
/* we still have enough data
for the next Read() - sleep
until we need more data */
idle
=
true
;
for the next Read() - seek
to the first hole */
size_t
new_offset
=
FindFirstHole
();
if
(
new_offset
==
INVALID_OFFSET
)
/* the file has been
read completely */
break
;
try
{
input
->
Seek
(
lock
,
new_offset
);
}
catch
(...)
{
read_error
=
std
::
current_exception
();
client_cond
.
notify_one
();
OnBufferAvailable
();
}
}
else
{
/* we need more data at our
current position, because
...
...
src/input/BufferingInputStream.hxx
View file @
2cf6b776
...
...
@@ -55,7 +55,7 @@ class BufferingInputStream : InputStreamHandler {
SparseBuffer
<
uint8_t
>
buffer
;
bool
stop
=
false
,
seek
=
false
,
idle
=
false
;
bool
stop
=
false
,
seek
=
false
;
size_t
offset
=
0
;
...
...
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