aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-04-13 01:16:15 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-13 01:16:15 +0000
commitc1963ed483c66e85ac19ce8c3a6dbc6b19ca30c3 (patch)
treeb8c2ff14310e1e659f509aeae0cf847608af2d5f
parentdec6b1612e953c6029d963ff55d2b4a669b60f43 (diff)
downloadmpd-c1963ed483c66e85ac19ce8c3a6dbc6b19ca30c3.tar.gz
mpd-c1963ed483c66e85ac19ce8c3a6dbc6b19ca30c3.tar.xz
mpd-c1963ed483c66e85ac19ce8c3a6dbc6b19ca30c3.zip
Stop passing our single OutputBuffer object everywhere
All of our main singleton data structures are implicitly shared, so there's no reason to keep passing them around and around in the stack and making our internal API harder to deal with. git-svn-id: https://svn.musicpd.org/mpd/trunk@7354 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/decode.c77
-rw-r--r--src/inputPlugin.h4
-rw-r--r--src/inputPlugins/_flac_common.c6
-rw-r--r--src/inputPlugins/_flac_common.h5
-rw-r--r--src/inputPlugins/aac_plugin.c8
-rw-r--r--src/inputPlugins/audiofile_plugin.c11
-rw-r--r--src/inputPlugins/flac_plugin.c17
-rw-r--r--src/inputPlugins/mod_plugin.c8
-rw-r--r--src/inputPlugins/mp3_plugin.c22
-rw-r--r--src/inputPlugins/mp4_plugin.c31
-rw-r--r--src/inputPlugins/mpc_plugin.c12
-rw-r--r--src/inputPlugins/oggflac_plugin.c8
-rw-r--r--src/inputPlugins/oggvorbis_plugin.c16
-rw-r--r--src/inputPlugins/wavpack_plugin.c19
-rw-r--r--src/outputBuffer.c138
-rw-r--r--src/outputBuffer.h25
-rw-r--r--src/playerData.c5
-rw-r--r--src/playerData.h2
18 files changed, 199 insertions, 215 deletions
diff --git a/src/decode.c b/src/decode.c
index 3758ca27b..1e8700019 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -85,7 +85,7 @@ static unsigned calculateCrossFadeChunks(AudioFormat * af, float totalTime)
chunks = (af->sampleRate * af->bits * af->channels / 8.0 / CHUNK_SIZE);
chunks = (chunks * pc.crossFade + 0.5);
- buffered_chunks = getPlayerData()->buffer.size;
+ buffered_chunks = cb.size;
assert(buffered_chunks >= buffered_before_play);
if (chunks > (buffered_chunks - buffered_before_play))
chunks = buffered_chunks - buffered_before_play;
@@ -93,7 +93,7 @@ static unsigned calculateCrossFadeChunks(AudioFormat * af, float totalTime)
return chunks;
}
-static int waitOnDecode(OutputBuffer * cb, int *decodeWaitedOn)
+static int waitOnDecode(int *decodeWaitedOn)
{
while (dc.start)
player_wakeup_decoder();
@@ -115,7 +115,7 @@ static int waitOnDecode(OutputBuffer * cb, int *decodeWaitedOn)
return 0;
}
-static int decodeSeek(OutputBuffer * cb, int *decodeWaitedOn, int *next)
+static int decodeSeek(int *decodeWaitedOn, int *next)
{
int ret = -1;
@@ -124,10 +124,10 @@ static int decodeSeek(OutputBuffer * cb, int *decodeWaitedOn, int *next)
dc.current_song != pc.current_song) {
stopDecode();
*next = -1;
- clearOutputBuffer(cb);
+ clearOutputBuffer();
dc.error = DECODE_ERROR_NOERROR;
dc.start = 1;
- waitOnDecode(cb, decodeWaitedOn);
+ waitOnDecode(decodeWaitedOn);
}
if (dc.state != DECODE_STATE_STOP && dc.seekable) {
*next = -1;
@@ -148,8 +148,7 @@ static int decodeSeek(OutputBuffer * cb, int *decodeWaitedOn, int *next)
return ret;
}
-static void processDecodeInput(OutputBuffer * cb,
- int *pause_r, unsigned int *bbp_r,
+static void processDecodeInput(int *pause_r, unsigned int *bbp_r,
int *doCrossFade_r,
int *decodeWaitedOn_r,
int *next_r)
@@ -192,14 +191,14 @@ static void processDecodeInput(OutputBuffer * cb,
}
if(pc.seek) {
dropBufferedAudio();
- if (decodeSeek(cb, decodeWaitedOn_r, next_r) == 0) {
+ if (decodeSeek(decodeWaitedOn_r, next_r) == 0) {
*doCrossFade_r = 0;
*bbp_r = 0;
}
}
}
-static void decodeStart(OutputBuffer * cb)
+static void decodeStart(void)
{
int ret;
int close_instream = 1;
@@ -245,7 +244,7 @@ static void decodeStart(OutputBuffer * cb)
if (plugin->tryDecodeFunc
&& !plugin->tryDecodeFunc(&inStream))
continue;
- ret = plugin->streamDecodeFunc(cb, &inStream);
+ ret = plugin->streamDecodeFunc(&inStream);
break;
}
@@ -262,7 +261,7 @@ static void decodeStart(OutputBuffer * cb)
if (plugin->tryDecodeFunc &&
!plugin->tryDecodeFunc(&inStream))
continue;
- ret = plugin->streamDecodeFunc(cb, &inStream);
+ ret = plugin->streamDecodeFunc(&inStream);
break;
}
}
@@ -273,7 +272,7 @@ static void decodeStart(OutputBuffer * cb)
/* we already know our mp3Plugin supports streams, no
* need to check for stream{Types,DecodeFunc} */
if ((plugin = getInputPluginFromName("mp3"))) {
- ret = plugin->streamDecodeFunc(cb, &inStream);
+ ret = plugin->streamDecodeFunc(&inStream);
}
}
} else {
@@ -290,10 +289,10 @@ static void decodeStart(OutputBuffer * cb)
if (plugin->fileDecodeFunc) {
closeInputStream(&inStream);
close_instream = 0;
- ret = plugin->fileDecodeFunc(cb, path_max_fs);
+ ret = plugin->fileDecodeFunc(path_max_fs);
break;
} else if (plugin->streamDecodeFunc) {
- ret = plugin->streamDecodeFunc(cb, &inStream);
+ ret = plugin->streamDecodeFunc(&inStream);
break;
}
}
@@ -317,13 +316,11 @@ stop_no_close:
static void * decoder_task(mpd_unused void *arg)
{
- OutputBuffer *cb = &(getPlayerData()->buffer);
-
notifyEnter(&dc.notify);
while (1) {
if (dc.start || dc.seek) {
- decodeStart(cb);
+ decodeStart();
} else if (dc.stop) {
dc.state = DECODE_STATE_STOP;
dc.stop = 0;
@@ -381,7 +378,7 @@ static int playChunk(OutputBufferChunk * chunk,
return 0;
}
-static void decodeParent(OutputBuffer * cb)
+static void decodeParent(void)
{
int do_pause = 0;
int buffering = 1;
@@ -399,7 +396,7 @@ static void decodeParent(OutputBuffer * cb)
/** the position of the first chunk in the next song */
int next = -1;
- if (waitOnDecode(cb, &decodeWaitedOn) < 0)
+ if (waitOnDecode(&decodeWaitedOn) < 0)
return;
pc.elapsedTime = 0;
@@ -408,8 +405,7 @@ static void decodeParent(OutputBuffer * cb)
wakeup_main_task();
while (1) {
- processDecodeInput(cb,
- &do_pause, &bbp, &doCrossFade,
+ processDecodeInput(&do_pause, &bbp, &doCrossFade,
&decodeWaitedOn, &next);
if (pc.stop) {
dropBufferedAudio();
@@ -417,7 +413,7 @@ static void decodeParent(OutputBuffer * cb)
}
if (buffering) {
- if (availableOutputBuffer(cb) < bbp) {
+ if (availableOutputBuffer() < bbp) {
/* not enough decoded buffer space yet */
player_sleep();
continue;
@@ -431,7 +427,7 @@ static void decodeParent(OutputBuffer * cb)
dc.error==DECODE_ERROR_NOERROR) {
/* the decoder is ready and ok */
decodeWaitedOn = 0;
- if(openAudioDevice(&(cb->audioFormat))<0) {
+ if(openAudioDevice(&(cb.audioFormat))<0) {
char tmp[MPD_PATH_MAX];
pc.errored_song = pc.current_song;
pc.error = PLAYER_ERROR_AUDIO;
@@ -450,7 +446,7 @@ static void decodeParent(OutputBuffer * cb)
pc.sampleRate = dc.audioFormat.sampleRate;
pc.bits = dc.audioFormat.bits;
pc.channels = dc.audioFormat.channels;
- sizeToTime = audioFormatSizeToTime(&cb->audioFormat);
+ sizeToTime = audioFormatSizeToTime(&cb.audioFormat);
}
else if(dc.state!=DECODE_STATE_START) {
/* the decoder failed */
@@ -471,7 +467,7 @@ static void decodeParent(OutputBuffer * cb)
pc.queueLockState == PLAYER_QUEUE_UNLOCKED) {
/* the decoder has finished the current song;
make it decode the next song */
- next = cb->end;
+ next = cb.end;
dc.start = 1;
pc.queueState = PLAYER_QUEUE_DECODE;
wakeup_main_task();
@@ -483,7 +479,7 @@ static void decodeParent(OutputBuffer * cb)
calculate how many chunks will be required
for it */
crossFadeChunks =
- calculateCrossFadeChunks(&(cb->audioFormat),
+ calculateCrossFadeChunks(&(cb.audioFormat),
dc.totalTime);
if (crossFadeChunks > 0) {
doCrossFade = 1;
@@ -496,12 +492,12 @@ static void decodeParent(OutputBuffer * cb)
if (do_pause)
player_sleep();
- else if (!outputBufferEmpty(cb) && (int)cb->begin != next) {
+ else if (!outputBufferEmpty() && (int)cb.begin != next) {
OutputBufferChunk *beginChunk =
- outputBufferGetChunk(cb, cb->begin);
+ outputBufferGetChunk(cb.begin);
unsigned int fadePosition;
if (doCrossFade == 1 && next >= 0 &&
- (fadePosition = outputBufferRelative(cb, next))
+ (fadePosition = outputBufferRelative(next))
<= crossFadeChunks) {
/* perform cross fade */
if (nextChunk < 0) {
@@ -512,11 +508,11 @@ static void decodeParent(OutputBuffer * cb)
chunks in the old song */
crossFadeChunks = fadePosition;
}
- nextChunk = outputBufferAbsolute(cb, crossFadeChunks);
+ nextChunk = outputBufferAbsolute(crossFadeChunks);
if (nextChunk >= 0) {
crossFade(beginChunk,
- outputBufferGetChunk(cb, nextChunk),
- &(cb->audioFormat),
+ outputBufferGetChunk(nextChunk),
+ &(cb.audioFormat),
fadePosition,
crossFadeChunks);
} else {
@@ -537,19 +533,19 @@ static void decodeParent(OutputBuffer * cb)
}
/* play the current chunk */
- if (playChunk(beginChunk, &(cb->audioFormat),
+ if (playChunk(beginChunk, &(cb.audioFormat),
sizeToTime) < 0)
break;
- outputBufferShift(cb);
+ outputBufferShift();
player_wakeup_decoder_nb();
- } else if (!outputBufferEmpty(cb) && (int)cb->begin == next) {
+ } else if (!outputBufferEmpty() && (int)cb.begin == next) {
/* at the beginning of a new song */
if (doCrossFade == 1 && nextChunk >= 0) {
/* the cross-fade is finished; skip
the section which was cross-faded
(and thus already played) */
- output_buffer_skip(cb, crossFadeChunks);
+ output_buffer_skip(crossFadeChunks);
}
doCrossFade = 0;
@@ -564,7 +560,7 @@ static void decodeParent(OutputBuffer * cb)
break;
next = -1;
- if (waitOnDecode(cb, &decodeWaitedOn) < 0)
+ if (waitOnDecode(&decodeWaitedOn) < 0)
return;
pc.queueState = PLAYER_QUEUE_EMPTY;
@@ -588,10 +584,7 @@ static void decodeParent(OutputBuffer * cb)
*/
void decode(void)
{
- OutputBuffer *cb;
-
- cb = &(getPlayerData()->buffer);
- clearOutputBuffer(cb);
+ clearOutputBuffer();
dc.error = DECODE_ERROR_NOERROR;
dc.seek = 0;
@@ -599,5 +592,5 @@ void decode(void)
dc.start = 1;
do { player_wakeup_decoder(); } while (dc.start);
- decodeParent(cb);
+ decodeParent();
}
diff --git a/src/inputPlugin.h b/src/inputPlugin.h
index 4b591ee53..169781931 100644
--- a/src/inputPlugin.h
+++ b/src/inputPlugin.h
@@ -42,14 +42,14 @@ typedef unsigned int (*InputPlugin_tryDecodeFunc) (InputStream *);
* and networked (HTTP) connections.
*
* returns -1 on error, 0 on success */
-typedef int (*InputPlugin_streamDecodeFunc) (OutputBuffer *, InputStream *);
+typedef int (*InputPlugin_streamDecodeFunc) (InputStream *);
/* use this if and only if your InputPlugin can only be passed a filename or
* handle as input, and will not allow callbacks to be set (like Ogg-Vorbis
* and FLAC libraries allow)
*
* returns -1 on error, 0 on success */
-typedef int (*InputPlugin_fileDecodeFunc) (OutputBuffer *, char *path);
+typedef int (*InputPlugin_fileDecodeFunc) (char *path);
/* file should be the full path! Returns NULL if a tag cannot be found
* or read */
diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c
index a26163303..80b1210d1 100644
--- a/src/inputPlugins/_flac_common.c
+++ b/src/inputPlugins/_flac_common.c
@@ -36,13 +36,12 @@
#include <FLAC/format.h>
#include <FLAC/metadata.h>
-void init_FlacData(FlacData * data, OutputBuffer * cb, InputStream * inStream)
+void init_FlacData(FlacData * data, InputStream * inStream)
{
data->chunk_length = 0;
data->time = 0;
data->position = 0;
data->bitRate = 0;
- data->cb = cb;
data->inStream = inStream;
data->replayGainInfo = NULL;
data->tag = NULL;
@@ -171,8 +170,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
dc.audioFormat.sampleRate = si->sample_rate;
dc.audioFormat.channels = (mpd_sint8)si->channels;
dc.totalTime = ((float)si->total_samples) / (si->sample_rate);
- getOutputAudioFormat(&(dc.audioFormat),
- &(data->cb->audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(cb.audioFormat));
break;
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
flacParseReplayGain(block, data);
diff --git a/src/inputPlugins/_flac_common.h b/src/inputPlugins/_flac_common.h
index 37b5fdaae..18e51d587 100644
--- a/src/inputPlugins/_flac_common.h
+++ b/src/inputPlugins/_flac_common.h
@@ -148,14 +148,13 @@ typedef struct {
float time;
unsigned int bitRate;
FLAC__uint64 position;
- OutputBuffer *cb;
InputStream *inStream;
ReplayGainInfo *replayGainInfo;
MpdTag *tag;
} FlacData;
/* initializes a given FlacData struct */
-void init_FlacData(FlacData * data, OutputBuffer * cb, InputStream * inStream);
+void init_FlacData(FlacData * data, InputStream * inStream);
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
FlacData * data);
void flac_error_common_cb(const char *plugin,
@@ -168,7 +167,7 @@ MpdTag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block,
/* keep this inlined, this is just macro but prettier :) */
static inline int flacSendChunk(FlacData * data)
{
- if (sendDataToOutputBuffer(data->cb, data->inStream,
+ if (sendDataToOutputBuffer(data->inStream,
1, data->chunk,
data->chunk_length, data->time,
data->bitRate,
diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c
index aeda10492..ebf402be1 100644
--- a/src/inputPlugins/aac_plugin.c
+++ b/src/inputPlugins/aac_plugin.c
@@ -282,7 +282,7 @@ static int getAacTotalTime(char *file)
return file_time;
}
-static int aac_decode(OutputBuffer * cb, char *path)
+static int aac_decode(char *path)
{
float file_time;
float totalTime;
@@ -376,7 +376,7 @@ static int aac_decode(OutputBuffer * cb, char *path)
dc.audioFormat.channels = frameInfo.channels;
dc.audioFormat.sampleRate = sampleRate;
getOutputAudioFormat(&(dc.audioFormat),
- &(cb->audioFormat));
+ &(cb.audioFormat));
dc.state = DECODE_STATE_DECODE;
}
@@ -395,7 +395,7 @@ static int aac_decode(OutputBuffer * cb, char *path)
sampleBufferLen = sampleCount * 2;
- sendDataToOutputBuffer(cb, NULL, 0, sampleBuffer,
+ sendDataToOutputBuffer(NULL, 0, sampleBuffer,
sampleBufferLen, file_time,
bitRate, NULL);
if (dc.seek) {
@@ -408,7 +408,7 @@ static int aac_decode(OutputBuffer * cb, char *path)
}
}
- flushOutputBuffer(cb);
+ flushOutputBuffer();
faacDecClose(decoder);
if (b.buffer)
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index 4510ba46a..d661278b1 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -45,7 +45,7 @@ static int getAudiofileTotalTime(char *file)
return total_time;
}
-static int audiofile_decode(OutputBuffer * cb, char *path)
+static int audiofile_decode(char *path)
{
int fs, frame_count;
AFfilehandle af_fp;
@@ -72,7 +72,7 @@ static int audiofile_decode(OutputBuffer * cb, char *path)
(unsigned int)afGetRate(af_fp, AF_DEFAULT_TRACK);
dc.audioFormat.channels =
(mpd_uint8)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK);
- getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(cb.audioFormat));
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
@@ -97,7 +97,7 @@ static int audiofile_decode(OutputBuffer * cb, char *path)
while (!eof) {
if (dc.seek) {
- clearOutputBuffer(cb);
+ clearOutputBuffer();
current = dc.seekWhere *
dc.audioFormat.sampleRate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
@@ -112,8 +112,7 @@ static int audiofile_decode(OutputBuffer * cb, char *path)
eof = 1;
else {
current += ret;
- sendDataToOutputBuffer(cb,
- NULL,
+ sendDataToOutputBuffer(NULL,
1,
chunk,
ret * fs,
@@ -126,7 +125,7 @@ static int audiofile_decode(OutputBuffer * cb, char *path)
}
}
- flushOutputBuffer(cb);
+ flushOutputBuffer();
}
afCloseFile(af_fp);
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c
index f171ee457..70b5c7a80 100644
--- a/src/inputPlugins/flac_plugin.c
+++ b/src/inputPlugins/flac_plugin.c
@@ -381,8 +381,7 @@ static MpdTag *flacTagDup(char *file)
return ret;
}
-static int flac_decode_internal(OutputBuffer * cb,
- InputStream * inStream, int is_ogg)
+static int flac_decode_internal(InputStream * inStream, int is_ogg)
{
flac_decoder *flacDec;
FlacData data;
@@ -390,7 +389,7 @@ static int flac_decode_internal(OutputBuffer * cb,
if (!(flacDec = flac_new()))
return -1;
- init_FlacData(&data, cb, inStream);
+ init_FlacData(&data, inStream);
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
if(!FLAC__stream_decoder_set_metadata_respond(flacDec, FLAC__METADATA_TYPE_VORBIS_COMMENT))
@@ -431,7 +430,7 @@ static int flac_decode_internal(OutputBuffer * cb,
FLAC__uint64 sampleToSeek = dc.seekWhere *
dc.audioFormat.sampleRate + 0.5;
if (flac_seek_absolute(flacDec, sampleToSeek)) {
- clearOutputBuffer(cb);
+ clearOutputBuffer();
data.time = ((float)sampleToSeek) /
dc.audioFormat.sampleRate;
data.position = 0;
@@ -448,7 +447,7 @@ static int flac_decode_internal(OutputBuffer * cb,
/* send last little bit */
if (data.chunk_length > 0 && !dc.stop) {
flacSendChunk(&data);
- flushOutputBuffer(data.cb);
+ flushOutputBuffer();
}
fail:
@@ -465,9 +464,9 @@ fail:
return 0;
}
-static int flac_decode(OutputBuffer * cb, InputStream * inStream)
+static int flac_decode(InputStream * inStream)
{
- return flac_decode_internal(cb, inStream, 0);
+ return flac_decode_internal(inStream, 0);
}
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
@@ -506,9 +505,9 @@ out:
return ret;
}
-static int oggflac_decode(OutputBuffer * cb, InputStream * inStream)
+static int oggflac_decode(InputStream * inStream)
{
- return flac_decode_internal(cb, inStream, 1);
+ return flac_decode_internal(inStream, 1);
}
static unsigned int oggflac_try_decode(InputStream * inStream)
diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c
index 728f42d6f..31ffa9a3d 100644
--- a/src/inputPlugins/mod_plugin.c
+++ b/src/inputPlugins/mod_plugin.c
@@ -163,7 +163,7 @@ static void mod_close(mod_Data * data)
free(data);
}
-static int mod_decode(OutputBuffer * cb, char *path)
+static int mod_decode(char *path)
{
mod_Data *data;
float total_time = 0.0;
@@ -183,7 +183,7 @@ static int mod_decode(OutputBuffer * cb, char *path)
dc.audioFormat.bits = 16;
dc.audioFormat.sampleRate = 44100;
dc.audioFormat.channels = 2;
- getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(cb.audioFormat));
secPerByte =
1.0 / ((dc.audioFormat.bits * dc.audioFormat.channels / 8.0) *
@@ -205,12 +205,12 @@ static int mod_decode(OutputBuffer * cb, char *path)
ret = VC_WriteBytes(data->audio_buffer, MIKMOD_FRAME_SIZE);
total_time += ret * secPerByte;
- sendDataToOutputBuffer(cb, NULL, 0,
+ sendDataToOutputBuffer(NULL, 0,
(char *)data->audio_buffer, ret,
total_time, 0, NULL);
}
- flushOutputBuffer(cb);
+ flushOutputBuffer();
mod_close(data);
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index ea33ad5ad..ee26385d9 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -813,8 +813,7 @@ static int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data,
return 0;
}
-static int mp3Read(mp3DecodeData * data, OutputBuffer * cb,
- ReplayGainInfo ** replayGainInfo)
+static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
{
int samplesPerFrame;
int samplesLeft;
@@ -854,7 +853,7 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb,
case MUTEFRAME_SEEK:
if (dc.seekWhere <= data->elapsedTime) {
data->outputPtr = data->outputBuffer;
- clearOutputBuffer(cb);
+ clearOutputBuffer();
data->muteFrame = 0;
dc.seek = 0;
decoder_wakeup_player();
@@ -929,8 +928,7 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb,
}
if (data->outputPtr >= data->outputBufferEnd) {
- ret = sendDataToOutputBuffer(cb,
- data->inStream,
+ ret = sendDataToOutputBuffer(data->inStream,
data->inStream->seekable,
data->outputBuffer,
data->outputPtr - data->outputBuffer,
@@ -965,7 +963,7 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb,
data->frameOffset[j]) ==
0) {
data->outputPtr = data->outputBuffer;
- clearOutputBuffer(cb);
+ clearOutputBuffer();
data->currentFrame = j;
} else
dc.seekError = 1;
@@ -1014,7 +1012,7 @@ static void initAudioFormatFromMp3DecodeData(mp3DecodeData * data,
af->channels = MAD_NCHANNELS(&(data->frame).header);
}
-static int mp3_decode(OutputBuffer * cb, InputStream * inStream)
+static int mp3_decode(InputStream * inStream)
{
mp3DecodeData data;
MpdTag *tag = NULL;
@@ -1031,7 +1029,7 @@ static int mp3_decode(OutputBuffer * cb, InputStream * inStream)
}
initAudioFormatFromMp3DecodeData(&data, &(dc.audioFormat));
- getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(cb.audioFormat));
dc.totalTime = data.totalTime;
@@ -1062,10 +1060,10 @@ static int mp3_decode(OutputBuffer * cb, InputStream * inStream)
dc.state = DECODE_STATE_DECODE;
- while (mp3Read(&data, cb, &replayGainInfo) != DECODE_BREAK) ;
+ while (mp3Read(&data, &replayGainInfo) != DECODE_BREAK) ;
/* send last little bit if not dc.stop */
if (!dc.stop && data.outputPtr != data.outputBuffer && data.flush) {
- sendDataToOutputBuffer(cb, NULL,
+ sendDataToOutputBuffer(NULL,
data.inStream->seekable,
data.outputBuffer,
data.outputPtr - data.outputBuffer,
@@ -1077,12 +1075,12 @@ static int mp3_decode(OutputBuffer * cb, InputStream * inStream)
freeReplayGainInfo(replayGainInfo);
if (dc.seek && data.muteFrame == MUTEFRAME_SEEK) {
- clearOutputBuffer(cb);
+ clearOutputBuffer();
dc.seek = 0;
decoder_wakeup_player();
}
- flushOutputBuffer(cb);
+ flushOutputBuffer();
mp3DecodeDataFinalize(&data);
return 0;
diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c
index fb8c71020..1dd418b2d 100644
--- a/src/inputPlugins/mp4_plugin.c
+++ b/src/inputPlugins/mp4_plugin.c
@@ -84,7 +84,7 @@ static uint32_t mp4_inputStreamSeekCallback(void *inStream, uint64_t position)
return seekInputStream((InputStream *) inStream, position, SEEK_SET);
}
-static int mp4_decode(OutputBuffer * cb, InputStream * inStream)
+static int mp4_decode(InputStream * inStream)
{
mp4ff_t *mp4fh;
mp4ff_callback_t *mp4cb;
@@ -217,7 +217,7 @@ static int mp4_decode(OutputBuffer * cb, InputStream * inStream)
if (seeking && seekPositionFound) {
seekPositionFound = 0;
- clearOutputBuffer(cb);
+ clearOutputBuffer();
seeking = 0;
dc.seek = 0;
decoder_wakeup_player();
@@ -255,7 +255,7 @@ static int mp4_decode(OutputBuffer * cb, InputStream * inStream)
dc.audioFormat.sampleRate = scale;
dc.audioFormat.channels = frameInfo.channels;
getOutputAudioFormat(&(dc.audioFormat),
- &(cb->audioFormat));
+ &(cb.audioFormat));
dc.state = DECODE_STATE_DECODE;
}
@@ -277,7 +277,7 @@ static int mp4_decode(OutputBuffer * cb, InputStream * inStream)
sampleBuffer += offset * channels * 2;
- sendDataToOutputBuffer(cb, inStream, 1, sampleBuffer,
+ sendDataToOutputBuffer(inStream, 1, sampleBuffer,
sampleBufferLen, file_time,
bitRate, NULL);
if (dc.stop) {
@@ -295,11 +295,11 @@ static int mp4_decode(OutputBuffer * cb, InputStream * inStream)
return -1;
if (dc.seek && seeking) {
- clearOutputBuffer(cb);
+ clearOutputBuffer();
dc.seek = 0;
decoder_wakeup_player();
}
- flushOutputBuffer(cb);
+ flushOutputBuffer();
return 0;
}
@@ -309,7 +309,7 @@ static MpdTag *mp4DataDup(char *file, int *mp4MetadataFound)
MpdTag *ret = NULL;
InputStream inStream;
mp4ff_t *mp4fh;
- mp4ff_callback_t *cb;
+ mp4ff_callback_t *callback;
int32_t track;
int32_t file_time;
int32_t scale;
@@ -322,14 +322,14 @@ static MpdTag *mp4DataDup(char *file, int *mp4MetadataFound)
return NULL;
}
- cb = xmalloc(sizeof(mp4ff_callback_t));
- cb->read = mp4_inputStreamReadCallback;
- cb->seek = mp4_inputStreamSeekCallback;
- cb->user_data = &inStream;
+ callback = xmalloc(sizeof(mp4ff_callback_t));
+ callback->read = mp4_inputStreamReadCallback;
+ callback->seek = mp4_inputStreamSeekCallback;
+ callback->user_data = &inStream;
- mp4fh = mp4ff_open_read(cb);
+ mp4fh = mp4ff_open_read(callback);
if (!mp4fh) {
- free(cb);
+ free(callback);
closeInputStream(&inStream);
return NULL;
}
@@ -338,7 +338,7 @@ static MpdTag *mp4DataDup(char *file, int *mp4MetadataFound)
if (track < 0) {
mp4ff_close(mp4fh);
closeInputStream(&inStream);
- free(cb);
+ free(callback);
return NULL;
}
@@ -348,7 +348,7 @@ static MpdTag *mp4DataDup(char *file, int *mp4MetadataFound)
if (scale < 0) {
mp4ff_close(mp4fh);
closeInputStream(&inStream);
- free(cb);
+ free(callback);
freeMpdTag(ret);
return NULL;
}
@@ -389,7 +389,6 @@ static MpdTag *mp4DataDup(char *file, int *mp4MetadataFound)
mp4ff_close(mp4fh);
closeInputStream(&inStream);
- free(cb);
return ret;
}
diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c
index 867965688..77ca07b30 100644
--- a/src/inputPlugins/mpc_plugin.c
+++ b/src/inputPlugins/mpc_plugin.c
@@ -111,7 +111,7 @@ static inline mpd_sint16 convertSample(MPC_SAMPLE_FORMAT sample)
return val;
}
-static int mpc_decode(OutputBuffer * cb, InputStream * inStream)
+static int mpc_decode(InputStream * inStream)
{
mpc_decoder decoder;
mpc_reader reader;
@@ -170,7 +170,7 @@ static int mpc_decode(OutputBuffer * cb, InputStream * inStream)
dc.audioFormat.channels = info.channels;
dc.audioFormat.sampleRate = info.sample_freq;
- getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(cb.audioFormat));
replayGainInfo = newReplayGainInfo();
replayGainInfo->albumGain = info.gain_album * 0.01;
@@ -184,7 +184,7 @@ static int mpc_decode(OutputBuffer * cb, InputStream * inStream)
if (dc.seek) {
samplePos = dc.seekWhere * dc.audioFormat.sampleRate;
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
- clearOutputBuffer(cb);
+ clearOutputBuffer();
s16 = (mpd_sint16 *) chunk;
chunkpos = 0;
} else
@@ -221,7 +221,7 @@ static int mpc_decode(OutputBuffer * cb, InputStream * inStream)
bitRate = vbrUpdateBits *
dc.audioFormat.sampleRate / 1152 / 1000;
- sendDataToOutputBuffer(cb, inStream,
+ sendDataToOutputBuffer(inStream,
inStream->seekable,
chunk, chunkpos,
total_time,
@@ -243,12 +243,12 @@ static int mpc_decode(OutputBuffer * cb, InputStream * inStream)
bitRate =
vbrUpdateBits * dc.audioFormat.sampleRate / 1152 / 1000;
- sendDataToOutputBuffer(cb, NULL, inStream->seekable,
+ sendDataToOutputBuffer(NULL, inStream->seekable,
chunk, chunkpos, total_time, bitRate,
replayGainInfo);
}
- flushOutputBuffer(cb);
+ flushOutputBuffer();
freeReplayGainInfo(replayGainInfo);
diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c
index 070404e26..003b057d9 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -336,13 +336,13 @@ static unsigned int oggflac_try_decode(InputStream * inStream)
return (ogg_stream_type_detect(inStream) == FLAC) ? 1 : 0;
}
-static int oggflac_decode(OutputBuffer * cb, InputStream * inStream)
+static int oggflac_decode(InputStream * inStream)
{
OggFLAC__SeekableStreamDecoder *decoder = NULL;
FlacData data;
int ret = 0;
- init_FlacData(&data, cb, inStream);
+ init_FlacData(&data, inStream);
if (!(decoder = full_decoder_init_and_read_metadata(&data, 0))) {
ret = -1;
@@ -362,7 +362,7 @@ static int oggflac_decode(OutputBuffer * cb, InputStream * inStream)
dc.audioFormat.sampleRate + 0.5;
if (OggFLAC__seekable_stream_decoder_seek_absolute
(decoder, sampleToSeek)) {
- clearOutputBuffer(cb);
+ clearOutputBuffer();
data.time = ((float)sampleToSeek) /
dc.audioFormat.sampleRate;
data.position = 0;
@@ -381,7 +381,7 @@ static int oggflac_decode(OutputBuffer * cb, InputStream * inStream)
/* send last little bit */
if (data.chunk_length > 0 && !dc.stop) {
flacSendChunk(&data);
- flushOutputBuffer(data.cb);
+ flushOutputBuffer();
}
fail:
diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c
index afcef3e08..eb44b5c6e 100644
--- a/src/inputPlugins/oggvorbis_plugin.c
+++ b/src/inputPlugins/oggvorbis_plugin.c
@@ -195,7 +195,7 @@ static MpdTag *oggCommentsParse(char **comments)
return tag;
}
-static void putOggCommentsIntoOutputBuffer(OutputBuffer * cb, char *streamName,
+static void putOggCommentsIntoOutputBuffer(char *streamName,
char **comments)
{
MpdTag *tag;
@@ -216,7 +216,7 @@ static void putOggCommentsIntoOutputBuffer(OutputBuffer * cb, char *streamName,
}
/* public */
-static int oggvorbis_decode(OutputBuffer * cb, InputStream * inStream)
+static int oggvorbis_decode(InputStream * inStream)
{
OggVorbis_File vf;
ov_callbacks callbacks;
@@ -275,7 +275,7 @@ static int oggvorbis_decode(OutputBuffer * cb, InputStream * inStream)
while (1) {
if (dc.seek) {
if (0 == ov_time_seek_page(&vf, dc.seekWhere)) {
- clearOutputBuffer(cb);
+ clearOutputBuffer();
chunkpos = 0;
} else
dc.seekError = 1;
@@ -292,11 +292,11 @@ static int oggvorbis_decode(OutputBuffer * cb, InputStream * inStream)
dc.audioFormat.sampleRate = vi->rate;
if (dc.state == DECODE_STATE_START) {
getOutputAudioFormat(&(dc.audioFormat),
- &(cb->audioFormat));
+ &(cb.audioFormat));
dc.state = DECODE_STATE_DECODE;
}
comments = ov_comment(&vf, -1)->user_comments;
- putOggCommentsIntoOutputBuffer(cb, inStream->metaName,
+ putOggCommentsIntoOutputBuffer(inStream->metaName,
comments);
ogg_getReplayGainInfo(comments, &replayGainInfo);
}
@@ -316,7 +316,7 @@ static int oggvorbis_decode(OutputBuffer * cb, InputStream * inStream)
if ((test = ov_bitrate_instant(&vf)) > 0) {
bitRate = test / 1000;
}
- sendDataToOutputBuffer(cb, inStream,
+ sendDataToOutputBuffer(inStream,
inStream->seekable,
chunk, chunkpos,
ov_pcm_tell(&vf) /
@@ -329,7 +329,7 @@ static int oggvorbis_decode(OutputBuffer * cb, InputStream * inStream)
}
if (!dc.stop && chunkpos > 0) {
- sendDataToOutputBuffer(cb, NULL, inStream->seekable,
+ sendDataToOutputBuffer(NULL, inStream->seekable,
chunk, chunkpos,
ov_time_tell(&vf), bitRate,
replayGainInfo);
@@ -340,7 +340,7 @@ static int oggvorbis_decode(OutputBuffer * cb, InputStream * inStream)
ov_clear(&vf);
- flushOutputBuffer(cb);
+ flushOutputBuffer();
return 0;
}
diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c
index bae5f6acb..13f10a1e9 100644
--- a/src/inputPlugins/wavpack_plugin.c
+++ b/src/inputPlugins/wavpack_plugin.c
@@ -128,8 +128,7 @@ static void format_samples_float(int Bps, void *buffer, uint32_t samcnt)
* This does the main decoding thing.
* Requires an already opened WavpackContext.
*/
-static void wavpack_decode(OutputBuffer *cb,
- WavpackContext *wpc, int canseek,
+static void wavpack_decode(WavpackContext *wpc, int canseek,
ReplayGainInfo *replayGainInfo)
{
void (*format_samples)(int Bps, void *buffer, uint32_t samcnt);
@@ -167,7 +166,7 @@ static void wavpack_decode(OutputBuffer *cb,
samplesreq = sizeof(chunk) / (4 * dc.audioFormat.channels);
- getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(cb.audioFormat));
dc.totalTime = (float)allsamples / dc.audioFormat.sampleRate;
dc.state = DECODE_STATE_DECODE;
@@ -180,7 +179,7 @@ static void wavpack_decode(OutputBuffer *cb,
if (canseek) {
int where;
- clearOutputBuffer(cb);
+ clearOutputBuffer();
where = dc.seekWhere *
dc.audioFormat.sampleRate;
@@ -211,14 +210,14 @@ static void wavpack_decode(OutputBuffer *cb,
format_samples(Bps, chunk,
samplesgot * dc.audioFormat.channels);
- sendDataToOutputBuffer(cb, NULL, 0, chunk,
+ sendDataToOutputBuffer(NULL, 0, chunk,
samplesgot * outsamplesize,
file_time, bitrate,
replayGainInfo);
}
} while (samplesgot == samplesreq);
- flushOutputBuffer(cb);
+ flushOutputBuffer();
}
static char *wavpack_tag(WavpackContext *wpc, char *key)
@@ -442,7 +441,7 @@ static unsigned int wavpack_trydecode(InputStream *is)
/*
* Decodes a stream.
*/
-static int wavpack_streamdecode(OutputBuffer *cb, InputStream *is)
+static int wavpack_streamdecode(InputStream *is)
{
char error[ERRORLEN];
WavpackContext *wpc;
@@ -541,7 +540,7 @@ static int wavpack_streamdecode(OutputBuffer *cb, InputStream *is)
return -1;
}
- wavpack_decode(cb, wpc, canseek, NULL);
+ wavpack_decode(wpc, canseek, NULL);
WavpackCloseFile(wpc);
if (wvc_url != NULL) {
@@ -556,7 +555,7 @@ static int wavpack_streamdecode(OutputBuffer *cb, InputStream *is)
/*
* Decodes a file.
*/
-static int wavpack_filedecode(OutputBuffer *cb, char *fname)
+static int wavpack_filedecode(char *fname)
{
char error[ERRORLEN];
WavpackContext *wpc;
@@ -572,7 +571,7 @@ static int wavpack_filedecode(OutputBuffer *cb, char *fname)
replayGainInfo = wavpack_replaygain(wpc);
- wavpack_decode(cb, wpc, 1, replayGainInfo);
+ wavpack_decode(wpc, 1, replayGainInfo);
if (replayGainInfo)
freeReplayGainInfo(replayGainInfo);
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index f44f4c5e3..1db523817 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -22,52 +22,52 @@
#include "normalize.h"
#include "playerData.h"
-void initOutputBuffer(OutputBuffer * cb, unsigned int size)
+void initOutputBuffer(unsigned int size)
{
assert(size > 0);
- memset(&cb->convState, 0, sizeof(ConvState));
- cb->chunks = xmalloc(size * sizeof(*cb->chunks));
- cb->size = size;
- cb->begin = 0;
- cb->end = 0;
- cb->chunks[0].chunkSize = 0;
+ memset(&cb.convState, 0, sizeof(ConvState));
+ cb.chunks = xmalloc(size * sizeof(*cb.chunks));
+ cb.size = size;
+ cb.begin = 0;
+ cb.end = 0;
+ cb.chunks[0].chunkSize = 0;
}
-void output_buffer_free(OutputBuffer * cb)
+void output_buffer_free(void)
{
- assert(cb->chunks != NULL);
- free(cb->chunks);
+ assert(cb.chunks != NULL);
+ free(cb.chunks);
}
-void clearOutputBuffer(OutputBuffer * cb)
+void clearOutputBuffer(void)
{
- cb->end = cb->begin;
- cb->chunks[cb->end].chunkSize = 0;
+ cb.end = cb.begin;
+ cb.chunks[cb.end].chunkSize = 0;
}
/** return the index of the chunk after i */
-static inline unsigned successor(const OutputBuffer * cb, unsigned i)
+static inline unsigned successor(unsigned i)
{
- assert(i <= cb->size);
+ assert(i <= cb.size);
++i;
- return i == cb->size ? 0 : i;
+ return i == cb.size ? 0 : i;
}
/**
* Mark the tail chunk as "full" and wake up the player if is waiting
* for the decoder.
*/
-static void output_buffer_expand(OutputBuffer * cb, unsigned i)
+static void output_buffer_expand(unsigned i)
{
- int was_empty = outputBufferEmpty(cb);
+ int was_empty = outputBufferEmpty();
- assert(i == (cb->end + 1) % cb->size);
- assert(i != cb->end);
+ assert(i == (cb.end + 1) % cb.size);
+ assert(i != cb.end);
- cb->end = i;
- cb->chunks[i].chunkSize = 0;
+ cb.end = i;
+ cb.chunks[i].chunkSize = 0;
if (was_empty)
/* if the buffer was empty, the player thread might be
waiting for us; wake it up now that another decoded
@@ -75,70 +75,70 @@ static void output_buffer_expand(OutputBuffer * cb, unsigned i)
decoder_wakeup_player();
}
-void flushOutputBuffer(OutputBuffer * cb)
+void flushOutputBuffer(void)
{
- OutputBufferChunk *chunk = outputBufferGetChunk(cb, cb->end);
+ OutputBufferChunk *chunk = outputBufferGetChunk(cb.end);
if (chunk->chunkSize > 0) {
- unsigned int next = successor(cb, cb->end);
- if (next == cb->begin)
+ unsigned int next = successor(cb.end);
+ if (next == cb.begin)
/* all buffers are full; we have to wait for
the player to free one, so don't flush
right now */
return;
- output_buffer_expand(cb, next);
+ output_buffer_expand(next);
}
}
-int outputBufferEmpty(const OutputBuffer * cb)
+int outputBufferEmpty(void)
{
- return cb->begin == cb->end;
+ return cb.begin == cb.end;
}
-void outputBufferShift(OutputBuffer * cb)
+void outputBufferShift(void)
{
- assert(cb->begin != cb->end);
- assert(cb->begin < cb->size);
+ assert(cb.begin != cb.end);
+ assert(cb.begin < cb.size);
- cb->begin = successor(cb, cb->begin);
+ cb.begin = successor(cb.begin);
}
-unsigned int outputBufferRelative(const OutputBuffer * cb, unsigned i)
+unsigned int outputBufferRelative(const unsigned i)
{
- if (i >= cb->begin)
- return i - cb->begin;
+ if (i >= cb.begin)
+ return i - cb.begin;
else
- return i + cb->size - cb->begin;
+ return i + cb.size - cb.begin;
}
-unsigned availableOutputBuffer(const OutputBuffer * cb)
+unsigned availableOutputBuffer(void)
{
- return outputBufferRelative(cb, cb->end);
+ return outputBufferRelative(cb.end);
}
-int outputBufferAbsolute(const OutputBuffer * cb, unsigned relative)
+int outputBufferAbsolute(const unsigned relative)
{
unsigned i, max;
- max = cb->end;
- if (max < cb->begin)
- max += cb->size;
- i = (unsigned)cb->begin + relative;
+ max = cb.end;
+ if (max < cb.begin)
+ max += cb.size;
+ i = (unsigned)cb.begin + relative;
if (i >= max)
return -1;
- if (i >= cb->size)
- i -= cb->size;
+ if (i >= cb.size)
+ i -= cb.size;
return (int)i;
}
-OutputBufferChunk * outputBufferGetChunk(const OutputBuffer * cb, unsigned i)
+OutputBufferChunk * outputBufferGetChunk(const unsigned i)
{
- assert(i < cb->size);
+ assert(i < cb.size);
- return &cb->chunks[i];
+ return &cb.chunks[i];
}
/**
@@ -150,18 +150,18 @@ OutputBufferChunk * outputBufferGetChunk(const OutputBuffer * cb, unsigned i)
* if another thread requested seeking; OUTPUT_BUFFER_DC_STOP if
* another thread requested stopping the decoder.
*/
-static int tailChunk(OutputBuffer * cb, InputStream * inStream,
+static int tailChunk(InputStream * inStream,
int seekable, float data_time, mpd_uint16 bitRate)
{
unsigned int next;
OutputBufferChunk *chunk;
- chunk = outputBufferGetChunk(cb, cb->end);
+ chunk = outputBufferGetChunk(cb.end);
assert(chunk->chunkSize <= sizeof(chunk->data));
if (chunk->chunkSize == sizeof(chunk->data)) {
/* this chunk is full; allocate a new chunk */
- next = successor(cb, cb->end);
- while (cb->begin == next) {
+ next = successor(cb.end);
+ while (cb.begin == next) {
/* all chunks are full of decoded data; wait
for the player to free one */
@@ -182,8 +182,8 @@ static int tailChunk(OutputBuffer * cb, InputStream * inStream,
}
}
- output_buffer_expand(cb, next);
- chunk = outputBufferGetChunk(cb, next);
+ output_buffer_expand(next);
+ chunk = outputBufferGetChunk(next);
assert(chunk->chunkSize == 0);
}
@@ -195,10 +195,10 @@ static int tailChunk(OutputBuffer * cb, InputStream * inStream,
chunk->times = data_time;
}
- return cb->end;
+ return cb.end;
}
-int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
+int sendDataToOutputBuffer(InputStream * inStream,
int seekable, void *dataIn,
size_t dataInLen, float data_time, mpd_uint16 bitRate,
ReplayGainInfo * replayGainInfo)
@@ -210,12 +210,12 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
static size_t convBufferLen;
OutputBufferChunk *chunk = NULL;
- if (cmpAudioFormat(&(cb->audioFormat), &(dc.audioFormat)) == 0) {
+ if (cmpAudioFormat(&(cb.audioFormat), &(dc.audioFormat)) == 0) {
data = dataIn;
datalen = dataInLen;
} else {
datalen = pcm_sizeOfConvBuffer(&(dc.audioFormat), dataInLen,
- &(cb->audioFormat));
+ &(cb.audioFormat));
if (datalen > convBufferLen) {
if (convBuffer != NULL)
free(convBuffer);
@@ -224,22 +224,22 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
}
data = convBuffer;
datalen = pcm_convertAudioFormat(&(dc.audioFormat), dataIn,
- dataInLen, &(cb->audioFormat),
- data, &(cb->convState));
+ dataInLen, &(cb.audioFormat),
+ data, &(cb.convState));
}
if (replayGainInfo && (replayGainState != REPLAYGAIN_OFF))
- doReplayGain(replayGainInfo, data, datalen, &cb->audioFormat);
+ doReplayGain(replayGainInfo, data, datalen, &cb.audioFormat);
else if (normalizationEnabled)
- normalizeData(data, datalen, &cb->audioFormat);
+ normalizeData(data, datalen, &cb.audioFormat);
while (datalen) {
- int chunk_index = tailChunk(cb, inStream, seekable,
+ int chunk_index = tailChunk(inStream, seekable,
data_time, bitRate);
if (chunk_index < 0)
return chunk_index;
- chunk = outputBufferGetChunk(cb, chunk_index);
+ chunk = outputBufferGetChunk(chunk_index);
dataToSend = sizeof(chunk->data) - chunk->chunkSize;
if (dataToSend > datalen)
@@ -252,14 +252,14 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
}
if (chunk != NULL && chunk->chunkSize == sizeof(chunk->data))
- flushOutputBuffer(cb);
+ flushOutputBuffer();
return 0;
}
-void output_buffer_skip(OutputBuffer * cb, unsigned num)
+void output_buffer_skip(unsigned num)
{
- int i = outputBufferAbsolute(cb, num);
+ int i = outputBufferAbsolute(num);
if (i >= 0)
- cb->begin = i;
+ cb.begin = i;
}
diff --git a/src/outputBuffer.h b/src/outputBuffer.h
index 03260e440..b0287192e 100644
--- a/src/outputBuffer.h
+++ b/src/outputBuffer.h
@@ -57,46 +57,45 @@ typedef struct _OutputBuffer {
ConvState convState;
} OutputBuffer;
-void initOutputBuffer(OutputBuffer * cb, unsigned int size);
+void initOutputBuffer(unsigned int size);
-void output_buffer_free(OutputBuffer * cb);
+void output_buffer_free(void);
-void clearOutputBuffer(OutputBuffer * cb);
+void clearOutputBuffer(void);
-void flushOutputBuffer(OutputBuffer * cb);
+void flushOutputBuffer(void);
/** is the buffer empty? */
-int outputBufferEmpty(const OutputBuffer * cb);
+int outputBufferEmpty(void);
-void outputBufferShift(OutputBuffer * cb);
+void outputBufferShift(void);
/**
* what is the position of the specified chunk number, relative to
* the first chunk in use?
*/
-unsigned int outputBufferRelative(const OutputBuffer * cb, unsigned i);
+unsigned int outputBufferRelative(const unsigned i);
/** determine the number of decoded chunks */
-unsigned availableOutputBuffer(const OutputBuffer * cb);
+unsigned availableOutputBuffer(void);
/**
* Get the absolute index of the nth used chunk after the first one.
* Returns -1 if there is no such chunk.
*/
-int outputBufferAbsolute(const OutputBuffer * cb, unsigned relative);
+int outputBufferAbsolute(const unsigned relative);
-OutputBufferChunk * outputBufferGetChunk(const OutputBuffer * cb, unsigned i);
+OutputBufferChunk * outputBufferGetChunk(const unsigned i);
/* we send inStream for buffering the inputStream while waiting to
send the next chunk */
-int sendDataToOutputBuffer(OutputBuffer * cb,
- InputStream * inStream,
+int sendDataToOutputBuffer(InputStream * inStream,
int seekable,
void *data,
size_t datalen,
float data_time,
mpd_uint16 bitRate, ReplayGainInfo * replayGainInfo);
-void output_buffer_skip(OutputBuffer * cb, unsigned num);
+void output_buffer_skip(unsigned num);
#endif
diff --git a/src/playerData.c b/src/playerData.c
index a466ab5d7..5ac7c4785 100644
--- a/src/playerData.c
+++ b/src/playerData.c
@@ -29,6 +29,7 @@ unsigned int buffered_before_play;
static PlayerData playerData_pd;
PlayerControl pc;
DecoderControl dc;
+OutputBuffer cb; /* rename this to 'ob' */
void initPlayerData(void)
{
@@ -76,7 +77,7 @@ void initPlayerData(void)
playerData_pd.audioDeviceStates = xmalloc(device_array_size);
- initOutputBuffer(&(playerData_pd.buffer), buffered_chunks);
+ initOutputBuffer(buffered_chunks);
notifyInit(&pc.notify);
pc.error = PLAYER_ERROR_NOERROR;
@@ -103,6 +104,6 @@ void freePlayerData(void)
* access playerData_pd and we need to keep it available for them */
waitpid(-1, NULL, 0);
- output_buffer_free(&playerData_pd.buffer);
+ output_buffer_free();
free(playerData_pd.audioDeviceStates);
}
diff --git a/src/playerData.h b/src/playerData.h
index 2777edc17..80423717d 100644
--- a/src/playerData.h
+++ b/src/playerData.h
@@ -28,9 +28,9 @@
extern unsigned int buffered_before_play;
extern PlayerControl pc;
extern DecoderControl dc;
+extern OutputBuffer cb; /* rename this to 'ob' */
typedef struct _PlayerData {
- OutputBuffer buffer;
mpd_uint8 *audioDeviceStates;
} PlayerData;