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
fe9db8b3
Commit
fe9db8b3
authored
Dec 29, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{mixer,output}/pulse: use a common Domain instance
parent
ca035d0e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
20 deletions
+73
-20
Makefile.am
Makefile.am
+8
-2
Domain.cxx
src/lib/pulse/Domain.cxx
+24
-0
Domain.hxx
src/lib/pulse/Domain.hxx
+27
-0
PulseMixerPlugin.cxx
src/mixer/plugins/PulseMixerPlugin.cxx
+4
-6
PulseOutputPlugin.cxx
src/output/plugins/PulseOutputPlugin.cxx
+10
-12
No files found.
Makefile.am
View file @
fe9db8b3
...
...
@@ -1231,7 +1231,6 @@ OUTPUT_LIBS = \
$(ROAR_LIBS)
\
$(JACK_LIBS)
\
$(OPENAL_LIBS)
\
$(PULSE_LIBS)
\
$(SHOUT_LIBS)
OUTPUT_API_SRC
=
\
...
...
@@ -1256,7 +1255,7 @@ liboutput_plugins_a_SOURCES = \
MIXER_LIBS
=
\
libmixer_plugins.a
\
$(PULSE_LIBS)
$(PULSE_LIBS
2
)
MIXER_API_SRC
=
\
src/mixer/Listener.hxx
\
...
...
@@ -1349,6 +1348,13 @@ liboutput_plugins_a_SOURCES += \
src/output/plugins/PulseOutputPlugin.hxx
libmixer_plugins_a_SOURCES
+=
\
src/mixer/plugins/PulseMixerPlugin.cxx src/mixer/plugins/PulseMixerPlugin.hxx
noinst_LIBRARIES
+=
libpulse.a
libpulse_a_SOURCES
=
\
src/lib/pulse/Domain.cxx src/lib/pulse/Domain.hxx
libpulse_a_CPPFLAGS
=
$(AM_CPPFLAGS)
$(PULSE_CFLAGS)
PULSE_LIBS2
=
libpulse.a
$(PULSE_LIBS)
OUTPUT_LIBS
+=
$(PULSE_LIBS2)
endif
if
HAVE_SHOUT
...
...
src/lib/pulse/Domain.cxx
0 → 100644
View file @
fe9db8b3
/*
* 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.
*/
#include "config.h"
#include "Domain.hxx"
#include "util/Domain.hxx"
const
Domain
pulse_domain
(
"pulse"
);
src/lib/pulse/Domain.hxx
0 → 100644
View file @
fe9db8b3
/*
* 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_PULSE_DOMAIN_HXX
#define MPD_PULSE_DOMAIN_HXX
class
Domain
;
extern
const
Domain
pulse_domain
;
#endif
src/mixer/plugins/PulseMixerPlugin.cxx
View file @
fe9db8b3
...
...
@@ -19,11 +19,11 @@
#include "config.h"
#include "PulseMixerPlugin.hxx"
#include "lib/pulse/Domain.hxx"
#include "mixer/MixerInternal.hxx"
#include "mixer/Listener.hxx"
#include "output/plugins/PulseOutputPlugin.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include <pulse/context.h>
...
...
@@ -66,8 +66,6 @@ public:
bool
SetVolume
(
unsigned
volume
,
Error
&
error
)
override
;
};
static
constexpr
Domain
pulse_mixer_domain
(
"pulse_mixer"
);
void
PulseMixer
::
Offline
()
{
...
...
@@ -120,7 +118,7 @@ PulseMixer::Update(pa_context *context, pa_stream *stream)
pa_stream_get_index
(
stream
),
pulse_mixer_volume_cb
,
this
);
if
(
o
==
nullptr
)
{
FormatError
(
pulse_
mixer_
domain
,
FormatError
(
pulse_domain
,
"pa_context_get_sink_input_info() failed: %s"
,
pa_strerror
(
pa_context_errno
(
context
)));
Offline
();
...
...
@@ -142,7 +140,7 @@ pulse_mixer_on_connect(gcc_unused PulseMixer &pm,
(
pa_subscription_mask_t
)
PA_SUBSCRIPTION_MASK_SINK_INPUT
,
nullptr
,
nullptr
);
if
(
o
==
nullptr
)
{
FormatError
(
pulse_
mixer_
domain
,
FormatError
(
pulse_domain
,
"pa_context_subscribe() failed: %s"
,
pa_strerror
(
pa_context_errno
(
context
)));
return
;
...
...
@@ -212,7 +210,7 @@ PulseMixer::SetVolume(unsigned new_volume, Error &error)
if
(
!
online
)
{
pulse_output_unlock
(
output
);
error
.
Set
(
pulse_
mixer_
domain
,
"disconnected"
);
error
.
Set
(
pulse_domain
,
"disconnected"
);
return
false
;
}
...
...
src/output/plugins/PulseOutputPlugin.cxx
View file @
fe9db8b3
...
...
@@ -19,11 +19,11 @@
#include "config.h"
#include "PulseOutputPlugin.hxx"
#include "lib/pulse/Domain.hxx"
#include "../OutputAPI.hxx"
#include "mixer/MixerList.hxx"
#include "mixer/plugins/PulseMixerPlugin.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include <pulse/thread-mainloop.h>
...
...
@@ -59,13 +59,11 @@ struct PulseOutput {
:
base
(
pulse_output_plugin
)
{}
};
static
constexpr
Domain
pulse_output_domain
(
"pulse_output"
);
static
void
SetError
(
Error
&
error
,
pa_context
*
context
,
const
char
*
msg
)
{
const
int
e
=
pa_context_errno
(
context
);
error
.
Format
(
pulse_
output_
domain
,
e
,
"%s: %s"
,
msg
,
pa_strerror
(
e
));
error
.
Format
(
pulse_domain
,
e
,
"%s: %s"
,
msg
,
pa_strerror
(
e
));
}
void
...
...
@@ -120,7 +118,7 @@ pulse_output_set_volume(PulseOutput &po, const pa_cvolume *volume,
if
(
po
.
context
==
nullptr
||
po
.
stream
==
nullptr
||
pa_stream_get_state
(
po
.
stream
)
!=
PA_STREAM_READY
)
{
error
.
Set
(
pulse_
output_
domain
,
"disconnected"
);
error
.
Set
(
pulse_domain
,
"disconnected"
);
return
false
;
}
...
...
@@ -301,7 +299,7 @@ pulse_output_setup_context(PulseOutput *po, Error &error)
po
->
context
=
pa_context_new
(
pa_threaded_mainloop_get_api
(
po
->
mainloop
),
MPD_PULSE_NAME
);
if
(
po
->
context
==
nullptr
)
{
error
.
Set
(
pulse_
output_
domain
,
"pa_context_new() has failed"
);
error
.
Set
(
pulse_domain
,
"pa_context_new() has failed"
);
return
false
;
}
...
...
@@ -364,7 +362,7 @@ pulse_output_enable(AudioOutput *ao, Error &error)
po
->
mainloop
=
pa_threaded_mainloop_new
();
if
(
po
->
mainloop
==
nullptr
)
{
error
.
Set
(
pulse_
output_
domain
,
error
.
Set
(
pulse_domain
,
"pa_threaded_mainloop_new() has failed"
);
return
false
;
}
...
...
@@ -376,7 +374,7 @@ pulse_output_enable(AudioOutput *ao, Error &error)
pa_threaded_mainloop_free
(
po
->
mainloop
);
po
->
mainloop
=
nullptr
;
error
.
Set
(
pulse_
output_
domain
,
error
.
Set
(
pulse_domain
,
"pa_threaded_mainloop_start() has failed"
);
return
false
;
}
...
...
@@ -626,7 +624,7 @@ pulse_output_close(AudioOutput *ao)
o
=
pa_stream_drain
(
po
->
stream
,
pulse_output_stream_success_cb
,
po
);
if
(
o
==
nullptr
)
{
FormatWarning
(
pulse_
output_
domain
,
FormatWarning
(
pulse_domain
,
"pa_stream_drain() has failed: %s"
,
pa_strerror
(
pa_context_errno
(
po
->
context
)));
}
else
...
...
@@ -749,7 +747,7 @@ pulse_output_play(AudioOutput *ao, const void *chunk, size_t size,
while
(
po
->
writable
==
0
)
{
if
(
pa_stream_is_suspended
(
po
->
stream
))
{
pa_threaded_mainloop_unlock
(
po
->
mainloop
);
error
.
Set
(
pulse_
output_
domain
,
"suspended"
);
error
.
Set
(
pulse_domain
,
"suspended"
);
return
0
;
}
...
...
@@ -757,7 +755,7 @@ pulse_output_play(AudioOutput *ao, const void *chunk, size_t size,
if
(
pa_stream_get_state
(
po
->
stream
)
!=
PA_STREAM_READY
)
{
pa_threaded_mainloop_unlock
(
po
->
mainloop
);
error
.
Set
(
pulse_
output_
domain
,
"disconnected"
);
error
.
Set
(
pulse_domain
,
"disconnected"
);
return
0
;
}
}
...
...
@@ -803,7 +801,7 @@ pulse_output_cancel(AudioOutput *ao)
o
=
pa_stream_flush
(
po
->
stream
,
pulse_output_stream_success_cb
,
po
);
if
(
o
==
nullptr
)
{
FormatWarning
(
pulse_
output_
domain
,
FormatWarning
(
pulse_domain
,
"pa_stream_flush() has failed: %s"
,
pa_strerror
(
pa_context_errno
(
po
->
context
)));
pa_threaded_mainloop_unlock
(
po
->
mainloop
);
...
...
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