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
7db9c7f2
Commit
7db9c7f2
authored
Mar 06, 2019
by
borine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/plugins/AlsaInputPlugin: introduce mpd.conf config block to allow user to…
input/plugins/AlsaInputPlugin: introduce mpd.conf config block to allow user to override the builtin defaults
parent
c834eb45
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
7 deletions
+34
-7
AlsaInputPlugin.cxx
src/input/plugins/AlsaInputPlugin.cxx
+34
-7
No files found.
src/input/plugins/AlsaInputPlugin.cxx
View file @
7db9c7f2
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "../AsyncInputStream.hxx"
#include "../AsyncInputStream.hxx"
#include "event/Call.hxx"
#include "event/Call.hxx"
#include "thread/Cond.hxx"
#include "thread/Cond.hxx"
#include "config/Block.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
#include "util/RuntimeError.hxx"
#include "util/RuntimeError.hxx"
#include "util/StringCompare.hxx"
#include "util/StringCompare.hxx"
...
@@ -57,6 +58,15 @@ static constexpr auto BUILTIN_DEFAULT_FORMAT = "44100:16:2";
...
@@ -57,6 +58,15 @@ static constexpr auto BUILTIN_DEFAULT_FORMAT = "44100:16:2";
static
constexpr
auto
DEFAULT_BUFFER_TIME
=
std
::
chrono
::
milliseconds
(
1000
);
static
constexpr
auto
DEFAULT_BUFFER_TIME
=
std
::
chrono
::
milliseconds
(
1000
);
static
constexpr
auto
DEFAULT_RESUME_TIME
=
DEFAULT_BUFFER_TIME
/
2
;
static
constexpr
auto
DEFAULT_RESUME_TIME
=
DEFAULT_BUFFER_TIME
/
2
;
static
struct
{
EventLoop
*
event_loop
;
const
char
*
default_device
;
const
char
*
default_format
;
int
mode
;
}
global_config
;
class
AlsaInputStream
final
class
AlsaInputStream
final
:
public
AsyncInputStream
,
:
public
AsyncInputStream
,
MultiSocketMonitor
{
MultiSocketMonitor
{
...
@@ -143,11 +153,11 @@ public:
...
@@ -143,11 +153,11 @@ public:
}
}
else
{
else
{
device_name
=
StringAfterPrefixCaseASCII
(
uri
,
ALSA_URI_PREFIX
);
device_name
=
StringAfterPrefixCaseASCII
(
uri
,
ALSA_URI_PREFIX
);
format_string
=
BUILTIN_DEFAULT_FORMAT
;
format_string
=
global_config
.
default_format
;
}
}
if
(
IsValidScheme
())
{
if
(
IsValidScheme
())
{
if
(
*
device_name
==
0
)
if
(
*
device_name
==
0
)
device_name
=
BUILTIN_DEFAULT_DEVICE
;
device_name
=
global_config
.
default_device
;
if
(
format_string
!=
nullptr
)
if
(
format_string
!=
nullptr
)
audio_format
=
ParseAudioFormat
(
format_string
,
false
);
audio_format
=
ParseAudioFormat
(
format_string
,
false
);
}
}
...
@@ -417,7 +427,7 @@ AlsaInputStream::OpenDevice(const SourceSpec &spec)
...
@@ -417,7 +427,7 @@ AlsaInputStream::OpenDevice(const SourceSpec &spec)
if
((
err
=
snd_pcm_open
(
&
capture_handle
,
spec
.
GetDeviceName
(),
if
((
err
=
snd_pcm_open
(
&
capture_handle
,
spec
.
GetDeviceName
(),
SND_PCM_STREAM_CAPTURE
,
SND_PCM_STREAM_CAPTURE
,
SND_PCM_NONBLOCK
))
<
0
)
SND_PCM_NONBLOCK
|
global_config
.
mode
))
<
0
)
throw
FormatRuntimeError
(
"Failed to open device: %s (%s)"
,
throw
FormatRuntimeError
(
"Failed to open device: %s (%s)"
,
spec
.
GetDeviceName
(),
snd_strerror
(
err
));
spec
.
GetDeviceName
(),
snd_strerror
(
err
));
...
@@ -433,18 +443,35 @@ AlsaInputStream::OpenDevice(const SourceSpec &spec)
...
@@ -433,18 +443,35 @@ AlsaInputStream::OpenDevice(const SourceSpec &spec)
/*######################### Plugin Functions ##############################*/
/*######################### Plugin Functions ##############################*/
static
EventLoop
*
alsa_input_event_loop
;
static
void
static
void
alsa_input_init
(
EventLoop
&
event_loop
,
const
ConfigBlock
&
)
alsa_input_init
(
EventLoop
&
event_loop
,
const
ConfigBlock
&
block
)
{
{
alsa_input_event_loop
=
&
event_loop
;
global_config
.
event_loop
=
&
event_loop
;
global_config
.
default_device
=
block
.
GetBlockValue
(
"default_device"
,
BUILTIN_DEFAULT_DEVICE
);
global_config
.
default_format
=
block
.
GetBlockValue
(
"default_format"
,
BUILTIN_DEFAULT_FORMAT
);
global_config
.
mode
=
0
;
#ifdef SND_PCM_NO_AUTO_RESAMPLE
if
(
!
block
.
GetBlockValue
(
"auto_resample"
,
true
))
global_config
.
mode
|=
SND_PCM_NO_AUTO_RESAMPLE
;
#endif
#ifdef SND_PCM_NO_AUTO_CHANNELS
if
(
!
block
.
GetBlockValue
(
"auto_channels"
,
true
))
global_config
.
mode
|=
SND_PCM_NO_AUTO_CHANNELS
;
#endif
#ifdef SND_PCM_NO_AUTO_FORMAT
if
(
!
block
.
GetBlockValue
(
"auto_format"
,
true
))
global_config
.
mode
|=
SND_PCM_NO_AUTO_FORMAT
;
#endif
}
}
static
InputStreamPtr
static
InputStreamPtr
alsa_input_open
(
const
char
*
uri
,
Mutex
&
mutex
)
alsa_input_open
(
const
char
*
uri
,
Mutex
&
mutex
)
{
{
return
AlsaInputStream
::
Create
(
*
alsa_input_
event_loop
,
uri
,
return
AlsaInputStream
::
Create
(
*
global_config
.
event_loop
,
uri
,
mutex
);
mutex
);
}
}
...
...
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