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
aa2e1bb3
Commit
aa2e1bb3
authored
Feb 16, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encoder/wave: refactor fill_wave_header() to function
parent
6153fca4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
WaveEncoderPlugin.cxx
src/encoder/plugins/WaveEncoderPlugin.cxx
+20
-17
No files found.
src/encoder/plugins/WaveEncoderPlugin.cxx
View file @
aa2e1bb3
...
...
@@ -71,30 +71,34 @@ struct WaveHeader {
uint32_t
data_size
;
};
static
void
fill_wave_header
(
WaveHeader
*
header
,
int
channels
,
int
bits
,
static
constexpr
WaveHeader
MakeWaveHeader
(
int
channels
,
int
bits
,
int
freq
,
int
block_size
)
noexcept
{
WaveHeader
header
{};
int
data_size
=
0x0FFFFFFF
;
/* constants */
header
->
id_riff
=
ToLE32
(
0x46464952
);
header
->
id_wave
=
ToLE32
(
0x45564157
);
header
->
id_fmt
=
ToLE32
(
0x20746d66
);
header
->
id_data
=
ToLE32
(
0x61746164
);
header
.
id_riff
=
ToLE32
(
0x46464952
);
header
.
id_wave
=
ToLE32
(
0x45564157
);
header
.
id_fmt
=
ToLE32
(
0x20746d66
);
header
.
id_data
=
ToLE32
(
0x61746164
);
/* wave format */
header
->
format
=
ToLE16
(
WAVE_FORMAT_PCM
);
header
->
channels
=
ToLE16
(
channels
);
header
->
bits
=
ToLE16
(
bits
);
header
->
freq
=
ToLE32
(
freq
);
header
->
blocksize
=
ToLE16
(
block_size
);
header
->
byterate
=
ToLE32
(
freq
*
block_size
);
header
.
format
=
ToLE16
(
WAVE_FORMAT_PCM
);
header
.
channels
=
ToLE16
(
channels
);
header
.
bits
=
ToLE16
(
bits
);
header
.
freq
=
ToLE32
(
freq
);
header
.
blocksize
=
ToLE16
(
block_size
);
header
.
byterate
=
ToLE32
(
freq
*
block_size
);
/* chunk sizes (fake data length) */
header
->
fmt_size
=
ToLE32
(
16
);
header
->
data_size
=
ToLE32
(
data_size
);
header
->
riff_size
=
ToLE32
(
4
+
(
8
+
16
)
+
(
8
+
data_size
));
header
.
fmt_size
=
ToLE32
(
16
);
header
.
data_size
=
ToLE32
(
data_size
);
header
.
riff_size
=
ToLE32
(
4
+
(
8
+
16
)
+
(
8
+
data_size
));
return
header
;
}
static
PreparedEncoder
*
...
...
@@ -137,8 +141,7 @@ WaveEncoder::WaveEncoder(AudioFormat &audio_format) noexcept
auto
*
header
=
(
WaveHeader
*
)
range
.
data
;
/* create PCM wave header in initial buffer */
fill_wave_header
(
header
,
audio_format
.
channels
,
*
header
=
MakeWaveHeader
(
audio_format
.
channels
,
bits
,
audio_format
.
sample_rate
,
(
bits
/
8
)
*
audio_format
.
channels
);
...
...
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