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
de1261ba
Commit
de1261ba
authored
Oct 28, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MusicChunk: return WritableBuffer
parent
5ee5a89a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
16 deletions
+15
-16
DecoderAPI.cxx
src/DecoderAPI.cxx
+8
-7
MusicChunk.cxx
src/MusicChunk.cxx
+4
-6
MusicChunk.hxx
src/MusicChunk.hxx
+3
-3
No files found.
src/DecoderAPI.cxx
View file @
de1261ba
...
...
@@ -406,7 +406,6 @@ decoder_data(Decoder &decoder,
while
(
length
>
0
)
{
struct
music_chunk
*
chunk
;
size_t
nbytes
;
bool
full
;
chunk
=
decoder_get_chunk
(
decoder
);
...
...
@@ -415,17 +414,19 @@ decoder_data(Decoder &decoder,
return
dc
.
command
;
}
void
*
dest
=
chunk
->
Write
(
dc
.
out_audio_format
,
decoder
.
timestamp
-
dc
.
song
->
start_ms
/
1000.0
,
kbit_rate
,
&
nbytes
);
if
(
dest
==
nullptr
)
{
const
auto
dest
=
chunk
->
Write
(
dc
.
out_audio_format
,
decoder
.
timestamp
-
dc
.
song
->
start_ms
/
1000.0
,
kbit_rate
);
if
(
dest
.
IsNull
())
{
/* the chunk is full, flush it */
decoder_flush_chunk
(
decoder
);
dc
.
client_cond
.
signal
();
continue
;
}
size_t
nbytes
=
dest
.
size
;
assert
(
nbytes
>
0
);
if
(
nbytes
>
length
)
...
...
@@ -433,7 +434,7 @@ decoder_data(Decoder &decoder,
/* copy the buffer */
memcpy
(
dest
,
data
,
nbytes
);
memcpy
(
dest
.
data
,
data
,
nbytes
);
/* expand the music pipe chunk */
...
...
src/MusicChunk.cxx
View file @
de1261ba
...
...
@@ -39,10 +39,9 @@ music_chunk::CheckFormat(const AudioFormat other_format) const
}
#endif
void
*
WritableBuffer
<
void
>
music_chunk
::
Write
(
const
AudioFormat
af
,
float
data_time
,
uint16_t
_bit_rate
,
size_t
*
max_length_r
)
float
data_time
,
uint16_t
_bit_rate
)
{
assert
(
CheckFormat
(
af
));
assert
(
length
==
0
||
audio_format
.
IsValid
());
...
...
@@ -58,14 +57,13 @@ music_chunk::Write(const AudioFormat af,
const
size_t
frame_size
=
af
.
GetFrameSize
();
size_t
num_frames
=
(
sizeof
(
data
)
-
length
)
/
frame_size
;
if
(
num_frames
==
0
)
return
nullptr
;
return
WritableBuffer
<
void
>::
Null
()
;
#ifndef NDEBUG
audio_format
=
af
;
#endif
*
max_length_r
=
num_frames
*
frame_size
;
return
data
+
length
;
return
{
data
+
length
,
num_frames
*
frame_size
};
}
bool
...
...
src/MusicChunk.hxx
View file @
de1261ba
...
...
@@ -21,6 +21,7 @@
#define MPD_MUSIC_CHUNK_HXX
#include "ReplayGainInfo.hxx"
#include "util/WritableBuffer.hxx"
#ifndef NDEBUG
#include "AudioFormat.hxx"
...
...
@@ -126,9 +127,8 @@ struct music_chunk {
* here
* @return a writable buffer, or nullptr if the chunk is full
*/
void
*
Write
(
AudioFormat
af
,
float
data_time
,
uint16_t
bit_rate
,
size_t
*
max_length_r
);
WritableBuffer
<
void
>
Write
(
AudioFormat
af
,
float
data_time
,
uint16_t
bit_rate
);
/**
* Increases the length of the chunk after the caller has written to
...
...
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