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
12ecfdd4
Commit
12ecfdd4
authored
Dec 20, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/Thread: convert pointer to reference
parent
67cfbfc2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
34 deletions
+31
-34
Internal.hxx
src/output/Internal.hxx
+1
-1
OutputThread.cxx
src/output/OutputThread.cxx
+30
-33
No files found.
src/output/Internal.hxx
View file @
12ecfdd4
...
@@ -475,7 +475,7 @@ private:
...
@@ -475,7 +475,7 @@ private:
*/
*/
bool
WaitForDelay
();
bool
WaitForDelay
();
bool
PlayChunk
(
const
MusicChunk
*
chunk
);
bool
PlayChunk
(
const
MusicChunk
&
chunk
);
/**
/**
* Plays all remaining chunks, until the tail of the pipe has
* Plays all remaining chunks, until the tail of the pipe has
...
...
src/output/OutputThread.cxx
View file @
12ecfdd4
...
@@ -312,37 +312,34 @@ AudioOutput::WaitForDelay()
...
@@ -312,37 +312,34 @@ AudioOutput::WaitForDelay()
}
}
static
ConstBuffer
<
void
>
static
ConstBuffer
<
void
>
ao_chunk_data
(
AudioOutput
*
ao
,
const
MusicChunk
*
chunk
,
ao_chunk_data
(
AudioOutput
&
ao
,
const
MusicChunk
&
chunk
,
Filter
*
replay_gain_filter
,
Filter
*
replay_gain_filter
,
unsigned
*
replay_gain_serial_p
)
unsigned
*
replay_gain_serial_p
)
{
{
assert
(
chunk
!=
nullptr
);
assert
(
!
chunk
.
IsEmpty
());
assert
(
!
chunk
->
IsEmpty
());
assert
(
chunk
.
CheckFormat
(
ao
.
in_audio_format
));
assert
(
chunk
->
CheckFormat
(
ao
->
in_audio_format
));
ConstBuffer
<
void
>
data
(
chunk
->
data
,
chunk
->
length
);
ConstBuffer
<
void
>
data
(
chunk
.
data
,
chunk
.
length
);
(
void
)
ao
;
assert
(
data
.
size
%
ao
.
in_audio_format
.
GetFrameSize
()
==
0
);
assert
(
data
.
size
%
ao
->
in_audio_format
.
GetFrameSize
()
==
0
);
if
(
!
data
.
IsEmpty
()
&&
replay_gain_filter
!=
nullptr
)
{
if
(
!
data
.
IsEmpty
()
&&
replay_gain_filter
!=
nullptr
)
{
replay_gain_filter_set_mode
(
*
replay_gain_filter
,
replay_gain_filter_set_mode
(
*
replay_gain_filter
,
ao
->
replay_gain_mode
);
ao
.
replay_gain_mode
);
if
(
chunk
->
replay_gain_serial
!=
*
replay_gain_serial_p
)
{
if
(
chunk
.
replay_gain_serial
!=
*
replay_gain_serial_p
)
{
replay_gain_filter_set_info
(
*
replay_gain_filter
,
replay_gain_filter_set_info
(
*
replay_gain_filter
,
chunk
->
replay_gain_serial
!=
0
chunk
.
replay_gain_serial
!=
0
?
&
chunk
->
replay_gain_info
?
&
chunk
.
replay_gain_info
:
nullptr
);
:
nullptr
);
*
replay_gain_serial_p
=
chunk
->
replay_gain_serial
;
*
replay_gain_serial_p
=
chunk
.
replay_gain_serial
;
}
}
try
{
try
{
data
=
replay_gain_filter
->
FilterPCM
(
data
);
data
=
replay_gain_filter
->
FilterPCM
(
data
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
catch
(
const
std
::
runtime_error
&
e
)
{
FormatError
(
e
,
"
\"
%s
\"
[%s] failed to filter"
,
FormatError
(
e
,
"
\"
%s
\"
[%s] failed to filter"
,
ao
->
name
,
ao
->
plugin
.
name
);
ao
.
name
,
ao
.
plugin
.
name
);
return
nullptr
;
return
nullptr
;
}
}
}
}
...
@@ -351,21 +348,21 @@ ao_chunk_data(AudioOutput *ao, const MusicChunk *chunk,
...
@@ -351,21 +348,21 @@ ao_chunk_data(AudioOutput *ao, const MusicChunk *chunk,
}
}
static
ConstBuffer
<
void
>
static
ConstBuffer
<
void
>
ao_filter_chunk
(
AudioOutput
*
ao
,
const
MusicChunk
*
chunk
)
ao_filter_chunk
(
AudioOutput
&
ao
,
const
MusicChunk
&
chunk
)
{
{
ConstBuffer
<
void
>
data
=
ConstBuffer
<
void
>
data
=
ao_chunk_data
(
ao
,
chunk
,
ao
->
replay_gain_filter_instance
,
ao_chunk_data
(
ao
,
chunk
,
ao
.
replay_gain_filter_instance
,
&
ao
->
replay_gain_serial
);
&
ao
.
replay_gain_serial
);
if
(
data
.
IsEmpty
())
if
(
data
.
IsEmpty
())
return
data
;
return
data
;
/* cross-fade */
/* cross-fade */
if
(
chunk
->
other
!=
nullptr
)
{
if
(
chunk
.
other
!=
nullptr
)
{
ConstBuffer
<
void
>
other_data
=
ConstBuffer
<
void
>
other_data
=
ao_chunk_data
(
ao
,
chunk
->
other
,
ao_chunk_data
(
ao
,
*
chunk
.
other
,
ao
->
other_replay_gain_filter_instance
,
ao
.
other_replay_gain_filter_instance
,
&
ao
->
other_replay_gain_serial
);
&
ao
.
other_replay_gain_serial
);
if
(
other_data
.
IsNull
())
if
(
other_data
.
IsNull
())
return
nullptr
;
return
nullptr
;
...
@@ -380,7 +377,7 @@ ao_filter_chunk(AudioOutput *ao, const MusicChunk *chunk)
...
@@ -380,7 +377,7 @@ ao_filter_chunk(AudioOutput *ao, const MusicChunk *chunk)
if
(
data
.
size
>
other_data
.
size
)
if
(
data
.
size
>
other_data
.
size
)
data
.
size
=
other_data
.
size
;
data
.
size
=
other_data
.
size
;
float
mix_ratio
=
chunk
->
mix_ratio
;
float
mix_ratio
=
chunk
.
mix_ratio
;
if
(
mix_ratio
>=
0
)
if
(
mix_ratio
>=
0
)
/* reverse the mix ratio (because the
/* reverse the mix ratio (because the
arguments to pcm_mix() are reversed), but
arguments to pcm_mix() are reversed), but
...
@@ -389,14 +386,14 @@ ao_filter_chunk(AudioOutput *ao, const MusicChunk *chunk)
...
@@ -389,14 +386,14 @@ ao_filter_chunk(AudioOutput *ao, const MusicChunk *chunk)
case */
case */
mix_ratio
=
1.0
-
mix_ratio
;
mix_ratio
=
1.0
-
mix_ratio
;
void
*
dest
=
ao
->
cross_fade_buffer
.
Get
(
other_data
.
size
);
void
*
dest
=
ao
.
cross_fade_buffer
.
Get
(
other_data
.
size
);
memcpy
(
dest
,
other_data
.
data
,
other_data
.
size
);
memcpy
(
dest
,
other_data
.
data
,
other_data
.
size
);
if
(
!
pcm_mix
(
ao
->
cross_fade_dither
,
dest
,
data
.
data
,
data
.
size
,
if
(
!
pcm_mix
(
ao
.
cross_fade_dither
,
dest
,
data
.
data
,
data
.
size
,
ao
->
in_audio_format
.
format
,
ao
.
in_audio_format
.
format
,
mix_ratio
))
{
mix_ratio
))
{
FormatError
(
output_domain
,
FormatError
(
output_domain
,
"Cannot cross-fade format %s"
,
"Cannot cross-fade format %s"
,
sample_format_to_string
(
ao
->
in_audio_format
.
format
));
sample_format_to_string
(
ao
.
in_audio_format
.
format
));
return
nullptr
;
return
nullptr
;
}
}
...
@@ -407,30 +404,30 @@ ao_filter_chunk(AudioOutput *ao, const MusicChunk *chunk)
...
@@ -407,30 +404,30 @@ ao_filter_chunk(AudioOutput *ao, const MusicChunk *chunk)
/* apply filter chain */
/* apply filter chain */
try
{
try
{
return
ao
->
filter_instance
->
FilterPCM
(
data
);
return
ao
.
filter_instance
->
FilterPCM
(
data
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
}
catch
(
const
std
::
runtime_error
&
e
)
{
FormatError
(
e
,
"
\"
%s
\"
[%s] failed to filter"
,
FormatError
(
e
,
"
\"
%s
\"
[%s] failed to filter"
,
ao
->
name
,
ao
->
plugin
.
name
);
ao
.
name
,
ao
.
plugin
.
name
);
return
nullptr
;
return
nullptr
;
}
}
}
}
inline
bool
inline
bool
AudioOutput
::
PlayChunk
(
const
MusicChunk
*
chunk
)
AudioOutput
::
PlayChunk
(
const
MusicChunk
&
chunk
)
{
{
assert
(
filter_instance
!=
nullptr
);
assert
(
filter_instance
!=
nullptr
);
if
(
tags
&&
gcc_unlikely
(
chunk
->
tag
!=
nullptr
))
{
if
(
tags
&&
gcc_unlikely
(
chunk
.
tag
!=
nullptr
))
{
const
ScopeUnlock
unlock
(
mutex
);
const
ScopeUnlock
unlock
(
mutex
);
try
{
try
{
ao_plugin_send_tag
(
this
,
*
chunk
->
tag
);
ao_plugin_send_tag
(
this
,
*
chunk
.
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
);
}
}
}
}
auto
data
=
ConstBuffer
<
char
>::
FromVoid
(
ao_filter_chunk
(
this
,
chunk
));
auto
data
=
ConstBuffer
<
char
>::
FromVoid
(
ao_filter_chunk
(
*
this
,
chunk
));
if
(
data
.
IsNull
())
{
if
(
data
.
IsNull
())
{
Close
(
false
);
Close
(
false
);
...
@@ -508,7 +505,7 @@ AudioOutput::Play()
...
@@ -508,7 +505,7 @@ AudioOutput::Play()
n
=
0
;
n
=
0
;
}
}
if
(
!
PlayChunk
(
chunk
))
if
(
!
PlayChunk
(
*
chunk
))
break
;
break
;
pipe
.
Consume
(
*
chunk
);
pipe
.
Consume
(
*
chunk
);
...
...
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