aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/outputBuffer.c17
-rw-r--r--src/outputBuffer.h2
-rw-r--r--src/playerData.c19
3 files changed, 22 insertions, 16 deletions
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 25325ecb7..25c9b3c12 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -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);
diff --git a/src/outputBuffer.h b/src/outputBuffer.h
index 150748328..9bd9d48c8 100644
--- a/src/outputBuffer.h
+++ b/src/outputBuffer.h
@@ -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);
diff --git a/src/playerData.c b/src/playerData.c
index a84601bb0..551582e45 100644
--- a/src/playerData.c
+++ b/src/playerData.c
@@ -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;