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,
...
@@ -406,7 +406,6 @@ decoder_data(Decoder &decoder,
while
(
length
>
0
)
{
while
(
length
>
0
)
{
struct
music_chunk
*
chunk
;
struct
music_chunk
*
chunk
;
size_t
nbytes
;
bool
full
;
bool
full
;
chunk
=
decoder_get_chunk
(
decoder
);
chunk
=
decoder_get_chunk
(
decoder
);
...
@@ -415,17 +414,19 @@ decoder_data(Decoder &decoder,
...
@@ -415,17 +414,19 @@ decoder_data(Decoder &decoder,
return
dc
.
command
;
return
dc
.
command
;
}
}
void
*
dest
=
chunk
->
Write
(
dc
.
out_audio_format
,
const
auto
dest
=
decoder
.
timestamp
-
chunk
->
Write
(
dc
.
out_audio_format
,
dc
.
song
->
start_ms
/
1000.0
,
decoder
.
timestamp
-
kbit_rate
,
&
nbytes
);
dc
.
song
->
start_ms
/
1000.0
,
if
(
dest
==
nullptr
)
{
kbit_rate
);
if
(
dest
.
IsNull
())
{
/* the chunk is full, flush it */
/* the chunk is full, flush it */
decoder_flush_chunk
(
decoder
);
decoder_flush_chunk
(
decoder
);
dc
.
client_cond
.
signal
();
dc
.
client_cond
.
signal
();
continue
;
continue
;
}
}
size_t
nbytes
=
dest
.
size
;
assert
(
nbytes
>
0
);
assert
(
nbytes
>
0
);
if
(
nbytes
>
length
)
if
(
nbytes
>
length
)
...
@@ -433,7 +434,7 @@ decoder_data(Decoder &decoder,
...
@@ -433,7 +434,7 @@ decoder_data(Decoder &decoder,
/* copy the buffer */
/* copy the buffer */
memcpy
(
dest
,
data
,
nbytes
);
memcpy
(
dest
.
data
,
data
,
nbytes
);
/* expand the music pipe chunk */
/* expand the music pipe chunk */
...
...
src/MusicChunk.cxx
View file @
de1261ba
...
@@ -39,10 +39,9 @@ music_chunk::CheckFormat(const AudioFormat other_format) const
...
@@ -39,10 +39,9 @@ music_chunk::CheckFormat(const AudioFormat other_format) const
}
}
#endif
#endif
void
*
WritableBuffer
<
void
>
music_chunk
::
Write
(
const
AudioFormat
af
,
music_chunk
::
Write
(
const
AudioFormat
af
,
float
data_time
,
uint16_t
_bit_rate
,
float
data_time
,
uint16_t
_bit_rate
)
size_t
*
max_length_r
)
{
{
assert
(
CheckFormat
(
af
));
assert
(
CheckFormat
(
af
));
assert
(
length
==
0
||
audio_format
.
IsValid
());
assert
(
length
==
0
||
audio_format
.
IsValid
());
...
@@ -58,14 +57,13 @@ music_chunk::Write(const AudioFormat af,
...
@@ -58,14 +57,13 @@ music_chunk::Write(const AudioFormat af,
const
size_t
frame_size
=
af
.
GetFrameSize
();
const
size_t
frame_size
=
af
.
GetFrameSize
();
size_t
num_frames
=
(
sizeof
(
data
)
-
length
)
/
frame_size
;
size_t
num_frames
=
(
sizeof
(
data
)
-
length
)
/
frame_size
;
if
(
num_frames
==
0
)
if
(
num_frames
==
0
)
return
nullptr
;
return
WritableBuffer
<
void
>::
Null
()
;
#ifndef NDEBUG
#ifndef NDEBUG
audio_format
=
af
;
audio_format
=
af
;
#endif
#endif
*
max_length_r
=
num_frames
*
frame_size
;
return
{
data
+
length
,
num_frames
*
frame_size
};
return
data
+
length
;
}
}
bool
bool
...
...
src/MusicChunk.hxx
View file @
de1261ba
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#define MPD_MUSIC_CHUNK_HXX
#define MPD_MUSIC_CHUNK_HXX
#include "ReplayGainInfo.hxx"
#include "ReplayGainInfo.hxx"
#include "util/WritableBuffer.hxx"
#ifndef NDEBUG
#ifndef NDEBUG
#include "AudioFormat.hxx"
#include "AudioFormat.hxx"
...
@@ -126,9 +127,8 @@ struct music_chunk {
...
@@ -126,9 +127,8 @@ struct music_chunk {
* here
* here
* @return a writable buffer, or nullptr if the chunk is full
* @return a writable buffer, or nullptr if the chunk is full
*/
*/
void
*
Write
(
AudioFormat
af
,
WritableBuffer
<
void
>
Write
(
AudioFormat
af
,
float
data_time
,
uint16_t
bit_rate
,
float
data_time
,
uint16_t
bit_rate
);
size_t
*
max_length_r
);
/**
/**
* Increases the length of the chunk after the caller has written to
* 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