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
56f61a6d
Commit
56f61a6d
authored
Aug 12, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PcmConvert: Convert() returns ConstBuffer
parent
4d5f6100
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
23 deletions
+19
-23
DecoderAPI.cxx
src/decoder/DecoderAPI.cxx
+6
-3
ConvertFilterPlugin.cxx
src/filter/plugins/ConvertFilterPlugin.cxx
+4
-2
PcmConvert.cxx
src/pcm/PcmConvert.cxx
+3
-7
PcmConvert.hxx
src/pcm/PcmConvert.hxx
+1
-5
run_convert.cxx
test/run_convert.cxx
+5
-6
No files found.
src/decoder/DecoderAPI.cxx
View file @
56f61a6d
...
...
@@ -31,6 +31,7 @@
#include "DetachedSong.hxx"
#include "input/InputStream.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "Log.hxx"
#include <assert.h>
...
...
@@ -472,9 +473,8 @@ decoder_data(Decoder &decoder,
assert
(
dc
.
in_audio_format
!=
dc
.
out_audio_format
);
Error
error
;
data
=
decoder
.
convert
->
Convert
(
data
,
length
,
&
length
,
error
);
auto
result
=
decoder
.
convert
->
Convert
({
data
,
length
},
error
);
if
(
data
==
nullptr
)
{
/* the PCM conversion has failed - stop
playback, since we have no better way to
...
...
@@ -482,6 +482,9 @@ decoder_data(Decoder &decoder,
LogError
(
error
);
return
DecoderCommand
::
STOP
;
}
data
=
result
.
data
;
length
=
result
.
size
;
}
else
{
assert
(
dc
.
in_audio_format
==
dc
.
out_audio_format
);
}
...
...
src/filter/plugins/ConvertFilterPlugin.cxx
View file @
56f61a6d
...
...
@@ -24,6 +24,7 @@
#include "filter/FilterRegistry.hxx"
#include "pcm/PcmConvert.hxx"
#include "util/Manual.hxx"
#include "util/ConstBuffer.hxx"
#include "AudioFormat.hxx"
#include "poison.h"
...
...
@@ -130,8 +131,9 @@ ConvertFilter::FilterPCM(const void *src, size_t src_size,
return
src
;
}
return
state
->
Convert
(
src
,
src_size
,
dest_size_r
,
error
);
auto
result
=
state
->
Convert
({
src
,
src_size
},
error
);
*
dest_size_r
=
result
.
size
;
return
result
.
data
;
}
const
struct
filter_plugin
convert_filter_plugin
=
{
...
...
src/pcm/PcmConvert.cxx
View file @
56f61a6d
...
...
@@ -117,12 +117,9 @@ PcmConvert::Close()
#endif
}
const
void
*
PcmConvert
::
Convert
(
const
void
*
src
,
size_t
src_size
,
size_t
*
dest_size_r
,
Error
&
error
)
ConstBuffer
<
void
>
PcmConvert
::
Convert
(
ConstBuffer
<
void
>
buffer
,
Error
&
error
)
{
ConstBuffer
<
void
>
buffer
(
src
,
src_size
);
AudioFormat
format
=
src_format
;
if
(
format
.
format
==
SampleFormat
::
DSD
)
{
...
...
@@ -164,6 +161,5 @@ PcmConvert::Convert(const void *src, size_t src_size,
format
.
channels
=
dest_format
.
channels
;
}
*
dest_size_r
=
buffer
.
size
;
return
buffer
.
data
;
return
buffer
;
}
src/pcm/PcmConvert.hxx
View file @
56f61a6d
...
...
@@ -70,16 +70,12 @@ public:
*
* @param src_format the source audio format
* @param src the source PCM buffer
* @param src_size the size of #src in bytes
* @param dest_format the requested destination audio format
* @param dest_size_r returns the number of bytes of the destination buffer
* @param error_r location to store the error occurring, or nullptr to
* ignore errors
* @return the destination buffer, or nullptr on error
*/
const
void
*
Convert
(
const
void
*
src
,
size_t
src_size
,
size_t
*
dest_size_r
,
Error
&
error
);
ConstBuffer
<
void
>
Convert
(
ConstBuffer
<
void
>
src
,
Error
&
error
);
};
bool
...
...
test/run_convert.cxx
View file @
56f61a6d
...
...
@@ -28,6 +28,7 @@
#include "AudioFormat.hxx"
#include "pcm/PcmConvert.hxx"
#include "config/ConfigGlobal.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StaticFifoBuffer.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
...
...
@@ -48,7 +49,6 @@ config_get_string(gcc_unused enum ConfigOption option,
int
main
(
int
argc
,
char
**
argv
)
{
AudioFormat
in_audio_format
,
out_audio_format
;
const
void
*
output
;
if
(
argc
!=
3
)
{
fprintf
(
stderr
,
...
...
@@ -104,16 +104,15 @@ int main(int argc, char **argv)
buffer
.
Consume
(
src
.
size
);
size_t
length
;
output
=
state
.
Convert
(
src
.
data
,
src
.
size
,
&
length
,
error
);
if
(
output
==
NULL
)
{
auto
output
=
state
.
Convert
({
src
.
data
,
src
.
size
},
error
);
if
(
output
.
IsNull
())
{
state
.
Close
();
LogError
(
error
,
"Failed to convert"
);
return
EXIT_FAILURE
;
}
gcc_unused
ssize_t
ignored
=
write
(
1
,
output
,
length
);
gcc_unused
ssize_t
ignored
=
write
(
1
,
output
.
data
,
output
.
size
);
}
state
.
Close
();
...
...
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