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
30d5186d
Commit
30d5186d
authored
Jan 25, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/ao: use const_cast instead of the union hack
parent
cbe59714
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
18 deletions
+6
-18
AoOutputPlugin.cxx
src/output/plugins/AoOutputPlugin.cxx
+6
-18
No files found.
src/output/plugins/AoOutputPlugin.cxx
View file @
30d5186d
...
...
@@ -182,23 +182,6 @@ ao_output_open(AudioOutput *ao, AudioFormat &audio_format)
throw
MakeAoError
();
}
/**
* 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.
*/
static
int
ao_play_deconst
(
ao_device
*
device
,
const
void
*
output_samples
,
uint_32
num_bytes
)
{
union
{
const
void
*
in
;
char
*
out
;
}
u
;
u
.
in
=
output_samples
;
return
ao_play
(
device
,
u
.
out
,
num_bytes
);
}
static
size_t
ao_output_play
(
AudioOutput
*
ao
,
const
void
*
chunk
,
size_t
size
)
{
...
...
@@ -207,7 +190,12 @@ ao_output_play(AudioOutput *ao, const void *chunk, size_t size)
if
(
size
>
ad
->
write_size
)
size
=
ad
->
write_size
;
if
(
ao_play_deconst
(
ad
->
device
,
chunk
,
size
)
==
0
)
/* 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
)
throw
MakeAoError
();
return
size
;
...
...
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