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
9d6b4f46
Commit
9d6b4f46
authored
Aug 07, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/Thread: move AudioOutput methods to Internal.cxx
parent
a4019cb6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
146 additions
and
126 deletions
+146
-126
Makefile.am
Makefile.am
+1
-1
Internal.cxx
src/output/Internal.cxx
+144
-0
Thread.cxx
src/output/Thread.cxx
+1
-125
No files found.
Makefile.am
View file @
9d6b4f46
...
...
@@ -1373,7 +1373,7 @@ OUTPUT_LIBS = \
OUTPUT_API_SRC
=
\
src/output/Client.hxx
\
src/output/OutputAPI.hxx
\
src/output/Internal.hxx
\
src/output/Internal.
cxx src/output/Internal.
hxx
\
src/output/Wrapper.hxx
\
src/output/Registry.cxx src/output/Registry.hxx
\
src/output/MultipleOutputs.cxx src/output/MultipleOutputs.hxx
\
...
...
src/output/Internal.cxx
0 → 100644
View file @
9d6b4f46
/*
* 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 "Internal.hxx"
#include "OutputPlugin.hxx"
#include "Domain.hxx"
#include "Log.hxx"
#include "mixer/MixerInternal.hxx"
#include "mixer/plugins/SoftwareMixerPlugin.hxx"
#include "filter/plugins/ConvertFilterPlugin.hxx"
#include "util/RuntimeError.hxx"
#include "util/StringBuffer.hxx"
void
AudioOutput
::
Enable
()
{
try
{
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_enable
(
*
this
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to enable output
\"
%s
\"
[%s]"
,
name
,
plugin
.
name
));
}
}
void
AudioOutput
::
Disable
()
noexcept
{
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_disable
(
*
this
);
}
void
AudioOutput
::
OpenOutputAndConvert
(
AudioFormat
desired_audio_format
)
{
out_audio_format
=
desired_audio_format
;
try
{
ao_plugin_open
(
*
this
,
out_audio_format
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to open
\"
%s
\"
[%s]"
,
name
,
plugin
.
name
));
}
FormatDebug
(
output_domain
,
"opened plugin=%s name=
\"
%s
\"
audio_format=%s"
,
plugin
.
name
,
name
,
ToString
(
out_audio_format
).
c_str
());
try
{
convert_filter_set
(
convert_filter
.
Get
(),
out_audio_format
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
ao_plugin_close
(
*
this
);
if
(
out_audio_format
.
format
==
SampleFormat
::
DSD
)
{
/* if the audio output supports DSD, but not
the given sample rate, it asks MPD to
resample; resampling DSD however is not
implemented; our last resort is to give up
DSD and fall back to PCM */
LogError
(
e
);
FormatError
(
output_domain
,
"Retrying without DSD"
);
desired_audio_format
.
format
=
SampleFormat
::
FLOAT
;
OpenOutputAndConvert
(
desired_audio_format
);
return
;
}
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to convert for
\"
%s
\"
[%s]"
,
name
,
plugin
.
name
));
}
}
void
AudioOutput
::
CloseOutput
(
bool
drain
)
noexcept
{
if
(
drain
)
ao_plugin_drain
(
*
this
);
else
ao_plugin_cancel
(
*
this
);
ao_plugin_close
(
*
this
);
}
void
AudioOutput
::
CloseFilter
()
noexcept
{
if
(
mixer
!=
nullptr
&&
mixer
->
IsPlugin
(
software_mixer_plugin
))
software_mixer_set_filter
(
*
mixer
,
nullptr
);
}
void
AudioOutput
::
Close
(
bool
drain
)
noexcept
{
const
ScopeUnlock
unlock
(
mutex
);
CloseOutput
(
drain
);
CloseFilter
();
FormatDebug
(
output_domain
,
"closed plugin=%s name=
\"
%s
\"
"
,
plugin
.
name
,
name
);
}
void
AudioOutput
::
BeginPause
()
noexcept
{
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_cancel
(
*
this
);
}
bool
AudioOutput
::
IteratePause
()
noexcept
{
bool
success
;
try
{
const
ScopeUnlock
unlock
(
mutex
);
success
=
ao_plugin_pause
(
*
this
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
FormatError
(
e
,
"
\"
%s
\"
[%s] failed to pause"
,
name
,
plugin
.
name
);
success
=
false
;
}
return
success
;
}
src/output/Thread.cxx
View file @
9d6b4f46
...
...
@@ -21,28 +21,19 @@
#include "Control.hxx"
#include "Internal.hxx"
#include "Client.hxx"
#include "Output
API
.hxx"
#include "Output
Plugin
.hxx"
#include "Domain.hxx"
#include "pcm/PcmMix.hxx"
#include "notify.hxx"
#include "filter/FilterInternal.hxx"
#include "filter/plugins/ConvertFilterPlugin.hxx"
#include "filter/plugins/ReplayGainFilterPlugin.hxx"
#include "mixer/MixerInternal.hxx"
#include "mixer/plugins/SoftwareMixerPlugin.hxx"
#include "MusicPipe.hxx"
#include "MusicChunk.hxx"
#include "thread/Util.hxx"
#include "thread/Slack.hxx"
#include "thread/Name.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringBuffer.hxx"
#include "util/ScopeExit.hxx"
#include "util/RuntimeError.hxx"
#include "Log.hxx"
#include "Compiler.h"
#include <stdexcept>
#include <assert.h>
#include <string.h>
...
...
@@ -58,32 +49,6 @@ AudioOutputControl::CommandFinished() noexcept
}
inline
void
AudioOutput
::
Enable
()
{
try
{
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_enable
(
*
this
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to enable output
\"
%s
\"
[%s]"
,
name
,
plugin
.
name
));
}
}
inline
void
AudioOutput
::
Disable
()
noexcept
{
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_disable
(
*
this
);
}
void
AudioOutput
::
CloseFilter
()
noexcept
{
if
(
mixer
!=
nullptr
&&
mixer
->
IsPlugin
(
software_mixer_plugin
))
software_mixer_set_filter
(
*
mixer
,
nullptr
);
}
inline
void
AudioOutputControl
::
InternalOpen2
(
const
AudioFormat
in_audio_format
)
{
assert
(
in_audio_format
.
IsValid
());
...
...
@@ -129,48 +94,6 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
}
}
void
AudioOutput
::
OpenOutputAndConvert
(
AudioFormat
desired_audio_format
)
{
out_audio_format
=
desired_audio_format
;
try
{
ao_plugin_open
(
*
this
,
out_audio_format
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to open
\"
%s
\"
[%s]"
,
name
,
plugin
.
name
));
}
FormatDebug
(
output_domain
,
"opened plugin=%s name=
\"
%s
\"
audio_format=%s"
,
plugin
.
name
,
name
,
ToString
(
out_audio_format
).
c_str
());
try
{
convert_filter_set
(
convert_filter
.
Get
(),
out_audio_format
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
ao_plugin_close
(
*
this
);
if
(
out_audio_format
.
format
==
SampleFormat
::
DSD
)
{
/* if the audio output supports DSD, but not
the given sample rate, it asks MPD to
resample; resampling DSD however is not
implemented; our last resort is to give up
DSD and fall back to PCM */
LogError
(
e
);
FormatError
(
output_domain
,
"Retrying without DSD"
);
desired_audio_format
.
format
=
SampleFormat
::
FLOAT
;
OpenOutputAndConvert
(
desired_audio_format
);
return
;
}
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to convert for
\"
%s
\"
[%s]"
,
name
,
plugin
.
name
));
}
}
inline
bool
AudioOutputControl
::
InternalEnable
()
noexcept
{
...
...
@@ -259,29 +182,6 @@ AudioOutputControl::InternalClose(bool drain) noexcept
source
.
Close
();
}
void
AudioOutput
::
Close
(
bool
drain
)
noexcept
{
const
ScopeUnlock
unlock
(
mutex
);
CloseOutput
(
drain
);
CloseFilter
();
FormatDebug
(
output_domain
,
"closed plugin=%s name=
\"
%s
\"
"
,
plugin
.
name
,
name
);
}
inline
void
AudioOutput
::
CloseOutput
(
bool
drain
)
noexcept
{
if
(
drain
)
ao_plugin_drain
(
*
this
);
else
ao_plugin_cancel
(
*
this
);
ao_plugin_close
(
*
this
);
}
/**
* Wait until the output's delay reaches zero.
*
...
...
@@ -418,30 +318,6 @@ AudioOutputControl::InternalPlay() noexcept
}
inline
void
AudioOutput
::
BeginPause
()
noexcept
{
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_cancel
(
*
this
);
}
inline
bool
AudioOutput
::
IteratePause
()
noexcept
{
bool
success
;
try
{
const
ScopeUnlock
unlock
(
mutex
);
success
=
ao_plugin_pause
(
*
this
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
FormatError
(
e
,
"
\"
%s
\"
[%s] failed to pause"
,
name
,
plugin
.
name
);
success
=
false
;
}
return
success
;
}
inline
void
AudioOutputControl
::
InternalPause
()
noexcept
{
output
->
BeginPause
();
...
...
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