aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEmanuele Giaquinta <e.giaquinta@glauco.it>2008-12-17 15:49:14 +0100
committerMax Kellermann <max@duempel.org>2008-12-17 15:56:43 +0100
commitc36a6b0aee4d300f0aa9e491bc49fa1b7cc740da (patch)
tree0f6ee75ed4c4e898a3924be9cc7d701d5e7b165b /src
parenta4f0c7b457a5806568097f88730433dc7bc19f00 (diff)
downloadmpd-c36a6b0aee4d300f0aa9e491bc49fa1b7cc740da.tar.gz
mpd-c36a6b0aee4d300f0aa9e491bc49fa1b7cc740da.tar.xz
mpd-c36a6b0aee4d300f0aa9e491bc49fa1b7cc740da.zip
Factor computation.
Diffstat (limited to '')
-rw-r--r--src/output/osx_plugin.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/output/osx_plugin.c b/src/output/osx_plugin.c
index d1d65ae00..ba44a8678 100644
--- a/src/output/osx_plugin.c
+++ b/src/output/osx_plugin.c
@@ -143,6 +143,7 @@ osx_render(void *vdata,
AudioBuffer *buffer = &bufferList->mBuffers[0];
size_t bufferSize = buffer->mDataByteSize;
size_t bytesToCopy;
+ size_t bytes;
int curpos = 0;
/*DEBUG("osx_render: enter : %i\n", (int)bufferList->mNumberBuffers);
@@ -185,8 +186,8 @@ osx_render(void *vdata,
bufferSize = bytesToCopy;
od->len -= bytesToCopy;
- if (od->pos + bytesToCopy > od->bufferSize) {
- size_t bytes = od->bufferSize - od->pos;
+ bytes = od->bufferSize - od->pos;
+ if (bytesToCopy > bytes) {
memcpy((unsigned char*)buffer->mData + curpos, od->buffer + od->pos, bytes);
od->pos = 0;
curpos += bytes;
@@ -299,6 +300,7 @@ osx_play(void *data, const char *playChunk, size_t size)
{
OsxData *od = data;
size_t bytesToCopy;
+ size_t bytes;
size_t curpos;
/* DEBUG("osx_play: enter\n"); */
@@ -333,8 +335,8 @@ osx_play(void *data, const char *playChunk, size_t size)
size -= bytesToCopy;
od->len += bytesToCopy;
- if (curpos + bytesToCopy > od->bufferSize) {
- size_t bytes = od->bufferSize - curpos;
+ bytes = od->bufferSize - curpos;
+ if (bytesToCopy > bytes) {
memcpy(od->buffer + curpos, playChunk, bytes);
curpos = 0;
playChunk += bytes;