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
69a9d291
Commit
69a9d291
authored
Dec 31, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/httpd: move code to methods Delay(), Play(), Cancel()
parent
e2425592
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
22 deletions
+46
-22
HttpdInternal.hxx
src/output/HttpdInternal.hxx
+7
-0
HttpdOutputPlugin.cxx
src/output/HttpdOutputPlugin.cxx
+39
-22
No files found.
src/output/HttpdInternal.hxx
View file @
69a9d291
...
...
@@ -213,6 +213,9 @@ struct HttpdOutput final : private ServerSocket {
*/
void
SendHeader
(
HttpdClient
&
client
)
const
;
gcc_pure
unsigned
Delay
()
const
;
/**
* Reads data from the encoder (as much as available) and
* returns it as a new #page object.
...
...
@@ -235,6 +238,10 @@ struct HttpdOutput final : private ServerSocket {
void
SendTag
(
const
Tag
*
tag
);
size_t
Play
(
const
void
*
chunk
,
size_t
size
,
Error
&
error
);
void
CancelAllClients
();
private
:
virtual
void
OnAccept
(
int
fd
,
const
sockaddr
&
address
,
size_t
address_length
,
int
uid
)
override
;
...
...
src/output/HttpdOutputPlugin.cxx
View file @
69a9d291
...
...
@@ -361,17 +361,15 @@ HttpdOutput::SendHeader(HttpdClient &client) const
client
.
PushPage
(
header
);
}
static
unsigned
httpd_output_delay
(
struct
audio_output
*
ao
)
inline
unsigned
HttpdOutput
::
Delay
()
const
{
HttpdOutput
*
httpd
=
HttpdOutput
::
Cast
(
ao
);
if
(
!
httpd
->
LockHasClients
()
&&
httpd
->
base
.
pause
)
{
if
(
!
LockHasClients
()
&&
base
.
pause
)
{
/* if there's no client and this output is paused,
then httpd_output_pause() will not do anything, it
will not fill the buffer and it will not update the
timer; therefore, we reset the timer here */
httpd
->
timer
->
Reset
();
timer
->
Reset
();
/* some arbitrary delay that is long enough to avoid
consuming too much CPU, and short enough to notice
...
...
@@ -379,11 +377,19 @@ httpd_output_delay(struct audio_output *ao)
return
1000
;
}
return
httpd
->
timer
->
IsStarted
()
?
httpd
->
timer
->
GetDelay
()
return
timer
->
IsStarted
()
?
timer
->
GetDelay
()
:
0
;
}
static
unsigned
httpd_output_delay
(
struct
audio_output
*
ao
)
{
HttpdOutput
*
httpd
=
HttpdOutput
::
Cast
(
ao
);
return
httpd
->
Delay
();
}
void
HttpdOutput
::
BroadcastPage
(
Page
*
page
)
{
...
...
@@ -426,24 +432,30 @@ HttpdOutput::EncodeAndPlay(const void *chunk, size_t size, Error &error)
return
true
;
}
static
size_t
httpd_output_play
(
struct
audio_output
*
ao
,
const
void
*
chunk
,
size_t
size
,
Error
&
error
)
inline
size_t
HttpdOutput
::
Play
(
const
void
*
chunk
,
size_t
size
,
Error
&
error
)
{
HttpdOutput
*
httpd
=
HttpdOutput
::
Cast
(
ao
);
if
(
httpd
->
LockHasClients
())
{
if
(
!
httpd
->
EncodeAndPlay
(
chunk
,
size
,
error
))
if
(
LockHasClients
())
{
if
(
!
EncodeAndPlay
(
chunk
,
size
,
error
))
return
0
;
}
if
(
!
httpd
->
timer
->
IsStarted
())
httpd
->
timer
->
Start
();
httpd
->
timer
->
Add
(
size
);
if
(
!
timer
->
IsStarted
())
timer
->
Start
();
timer
->
Add
(
size
);
return
size
;
}
static
size_t
httpd_output_play
(
struct
audio_output
*
ao
,
const
void
*
chunk
,
size_t
size
,
Error
&
error
)
{
HttpdOutput
*
httpd
=
HttpdOutput
::
Cast
(
ao
);
return
httpd
->
Play
(
chunk
,
size
,
error
);
}
static
bool
httpd_output_pause
(
struct
audio_output
*
ao
)
{
...
...
@@ -515,14 +527,19 @@ httpd_output_tag(struct audio_output *ao, const Tag *tag)
httpd
->
SendTag
(
tag
);
}
inline
void
HttpdOutput
::
CancelAllClients
()
{
const
ScopeLock
protect
(
mutex
);
for
(
auto
&
client
:
clients
)
client
.
CancelQueue
();
}
static
void
httpd_output_cancel
(
struct
audio_output
*
ao
)
{
HttpdOutput
*
httpd
=
HttpdOutput
::
Cast
(
ao
);
const
ScopeLock
protect
(
httpd
->
mutex
);
for
(
auto
&
client
:
httpd
->
clients
)
client
.
CancelQueue
();
httpd
->
CancelAllClients
();
}
const
struct
audio_output_plugin
httpd_output_plugin
=
{
...
...
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