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
390e8309
Commit
390e8309
authored
Nov 12, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{mixer,output}/alsa: migrate from DeferredMonitor to DeferEvent
parent
44c60567
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
20 deletions
+18
-20
AlsaMixerPlugin.cxx
src/mixer/plugins/AlsaMixerPlugin.cxx
+9
-9
AlsaOutputPlugin.cxx
src/output/plugins/AlsaOutputPlugin.cxx
+9
-11
No files found.
src/mixer/plugins/AlsaMixerPlugin.cxx
View file @
390e8309
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
#include "mixer/Listener.hxx"
#include "mixer/Listener.hxx"
#include "output/OutputAPI.hxx"
#include "output/OutputAPI.hxx"
#include "event/MultiSocketMonitor.hxx"
#include "event/MultiSocketMonitor.hxx"
#include "event/Defer
redMonitor
.hxx"
#include "event/Defer
Event
.hxx"
#include "event/Call.hxx"
#include "event/Call.hxx"
#include "util/ASCII.hxx"
#include "util/ASCII.hxx"
#include "util/ReusableArray.hxx"
#include "util/ReusableArray.hxx"
...
@@ -43,30 +43,30 @@ extern "C" {
...
@@ -43,30 +43,30 @@ extern "C" {
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM"
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM"
static
constexpr
unsigned
VOLUME_MIXER_ALSA_INDEX_DEFAULT
=
0
;
static
constexpr
unsigned
VOLUME_MIXER_ALSA_INDEX_DEFAULT
=
0
;
class
AlsaMixerMonitor
final
:
MultiSocketMonitor
,
DeferredMonitor
{
class
AlsaMixerMonitor
final
:
MultiSocketMonitor
{
DeferEvent
defer_invalidate_sockets
;
snd_mixer_t
*
mixer
;
snd_mixer_t
*
mixer
;
ReusableArray
<
pollfd
>
pfd_buffer
;
ReusableArray
<
pollfd
>
pfd_buffer
;
public
:
public
:
AlsaMixerMonitor
(
EventLoop
&
_loop
,
snd_mixer_t
*
_mixer
)
AlsaMixerMonitor
(
EventLoop
&
_loop
,
snd_mixer_t
*
_mixer
)
:
MultiSocketMonitor
(
_loop
),
DeferredMonitor
(
_loop
),
:
MultiSocketMonitor
(
_loop
),
defer_invalidate_sockets
(
_loop
,
BIND_THIS_METHOD
(
InvalidateSockets
)),
mixer
(
_mixer
)
{
mixer
(
_mixer
)
{
DeferredMonitor
::
Schedule
();
defer_invalidate_sockets
.
Schedule
();
}
}
~
AlsaMixerMonitor
()
{
~
AlsaMixerMonitor
()
{
BlockingCall
(
MultiSocketMonitor
::
GetEventLoop
(),
[
this
](){
BlockingCall
(
MultiSocketMonitor
::
GetEventLoop
(),
[
this
](){
MultiSocketMonitor
::
Reset
();
MultiSocketMonitor
::
Reset
();
DeferredMonitor
::
Cancel
();
defer_invalidate_sockets
.
Cancel
();
});
});
}
}
private
:
private
:
virtual
void
RunDeferred
()
override
{
InvalidateSockets
();
}
virtual
std
::
chrono
::
steady_clock
::
duration
PrepareSockets
()
override
;
virtual
std
::
chrono
::
steady_clock
::
duration
PrepareSockets
()
override
;
virtual
void
DispatchSockets
()
override
;
virtual
void
DispatchSockets
()
override
;
};
};
...
...
src/output/plugins/AlsaOutputPlugin.cxx
View file @
390e8309
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
#include "util/ConstBuffer.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringView.hxx"
#include "util/StringView.hxx"
#include "event/MultiSocketMonitor.hxx"
#include "event/MultiSocketMonitor.hxx"
#include "event/Defer
redMonitor
.hxx"
#include "event/Defer
Event
.hxx"
#include "event/Call.hxx"
#include "event/Call.hxx"
#include "Log.hxx"
#include "Log.hxx"
...
@@ -51,7 +51,9 @@ static const char default_device[] = "default";
...
@@ -51,7 +51,9 @@ static const char default_device[] = "default";
static
constexpr
unsigned
MPD_ALSA_BUFFER_TIME_US
=
500000
;
static
constexpr
unsigned
MPD_ALSA_BUFFER_TIME_US
=
500000
;
class
AlsaOutput
final
class
AlsaOutput
final
:
AudioOutput
,
MultiSocketMonitor
,
DeferredMonitor
{
:
AudioOutput
,
MultiSocketMonitor
{
DeferEvent
defer_invalidate_sockets
;
Manual
<
PcmExport
>
pcm_export
;
Manual
<
PcmExport
>
pcm_export
;
...
@@ -224,7 +226,7 @@ private:
...
@@ -224,7 +226,7 @@ private:
return
;
return
;
active
=
true
;
active
=
true
;
DeferredMonitor
::
Schedule
();
defer_invalidate_sockets
.
Schedule
();
}
}
/**
/**
...
@@ -294,11 +296,6 @@ private:
...
@@ -294,11 +296,6 @@ private:
return
!!
error
;
return
!!
error
;
}
}
/* virtual methods from class DeferredMonitor */
virtual
void
RunDeferred
()
override
{
InvalidateSockets
();
}
/* virtual methods from class MultiSocketMonitor */
/* virtual methods from class MultiSocketMonitor */
virtual
std
::
chrono
::
steady_clock
::
duration
PrepareSockets
()
override
;
virtual
std
::
chrono
::
steady_clock
::
duration
PrepareSockets
()
override
;
virtual
void
DispatchSockets
()
override
;
virtual
void
DispatchSockets
()
override
;
...
@@ -306,9 +303,10 @@ private:
...
@@ -306,9 +303,10 @@ private:
static
constexpr
Domain
alsa_output_domain
(
"alsa_output"
);
static
constexpr
Domain
alsa_output_domain
(
"alsa_output"
);
AlsaOutput
::
AlsaOutput
(
EventLoop
&
loop
,
const
ConfigBlock
&
block
)
AlsaOutput
::
AlsaOutput
(
EventLoop
&
_
loop
,
const
ConfigBlock
&
block
)
:
AudioOutput
(
FLAG_ENABLE_DISABLE
),
:
AudioOutput
(
FLAG_ENABLE_DISABLE
),
MultiSocketMonitor
(
loop
),
DeferredMonitor
(
loop
),
MultiSocketMonitor
(
_loop
),
defer_invalidate_sockets
(
_loop
,
BIND_THIS_METHOD
(
InvalidateSockets
)),
device
(
block
.
GetBlockValue
(
"device"
,
""
)),
device
(
block
.
GetBlockValue
(
"device"
,
""
)),
#ifdef ENABLE_DSD
#ifdef ENABLE_DSD
dop_setting
(
block
.
GetBlockValue
(
"dop"
,
false
)
||
dop_setting
(
block
.
GetBlockValue
(
"dop"
,
false
)
||
...
@@ -747,7 +745,7 @@ AlsaOutput::Close() noexcept
...
@@ -747,7 +745,7 @@ AlsaOutput::Close() noexcept
/* make sure the I/O thread isn't inside DispatchSockets() */
/* make sure the I/O thread isn't inside DispatchSockets() */
BlockingCall
(
MultiSocketMonitor
::
GetEventLoop
(),
[
this
](){
BlockingCall
(
MultiSocketMonitor
::
GetEventLoop
(),
[
this
](){
MultiSocketMonitor
::
Reset
();
MultiSocketMonitor
::
Reset
();
DeferredMonitor
::
Cancel
();
defer_invalidate_sockets
.
Cancel
();
});
});
period_buffer
.
Free
();
period_buffer
.
Free
();
...
...
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