You need to sign in or sign up before continuing.
Commit 78f60607 authored by Max Kellermann's avatar Max Kellermann Committed by Eric Wong

let initOutputBuffer() allocate memory

This is the first patch in a series which removes the shared memory, and moves all the playerData objects into the normal libc heap. git-svn-id: https://svn.musicpd.org/mpd/trunk@7304 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent f0e28ede
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
#include "conf.h" #include "conf.h"
#include "os_compat.h" #include "os_compat.h"
void initOutputBuffer(OutputBuffer * cb, OutputBufferChunk * chunks) void initOutputBuffer(OutputBuffer * cb)
{ {
memset(&cb->convState, 0, sizeof(ConvState)); memset(&cb->convState, 0, sizeof(ConvState));
cb->chunks = chunks; cb->chunks = xmalloc(buffered_chunks * sizeof(*cb->chunks));
cb->currentChunk = -1; cb->currentChunk = -1;
} }
......
...@@ -58,7 +58,7 @@ typedef struct _OutputBuffer { ...@@ -58,7 +58,7 @@ typedef struct _OutputBuffer {
ConvState convState; ConvState convState;
} OutputBuffer; } OutputBuffer;
void initOutputBuffer(OutputBuffer * cb, OutputBufferChunk * chunks); void initOutputBuffer(OutputBuffer * cb);
void clearOutputBuffer(OutputBuffer * cb); void clearOutputBuffer(OutputBuffer * cb);
......
...@@ -74,11 +74,8 @@ void initPlayerData(void) ...@@ -74,11 +74,8 @@ void initPlayerData(void)
buffered_before_play = buffered_chunks; buffered_before_play = buffered_chunks;
} }
allocationSize = buffered_chunks * sizeof(OutputBufferChunk); /*actual buffer */ /* for playerData struct */
allocationSize += buffered_chunks * sizeof(float); /*for times */ allocationSize = sizeof(PlayerData);
allocationSize += buffered_chunks * sizeof(mpd_sint16); /*for chunkSize */
allocationSize += buffered_chunks * sizeof(mpd_sint16); /*for bitRate */
allocationSize += sizeof(PlayerData); /*for playerData struct */
/* for audioDeviceStates[] */ /* for audioDeviceStates[] */
allocationSize += device_array_size; allocationSize += device_array_size;
...@@ -93,8 +90,7 @@ void initPlayerData(void) ...@@ -93,8 +90,7 @@ void initPlayerData(void)
playerData_pd->audioDeviceStates = (mpd_uint8 *)playerData_pd + playerData_pd->audioDeviceStates = (mpd_uint8 *)playerData_pd +
allocationSize - device_array_size; allocationSize - device_array_size;
initOutputBuffer(&(playerData_pd->buffer), initOutputBuffer(&(playerData_pd->buffer));
(OutputBufferChunk*)(((char *)playerData_pd) + sizeof(PlayerData)));
notifyInit(&playerData_pd->playerControl.notify); notifyInit(&playerData_pd->playerControl.notify);
playerData_pd->playerControl.stop = 0; playerData_pd->playerControl.stop = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment