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
487e2618
Commit
487e2618
authored
Jan 25, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/ao: use AudioOutputWrapper
parent
30d5186d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
37 deletions
+34
-37
AoOutputPlugin.cxx
src/output/plugins/AoOutputPlugin.cxx
+34
-37
No files found.
src/output/plugins/AoOutputPlugin.cxx
View file @
487e2618
...
...
@@ -20,6 +20,7 @@
#include "config.h"
#include "AoOutputPlugin.hxx"
#include "../OutputAPI.hxx"
#include "../Wrapper.hxx"
#include "system/Error.hxx"
#include "util/DivideString.hxx"
#include "util/SplitString.hxx"
...
...
@@ -45,6 +46,16 @@ struct AoOutput {
ao_device
*
device
;
AoOutput
(
const
ConfigBlock
&
block
);
~
AoOutput
();
static
AoOutput
*
Create
(
const
ConfigBlock
&
block
)
{
return
new
AoOutput
(
block
);
}
void
Open
(
AudioFormat
&
audio_format
);
void
Close
();
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
};
static
constexpr
Domain
ao_output_domain
(
"ao_output"
);
...
...
@@ -120,19 +131,9 @@ AoOutput::AoOutput(const ConfigBlock &block)
}
}
static
AudioOutput
*
ao_output_init
(
const
ConfigBlock
&
block
)
AoOutput
::~
AoOutput
()
{
return
&
(
new
AoOutput
(
block
))
->
base
;
}
static
void
ao_output_finish
(
AudioOutput
*
ao
)
{
AoOutput
*
ad
=
(
AoOutput
*
)
ao
;
ao_free_options
(
ad
->
options
);
delete
ad
;
ao_free_options
(
options
);
ao_output_ref
--
;
...
...
@@ -140,19 +141,10 @@ ao_output_finish(AudioOutput *ao)
ao_shutdown
();
}
static
void
ao_output_close
(
AudioOutput
*
ao
)
{
AoOutput
*
ad
=
(
AoOutput
*
)
ao
;
ao_close
(
ad
->
device
);
}
static
void
ao_output_open
(
AudioOutput
*
ao
,
AudioFormat
&
audio_format
)
void
AoOutput
::
Open
(
AudioFormat
&
audio_format
)
{
ao_sample_format
format
=
OUR_AO_FORMAT_INITIALIZER
;
AoOutput
*
ad
=
(
AoOutput
*
)
ao
;
switch
(
audio_format
.
format
)
{
case
SampleFormat
:
:
S8
:
...
...
@@ -176,43 +168,48 @@ ao_output_open(AudioOutput *ao, AudioFormat &audio_format)
format
.
byte_format
=
AO_FMT_NATIVE
;
format
.
channels
=
audio_format
.
channels
;
ad
->
device
=
ao_open_live
(
ad
->
driver
,
&
format
,
ad
->
options
);
if
(
ad
->
device
==
nullptr
)
device
=
ao_open_live
(
driver
,
&
format
,
options
);
if
(
device
==
nullptr
)
throw
MakeAoError
();
}
static
size_t
ao_output_play
(
AudioOutput
*
ao
,
const
void
*
chunk
,
size_t
size
)
void
AoOutput
::
Close
(
)
{
AoOutput
*
ad
=
(
AoOutput
*
)
ao
;
ao_close
(
device
);
}
if
(
size
>
ad
->
write_size
)
size
=
ad
->
write_size
;
size_t
AoOutput
::
Play
(
const
void
*
chunk
,
size_t
size
)
{
if
(
size
>
write_size
)
size
=
write_size
;
/* For whatever reason, libao wants a non-const pointer.
Let's hope it does not write to the buffer, and use the
union deconst hack to * work around this API misdesign. */
char
*
data
=
const_cast
<
char
*>
((
const
char
*
)
chunk
);
if
(
ao_play
(
ad
->
device
,
data
,
size
)
==
0
)
if
(
ao_play
(
device
,
data
,
size
)
==
0
)
throw
MakeAoError
();
return
size
;
}
typedef
AudioOutputWrapper
<
AoOutput
>
Wrapper
;
const
struct
AudioOutputPlugin
ao_output_plugin
=
{
"ao"
,
nullptr
,
ao_output_i
nit
,
ao_output_f
inish
,
&
Wrapper
::
I
nit
,
&
Wrapper
::
F
inish
,
nullptr
,
nullptr
,
ao_output_o
pen
,
ao_output_c
lose
,
&
Wrapper
::
O
pen
,
&
Wrapper
::
C
lose
,
nullptr
,
nullptr
,
ao_output_p
lay
,
&
Wrapper
::
P
lay
,
nullptr
,
nullptr
,
nullptr
,
...
...
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