diff options
author | Max Kellermann <max@duempel.org> | 2009-03-05 17:37:11 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-03-05 17:37:11 +0100 |
commit | 74a2813d781ec2bc2c0f5e4534552d4d8e99557b (patch) | |
tree | 21b7e5088d540b9974290ae2ad9a1544553d534e /src/pipe.c | |
parent | c655f804a92d82416b62d541c528b615e2ce27f6 (diff) | |
download | mpd-74a2813d781ec2bc2c0f5e4534552d4d8e99557b.tar.gz mpd-74a2813d781ec2bc2c0f5e4534552d4d8e99557b.tar.xz mpd-74a2813d781ec2bc2c0f5e4534552d4d8e99557b.zip |
music_chunk: added music_chunk_write(), music_chunk_expand()
Moved some code from music_pipe_write() and music_pipe_expand(). Only
music_chunk.c should access the music_chunk internals.
Diffstat (limited to 'src/pipe.c')
-rw-r--r-- | src/pipe.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/pipe.c b/src/pipe.c index 0c393c0b1..5aa931bd9 100644 --- a/src/pipe.c +++ b/src/pipe.c @@ -201,23 +201,13 @@ music_pipe_write(const struct audio_format *audio_format, { const size_t frame_size = audio_format_frame_size(audio_format); struct music_chunk *chunk; - size_t num_frames; chunk = tail_chunk(frame_size); if (chunk == NULL) return NULL; - if (chunk->length == 0) { - /* if the chunk is empty, nobody has set bitRate and - times yet */ - - chunk->bit_rate = bit_rate; - chunk->times = data_time; - } - - num_frames = (sizeof(chunk->data) - chunk->length) / frame_size; - *max_length_r = num_frames * frame_size; - return chunk->data + chunk->length; + return music_chunk_write(chunk, audio_format, data_time, bit_rate, + max_length_r); } void @@ -225,17 +215,16 @@ music_pipe_expand(const struct audio_format *audio_format, size_t length) { const size_t frame_size = audio_format_frame_size(audio_format); struct music_chunk *chunk; + bool full; /* no partial frames allowed */ assert(length % frame_size == 0); chunk = tail_chunk(frame_size); assert(chunk != NULL); - assert(chunk->length + length <= sizeof(chunk->data)); - - chunk->length += length; - if (chunk->length + frame_size > sizeof(chunk->data)) + full = music_chunk_expand(chunk, audio_format, length); + if (full) music_pipe_flush(); } |