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
e1b62fb9
Commit
e1b62fb9
authored
Mar 05, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v0.22.x'
parents
422cf5f1
93016ac6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
457 additions
and
76 deletions
+457
-76
NEWS
NEWS
+1
-0
WasapiMixerPlugin.cxx
src/mixer/plugins/WasapiMixerPlugin.cxx
+16
-38
Registry.cxx
src/output/Registry.cxx
+1
-1
meson.build
src/output/plugins/meson.build
+1
-1
AudioClient.hxx
src/output/plugins/wasapi/AudioClient.hxx
+103
-0
Device.hxx
src/output/plugins/wasapi/Device.hxx
+117
-0
ForMixer.hxx
src/output/plugins/wasapi/ForMixer.hxx
+44
-0
PropertyStore.hxx
src/output/plugins/wasapi/PropertyStore.hxx
+44
-0
WasapiOutputPlugin.cxx
src/output/plugins/wasapi/WasapiOutputPlugin.cxx
+0
-0
WasapiOutputPlugin.hxx
src/output/plugins/wasapi/WasapiOutputPlugin.hxx
+0
-19
ComPtr.hxx
src/win32/ComPtr.hxx
+2
-1
PropVariant.cxx
src/win32/PropVariant.cxx
+40
-0
PropVariant.hxx
src/win32/PropVariant.hxx
+31
-0
meson.build
src/win32/meson.build
+1
-0
run_output.cxx
test/run_output.cxx
+56
-16
No files found.
NEWS
View file @
e1b62fb9
...
...
@@ -15,6 +15,7 @@ ver 0.22.7 (not yet released)
- curl: don't use glibc extension
* output
- wasapi: add algorithm for finding usable audio format
- wasapi: use default device only if none was configured
ver 0.22.6 (2021/02/16)
* fix missing tags on songs in queue
...
...
src/mixer/plugins/WasapiMixerPlugin.cxx
View file @
e1b62fb9
...
...
@@ -17,15 +17,21 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "output/plugins/wasapi/ForMixer.hxx"
#include "output/plugins/wasapi/AudioClient.hxx"
#include "output/plugins/wasapi/Device.hxx"
#include "mixer/MixerInternal.hxx"
#include "
output/plugins/WasapiOutputPlugin
.hxx"
#include "
win32/ComPtr
.hxx"
#include "win32/ComWorker.hxx"
#include "win32/HResult.hxx"
#include <cmath>
#include <endpointvolume.h>
#include <optional>
#include <audioclient.h>
#include <endpointvolume.h>
#include <mmdeviceapi.h>
class
WasapiMixer
final
:
public
Mixer
{
WasapiOutput
&
output
;
...
...
@@ -43,15 +49,8 @@ public:
float
volume_level
;
if
(
wasapi_is_exclusive
(
output
))
{
ComPtr
<
IAudioEndpointVolume
>
endpoint_volume
;
result
=
wasapi_output_get_device
(
output
)
->
Activate
(
__uuidof
(
IAudioEndpointVolume
),
CLSCTX_ALL
,
nullptr
,
endpoint_volume
.
AddressCast
());
if
(
FAILED
(
result
))
{
throw
FormatHResultError
(
result
,
"Unable to get device "
"endpoint volume"
);
}
auto
endpoint_volume
=
Activate
<
IAudioEndpointVolume
>
(
*
wasapi_output_get_device
(
output
));
result
=
endpoint_volume
->
GetMasterVolumeLevelScalar
(
&
volume_level
);
...
...
@@ -61,15 +60,8 @@ public:
"volume level"
);
}
}
else
{
ComPtr
<
ISimpleAudioVolume
>
session_volume
;
result
=
wasapi_output_get_client
(
output
)
->
GetService
(
__uuidof
(
ISimpleAudioVolume
),
session_volume
.
AddressCast
<
void
>
());
if
(
FAILED
(
result
))
{
throw
FormatHResultError
(
result
,
"Unable to get client "
"session volume"
);
}
auto
session_volume
=
GetService
<
ISimpleAudioVolume
>
(
*
wasapi_output_get_client
(
output
));
result
=
session_volume
->
GetMasterVolume
(
&
volume_level
);
if
(
FAILED
(
result
))
{
...
...
@@ -89,15 +81,8 @@ public:
const
float
volume_level
=
volume
/
100.0
f
;
if
(
wasapi_is_exclusive
(
output
))
{
ComPtr
<
IAudioEndpointVolume
>
endpoint_volume
;
result
=
wasapi_output_get_device
(
output
)
->
Activate
(
__uuidof
(
IAudioEndpointVolume
),
CLSCTX_ALL
,
nullptr
,
endpoint_volume
.
AddressCast
());
if
(
FAILED
(
result
))
{
throw
FormatHResultError
(
result
,
"Unable to get device endpoint volume"
);
}
auto
endpoint_volume
=
Activate
<
IAudioEndpointVolume
>
(
*
wasapi_output_get_device
(
output
));
result
=
endpoint_volume
->
SetMasterVolumeLevelScalar
(
volume_level
,
nullptr
);
...
...
@@ -107,15 +92,8 @@ public:
"Unable to set master volume level"
);
}
}
else
{
ComPtr
<
ISimpleAudioVolume
>
session_volume
;
result
=
wasapi_output_get_client
(
output
)
->
GetService
(
__uuidof
(
ISimpleAudioVolume
),
session_volume
.
AddressCast
<
void
>
());
if
(
FAILED
(
result
))
{
throw
FormatHResultError
(
result
,
"Unable to get client session volume"
);
}
auto
session_volume
=
GetService
<
ISimpleAudioVolume
>
(
*
wasapi_output_get_client
(
output
));
result
=
session_volume
->
SetMasterVolume
(
volume_level
,
nullptr
);
...
...
src/output/Registry.cxx
View file @
e1b62fb9
...
...
@@ -44,7 +44,7 @@
#include "plugins/WinmmOutputPlugin.hxx"
#endif
#ifdef ENABLE_WASAPI_OUTPUT
#include "plugins/WasapiOutputPlugin.hxx"
#include "plugins/
wasapi/
WasapiOutputPlugin.hxx"
#endif
#include "util/StringAPI.hxx"
...
...
src/output/plugins/meson.build
View file @
e1b62fb9
...
...
@@ -154,7 +154,7 @@ endif
output_features.set('ENABLE_WASAPI_OUTPUT', is_windows)
if is_windows
output_plugins_sources += [
'WasapiOutputPlugin.cxx',
'
wasapi/
WasapiOutputPlugin.cxx',
]
wasapi_dep = [
c_compiler.find_library('ksuser', required: true),
...
...
src/output/plugins/wasapi/AudioClient.hxx
0 → 100644
View file @
e1b62fb9
/*
* Copyright 2020-2021 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_WASAPI_AUDIO_CLIENT_HXX
#define MPD_WASAPI_AUDIO_CLIENT_HXX
#include "win32/ComHeapPtr.hxx"
#include "win32/ComPtr.hxx"
#include "win32/HResult.hxx"
#include <audioclient.h>
inline
UINT32
GetBufferSizeInFrames
(
IAudioClient
&
client
)
{
UINT32
buffer_size_in_frames
;
HRESULT
result
=
client
.
GetBufferSize
(
&
buffer_size_in_frames
);
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Unable to get audio client buffer size"
);
return
buffer_size_in_frames
;
}
inline
UINT32
GetCurrentPaddingFrames
(
IAudioClient
&
client
)
{
UINT32
padding_frames
;
HRESULT
result
=
client
.
GetCurrentPadding
(
&
padding_frames
);
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Failed to get current padding"
);
return
padding_frames
;
}
inline
ComHeapPtr
<
WAVEFORMATEX
>
GetMixFormat
(
IAudioClient
&
client
)
{
WAVEFORMATEX
*
f
;
HRESULT
result
=
client
.
GetMixFormat
(
&
f
);
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"GetMixFormat failed"
);
return
ComHeapPtr
{
f
};
}
inline
void
Start
(
IAudioClient
&
client
)
{
HRESULT
result
=
client
.
Start
();
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Failed to start client"
);
}
inline
void
Stop
(
IAudioClient
&
client
)
{
HRESULT
result
=
client
.
Stop
();
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Failed to stop client"
);
}
inline
void
SetEventHandle
(
IAudioClient
&
client
,
HANDLE
h
)
{
HRESULT
result
=
client
.
SetEventHandle
(
h
);
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Unable to set event handle"
);
}
template
<
typename
T
>
inline
ComPtr
<
T
>
GetService
(
IAudioClient
&
client
)
{
T
*
p
=
nullptr
;
HRESULT
result
=
client
.
GetService
(
IID_PPV_ARGS
(
&
p
));
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Unable to get service"
);
return
ComPtr
{
p
};
}
#endif
src/output/plugins/wasapi/Device.hxx
0 → 100644
View file @
e1b62fb9
/*
* Copyright 2020-2021 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_WASAPI_DEVICE_COLLECTION_HXX
#define MPD_WASAPI_DEVICE_COLLECTION_HXX
#include "win32/ComPtr.hxx"
#include "win32/HResult.hxx"
#include <mmdeviceapi.h>
inline
ComPtr
<
IMMDevice
>
GetDefaultAudioEndpoint
(
IMMDeviceEnumerator
&
e
)
{
IMMDevice
*
device
=
nullptr
;
HRESULT
result
=
e
.
GetDefaultAudioEndpoint
(
eRender
,
eMultimedia
,
&
device
);
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Unable to get default device for multimedia"
);
return
ComPtr
{
device
};
}
inline
ComPtr
<
IMMDeviceCollection
>
EnumAudioEndpoints
(
IMMDeviceEnumerator
&
e
)
{
IMMDeviceCollection
*
dc
=
nullptr
;
HRESULT
result
=
e
.
EnumAudioEndpoints
(
eRender
,
DEVICE_STATE_ACTIVE
,
&
dc
);
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Unable to enumerate devices"
);
return
ComPtr
{
dc
};
}
inline
UINT
GetCount
(
IMMDeviceCollection
&
dc
)
{
UINT
count
;
HRESULT
result
=
dc
.
GetCount
(
&
count
);
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Collection->GetCount failed"
);
return
count
;
}
inline
ComPtr
<
IMMDevice
>
Item
(
IMMDeviceCollection
&
dc
,
UINT
i
)
{
IMMDevice
*
device
=
nullptr
;
auto
result
=
dc
.
Item
(
i
,
&
device
);
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Collection->Item failed"
);
return
ComPtr
{
device
};
}
inline
DWORD
GetState
(
IMMDevice
&
device
)
{
DWORD
state
;
HRESULT
result
=
device
.
GetState
(
&
state
);;
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Unable to get device status"
);
return
state
;
}
template
<
typename
T
>
inline
ComPtr
<
T
>
Activate
(
IMMDevice
&
device
)
{
T
*
p
=
nullptr
;
HRESULT
result
=
device
.
Activate
(
__uuidof
(
T
),
CLSCTX_ALL
,
nullptr
,
(
void
**
)
&
p
);
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Unable to activate device"
);
return
ComPtr
{
p
};
}
inline
ComPtr
<
IPropertyStore
>
OpenPropertyStore
(
IMMDevice
&
device
)
{
IPropertyStore
*
property_store
=
nullptr
;
HRESULT
result
=
device
.
OpenPropertyStore
(
STGM_READ
,
&
property_store
);
if
(
FAILED
(
result
))
throw
FormatHResultError
(
result
,
"Device->OpenPropertyStore failed"
);
return
ComPtr
{
property_store
};
}
#endif
src/output/plugins/wasapi/ForMixer.hxx
0 → 100644
View file @
e1b62fb9
/*
* Copyright 2020-2021 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_WASAPI_OUTPUT_FOR_MIXER_HXX
#define MPD_WASAPI_OUTPUT_FOR_MIXER_HXX
struct
IMMDevice
;
struct
IAudioClient
;
class
AudioOutput
;
class
WasapiOutput
;
[[
gnu
::
pure
]]
WasapiOutput
&
wasapi_output_downcast
(
AudioOutput
&
output
)
noexcept
;
[[
gnu
::
pure
]]
bool
wasapi_is_exclusive
(
WasapiOutput
&
output
)
noexcept
;
[[
gnu
::
pure
]]
IMMDevice
*
wasapi_output_get_device
(
WasapiOutput
&
output
)
noexcept
;
[[
gnu
::
pure
]]
IAudioClient
*
wasapi_output_get_client
(
WasapiOutput
&
output
)
noexcept
;
#endif
src/output/plugins/wasapi/PropertyStore.hxx
0 → 100644
View file @
e1b62fb9
/*
* Copyright 2020-2021 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_WASAPI_PROPERTY_STORE_HXX
#define MPD_WASAPI_PROPERTY_STORE_HXX
#include "win32/PropVariant.hxx"
#include "util/AllocatedString.hxx"
#include "util/ScopeExit.hxx"
#include <propsys.h>
[[
gnu
::
pure
]]
inline
AllocatedString
GetString
(
IPropertyStore
&
ps
,
REFPROPERTYKEY
key
)
noexcept
{
PROPVARIANT
pv
;
PropVariantInit
(
&
pv
);
HRESULT
result
=
ps
.
GetValue
(
key
,
&
pv
);
if
(
FAILED
(
result
))
return
nullptr
;
AtScopeExit
(
&
)
{
PropVariantClear
(
&
pv
);
};
return
ToString
(
pv
);
}
#endif
src/output/plugins/WasapiOutputPlugin.cxx
→
src/output/plugins/
wasapi/
WasapiOutputPlugin.cxx
View file @
e1b62fb9
This diff is collapsed.
Click to expand it.
src/output/plugins/WasapiOutputPlugin.hxx
→
src/output/plugins/
wasapi/
WasapiOutputPlugin.hxx
View file @
e1b62fb9
...
...
@@ -20,25 +20,6 @@
#ifndef MPD_WASAPI_OUTPUT_PLUGIN_HXX
#define MPD_WASAPI_OUTPUT_PLUGIN_HXX
#include "output/Features.h"
#include "../OutputAPI.hxx"
#include "util/Compiler.h"
#include "win32/ComPtr.hxx"
#include <audioclient.h>
#include <mmdeviceapi.h>
extern
const
struct
AudioOutputPlugin
wasapi_output_plugin
;
class
WasapiOutput
;
gcc_pure
WasapiOutput
&
wasapi_output_downcast
(
AudioOutput
&
output
)
noexcept
;
gcc_pure
bool
wasapi_is_exclusive
(
WasapiOutput
&
output
)
noexcept
;
gcc_pure
IMMDevice
*
wasapi_output_get_device
(
WasapiOutput
&
output
)
noexcept
;
gcc_pure
IAudioClient
*
wasapi_output_get_client
(
WasapiOutput
&
output
)
noexcept
;
#endif
src/win32/ComPtr.hxx
View file @
e1b62fb9
...
...
@@ -32,6 +32,7 @@ template <typename T>
class
ComPtr
{
public
:
using
pointer
=
T
*
;
using
reference
=
T
&
;
using
element_type
=
T
;
constexpr
ComPtr
()
noexcept
:
ptr
(
nullptr
)
{}
...
...
@@ -75,7 +76,7 @@ public:
pointer
get
()
const
noexcept
{
return
ptr
;
}
explicit
operator
bool
()
const
noexcept
{
return
ptr
;
}
auto
operator
*
()
cons
t
{
return
*
ptr
;
}
reference
operator
*
()
const
noexcep
t
{
return
*
ptr
;
}
pointer
operator
->
()
const
noexcept
{
return
ptr
;
}
void
CoCreateInstance
(
REFCLSID
class_id
,
LPUNKNOWN
unknown_outer
=
nullptr
,
...
...
src/win32/PropVariant.cxx
0 → 100644
View file @
e1b62fb9
/*
* Copyright 2020-2021 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 "PropVariant.hxx"
#include "lib/icu/Win32.hxx"
#include "util/AllocatedString.hxx"
#include "util/ScopeExit.hxx"
AllocatedString
ToString
(
const
PROPVARIANT
&
pv
)
noexcept
{
// TODO: VT_BSTR
switch
(
pv
.
vt
)
{
case
VT_LPSTR
:
return
AllocatedString
{
static_cast
<
const
char
*>
(
pv
.
pszVal
)};
case
VT_LPWSTR
:
return
WideCharToMultiByte
(
CP_UTF8
,
pv
.
pwszVal
);
default:
return
nullptr
;
}
}
src/win32/PropVariant.hxx
0 → 100644
View file @
e1b62fb9
/*
* Copyright 2020-2021 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_WIN32_PROPVARIANT_HXX
#define MPD_WIN32_PROPVARIANT_HXX
#include <propidl.h>
class
AllocatedString
;
[[
gnu
::
pure
]]
AllocatedString
ToString
(
const
PROPVARIANT
&
pv
)
noexcept
;
#endif
src/win32/meson.build
View file @
e1b62fb9
...
...
@@ -7,6 +7,7 @@ win32 = static_library(
'win32',
'ComWorker.cxx',
'HResult.cxx',
'PropVariant.cxx',
'WinEvent.cxx',
include_directories: inc,
)
...
...
test/run_output.cxx
View file @
e1b62fb9
...
...
@@ -26,10 +26,13 @@
#include "fs/NarrowPath.hxx"
#include "pcm/AudioParser.hxx"
#include "pcm/AudioFormat.hxx"
#include "util/OptionDef.hxx"
#include "util/OptionParser.hxx"
#include "util/StringBuffer.hxx"
#include "util/RuntimeError.hxx"
#include "util/ScopeExit.hxx"
#include "util/PrintException.hxx"
#include "LogBackend.hxx"
#include <cassert>
#include <memory>
...
...
@@ -39,6 +42,51 @@
#include <stdlib.h>
#include <stdio.h>
struct
CommandLine
{
FromNarrowPath
config_path
;
const
char
*
output_name
=
nullptr
;
AudioFormat
audio_format
{
44100
,
SampleFormat
::
S16
,
2
};
bool
verbose
=
false
;
};
enum
Option
{
OPTION_VERBOSE
,
};
static
constexpr
OptionDef
option_defs
[]
=
{
{
"verbose"
,
'v'
,
false
,
"Verbose logging"
},
};
static
CommandLine
ParseCommandLine
(
int
argc
,
char
**
argv
)
{
CommandLine
c
;
OptionParser
option_parser
(
option_defs
,
argc
,
argv
);
while
(
auto
o
=
option_parser
.
Next
())
{
switch
(
Option
(
o
.
index
))
{
case
OPTION_VERBOSE
:
c
.
verbose
=
true
;
break
;
}
}
auto
args
=
option_parser
.
GetRemaining
();
if
(
args
.
size
<
2
||
args
.
size
>
3
)
throw
std
::
runtime_error
(
"Usage: run_output CONFIG NAME [FORMAT] <IN"
);
c
.
config_path
=
args
[
0
];
c
.
output_name
=
args
[
1
];
if
(
args
.
size
>
2
)
c
.
audio_format
=
ParseAudioFormat
(
args
[
2
],
false
);
return
c
;
}
static
std
::
unique_ptr
<
AudioOutput
>
LoadAudioOutput
(
const
ConfigData
&
config
,
EventLoop
&
event_loop
,
const
char
*
name
)
...
...
@@ -57,6 +105,8 @@ LoadAudioOutput(const ConfigData &config, EventLoop &event_loop,
if
(
plugin
==
nullptr
)
throw
FormatRuntimeError
(
"No such audio output plugin: %s"
,
plugin_name
);
#include "util/OptionDef.hxx"
#include "util/OptionParser.hxx"
return
std
::
unique_ptr
<
AudioOutput
>
(
ao_plugin_init
(
event_loop
,
*
plugin
,
*
block
));
...
...
@@ -107,34 +157,24 @@ run_output(AudioOutput &ao, AudioFormat audio_format)
int
main
(
int
argc
,
char
**
argv
)
try
{
if
(
argc
<
3
||
argc
>
4
)
{
fprintf
(
stderr
,
"Usage: run_output CONFIG NAME [FORMAT] <IN
\n
"
);
return
EXIT_FAILURE
;
}
const
FromNarrowPath
config_path
=
argv
[
1
];
AudioFormat
audio_format
(
44100
,
SampleFormat
::
S16
,
2
);
const
auto
c
=
ParseCommandLine
(
argc
,
argv
);
SetLogThreshold
(
c
.
verbose
?
LogLevel
::
DEBUG
:
LogLevel
::
INFO
);
/* read configuration file (mpd.conf) */
const
auto
config
=
AutoLoadConfigFile
(
config_path
);
const
auto
config
=
AutoLoadConfigFile
(
c
.
c
onfig_path
);
EventThread
io_thread
;
io_thread
.
Start
();
/* initialize the audio output */
auto
ao
=
LoadAudioOutput
(
config
,
io_thread
.
GetEventLoop
(),
argv
[
2
]);
/* parse the audio format */
if
(
argc
>
3
)
audio_format
=
ParseAudioFormat
(
argv
[
3
],
false
);
auto
ao
=
LoadAudioOutput
(
config
,
io_thread
.
GetEventLoop
(),
c
.
output_name
);
/* do it */
run_output
(
*
ao
,
audio_format
);
run_output
(
*
ao
,
c
.
audio_format
);
/* cleanup and exit */
...
...
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