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
f1ca61d7
Commit
f1ca61d7
authored
Nov 13, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DecoderInternal: allocate PcmConvert dynamically
Reduce header dependencies and allow it to be nullptr to disable it.
parent
a80b5cf1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
10 deletions
+26
-10
DecoderAPI.cxx
src/DecoderAPI.cxx
+17
-8
DecoderInternal.cxx
src/DecoderInternal.cxx
+2
-0
DecoderInternal.hxx
src/DecoderInternal.hxx
+7
-2
No files found.
src/DecoderAPI.cxx
View file @
f1ca61d7
...
...
@@ -20,6 +20,7 @@
#include "config.h"
#include "DecoderAPI.hxx"
#include "DecoderError.hxx"
#include "pcm/PcmConvert.hxx"
#include "AudioConfig.hxx"
#include "ReplayGainConfig.hxx"
#include "MusicChunk.hxx"
...
...
@@ -47,6 +48,7 @@ decoder_initialized(Decoder &decoder,
assert
(
dc
.
state
==
DecoderState
::
START
);
assert
(
dc
.
pipe
!=
nullptr
);
assert
(
decoder
.
convert
==
nullptr
);
assert
(
decoder
.
stream_tag
==
nullptr
);
assert
(
decoder
.
decoder_tag
==
nullptr
);
assert
(
!
decoder
.
seeking
);
...
...
@@ -59,19 +61,22 @@ decoder_initialized(Decoder &decoder,
dc
.
seekable
=
seekable
;
dc
.
total_time
=
total_time
;
dc
.
Lock
();
dc
.
state
=
DecoderState
::
DECODE
;
dc
.
client_cond
.
signal
();
dc
.
Unlock
();
FormatDebug
(
decoder_domain
,
"audio_format=%s, seekable=%s"
,
audio_format_to_string
(
dc
.
in_audio_format
,
&
af_string
),
seekable
?
"true"
:
"false"
);
if
(
dc
.
in_audio_format
!=
dc
.
out_audio_format
)
if
(
dc
.
in_audio_format
!=
dc
.
out_audio_format
)
{
FormatDebug
(
decoder_domain
,
"converting to %s"
,
audio_format_to_string
(
dc
.
out_audio_format
,
&
af_string
));
decoder
.
convert
=
new
PcmConvert
();
}
dc
.
Lock
();
dc
.
state
=
DecoderState
::
DECODE
;
dc
.
client_cond
.
signal
();
dc
.
Unlock
();
}
/**
...
...
@@ -388,9 +393,11 @@ decoder_data(Decoder &decoder,
return
cmd
;
}
if
(
dc
.
in_audio_format
!=
dc
.
out_audio_format
)
{
if
(
decoder
.
convert
!=
nullptr
)
{
assert
(
dc
.
in_audio_format
!=
dc
.
out_audio_format
);
Error
error
;
data
=
decoder
.
conv
_state
.
Convert
(
dc
.
in_audio_format
,
data
=
decoder
.
conv
ert
->
Convert
(
dc
.
in_audio_format
,
data
,
length
,
dc
.
out_audio_format
,
&
length
,
...
...
@@ -402,6 +409,8 @@ decoder_data(Decoder &decoder,
LogError
(
error
);
return
DecoderCommand
::
STOP
;
}
}
else
{
assert
(
dc
.
in_audio_format
==
dc
.
out_audio_format
);
}
while
(
length
>
0
)
{
...
...
src/DecoderInternal.cxx
View file @
f1ca61d7
...
...
@@ -20,6 +20,7 @@
#include "config.h"
#include "DecoderInternal.hxx"
#include "DecoderControl.hxx"
#include "pcm/PcmConvert.hxx"
#include "MusicPipe.hxx"
#include "MusicBuffer.hxx"
#include "MusicChunk.hxx"
...
...
@@ -32,6 +33,7 @@ Decoder::~Decoder()
/* caller must flush the chunk */
assert
(
chunk
==
nullptr
);
delete
convert
;
delete
song_tag
;
delete
stream_tag
;
delete
decoder_tag
;
...
...
src/DecoderInternal.hxx
View file @
f1ca61d7
...
...
@@ -21,9 +21,9 @@
#define MPD_DECODER_INTERNAL_HXX
#include "DecoderCommand.hxx"
#include "pcm/PcmConvert.hxx"
#include "ReplayGainInfo.hxx"
class
PcmConvert
;
struct
DecoderControl
;
struct
InputStream
;
struct
Tag
;
...
...
@@ -31,7 +31,11 @@ struct Tag;
struct
Decoder
{
DecoderControl
&
dc
;
PcmConvert
conv_state
;
/**
* For converting input data to the configured audio format.
* nullptr means no conversion necessary.
*/
PcmConvert
*
convert
;
/**
* The time stamp of the next data chunk, in seconds.
...
...
@@ -85,6 +89,7 @@ struct Decoder {
Decoder
(
DecoderControl
&
_dc
,
bool
_initial_seek_pending
,
Tag
*
_tag
)
:
dc
(
_dc
),
convert
(
nullptr
),
timestamp
(
0
),
initial_seek_pending
(
_initial_seek_pending
),
initial_seek_running
(
false
),
...
...
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