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
9e503b21
Commit
9e503b21
authored
Feb 08, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{input,mixer}/alsa: move code to lib/alsa/NonBlock.cxx
parent
67a958a3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
26 deletions
+121
-26
Makefile.am
Makefile.am
+5
-0
AlsaInputPlugin.cxx
src/input/plugins/AlsaInputPlugin.cxx
+2
-14
NonBlock.cxx
src/lib/alsa/NonBlock.cxx
+62
-0
NonBlock.hxx
src/lib/alsa/NonBlock.hxx
+50
-0
AlsaMixerPlugin.cxx
src/mixer/plugins/AlsaMixerPlugin.cxx
+2
-12
No files found.
Makefile.am
View file @
9e503b21
...
...
@@ -256,6 +256,9 @@ UPNP_SOURCES = \
src/lib/upnp/WorkQueue.hxx
\
src/lib/upnp/Action.hxx
ALSA_SOURCES
=
\
src/lib/alsa/NonBlock.cxx src/lib/alsa/NonBlock.hxx
#
# Android native library
#
...
...
@@ -1294,6 +1297,7 @@ INPUT_LIBS = \
if
ENABLE_ALSA
libinput_a_SOURCES
+=
\
$(ALSA_SOURCES)
\
src/input/plugins/AlsaInputPlugin.cxx
\
src/input/plugins/AlsaInputPlugin.hxx
INPUT_LIBS
+=
$(ALSA_LIBS)
...
...
@@ -1412,6 +1416,7 @@ liboutput_plugins_a_SOURCES += \
src/output/plugins/AlsaOutputPlugin.cxx
\
src/output/plugins/AlsaOutputPlugin.hxx
libmixer_plugins_a_SOURCES
+=
\
$(ALSA_SOURCES)
\
src/mixer/plugins/volume_mapping.h
\
src/mixer/plugins/volume_mapping.c
\
src/mixer/plugins/AlsaMixerPlugin.cxx
...
...
src/input/plugins/AlsaInputPlugin.cxx
View file @
9e503b21
...
...
@@ -26,6 +26,7 @@
#include "config.h"
#include "AlsaInputPlugin.hxx"
#include "lib/alsa/NonBlock.hxx"
#include "../InputPlugin.hxx"
#include "../AsyncInputStream.hxx"
#include "event/Call.hxx"
...
...
@@ -177,20 +178,7 @@ AlsaInputStream::PrepareSockets()
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
}
int
count
=
snd_pcm_poll_descriptors_count
(
capture_handle
);
if
(
count
<=
0
)
{
ClearSocketList
();
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
}
struct
pollfd
*
pfds
=
pfd_buffer
.
Get
(
count
);
count
=
snd_pcm_poll_descriptors
(
capture_handle
,
pfds
,
count
);
if
(
count
<
0
)
count
=
0
;
ReplaceSocketList
(
pfds
,
count
);
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
return
PrepareAlsaPcmSockets
(
*
this
,
capture_handle
,
pfd_buffer
);
}
void
...
...
src/lib/alsa/NonBlock.cxx
0 → 100644
View file @
9e503b21
/*
* Copyright 2003-2017 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "NonBlock.hxx"
#include "event/MultiSocketMonitor.hxx"
std
::
chrono
::
steady_clock
::
duration
PrepareAlsaPcmSockets
(
MultiSocketMonitor
&
m
,
snd_pcm_t
*
pcm
,
ReusableArray
<
pollfd
>
&
pfd_buffer
)
{
int
count
=
snd_pcm_poll_descriptors_count
(
pcm
);
if
(
count
<=
0
)
{
m
.
ClearSocketList
();
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
}
struct
pollfd
*
pfds
=
pfd_buffer
.
Get
(
count
);
count
=
snd_pcm_poll_descriptors
(
pcm
,
pfds
,
count
);
if
(
count
<
0
)
count
=
0
;
m
.
ReplaceSocketList
(
pfds
,
count
);
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
}
std
::
chrono
::
steady_clock
::
duration
PrepareAlsaMixerSockets
(
MultiSocketMonitor
&
m
,
snd_mixer_t
*
mixer
,
ReusableArray
<
pollfd
>
&
pfd_buffer
)
{
int
count
=
snd_mixer_poll_descriptors_count
(
mixer
);
if
(
count
<=
0
)
{
m
.
ClearSocketList
();
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
}
struct
pollfd
*
pfds
=
pfd_buffer
.
Get
(
count
);
count
=
snd_mixer_poll_descriptors
(
mixer
,
pfds
,
count
);
if
(
count
<
0
)
count
=
0
;
m
.
ReplaceSocketList
(
pfds
,
count
);
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
}
src/lib/alsa/NonBlock.hxx
0 → 100644
View file @
9e503b21
/*
* Copyright 2003-2017 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ALSA_NON_BLOCK_HXX
#define MPD_ALSA_NON_BLOCK_HXX
#include "check.h"
#include "util/ReusableArray.hxx"
#include <alsa/asoundlib.h>
#include <chrono>
class
MultiSocketMonitor
;
/**
* Update #MultiSocketMonitor's socket list from
* snd_pcm_poll_descriptors(). To be called from
* MultiSocketMonitor::PrepareSockets().
*/
std
::
chrono
::
steady_clock
::
duration
PrepareAlsaPcmSockets
(
MultiSocketMonitor
&
m
,
snd_pcm_t
*
pcm
,
ReusableArray
<
pollfd
>
&
pfd_buffer
);
/**
* Update #MultiSocketMonitor's socket list from
* snd_mixer_poll_descriptors(). To be called from
* MultiSocketMonitor::PrepareSockets().
*/
std
::
chrono
::
steady_clock
::
duration
PrepareAlsaMixerSockets
(
MultiSocketMonitor
&
m
,
snd_mixer_t
*
mixer
,
ReusableArray
<
pollfd
>
&
pfd_buffer
);
#endif
src/mixer/plugins/AlsaMixerPlugin.cxx
View file @
9e503b21
...
...
@@ -18,6 +18,7 @@
*/
#include "config.h"
#include "lib/alsa/NonBlock.hxx"
#include "mixer/MixerInternal.hxx"
#include "mixer/Listener.hxx"
#include "output/OutputAPI.hxx"
...
...
@@ -108,18 +109,7 @@ AlsaMixerMonitor::PrepareSockets()
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
}
int
count
=
snd_mixer_poll_descriptors_count
(
mixer
);
if
(
count
<=
0
)
count
=
0
;
struct
pollfd
*
pfds
=
pfd_buffer
.
Get
(
count
);
count
=
snd_mixer_poll_descriptors
(
mixer
,
pfds
,
count
);
if
(
count
<
0
)
count
=
0
;
ReplaceSocketList
(
pfds
,
count
);
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
return
PrepareAlsaMixerSockets
(
*
this
,
mixer
,
pfd_buffer
);
}
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