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
a77506ae
Commit
a77506ae
authored
Aug 06, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/httpd: forced flush after 32 kB of input data
Avoid buffer underruns on the streaming client, if the encoder is "too efficient" (e.g. when encoding silence while paused).
parent
ed5d2973
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
httpd_internal.h
src/output/httpd_internal.h
+8
-0
httpd_output_plugin.c
src/output/httpd_output_plugin.c
+15
-0
No files found.
src/output/httpd_internal.h
View file @
a77506ae
...
...
@@ -52,6 +52,14 @@ struct httpd_output {
struct
encoder
*
encoder
;
/**
* Number of bytes which were fed into the encoder, without
* ever receiving new output. This is used to estimate
* whether MPD should manually flush the encoder, to avoid
* buffer underruns in the client.
*/
size_t
unflushed_input
;
/**
* The MIME type produced by the #encoder.
*/
const
char
*
content_type
;
...
...
src/output/httpd_output_plugin.c
View file @
a77506ae
...
...
@@ -262,12 +262,22 @@ httpd_output_read_page(struct httpd_output *httpd)
{
size_t
size
=
0
,
nbytes
;
if
(
httpd
->
unflushed_input
>=
65536
)
{
/* we have fed a lot of input into the encoder, but it
didn't give anything back yet - flush now to avoid
buffer underruns */
encoder_flush
(
httpd
->
encoder
,
NULL
);
httpd
->
unflushed_input
=
0
;
}
do
{
nbytes
=
encoder_read
(
httpd
->
encoder
,
httpd
->
buffer
+
size
,
sizeof
(
httpd
->
buffer
)
-
size
);
if
(
nbytes
==
0
)
break
;
httpd
->
unflushed_input
=
0
;
size
+=
nbytes
;
}
while
(
size
<
sizeof
(
httpd
->
buffer
));
...
...
@@ -292,6 +302,9 @@ httpd_output_encoder_open(struct httpd_output *httpd,
bytes of encoder output after opening it, because it has to
be sent to every new client */
httpd
->
header
=
httpd_output_read_page
(
httpd
);
httpd
->
unflushed_input
=
0
;
return
true
;
}
...
...
@@ -451,6 +464,8 @@ httpd_output_encode_and_play(struct httpd_output *httpd,
if
(
!
success
)
return
false
;
httpd
->
unflushed_input
+=
size
;
httpd_output_encoder_to_clients
(
httpd
);
return
true
;
...
...
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