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
f6ec43b9
Commit
f6ec43b9
authored
Jan 02, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/Resampler: add virtual method Flush()
Wired to Filter::Flush(). Closes #153
parent
6d0d8cf9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
69 additions
and
0 deletions
+69
-0
NEWS
NEWS
+2
-0
ConvertFilterPlugin.cxx
src/filter/plugins/ConvertFilterPlugin.cxx
+4
-0
GlueResampler.cxx
src/pcm/GlueResampler.cxx
+6
-0
GlueResampler.hxx
src/pcm/GlueResampler.hxx
+2
-0
PcmConvert.cxx
src/pcm/PcmConvert.cxx
+19
-0
PcmConvert.hxx
src/pcm/PcmConvert.hxx
+6
-0
Resampler.hxx
src/pcm/Resampler.hxx
+8
-0
SoxrResampler.cxx
src/pcm/SoxrResampler.cxx
+21
-0
SoxrResampler.hxx
src/pcm/SoxrResampler.hxx
+1
-0
No files found.
NEWS
View file @
f6ec43b9
...
...
@@ -10,6 +10,8 @@ ver 0.21 (not yet released)
* decoder
- gme: try loading m3u sidecar files
- pcm: support audio/L24 (RFC 3190)
* resampler
- soxr: flush resampler at end of song
* output
- alsa: non-blocking mode
- alsa: change "dop" and "allowed_formats" settings at runtime
...
...
src/filter/plugins/ConvertFilterPlugin.cxx
View file @
f6ec43b9
...
...
@@ -55,6 +55,10 @@ public:
}
ConstBuffer
<
void
>
FilterPCM
(
ConstBuffer
<
void
>
src
)
override
;
ConstBuffer
<
void
>
Flush
()
override
{
return
state
.
Flush
();
}
};
class
PreparedConvertFilter
final
:
public
PreparedFilter
{
...
...
src/pcm/GlueResampler.cxx
View file @
f6ec43b9
...
...
@@ -81,3 +81,9 @@ GluePcmResampler::Resample(ConstBuffer<void> src)
return
resampler
->
Resample
(
src
);
}
ConstBuffer
<
void
>
GluePcmResampler
::
Flush
()
{
return
resampler
->
Flush
();
}
src/pcm/GlueResampler.hxx
View file @
f6ec43b9
...
...
@@ -61,6 +61,8 @@ public:
void
Reset
()
noexcept
;
ConstBuffer
<
void
>
Resample
(
ConstBuffer
<
void
>
src
);
ConstBuffer
<
void
>
Flush
();
};
#endif
src/pcm/PcmConvert.cxx
View file @
f6ec43b9
...
...
@@ -152,3 +152,22 @@ PcmConvert::Convert(ConstBuffer<void> buffer)
return
buffer
;
}
ConstBuffer
<
void
>
PcmConvert
::
Flush
()
{
if
(
enable_resampler
)
{
auto
buffer
=
resampler
.
Flush
();
if
(
!
buffer
.
IsNull
())
{
if
(
enable_format
)
buffer
=
format_converter
.
Convert
(
buffer
);
if
(
enable_channels
)
buffer
=
channels_converter
.
Convert
(
buffer
);
return
buffer
;
}
}
return
nullptr
;
}
src/pcm/PcmConvert.hxx
View file @
f6ec43b9
...
...
@@ -81,6 +81,12 @@ public:
* @return the destination buffer
*/
ConstBuffer
<
void
>
Convert
(
ConstBuffer
<
void
>
src
);
/**
* Flush pending data and return it. This should be called
* repepatedly until it returns nullptr.
*/
ConstBuffer
<
void
>
Flush
();
};
void
...
...
src/pcm/Resampler.hxx
View file @
f6ec43b9
...
...
@@ -70,6 +70,14 @@ public:
* filter_close() or filter_filter())
*/
virtual
ConstBuffer
<
void
>
Resample
(
ConstBuffer
<
void
>
src
)
=
0
;
/**
* Flush pending data and return it. This should be called
* repepatedly until it returns nullptr.
*/
virtual
ConstBuffer
<
void
>
Flush
()
{
return
nullptr
;
}
};
#endif
src/pcm/SoxrResampler.cxx
View file @
f6ec43b9
...
...
@@ -160,3 +160,24 @@ SoxrPcmResampler::Resample(ConstBuffer<void> src)
return
{
output_buffer
,
o_done
*
frame_size
};
}
ConstBuffer
<
void
>
SoxrPcmResampler
::
Flush
()
{
const
size_t
frame_size
=
channels
*
sizeof
(
float
);
const
size_t
o_frames
=
1024
;
float
*
output_buffer
=
(
float
*
)
buffer
.
Get
(
o_frames
*
frame_size
);
size_t
o_done
;
soxr_error_t
e
=
soxr_process
(
soxr
,
nullptr
,
0
,
nullptr
,
output_buffer
,
o_frames
,
&
o_done
);
if
(
e
!=
nullptr
)
throw
FormatRuntimeError
(
"soxr error: %s"
,
e
);
if
(
o_done
==
0
)
/* flush complete */
output_buffer
=
nullptr
;
return
{
output_buffer
,
o_done
*
frame_size
};
}
src/pcm/SoxrResampler.hxx
View file @
f6ec43b9
...
...
@@ -42,6 +42,7 @@ public:
AudioFormat
Open
(
AudioFormat
&
af
,
unsigned
new_sample_rate
)
override
;
void
Close
()
noexcept
override
;
ConstBuffer
<
void
>
Resample
(
ConstBuffer
<
void
>
src
)
override
;
ConstBuffer
<
void
>
Flush
()
override
;
};
void
...
...
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