moved code to initOutputBuffer()

This patch moves code which initializes the OutputBuffer struct to
outputBuffer.c.  Although this is generally a good idea, it prepares
the following patch.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7206 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Max Kellermann 2008-03-26 10:38:12 +00:00 committed by Eric Wong
parent 27f12c173d
commit 1910df96a3
3 changed files with 21 additions and 15 deletions

View File

@ -30,6 +30,23 @@ static mpd_sint16 currentChunk = -1;
static mpd_sint8 currentMetaChunk = -1;
static mpd_sint8 sendMetaChunk;
void initOutputBuffer(OutputBuffer * cb, char *chunks)
{
memset(&cb->convState, 0, sizeof(ConvState));
cb->chunks = chunks;
cb->chunkSize = (mpd_uint16 *) (((char *)cb->chunks) +
buffered_chunks * CHUNK_SIZE);
cb->bitRate = (mpd_uint16 *) (((char *)cb->chunkSize) +
buffered_chunks * sizeof(mpd_sint16));
cb->metaChunk = (mpd_sint8 *) (((char *)cb->bitRate) +
buffered_chunks *
sizeof(mpd_sint16));
cb->times =
(float *)(((char *)cb->metaChunk) +
buffered_chunks * sizeof(mpd_sint8));
cb->acceptMetadata = 0;
}
void clearAllMetaChunkSets(OutputBuffer * cb)
{
memset(cb->metaChunkSet, 0, BUFFERED_METACHUNKS);

View File

@ -47,6 +47,8 @@ typedef struct _OutputBuffer {
volatile mpd_sint8 acceptMetadata;
} OutputBuffer;
void initOutputBuffer(OutputBuffer * cb, char *chunks);
void clearOutputBuffer(OutputBuffer * cb);
void flushOutputBuffer(OutputBuffer * cb);

View File

@ -37,7 +37,6 @@ void initPlayerData(void)
int crossfade = 0;
size_t bufferSize = DEFAULT_BUFFER_SIZE;
size_t allocationSize;
OutputBuffer *buffer;
ConfigParam *param;
size_t device_array_size = audio_device_count() * sizeof(mpd_sint8);
@ -95,21 +94,9 @@ void initPlayerData(void)
playerData_pd->audioDeviceStates = (mpd_uint8 *)playerData_pd +
allocationSize - device_array_size;
buffer = &(playerData_pd->buffer);
memset(&buffer->convState, 0, sizeof(ConvState));
buffer->chunks = ((char *)playerData_pd) + sizeof(PlayerData);
buffer->chunkSize = (mpd_uint16 *) (((char *)buffer->chunks) +
buffered_chunks * CHUNK_SIZE);
buffer->bitRate = (mpd_uint16 *) (((char *)buffer->chunkSize) +
buffered_chunks * sizeof(mpd_sint16));
buffer->metaChunk = (mpd_sint8 *) (((char *)buffer->bitRate) +
buffered_chunks *
sizeof(mpd_sint16));
buffer->times =
(float *)(((char *)buffer->metaChunk) +
buffered_chunks * sizeof(mpd_sint8));
buffer->acceptMetadata = 0;
initOutputBuffer(&(playerData_pd->buffer),
((char *)playerData_pd) + sizeof(PlayerData));
playerData_pd->playerControl.wait = 0;
playerData_pd->playerControl.stop = 0;