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
83f8eeec
Commit
83f8eeec
authored
Nov 10, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/httpd: migrate from DeferredMonitor to DeferEvent
parent
b83fbad6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
HttpdInternal.hxx
src/output/plugins/httpd/HttpdInternal.hxx
+7
-4
HttpdOutputPlugin.cxx
src/output/plugins/httpd/HttpdOutputPlugin.cxx
+6
-5
No files found.
src/output/plugins/httpd/HttpdInternal.hxx
View file @
83f8eeec
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
#include "thread/Mutex.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "thread/Cond.hxx"
#include "event/ServerSocket.hxx"
#include "event/ServerSocket.hxx"
#include "event/Defer
redMonitor
.hxx"
#include "event/Defer
Event
.hxx"
#include "util/Cast.hxx"
#include "util/Cast.hxx"
#include "Compiler.h"
#include "Compiler.h"
...
@@ -48,7 +48,7 @@ class PreparedEncoder;
...
@@ -48,7 +48,7 @@ class PreparedEncoder;
class
Encoder
;
class
Encoder
;
struct
Tag
;
struct
Tag
;
class
HttpdOutput
final
:
AudioOutput
,
ServerSocket
,
DeferredMonitor
{
class
HttpdOutput
final
:
AudioOutput
,
ServerSocket
{
/**
/**
* True if the audio output is open and accepts client
* True if the audio output is open and accepts client
* connections.
* connections.
...
@@ -114,6 +114,8 @@ private:
...
@@ -114,6 +114,8 @@ private:
*/
*/
std
::
queue
<
PagePtr
,
std
::
list
<
PagePtr
>>
pages
;
std
::
queue
<
PagePtr
,
std
::
list
<
PagePtr
>>
pages
;
DeferEvent
defer_broadcast
;
public
:
public
:
/**
/**
* The configured name.
* The configured name.
...
@@ -157,7 +159,7 @@ public:
...
@@ -157,7 +159,7 @@ public:
return
new
HttpdOutput
(
event_loop
,
block
);
return
new
HttpdOutput
(
event_loop
,
block
);
}
}
using
DeferredMonitor
::
GetEventLoop
;
using
ServerSocket
::
GetEventLoop
;
void
Bind
();
void
Bind
();
void
Unbind
();
void
Unbind
();
...
@@ -255,7 +257,8 @@ public:
...
@@ -255,7 +257,8 @@ public:
bool
Pause
()
override
;
bool
Pause
()
override
;
private
:
private
:
virtual
void
RunDeferred
()
override
;
/* DeferEvent callback */
void
OnDeferredBroadcast
()
noexcept
;
void
OnAccept
(
UniqueSocketDescriptor
fd
,
void
OnAccept
(
UniqueSocketDescriptor
fd
,
SocketAddress
address
,
int
uid
)
override
;
SocketAddress
address
,
int
uid
)
override
;
...
...
src/output/plugins/httpd/HttpdOutputPlugin.cxx
View file @
83f8eeec
...
@@ -51,7 +51,8 @@ const Domain httpd_output_domain("httpd_output");
...
@@ -51,7 +51,8 @@ const Domain httpd_output_domain("httpd_output");
inline
inline
HttpdOutput
::
HttpdOutput
(
EventLoop
&
_loop
,
const
ConfigBlock
&
block
)
HttpdOutput
::
HttpdOutput
(
EventLoop
&
_loop
,
const
ConfigBlock
&
block
)
:
AudioOutput
(
FLAG_ENABLE_DISABLE
|
FLAG_PAUSE
),
:
AudioOutput
(
FLAG_ENABLE_DISABLE
|
FLAG_PAUSE
),
ServerSocket
(
_loop
),
DeferredMonitor
(
_loop
)
ServerSocket
(
_loop
),
defer_broadcast
(
_loop
,
BIND_THIS_METHOD
(
OnDeferredBroadcast
))
{
{
/* read configuration */
/* read configuration */
name
=
block
.
GetBlockValue
(
"name"
,
"Set name in config"
);
name
=
block
.
GetBlockValue
(
"name"
,
"Set name in config"
);
...
@@ -128,7 +129,7 @@ HttpdOutput::AddClient(UniqueSocketDescriptor fd)
...
@@ -128,7 +129,7 @@ HttpdOutput::AddClient(UniqueSocketDescriptor fd)
}
}
void
void
HttpdOutput
::
RunDeferred
()
HttpdOutput
::
OnDeferredBroadcast
()
noexcept
{
{
/* this method runs in the IOThread; it broadcasts pages from
/* this method runs in the IOThread; it broadcasts pages from
our own queue to all clients */
our own queue to all clients */
...
@@ -258,7 +259,7 @@ HttpdOutput::Close() noexcept
...
@@ -258,7 +259,7 @@ HttpdOutput::Close() noexcept
delete
timer
;
delete
timer
;
BlockingCall
(
GetEventLoop
(),
[
this
](){
BlockingCall
(
GetEventLoop
(),
[
this
](){
DeferredMonitor
::
Cancel
();
defer_broadcast
.
Cancel
();
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
open
=
false
;
open
=
false
;
...
@@ -317,7 +318,7 @@ HttpdOutput::BroadcastPage(PagePtr page)
...
@@ -317,7 +318,7 @@ HttpdOutput::BroadcastPage(PagePtr page)
pages
.
emplace
(
std
::
move
(
page
));
pages
.
emplace
(
std
::
move
(
page
));
}
}
DeferredMonitor
::
Schedule
();
defer_broadcast
.
Schedule
();
}
}
void
void
...
@@ -340,7 +341,7 @@ HttpdOutput::BroadcastFromEncoder()
...
@@ -340,7 +341,7 @@ HttpdOutput::BroadcastFromEncoder()
}
}
if
(
!
empty
)
if
(
!
empty
)
DeferredMonitor
::
Schedule
();
defer_broadcast
.
Schedule
();
}
}
inline
void
inline
void
...
...
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