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
8d6fedf8
Commit
8d6fedf8
authored
Feb 05, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mixer: add class MixerListener
Use a listener interface instead of GlobalEvents.
parent
f4f8fa7c
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
144 additions
and
74 deletions
+144
-74
Makefile.am
Makefile.am
+1
-0
GlobalEvents.hxx
src/GlobalEvents.hxx
+0
-3
Main.cxx
src/Main.cxx
+0
-2
Partition.cxx
src/Partition.cxx
+11
-0
Partition.hxx
src/Partition.hxx
+7
-1
Listener.hxx
src/mixer/Listener.hxx
+34
-0
MixerControl.cxx
src/mixer/MixerControl.cxx
+2
-1
MixerControl.hxx
src/mixer/MixerControl.hxx
+2
-0
MixerInternal.hxx
src/mixer/MixerInternal.hxx
+6
-2
MixerPlugin.hxx
src/mixer/MixerPlugin.hxx
+2
-0
Volume.cxx
src/mixer/Volume.cxx
+2
-14
Volume.hxx
src/mixer/Volume.hxx
+2
-1
AlsaMixerPlugin.cxx
src/mixer/plugins/AlsaMixerPlugin.cxx
+15
-7
OssMixerPlugin.cxx
src/mixer/plugins/OssMixerPlugin.cxx
+4
-2
PulseMixerPlugin.cxx
src/mixer/plugins/PulseMixerPlugin.cxx
+8
-7
RoarMixerPlugin.cxx
src/mixer/plugins/RoarMixerPlugin.cxx
+5
-4
SoftwareMixerPlugin.cxx
src/mixer/plugins/SoftwareMixerPlugin.cxx
+4
-3
WinmmMixerPlugin.cxx
src/mixer/plugins/WinmmMixerPlugin.cxx
+4
-3
Init.cxx
src/output/Init.cxx
+11
-3
Internal.hxx
src/output/Internal.hxx
+4
-1
MultipleOutputs.cxx
src/output/MultipleOutputs.cxx
+12
-6
MultipleOutputs.hxx
src/output/MultipleOutputs.hxx
+4
-1
read_mixer.cxx
test/read_mixer.cxx
+1
-6
run_output.cxx
test/run_output.cxx
+3
-7
No files found.
Makefile.am
View file @
8d6fedf8
...
...
@@ -1033,6 +1033,7 @@ MIXER_LIBS = \
$(PULSE_LIBS)
MIXER_API_SRC
=
\
src/mixer/Listener.hxx
\
src/mixer/MixerPlugin.hxx
\
src/mixer/MixerList.hxx
\
src/mixer/MixerControl.cxx src/mixer/MixerControl.hxx
\
...
...
src/GlobalEvents.hxx
View file @
8d6fedf8
...
...
@@ -42,9 +42,6 @@ namespace GlobalEvents {
/** the current song's tag has changed */
TAG
,
/** a hardware mixer plugin has detected a change */
MIXER
,
#ifdef WIN32
/** shutdown requested */
SHUTDOWN
,
...
...
src/Main.cxx
View file @
8d6fedf8
...
...
@@ -33,7 +33,6 @@
#include "client/ClientList.hxx"
#include "command/AllCommands.hxx"
#include "Partition.hxx"
#include "mixer/Volume.hxx"
#include "tag/TagConfig.hxx"
#include "ReplayGainConfig.hxx"
#include "Idle.hxx"
...
...
@@ -469,7 +468,6 @@ int mpd_main(int argc, char *argv[])
command_init
();
initialize_decoder_and_player
();
volume_init
();
initAudioConfig
();
instance
->
partition
->
outputs
.
Configure
(
*
instance
->
event_loop
,
instance
->
partition
->
pc
);
...
...
src/Partition.cxx
View file @
8d6fedf8
...
...
@@ -21,6 +21,8 @@
#include "Partition.hxx"
#include "DetachedSong.hxx"
#include "output/MultipleOutputs.hxx"
#include "mixer/Volume.hxx"
#include "Idle.hxx"
#ifdef ENABLE_DATABASE
...
...
@@ -47,3 +49,12 @@ Partition::SyncWithPlayer()
{
playlist
.
SyncWithPlayer
(
pc
);
}
void
Partition
::
OnMixerVolumeChanged
(
gcc_unused
Mixer
&
mixer
,
gcc_unused
int
volume
)
{
InvalidateHardwareVolume
();
/* notify clients */
idle_add
(
IDLE_MIXER
);
}
src/Partition.hxx
View file @
8d6fedf8
...
...
@@ -22,6 +22,7 @@
#include "Playlist.hxx"
#include "output/MultipleOutputs.hxx"
#include "mixer/Listener.hxx"
#include "PlayerControl.hxx"
struct
Instance
;
...
...
@@ -32,7 +33,7 @@ class SongLoader;
* A partition of the Music Player Daemon. It is a separate unit with
* a playlist, a player, outputs etc.
*/
struct
Partition
{
struct
Partition
final
:
private
MixerListener
{
Instance
&
instance
;
struct
playlist
playlist
;
...
...
@@ -46,6 +47,7 @@ struct Partition {
unsigned
buffer_chunks
,
unsigned
buffered_before_play
)
:
instance
(
_instance
),
playlist
(
max_length
),
outputs
(
*
this
),
pc
(
outputs
,
buffer_chunks
,
buffered_before_play
)
{}
void
ClearQueue
()
{
...
...
@@ -188,6 +190,10 @@ struct Partition {
* Synchronize the player with the play queue.
*/
void
SyncWithPlayer
();
private
:
/* virtual methods from class MixerListener */
virtual
void
OnMixerVolumeChanged
(
Mixer
&
mixer
,
int
volume
)
override
;
};
#endif
src/mixer/Listener.hxx
0 → 100644
View file @
8d6fedf8
/*
* Copyright (C) 2003-2014 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_MIXER_LISTENER_HXX
#define MPD_MIXER_LISTENER_HXX
class
Mixer
;
/**
* An interface that listens on events from mixer plugins. The
* methods must be thread-safe and non-blocking.
*/
class
MixerListener
{
public
:
virtual
void
OnMixerVolumeChanged
(
Mixer
&
mixer
,
int
volume
)
=
0
;
};
#endif
src/mixer/MixerControl.cxx
View file @
8d6fedf8
...
...
@@ -27,10 +27,11 @@
Mixer
*
mixer_new
(
EventLoop
&
event_loop
,
const
MixerPlugin
&
plugin
,
AudioOutput
&
ao
,
MixerListener
&
listener
,
const
config_param
&
param
,
Error
&
error
)
{
Mixer
*
mixer
=
plugin
.
init
(
event_loop
,
ao
,
param
,
error
);
Mixer
*
mixer
=
plugin
.
init
(
event_loop
,
ao
,
listener
,
param
,
error
);
assert
(
mixer
==
nullptr
||
mixer
->
IsPlugin
(
plugin
));
...
...
src/mixer/MixerControl.hxx
View file @
8d6fedf8
...
...
@@ -30,10 +30,12 @@ class Mixer;
class
EventLoop
;
struct
AudioOutput
;
struct
MixerPlugin
;
class
MixerListener
;
struct
config_param
;
Mixer
*
mixer_new
(
EventLoop
&
event_loop
,
const
MixerPlugin
&
plugin
,
AudioOutput
&
ao
,
MixerListener
&
listener
,
const
config_param
&
param
,
Error
&
error
);
...
...
src/mixer/MixerInternal.hxx
View file @
8d6fedf8
...
...
@@ -25,10 +25,14 @@
#include "thread/Mutex.hxx"
#include "Compiler.h"
class
MixerListener
;
class
Mixer
{
public
:
const
MixerPlugin
&
plugin
;
MixerListener
&
listener
;
/**
* This mutex protects all of the mixer struct, including its
* implementation, so plugins don't have to deal with that.
...
...
@@ -47,8 +51,8 @@ public:
bool
failed
;
public
:
explicit
Mixer
(
const
MixerPlugin
&
_plugin
)
:
plugin
(
_plugin
),
explicit
Mixer
(
const
MixerPlugin
&
_plugin
,
MixerListener
&
_listener
)
:
plugin
(
_plugin
),
listener
(
_listener
),
open
(
false
),
failed
(
false
)
{}
...
...
src/mixer/MixerPlugin.hxx
View file @
8d6fedf8
...
...
@@ -30,6 +30,7 @@
struct
config_param
;
struct
AudioOutput
;
class
Mixer
;
class
MixerListener
;
class
EventLoop
;
class
Error
;
...
...
@@ -44,6 +45,7 @@ struct MixerPlugin {
* @return a mixer object, or nullptr on error
*/
Mixer
*
(
*
init
)(
EventLoop
&
event_loop
,
AudioOutput
&
ao
,
MixerListener
&
listener
,
const
config_param
&
param
,
Error
&
error
);
...
...
src/mixer/Volume.cxx
View file @
8d6fedf8
...
...
@@ -21,7 +21,6 @@
#include "Volume.hxx"
#include "output/MultipleOutputs.hxx"
#include "Idle.hxx"
#include "GlobalEvents.hxx"
#include "util/StringUtil.hxx"
#include "util/Domain.hxx"
#include "system/PeriodClock.hxx"
...
...
@@ -41,22 +40,11 @@ static int last_hardware_volume = -1;
/** the age of #last_hardware_volume */
static
PeriodClock
hardware_volume_clock
;
/**
* Handler for #GlobalEvents::MIXER.
*/
static
void
mixer_event_callback
(
void
)
void
InvalidateHardwareVolume
()
{
/* flush the hardware volume cache */
last_hardware_volume
=
-
1
;
/* notify clients */
idle_add
(
IDLE_MIXER
);
}
void
volume_init
(
void
)
{
GlobalEvents
::
Register
(
GlobalEvents
::
MIXER
,
mixer_event_callback
);
}
int
...
...
src/mixer/Volume.hxx
View file @
8d6fedf8
...
...
@@ -26,7 +26,8 @@
class
MultipleOutputs
;
void
volume_init
(
void
);
void
InvalidateHardwareVolume
();
gcc_pure
int
...
...
src/mixer/plugins/AlsaMixerPlugin.cxx
View file @
8d6fedf8
...
...
@@ -19,8 +19,8 @@
#include "config.h"
#include "mixer/MixerInternal.hxx"
#include "mixer/Listener.hxx"
#include "output/OutputAPI.hxx"
#include "GlobalEvents.hxx"
#include "event/MultiSocketMonitor.hxx"
#include "event/DeferredMonitor.hxx"
#include "event/Loop.hxx"
...
...
@@ -76,8 +76,9 @@ class AlsaMixer final : public Mixer {
AlsaMixerMonitor
*
monitor
;
public
:
AlsaMixer
(
EventLoop
&
_event_loop
)
:
Mixer
(
alsa_mixer_plugin
),
event_loop
(
_event_loop
)
{}
AlsaMixer
(
EventLoop
&
_event_loop
,
MixerListener
&
_listener
)
:
Mixer
(
alsa_mixer_plugin
,
_listener
),
event_loop
(
_event_loop
)
{}
virtual
~
AlsaMixer
();
...
...
@@ -142,10 +143,15 @@ AlsaMixerMonitor::DispatchSockets()
*/
static
int
alsa_mixer_elem_callback
(
gcc_unused
snd_mixer_elem_t
*
elem
,
unsigned
mask
)
alsa_mixer_elem_callback
(
snd_mixer_elem_t
*
elem
,
unsigned
mask
)
{
if
(
mask
&
SND_CTL_EVENT_MASK_VALUE
)
GlobalEvents
::
Emit
(
GlobalEvents
::
MIXER
);
AlsaMixer
&
mixer
=
*
(
AlsaMixer
*
)
snd_mixer_elem_get_callback_private
(
elem
);
if
(
mask
&
SND_CTL_EVENT_MASK_VALUE
)
{
int
volume
=
mixer
.
GetVolume
(
IgnoreError
());
mixer
.
listener
.
OnMixerVolumeChanged
(
mixer
,
volume
);
}
return
0
;
}
...
...
@@ -168,10 +174,11 @@ AlsaMixer::Configure(const config_param ¶m)
static
Mixer
*
alsa_mixer_init
(
EventLoop
&
event_loop
,
gcc_unused
AudioOutput
&
ao
,
MixerListener
&
listener
,
const
config_param
&
param
,
gcc_unused
Error
&
error
)
{
AlsaMixer
*
am
=
new
AlsaMixer
(
event_loop
);
AlsaMixer
*
am
=
new
AlsaMixer
(
event_loop
,
listener
);
am
->
Configure
(
param
);
return
am
;
...
...
@@ -236,6 +243,7 @@ AlsaMixer::Setup(Error &error)
snd_mixer_selem_get_playback_volume_range
(
elem
,
&
volume_min
,
&
volume_max
);
snd_mixer_elem_set_callback_private
(
elem
,
this
);
snd_mixer_elem_set_callback
(
elem
,
alsa_mixer_elem_callback
);
monitor
=
new
AlsaMixerMonitor
(
event_loop
,
handle
);
...
...
src/mixer/plugins/OssMixerPlugin.cxx
View file @
8d6fedf8
...
...
@@ -49,7 +49,8 @@ class OssMixer final : public Mixer {
int
volume_control
;
public
:
OssMixer
()
:
Mixer
(
oss_mixer_plugin
)
{}
OssMixer
(
MixerListener
&
_listener
)
:
Mixer
(
oss_mixer_plugin
,
_listener
)
{}
bool
Configure
(
const
config_param
&
param
,
Error
&
error
);
...
...
@@ -98,10 +99,11 @@ OssMixer::Configure(const config_param ¶m, Error &error)
static
Mixer
*
oss_mixer_init
(
gcc_unused
EventLoop
&
event_loop
,
gcc_unused
AudioOutput
&
ao
,
MixerListener
&
listener
,
const
config_param
&
param
,
Error
&
error
)
{
OssMixer
*
om
=
new
OssMixer
();
OssMixer
*
om
=
new
OssMixer
(
listener
);
if
(
!
om
->
Configure
(
param
,
error
))
{
delete
om
;
...
...
src/mixer/plugins/PulseMixerPlugin.cxx
View file @
8d6fedf8
...
...
@@ -20,8 +20,8 @@
#include "config.h"
#include "PulseMixerPlugin.hxx"
#include "mixer/MixerInternal.hxx"
#include "mixer/Listener.hxx"
#include "output/plugins/PulseOutputPlugin.hxx"
#include "GlobalEvents.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
...
...
@@ -41,9 +41,9 @@ class PulseMixer final : public Mixer {
struct
pa_cvolume
volume
;
public
:
PulseMixer
(
PulseOutput
&
_output
)
:
Mixer
(
pulse_mixer_plugin
),
output
(
_output
),
online
(
false
)
PulseMixer
(
PulseOutput
&
_output
,
MixerListener
&
_listener
)
:
Mixer
(
pulse_mixer_plugin
,
_listener
),
output
(
_output
),
online
(
false
)
{
}
...
...
@@ -75,7 +75,7 @@ PulseMixer::Offline()
online
=
false
;
GlobalEvents
::
Emit
(
GlobalEvents
::
MIXER
);
listener
.
OnMixerVolumeChanged
(
*
this
,
-
1
);
}
inline
void
...
...
@@ -92,7 +92,7 @@ PulseMixer::VolumeCallback(const pa_sink_input_info *i, int eol)
online
=
true
;
volume
=
i
->
volume
;
GlobalEvents
::
Emit
(
GlobalEvents
::
MIXER
);
listener
.
OnMixerVolumeChanged
(
*
this
,
GetVolume
(
IgnoreError
())
);
}
/**
...
...
@@ -165,11 +165,12 @@ pulse_mixer_on_change(PulseMixer &pm,
static
Mixer
*
pulse_mixer_init
(
gcc_unused
EventLoop
&
event_loop
,
AudioOutput
&
ao
,
MixerListener
&
listener
,
gcc_unused
const
config_param
&
param
,
gcc_unused
Error
&
error
)
{
PulseOutput
&
po
=
(
PulseOutput
&
)
ao
;
PulseMixer
*
pm
=
new
PulseMixer
(
po
);
PulseMixer
*
pm
=
new
PulseMixer
(
po
,
listener
);
pulse_output_set_mixer
(
po
,
*
pm
);
...
...
src/mixer/plugins/RoarMixerPlugin.cxx
View file @
8d6fedf8
...
...
@@ -29,9 +29,9 @@ class RoarMixer final : public Mixer {
RoarOutput
&
self
;
public
:
RoarMixer
(
RoarOutput
&
_output
)
:
Mixer
(
roar_mixer_plugin
),
self
(
_output
)
{}
RoarMixer
(
RoarOutput
&
_output
,
MixerListener
&
_listener
)
:
Mixer
(
roar_mixer_plugin
,
_listener
),
self
(
_output
)
{}
/* virtual methods from class Mixer */
virtual
bool
Open
(
gcc_unused
Error
&
error
)
override
{
...
...
@@ -47,10 +47,11 @@ public:
static
Mixer
*
roar_mixer_init
(
gcc_unused
EventLoop
&
event_loop
,
AudioOutput
&
ao
,
MixerListener
&
listener
,
gcc_unused
const
config_param
&
param
,
gcc_unused
Error
&
error
)
{
return
new
RoarMixer
((
RoarOutput
&
)
ao
);
return
new
RoarMixer
((
RoarOutput
&
)
ao
,
listener
);
}
int
...
...
src/mixer/plugins/SoftwareMixerPlugin.cxx
View file @
8d6fedf8
...
...
@@ -52,8 +52,8 @@ class SoftwareMixer final : public Mixer {
unsigned
volume
;
public
:
SoftwareMixer
()
:
Mixer
(
software_mixer_plugin
),
SoftwareMixer
(
MixerListener
&
_listener
)
:
Mixer
(
software_mixer_plugin
,
_listener
),
filter
(
CreateVolumeFilter
()),
owns_filter
(
true
),
volume
(
100
)
...
...
@@ -86,10 +86,11 @@ public:
static
Mixer
*
software_mixer_init
(
gcc_unused
EventLoop
&
event_loop
,
gcc_unused
AudioOutput
&
ao
,
MixerListener
&
listener
,
gcc_unused
const
config_param
&
param
,
gcc_unused
Error
&
error
)
{
return
new
SoftwareMixer
();
return
new
SoftwareMixer
(
listener
);
}
bool
...
...
src/mixer/plugins/WinmmMixerPlugin.cxx
View file @
8d6fedf8
...
...
@@ -34,8 +34,8 @@ class WinmmMixer final : public Mixer {
WinmmOutput
&
output
;
public
:
WinmmMixer
(
WinmmOutput
&
_output
)
:
Mixer
(
winmm_mixer_plugin
),
WinmmMixer
(
WinmmOutput
&
_output
,
MixerListener
&
_listener
)
:
Mixer
(
winmm_mixer_plugin
,
_listener
),
output
(
_output
)
{
}
...
...
@@ -68,10 +68,11 @@ winmm_volume_encode(int volume)
static
Mixer
*
winmm_mixer_init
(
gcc_unused
EventLoop
&
event_loop
,
AudioOutput
&
ao
,
MixerListener
&
listener
,
gcc_unused
const
config_param
&
param
,
gcc_unused
Error
&
error
)
{
return
new
WinmmMixer
((
WinmmOutput
&
)
ao
);
return
new
WinmmMixer
((
WinmmOutput
&
)
ao
,
listener
);
}
int
...
...
src/output/Init.cxx
View file @
8d6fedf8
...
...
@@ -116,6 +116,7 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
const
config_param
&
param
,
const
MixerPlugin
*
plugin
,
Filter
&
filter_chain
,
MixerListener
&
listener
,
Error
&
error
)
{
Mixer
*
mixer
;
...
...
@@ -129,10 +130,12 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
if
(
plugin
==
nullptr
)
return
nullptr
;
return
mixer_new
(
event_loop
,
*
plugin
,
ao
,
param
,
error
);
return
mixer_new
(
event_loop
,
*
plugin
,
ao
,
listener
,
param
,
error
);
case
MIXER_TYPE_SOFTWARE
:
mixer
=
mixer_new
(
event_loop
,
software_mixer_plugin
,
ao
,
listener
,
config_param
(),
IgnoreError
());
assert
(
mixer
!=
nullptr
);
...
...
@@ -212,6 +215,7 @@ AudioOutput::Configure(const config_param ¶m, Error &error)
static
bool
audio_output_setup
(
EventLoop
&
event_loop
,
AudioOutput
&
ao
,
MixerListener
&
mixer_listener
,
const
config_param
&
param
,
Error
&
error
)
{
...
...
@@ -244,7 +248,9 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
Error
mixer_error
;
ao
.
mixer
=
audio_output_load_mixer
(
event_loop
,
ao
,
param
,
ao
.
plugin
.
mixer_plugin
,
*
ao
.
filter
,
mixer_error
);
*
ao
.
filter
,
mixer_listener
,
mixer_error
);
if
(
ao
.
mixer
==
nullptr
&&
mixer_error
.
IsDefined
())
FormatError
(
mixer_error
,
"Failed to initialize hardware mixer for '%s'"
,
...
...
@@ -279,6 +285,7 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
AudioOutput
*
audio_output_new
(
EventLoop
&
event_loop
,
const
config_param
&
param
,
MixerListener
&
mixer_listener
,
PlayerControl
&
pc
,
Error
&
error
)
{
...
...
@@ -317,7 +324,8 @@ audio_output_new(EventLoop &event_loop, const config_param ¶m,
if
(
ao
==
nullptr
)
return
nullptr
;
if
(
!
audio_output_setup
(
event_loop
,
*
ao
,
param
,
error
))
{
if
(
!
audio_output_setup
(
event_loop
,
*
ao
,
mixer_listener
,
param
,
error
))
{
ao_plugin_finish
(
ao
);
return
nullptr
;
}
...
...
src/output/Internal.hxx
View file @
8d6fedf8
...
...
@@ -33,6 +33,8 @@ class Error;
class
Filter
;
class
MusicPipe
;
class
EventLoop
;
class
Mixer
;
class
MixerListener
;
struct
music_chunk
;
struct
config_param
;
struct
PlayerControl
;
...
...
@@ -79,7 +81,7 @@ struct AudioOutput {
* May be nullptr if none is available, or if software volume is
* configured.
*/
class
Mixer
*
mixer
;
Mixer
*
mixer
;
/**
* Will this output receive tags from the decoder? The
...
...
@@ -424,6 +426,7 @@ extern struct notify audio_output_client_notify;
AudioOutput
*
audio_output_new
(
EventLoop
&
event_loop
,
const
config_param
&
param
,
MixerListener
&
mixer_listener
,
PlayerControl
&
pc
,
Error
&
error
);
...
...
src/output/MultipleOutputs.cxx
View file @
8d6fedf8
...
...
@@ -35,8 +35,9 @@
#include <assert.h>
#include <string.h>
MultipleOutputs
::
MultipleOutputs
()
:
buffer
(
nullptr
),
pipe
(
nullptr
),
MultipleOutputs
::
MultipleOutputs
(
MixerListener
&
_mixer_listener
)
:
mixer_listener
(
_mixer_listener
),
buffer
(
nullptr
),
pipe
(
nullptr
),
elapsed_time
(
-
1
)
{
}
...
...
@@ -50,10 +51,13 @@ MultipleOutputs::~MultipleOutputs()
}
static
AudioOutput
*
LoadOutput
(
EventLoop
&
event_loop
,
PlayerControl
&
pc
,
const
config_param
&
param
)
LoadOutput
(
EventLoop
&
event_loop
,
MixerListener
&
mixer_listener
,
PlayerControl
&
pc
,
const
config_param
&
param
)
{
Error
error
;
AudioOutput
*
output
=
audio_output_new
(
event_loop
,
param
,
pc
,
error
);
AudioOutput
*
output
=
audio_output_new
(
event_loop
,
param
,
mixer_listener
,
pc
,
error
);
if
(
output
==
nullptr
)
{
if
(
param
.
line
>
0
)
FormatFatalError
(
"line %i: %s"
,
...
...
@@ -72,7 +76,8 @@ MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
const
config_param
*
param
=
nullptr
;
while
((
param
=
config_get_next_param
(
CONF_AUDIO_OUTPUT
,
param
))
!=
nullptr
)
{
auto
output
=
LoadOutput
(
event_loop
,
pc
,
*
param
);
auto
output
=
LoadOutput
(
event_loop
,
mixer_listener
,
pc
,
*
param
);
if
(
FindByName
(
output
->
name
)
!=
nullptr
)
FormatFatalError
(
"output devices with identical "
"names: %s"
,
output
->
name
);
...
...
@@ -83,7 +88,8 @@ MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
if
(
outputs
.
empty
())
{
/* auto-detect device */
const
config_param
empty
;
auto
output
=
LoadOutput
(
event_loop
,
pc
,
empty
);
auto
output
=
LoadOutput
(
event_loop
,
mixer_listener
,
pc
,
empty
);
outputs
.
push_back
(
output
);
}
}
...
...
src/output/MultipleOutputs.hxx
View file @
8d6fedf8
...
...
@@ -38,12 +38,15 @@ struct AudioFormat;
class
MusicBuffer
;
class
MusicPipe
;
class
EventLoop
;
class
MixerListener
;
struct
music_chunk
;
struct
PlayerControl
;
struct
AudioOutput
;
class
Error
;
class
MultipleOutputs
{
MixerListener
&
mixer_listener
;
std
::
vector
<
AudioOutput
*>
outputs
;
AudioFormat
input_audio_format
;
...
...
@@ -70,7 +73,7 @@ public:
* Load audio outputs from the configuration file and
* initialize them.
*/
MultipleOutputs
();
MultipleOutputs
(
MixerListener
&
_mixer_listener
);
~
MultipleOutputs
();
void
Configure
(
EventLoop
&
event_loop
,
PlayerControl
&
pc
);
...
...
test/read_mixer.cxx
View file @
8d6fedf8
...
...
@@ -22,7 +22,6 @@
#include "mixer/MixerList.hxx"
#include "filter/FilterRegistry.hxx"
#include "pcm/Volume.hxx"
#include "GlobalEvents.hxx"
#include "Main.hxx"
#include "event/Loop.hxx"
#include "config/ConfigData.hxx"
...
...
@@ -35,11 +34,6 @@
#include <string.h>
#include <unistd.h>
void
GlobalEvents
::
Emit
(
gcc_unused
Event
event
)
{
}
const
struct
filter_plugin
*
filter_plugin_by_name
(
gcc_unused
const
char
*
name
)
{
...
...
@@ -65,6 +59,7 @@ int main(int argc, gcc_unused char **argv)
Error
error
;
Mixer
*
mixer
=
mixer_new
(
event_loop
,
alsa_mixer_plugin
,
*
(
AudioOutput
*
)
nullptr
,
*
(
MixerListener
*
)
nullptr
,
config_param
(),
error
);
if
(
mixer
==
NULL
)
{
LogError
(
error
,
"mixer_new() failed"
);
...
...
test/run_output.cxx
View file @
8d6fedf8
...
...
@@ -26,7 +26,6 @@
#include "Idle.hxx"
#include "Main.hxx"
#include "event/Loop.hxx"
#include "GlobalEvents.hxx"
#include "IOThread.hxx"
#include "fs/Path.hxx"
#include "AudioParser.hxx"
...
...
@@ -47,11 +46,6 @@
#include <stdlib.h>
#include <stdio.h>
void
GlobalEvents
::
Emit
(
gcc_unused
Event
event
)
{
}
const
struct
filter_plugin
*
filter_plugin_by_name
(
gcc_unused
const
char
*
name
)
{
...
...
@@ -95,7 +89,9 @@ load_audio_output(EventLoop &event_loop, const char *name)
Error
error
;
AudioOutput
*
ao
=
audio_output_new
(
event_loop
,
*
param
,
dummy_player_control
,
audio_output_new
(
event_loop
,
*
param
,
*
(
MixerListener
*
)
nullptr
,
dummy_player_control
,
error
);
if
(
ao
==
nullptr
)
LogError
(
error
);
...
...
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