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
fead4bbf
Commit
fead4bbf
authored
Jan 25, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/Plugin: convert pointers to references
parent
872ecc1a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
60 deletions
+59
-60
Init.cxx
src/output/Init.cxx
+1
-1
OutputPlugin.cxx
src/output/OutputPlugin.cxx
+29
-30
OutputPlugin.hxx
src/output/OutputPlugin.hxx
+11
-11
OutputThread.cxx
src/output/OutputThread.cxx
+14
-14
run_output.cxx
test/run_output.cxx
+4
-4
No files found.
src/output/Init.cxx
View file @
fead4bbf
...
@@ -295,7 +295,7 @@ audio_output_new(EventLoop &event_loop,
...
@@ -295,7 +295,7 @@ audio_output_new(EventLoop &event_loop,
plugin
->
name
);
plugin
->
name
);
}
}
AudioOutput
*
ao
=
ao_plugin_init
(
plugin
,
block
);
AudioOutput
*
ao
=
ao_plugin_init
(
*
plugin
,
block
);
assert
(
ao
!=
nullptr
);
assert
(
ao
!=
nullptr
);
try
{
try
{
...
...
src/output/OutputPlugin.cxx
View file @
fead4bbf
...
@@ -22,13 +22,12 @@
...
@@ -22,13 +22,12 @@
#include "Internal.hxx"
#include "Internal.hxx"
AudioOutput
*
AudioOutput
*
ao_plugin_init
(
const
AudioOutputPlugin
*
plugin
,
ao_plugin_init
(
const
AudioOutputPlugin
&
plugin
,
const
ConfigBlock
&
block
)
const
ConfigBlock
&
block
)
{
{
assert
(
plugin
!=
nullptr
);
assert
(
plugin
.
init
!=
nullptr
);
assert
(
plugin
->
init
!=
nullptr
);
return
plugin
->
init
(
block
);
return
plugin
.
init
(
block
);
}
}
void
void
...
@@ -38,68 +37,68 @@ ao_plugin_finish(AudioOutput *ao)
...
@@ -38,68 +37,68 @@ ao_plugin_finish(AudioOutput *ao)
}
}
void
void
ao_plugin_enable
(
AudioOutput
*
ao
)
ao_plugin_enable
(
AudioOutput
&
ao
)
{
{
if
(
ao
->
plugin
.
enable
!=
nullptr
)
if
(
ao
.
plugin
.
enable
!=
nullptr
)
ao
->
plugin
.
enable
(
ao
);
ao
.
plugin
.
enable
(
&
ao
);
}
}
void
void
ao_plugin_disable
(
AudioOutput
*
ao
)
ao_plugin_disable
(
AudioOutput
&
ao
)
{
{
if
(
ao
->
plugin
.
disable
!=
nullptr
)
if
(
ao
.
plugin
.
disable
!=
nullptr
)
ao
->
plugin
.
disable
(
ao
);
ao
.
plugin
.
disable
(
&
ao
);
}
}
void
void
ao_plugin_open
(
AudioOutput
*
ao
,
AudioFormat
&
audio_format
)
ao_plugin_open
(
AudioOutput
&
ao
,
AudioFormat
&
audio_format
)
{
{
ao
->
plugin
.
open
(
ao
,
audio_format
);
ao
.
plugin
.
open
(
&
ao
,
audio_format
);
}
}
void
void
ao_plugin_close
(
AudioOutput
*
ao
)
ao_plugin_close
(
AudioOutput
&
ao
)
{
{
ao
->
plugin
.
close
(
ao
);
ao
.
plugin
.
close
(
&
ao
);
}
}
std
::
chrono
::
steady_clock
::
duration
std
::
chrono
::
steady_clock
::
duration
ao_plugin_delay
(
AudioOutput
*
ao
)
ao_plugin_delay
(
AudioOutput
&
ao
)
{
{
return
ao
->
plugin
.
delay
!=
nullptr
return
ao
.
plugin
.
delay
!=
nullptr
?
ao
->
plugin
.
delay
(
ao
)
?
ao
.
plugin
.
delay
(
&
ao
)
:
std
::
chrono
::
steady_clock
::
duration
::
zero
();
:
std
::
chrono
::
steady_clock
::
duration
::
zero
();
}
}
void
void
ao_plugin_send_tag
(
AudioOutput
*
ao
,
const
Tag
&
tag
)
ao_plugin_send_tag
(
AudioOutput
&
ao
,
const
Tag
&
tag
)
{
{
if
(
ao
->
plugin
.
send_tag
!=
nullptr
)
if
(
ao
.
plugin
.
send_tag
!=
nullptr
)
ao
->
plugin
.
send_tag
(
ao
,
tag
);
ao
.
plugin
.
send_tag
(
&
ao
,
tag
);
}
}
size_t
size_t
ao_plugin_play
(
AudioOutput
*
ao
,
const
void
*
chunk
,
size_t
size
)
ao_plugin_play
(
AudioOutput
&
ao
,
const
void
*
chunk
,
size_t
size
)
{
{
return
ao
->
plugin
.
play
(
ao
,
chunk
,
size
);
return
ao
.
plugin
.
play
(
&
ao
,
chunk
,
size
);
}
}
void
void
ao_plugin_drain
(
AudioOutput
*
ao
)
ao_plugin_drain
(
AudioOutput
&
ao
)
{
{
if
(
ao
->
plugin
.
drain
!=
nullptr
)
if
(
ao
.
plugin
.
drain
!=
nullptr
)
ao
->
plugin
.
drain
(
ao
);
ao
.
plugin
.
drain
(
&
ao
);
}
}
void
void
ao_plugin_cancel
(
AudioOutput
*
ao
)
ao_plugin_cancel
(
AudioOutput
&
ao
)
{
{
if
(
ao
->
plugin
.
cancel
!=
nullptr
)
if
(
ao
.
plugin
.
cancel
!=
nullptr
)
ao
->
plugin
.
cancel
(
ao
);
ao
.
plugin
.
cancel
(
&
ao
);
}
}
bool
bool
ao_plugin_pause
(
AudioOutput
*
ao
)
ao_plugin_pause
(
AudioOutput
&
ao
)
{
{
return
ao
->
plugin
.
pause
!=
nullptr
&&
ao
->
plugin
.
pause
(
ao
);
return
ao
.
plugin
.
pause
!=
nullptr
&&
ao
.
plugin
.
pause
(
&
ao
);
}
}
src/output/OutputPlugin.hxx
View file @
fead4bbf
...
@@ -162,41 +162,41 @@ ao_plugin_test_default_device(const AudioOutputPlugin *plugin)
...
@@ -162,41 +162,41 @@ ao_plugin_test_default_device(const AudioOutputPlugin *plugin)
gcc_malloc
gcc_malloc
AudioOutput
*
AudioOutput
*
ao_plugin_init
(
const
AudioOutputPlugin
*
plugin
,
ao_plugin_init
(
const
AudioOutputPlugin
&
plugin
,
const
ConfigBlock
&
block
);
const
ConfigBlock
&
block
);
void
void
ao_plugin_finish
(
AudioOutput
*
ao
);
ao_plugin_finish
(
AudioOutput
*
ao
);
void
void
ao_plugin_enable
(
AudioOutput
*
ao
);
ao_plugin_enable
(
AudioOutput
&
ao
);
void
void
ao_plugin_disable
(
AudioOutput
*
ao
);
ao_plugin_disable
(
AudioOutput
&
ao
);
void
void
ao_plugin_open
(
AudioOutput
*
ao
,
AudioFormat
&
audio_format
);
ao_plugin_open
(
AudioOutput
&
ao
,
AudioFormat
&
audio_format
);
void
void
ao_plugin_close
(
AudioOutput
*
ao
);
ao_plugin_close
(
AudioOutput
&
ao
);
gcc_pure
gcc_pure
std
::
chrono
::
steady_clock
::
duration
std
::
chrono
::
steady_clock
::
duration
ao_plugin_delay
(
AudioOutput
*
ao
);
ao_plugin_delay
(
AudioOutput
&
ao
);
void
void
ao_plugin_send_tag
(
AudioOutput
*
ao
,
const
Tag
&
tag
);
ao_plugin_send_tag
(
AudioOutput
&
ao
,
const
Tag
&
tag
);
size_t
size_t
ao_plugin_play
(
AudioOutput
*
ao
,
const
void
*
chunk
,
size_t
size
);
ao_plugin_play
(
AudioOutput
&
ao
,
const
void
*
chunk
,
size_t
size
);
void
void
ao_plugin_drain
(
AudioOutput
*
ao
);
ao_plugin_drain
(
AudioOutput
&
ao
);
void
void
ao_plugin_cancel
(
AudioOutput
*
ao
);
ao_plugin_cancel
(
AudioOutput
&
ao
);
bool
bool
ao_plugin_pause
(
AudioOutput
*
ao
);
ao_plugin_pause
(
AudioOutput
&
ao
);
#endif
#endif
src/output/OutputThread.cxx
View file @
fead4bbf
...
@@ -64,7 +64,7 @@ AudioOutput::Enable()
...
@@ -64,7 +64,7 @@ AudioOutput::Enable()
try
{
try
{
const
ScopeUnlock
unlock
(
mutex
);
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_enable
(
this
);
ao_plugin_enable
(
*
this
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
catch
(
const
std
::
runtime_error
&
e
)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to enable output
\"
%s
\"
[%s]"
,
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to enable output
\"
%s
\"
[%s]"
,
name
,
plugin
.
name
));
name
,
plugin
.
name
));
...
@@ -83,7 +83,7 @@ AudioOutput::Disable()
...
@@ -83,7 +83,7 @@ AudioOutput::Disable()
really_enabled
=
false
;
really_enabled
=
false
;
const
ScopeUnlock
unlock
(
mutex
);
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_disable
(
this
);
ao_plugin_disable
(
*
this
);
}
}
}
}
...
@@ -168,7 +168,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
...
@@ -168,7 +168,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
out_audio_format
=
desired_audio_format
;
out_audio_format
=
desired_audio_format
;
try
{
try
{
ao_plugin_open
(
this
,
out_audio_format
);
ao_plugin_open
(
*
this
,
out_audio_format
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
catch
(
const
std
::
runtime_error
&
e
)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to open
\"
%s
\"
[%s]"
,
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to open
\"
%s
\"
[%s]"
,
name
,
plugin
.
name
));
name
,
plugin
.
name
));
...
@@ -182,7 +182,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
...
@@ -182,7 +182,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
try
{
try
{
convert_filter_set
(
convert_filter
.
Get
(),
out_audio_format
);
convert_filter_set
(
convert_filter
.
Get
(),
out_audio_format
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
catch
(
const
std
::
runtime_error
&
e
)
{
ao_plugin_close
(
this
);
ao_plugin_close
(
*
this
);
if
(
out_audio_format
.
format
==
SampleFormat
::
DSD
)
{
if
(
out_audio_format
.
format
==
SampleFormat
::
DSD
)
{
/* if the audio output supports DSD, but not
/* if the audio output supports DSD, but not
...
@@ -224,11 +224,11 @@ inline void
...
@@ -224,11 +224,11 @@ inline void
AudioOutput
::
CloseOutput
(
bool
drain
)
AudioOutput
::
CloseOutput
(
bool
drain
)
{
{
if
(
drain
)
if
(
drain
)
ao_plugin_drain
(
this
);
ao_plugin_drain
(
*
this
);
else
else
ao_plugin_cancel
(
this
);
ao_plugin_cancel
(
*
this
);
ao_plugin_close
(
this
);
ao_plugin_close
(
*
this
);
}
}
/**
/**
...
@@ -241,7 +241,7 @@ inline bool
...
@@ -241,7 +241,7 @@ inline bool
AudioOutput
::
WaitForDelay
()
AudioOutput
::
WaitForDelay
()
{
{
while
(
true
)
{
while
(
true
)
{
const
auto
delay
=
ao_plugin_delay
(
this
);
const
auto
delay
=
ao_plugin_delay
(
*
this
);
if
(
delay
<=
std
::
chrono
::
steady_clock
::
duration
::
zero
())
if
(
delay
<=
std
::
chrono
::
steady_clock
::
duration
::
zero
())
return
true
;
return
true
;
...
@@ -276,7 +276,7 @@ AudioOutput::PlayChunk()
...
@@ -276,7 +276,7 @@ AudioOutput::PlayChunk()
if
(
tag
!=
nullptr
)
{
if
(
tag
!=
nullptr
)
{
const
ScopeUnlock
unlock
(
mutex
);
const
ScopeUnlock
unlock
(
mutex
);
try
{
try
{
ao_plugin_send_tag
(
this
,
*
tag
);
ao_plugin_send_tag
(
*
this
,
*
tag
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
catch
(
const
std
::
runtime_error
&
e
)
{
FormatError
(
e
,
"Failed to send tag to
\"
%s
\"
[%s]"
,
FormatError
(
e
,
"Failed to send tag to
\"
%s
\"
[%s]"
,
name
,
plugin
.
name
);
name
,
plugin
.
name
);
...
@@ -296,7 +296,7 @@ AudioOutput::PlayChunk()
...
@@ -296,7 +296,7 @@ AudioOutput::PlayChunk()
try
{
try
{
const
ScopeUnlock
unlock
(
mutex
);
const
ScopeUnlock
unlock
(
mutex
);
nbytes
=
ao_plugin_play
(
this
,
data
.
data
,
data
.
size
);
nbytes
=
ao_plugin_play
(
*
this
,
data
.
data
,
data
.
size
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
catch
(
const
std
::
runtime_error
&
e
)
{
FormatError
(
e
,
"
\"
%s
\"
[%s] failed to play"
,
FormatError
(
e
,
"
\"
%s
\"
[%s] failed to play"
,
name
,
plugin
.
name
);
name
,
plugin
.
name
);
...
@@ -368,7 +368,7 @@ AudioOutput::Pause()
...
@@ -368,7 +368,7 @@ AudioOutput::Pause()
{
{
{
{
const
ScopeUnlock
unlock
(
mutex
);
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_cancel
(
this
);
ao_plugin_cancel
(
*
this
);
}
}
pause
=
true
;
pause
=
true
;
...
@@ -381,7 +381,7 @@ AudioOutput::Pause()
...
@@ -381,7 +381,7 @@ AudioOutput::Pause()
bool
success
;
bool
success
;
try
{
try
{
const
ScopeUnlock
unlock
(
mutex
);
const
ScopeUnlock
unlock
(
mutex
);
success
=
ao_plugin_pause
(
this
);
success
=
ao_plugin_pause
(
*
this
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
catch
(
const
std
::
runtime_error
&
e
)
{
FormatError
(
e
,
"
\"
%s
\"
[%s] failed to pause"
,
FormatError
(
e
,
"
\"
%s
\"
[%s] failed to pause"
,
name
,
plugin
.
name
);
name
,
plugin
.
name
);
...
@@ -477,7 +477,7 @@ AudioOutput::Task()
...
@@ -477,7 +477,7 @@ AudioOutput::Task()
case
Command
:
:
DRAIN
:
case
Command
:
:
DRAIN
:
if
(
open
)
{
if
(
open
)
{
const
ScopeUnlock
unlock
(
mutex
);
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_drain
(
this
);
ao_plugin_drain
(
*
this
);
}
}
CommandFinished
();
CommandFinished
();
...
@@ -488,7 +488,7 @@ AudioOutput::Task()
...
@@ -488,7 +488,7 @@ AudioOutput::Task()
if
(
open
)
{
if
(
open
)
{
const
ScopeUnlock
unlock
(
mutex
);
const
ScopeUnlock
unlock
(
mutex
);
ao_plugin_cancel
(
this
);
ao_plugin_cancel
(
*
this
);
}
}
CommandFinished
();
CommandFinished
();
...
...
test/run_output.cxx
View file @
fead4bbf
...
@@ -77,15 +77,15 @@ load_audio_output(EventLoop &event_loop, AudioOutputClient &client,
...
@@ -77,15 +77,15 @@ load_audio_output(EventLoop &event_loop, AudioOutputClient &client,
}
}
static
void
static
void
run_output
(
AudioOutput
*
ao
,
AudioFormat
audio_format
)
run_output
(
AudioOutput
&
ao
,
AudioFormat
audio_format
)
{
{
/* open the audio output */
/* open the audio output */
ao_plugin_enable
(
ao
);
ao_plugin_enable
(
ao
);
AtScopeExit
(
ao
)
{
ao_plugin_disable
(
ao
);
};
AtScopeExit
(
&
ao
)
{
ao_plugin_disable
(
ao
);
};
ao_plugin_open
(
ao
,
audio_format
);
ao_plugin_open
(
ao
,
audio_format
);
AtScopeExit
(
ao
)
{
ao_plugin_close
(
ao
);
};
AtScopeExit
(
&
ao
)
{
ao_plugin_close
(
ao
);
};
fprintf
(
stderr
,
"audio_format=%s
\n
"
,
fprintf
(
stderr
,
"audio_format=%s
\n
"
,
ToString
(
audio_format
).
c_str
());
ToString
(
audio_format
).
c_str
());
...
@@ -152,7 +152,7 @@ try {
...
@@ -152,7 +152,7 @@ try {
/* do it */
/* do it */
run_output
(
ao
,
audio_format
);
run_output
(
*
ao
,
audio_format
);
/* cleanup and exit */
/* 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