aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-04-13 01:16:27 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-13 01:16:27 +0000
commit412ce8bdc48f05963b7ef7eca27d760aff3a8500 (patch)
tree1d6fffc5adb99c46405fb700650a8d68baa60b6a
parentc1963ed483c66e85ac19ce8c3a6dbc6b19ca30c3 (diff)
downloadmpd-412ce8bdc48f05963b7ef7eca27d760aff3a8500.tar.gz
mpd-412ce8bdc48f05963b7ef7eca27d760aff3a8500.tar.xz
mpd-412ce8bdc48f05963b7ef7eca27d760aff3a8500.zip
Make the OutputBuffer API more consistent
We had functions names varied between outputBufferFoo, fooOutputBuffer, and output_buffer_foo That was too confusing for my little brain to handle. And the global variable was somehow named 'cb' instead of the more obvious 'ob'... git-svn-id: https://svn.musicpd.org/mpd/trunk@7355 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/decode.c42
-rw-r--r--src/inputPlugins/_flac_common.c2
-rw-r--r--src/inputPlugins/_flac_common.h2
-rw-r--r--src/inputPlugins/aac_plugin.c6
-rw-r--r--src/inputPlugins/audiofile_plugin.c8
-rw-r--r--src/inputPlugins/flac_plugin.c4
-rw-r--r--src/inputPlugins/mod_plugin.c6
-rw-r--r--src/inputPlugins/mp3_plugin.c14
-rw-r--r--src/inputPlugins/mp4_plugin.c10
-rw-r--r--src/inputPlugins/mpc_plugin.c10
-rw-r--r--src/inputPlugins/oggflac_plugin.c4
-rw-r--r--src/inputPlugins/oggvorbis_plugin.c10
-rw-r--r--src/inputPlugins/wavpack_plugin.c8
-rw-r--r--src/outputBuffer.c130
-rw-r--r--src/outputBuffer.h28
-rw-r--r--src/playerData.c6
-rw-r--r--src/playerData.h2
17 files changed, 146 insertions, 146 deletions
diff --git a/src/decode.c b/src/decode.c
index 1e8700019..a5110f752 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 = cb.size;
+ buffered_chunks = ob.size;
assert(buffered_chunks >= buffered_before_play);
if (chunks > (buffered_chunks - buffered_before_play))
chunks = buffered_chunks - buffered_before_play;
@@ -124,7 +124,7 @@ static int decodeSeek(int *decodeWaitedOn, int *next)
dc.current_song != pc.current_song) {
stopDecode();
*next = -1;
- clearOutputBuffer();
+ ob_clear();
dc.error = DECODE_ERROR_NOERROR;
dc.start = 1;
waitOnDecode(decodeWaitedOn);
@@ -344,7 +344,7 @@ void decoderInit(void)
FATAL("Failed to spawn decoder task: %s\n", strerror(errno));
}
-static void crossFade(OutputBufferChunk * a, OutputBufferChunk * b,
+static void crossFade(ob_chunk * a, ob_chunk * b,
AudioFormat * format,
unsigned int fadePosition, unsigned int crossFadeChunks)
{
@@ -361,7 +361,7 @@ static void crossFade(OutputBufferChunk * a, OutputBufferChunk * b,
a->chunkSize = b->chunkSize;
}
-static int playChunk(OutputBufferChunk * chunk,
+static int playChunk(ob_chunk * chunk,
AudioFormat * format, double sizeToTime)
{
pc.elapsedTime = chunk->times;
@@ -413,7 +413,7 @@ static void decodeParent(void)
}
if (buffering) {
- if (availableOutputBuffer() < bbp) {
+ if (ob_available() < bbp) {
/* not enough decoded buffer space yet */
player_sleep();
continue;
@@ -427,7 +427,7 @@ static void decodeParent(void)
dc.error==DECODE_ERROR_NOERROR) {
/* the decoder is ready and ok */
decodeWaitedOn = 0;
- if(openAudioDevice(&(cb.audioFormat))<0) {
+ if(openAudioDevice(&(ob.audioFormat))<0) {
char tmp[MPD_PATH_MAX];
pc.errored_song = pc.current_song;
pc.error = PLAYER_ERROR_AUDIO;
@@ -446,7 +446,7 @@ static void decodeParent(void)
pc.sampleRate = dc.audioFormat.sampleRate;
pc.bits = dc.audioFormat.bits;
pc.channels = dc.audioFormat.channels;
- sizeToTime = audioFormatSizeToTime(&cb.audioFormat);
+ sizeToTime = audioFormatSizeToTime(&ob.audioFormat);
}
else if(dc.state!=DECODE_STATE_START) {
/* the decoder failed */
@@ -467,7 +467,7 @@ static void decodeParent(void)
pc.queueLockState == PLAYER_QUEUE_UNLOCKED) {
/* the decoder has finished the current song;
make it decode the next song */
- next = cb.end;
+ next = ob.end;
dc.start = 1;
pc.queueState = PLAYER_QUEUE_DECODE;
wakeup_main_task();
@@ -479,7 +479,7 @@ static void decodeParent(void)
calculate how many chunks will be required
for it */
crossFadeChunks =
- calculateCrossFadeChunks(&(cb.audioFormat),
+ calculateCrossFadeChunks(&(ob.audioFormat),
dc.totalTime);
if (crossFadeChunks > 0) {
doCrossFade = 1;
@@ -492,12 +492,12 @@ static void decodeParent(void)
if (do_pause)
player_sleep();
- else if (!outputBufferEmpty() && (int)cb.begin != next) {
- OutputBufferChunk *beginChunk =
- outputBufferGetChunk(cb.begin);
+ else if (!ob_is_empty() && (int)ob.begin != next) {
+ ob_chunk *beginChunk =
+ ob_get_chunk(ob.begin);
unsigned int fadePosition;
if (doCrossFade == 1 && next >= 0 &&
- (fadePosition = outputBufferRelative(next))
+ (fadePosition = ob_relative(next))
<= crossFadeChunks) {
/* perform cross fade */
if (nextChunk < 0) {
@@ -508,11 +508,11 @@ static void decodeParent(void)
chunks in the old song */
crossFadeChunks = fadePosition;
}
- nextChunk = outputBufferAbsolute(crossFadeChunks);
+ nextChunk = ob_absolute(crossFadeChunks);
if (nextChunk >= 0) {
crossFade(beginChunk,
- outputBufferGetChunk(nextChunk),
- &(cb.audioFormat),
+ ob_get_chunk(nextChunk),
+ &(ob.audioFormat),
fadePosition,
crossFadeChunks);
} else {
@@ -533,19 +533,19 @@ static void decodeParent(void)
}
/* play the current chunk */
- if (playChunk(beginChunk, &(cb.audioFormat),
+ if (playChunk(beginChunk, &(ob.audioFormat),
sizeToTime) < 0)
break;
- outputBufferShift();
+ ob_shift();
player_wakeup_decoder_nb();
- } else if (!outputBufferEmpty() && (int)cb.begin == next) {
+ } else if (!ob_is_empty() && (int)ob.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(crossFadeChunks);
+ ob_skip(crossFadeChunks);
}
doCrossFade = 0;
@@ -584,7 +584,7 @@ static void decodeParent(void)
*/
void decode(void)
{
- clearOutputBuffer();
+ ob_clear();
dc.error = DECODE_ERROR_NOERROR;
dc.seek = 0;
diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c
index 80b1210d1..cf23a5e8c 100644
--- a/src/inputPlugins/_flac_common.c
+++ b/src/inputPlugins/_flac_common.c
@@ -170,7 +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), &(cb.audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(ob.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 18e51d587..10c2f3d38 100644
--- a/src/inputPlugins/_flac_common.h
+++ b/src/inputPlugins/_flac_common.h
@@ -167,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->inStream,
+ if (ob_send(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 ebf402be1..6e53c6420 100644
--- a/src/inputPlugins/aac_plugin.c
+++ b/src/inputPlugins/aac_plugin.c
@@ -376,7 +376,7 @@ static int aac_decode(char *path)
dc.audioFormat.channels = frameInfo.channels;
dc.audioFormat.sampleRate = sampleRate;
getOutputAudioFormat(&(dc.audioFormat),
- &(cb.audioFormat));
+ &(ob.audioFormat));
dc.state = DECODE_STATE_DECODE;
}
@@ -395,7 +395,7 @@ static int aac_decode(char *path)
sampleBufferLen = sampleCount * 2;
- sendDataToOutputBuffer(NULL, 0, sampleBuffer,
+ ob_send(NULL, 0, sampleBuffer,
sampleBufferLen, file_time,
bitRate, NULL);
if (dc.seek) {
@@ -408,7 +408,7 @@ static int aac_decode(char *path)
}
}
- flushOutputBuffer();
+ ob_flush();
faacDecClose(decoder);
if (b.buffer)
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index d661278b1..558731dd3 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -72,7 +72,7 @@ static int audiofile_decode(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), &(ob.audioFormat));
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
@@ -97,7 +97,7 @@ static int audiofile_decode(char *path)
while (!eof) {
if (dc.seek) {
- clearOutputBuffer();
+ ob_clear();
current = dc.seekWhere *
dc.audioFormat.sampleRate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
@@ -112,7 +112,7 @@ static int audiofile_decode(char *path)
eof = 1;
else {
current += ret;
- sendDataToOutputBuffer(NULL,
+ ob_send(NULL,
1,
chunk,
ret * fs,
@@ -125,7 +125,7 @@ static int audiofile_decode(char *path)
}
}
- flushOutputBuffer();
+ ob_flush();
}
afCloseFile(af_fp);
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c
index 70b5c7a80..38131bac9 100644
--- a/src/inputPlugins/flac_plugin.c
+++ b/src/inputPlugins/flac_plugin.c
@@ -430,7 +430,7 @@ static int flac_decode_internal(InputStream * inStream, int is_ogg)
FLAC__uint64 sampleToSeek = dc.seekWhere *
dc.audioFormat.sampleRate + 0.5;
if (flac_seek_absolute(flacDec, sampleToSeek)) {
- clearOutputBuffer();
+ ob_clear();
data.time = ((float)sampleToSeek) /
dc.audioFormat.sampleRate;
data.position = 0;
@@ -447,7 +447,7 @@ static int flac_decode_internal(InputStream * inStream, int is_ogg)
/* send last little bit */
if (data.chunk_length > 0 && !dc.stop) {
flacSendChunk(&data);
- flushOutputBuffer();
+ ob_flush();
}
fail:
diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c
index 31ffa9a3d..4b79a3672 100644
--- a/src/inputPlugins/mod_plugin.c
+++ b/src/inputPlugins/mod_plugin.c
@@ -183,7 +183,7 @@ static int mod_decode(char *path)
dc.audioFormat.bits = 16;
dc.audioFormat.sampleRate = 44100;
dc.audioFormat.channels = 2;
- getOutputAudioFormat(&(dc.audioFormat), &(cb.audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
secPerByte =
1.0 / ((dc.audioFormat.bits * dc.audioFormat.channels / 8.0) *
@@ -205,12 +205,12 @@ static int mod_decode(char *path)
ret = VC_WriteBytes(data->audio_buffer, MIKMOD_FRAME_SIZE);
total_time += ret * secPerByte;
- sendDataToOutputBuffer(NULL, 0,
+ ob_send(NULL, 0,
(char *)data->audio_buffer, ret,
total_time, 0, NULL);
}
- flushOutputBuffer();
+ ob_flush();
mod_close(data);
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index ee26385d9..dcfc25cdc 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -853,7 +853,7 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
case MUTEFRAME_SEEK:
if (dc.seekWhere <= data->elapsedTime) {
data->outputPtr = data->outputBuffer;
- clearOutputBuffer();
+ ob_clear();
data->muteFrame = 0;
dc.seek = 0;
decoder_wakeup_player();
@@ -928,7 +928,7 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
}
if (data->outputPtr >= data->outputBufferEnd) {
- ret = sendDataToOutputBuffer(data->inStream,
+ ret = ob_send(data->inStream,
data->inStream->seekable,
data->outputBuffer,
data->outputPtr - data->outputBuffer,
@@ -963,7 +963,7 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
data->frameOffset[j]) ==
0) {
data->outputPtr = data->outputBuffer;
- clearOutputBuffer();
+ ob_clear();
data->currentFrame = j;
} else
dc.seekError = 1;
@@ -1029,7 +1029,7 @@ static int mp3_decode(InputStream * inStream)
}
initAudioFormatFromMp3DecodeData(&data, &(dc.audioFormat));
- getOutputAudioFormat(&(dc.audioFormat), &(cb.audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
dc.totalTime = data.totalTime;
@@ -1063,7 +1063,7 @@ static int mp3_decode(InputStream * inStream)
while (mp3Read(&data, &replayGainInfo) != DECODE_BREAK) ;
/* send last little bit if not dc.stop */
if (!dc.stop && data.outputPtr != data.outputBuffer && data.flush) {
- sendDataToOutputBuffer(NULL,
+ ob_send(NULL,
data.inStream->seekable,
data.outputBuffer,
data.outputPtr - data.outputBuffer,
@@ -1075,12 +1075,12 @@ static int mp3_decode(InputStream * inStream)
freeReplayGainInfo(replayGainInfo);
if (dc.seek && data.muteFrame == MUTEFRAME_SEEK) {
- clearOutputBuffer();
+ ob_clear();
dc.seek = 0;
decoder_wakeup_player();
}
- flushOutputBuffer();
+ ob_flush();
mp3DecodeDataFinalize(&data);
return 0;
diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c
index 1dd418b2d..7f13ca344 100644
--- a/src/inputPlugins/mp4_plugin.c
+++ b/src/inputPlugins/mp4_plugin.c
@@ -217,7 +217,7 @@ static int mp4_decode(InputStream * inStream)
if (seeking && seekPositionFound) {
seekPositionFound = 0;
- clearOutputBuffer();
+ ob_clear();
seeking = 0;
dc.seek = 0;
decoder_wakeup_player();
@@ -255,7 +255,7 @@ static int mp4_decode(InputStream * inStream)
dc.audioFormat.sampleRate = scale;
dc.audioFormat.channels = frameInfo.channels;
getOutputAudioFormat(&(dc.audioFormat),
- &(cb.audioFormat));
+ &(ob.audioFormat));
dc.state = DECODE_STATE_DECODE;
}
@@ -277,7 +277,7 @@ static int mp4_decode(InputStream * inStream)
sampleBuffer += offset * channels * 2;
- sendDataToOutputBuffer(inStream, 1, sampleBuffer,
+ ob_send(inStream, 1, sampleBuffer,
sampleBufferLen, file_time,
bitRate, NULL);
if (dc.stop) {
@@ -295,11 +295,11 @@ static int mp4_decode(InputStream * inStream)
return -1;
if (dc.seek && seeking) {
- clearOutputBuffer();
+ ob_clear();
dc.seek = 0;
decoder_wakeup_player();
}
- flushOutputBuffer();
+ ob_flush();
return 0;
}
diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c
index 77ca07b30..1003f15d5 100644
--- a/src/inputPlugins/mpc_plugin.c
+++ b/src/inputPlugins/mpc_plugin.c
@@ -170,7 +170,7 @@ static int mpc_decode(InputStream * inStream)
dc.audioFormat.channels = info.channels;
dc.audioFormat.sampleRate = info.sample_freq;
- getOutputAudioFormat(&(dc.audioFormat), &(cb.audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
replayGainInfo = newReplayGainInfo();
replayGainInfo->albumGain = info.gain_album * 0.01;
@@ -184,7 +184,7 @@ static int mpc_decode(InputStream * inStream)
if (dc.seek) {
samplePos = dc.seekWhere * dc.audioFormat.sampleRate;
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
- clearOutputBuffer();
+ ob_clear();
s16 = (mpd_sint16 *) chunk;
chunkpos = 0;
} else
@@ -221,7 +221,7 @@ static int mpc_decode(InputStream * inStream)
bitRate = vbrUpdateBits *
dc.audioFormat.sampleRate / 1152 / 1000;
- sendDataToOutputBuffer(inStream,
+ ob_send(inStream,
inStream->seekable,
chunk, chunkpos,
total_time,
@@ -243,12 +243,12 @@ static int mpc_decode(InputStream * inStream)
bitRate =
vbrUpdateBits * dc.audioFormat.sampleRate / 1152 / 1000;
- sendDataToOutputBuffer(NULL, inStream->seekable,
+ ob_send(NULL, inStream->seekable,
chunk, chunkpos, total_time, bitRate,
replayGainInfo);
}
- flushOutputBuffer();
+ ob_flush();
freeReplayGainInfo(replayGainInfo);
diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c
index 003b057d9..67259b626 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -362,7 +362,7 @@ static int oggflac_decode(InputStream * inStream)
dc.audioFormat.sampleRate + 0.5;
if (OggFLAC__seekable_stream_decoder_seek_absolute
(decoder, sampleToSeek)) {
- clearOutputBuffer();
+ ob_clear();
data.time = ((float)sampleToSeek) /
dc.audioFormat.sampleRate;
data.position = 0;
@@ -381,7 +381,7 @@ static int oggflac_decode(InputStream * inStream)
/* send last little bit */
if (data.chunk_length > 0 && !dc.stop) {
flacSendChunk(&data);
- flushOutputBuffer();
+ ob_flush();
}
fail:
diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c
index eb44b5c6e..16040b388 100644
--- a/src/inputPlugins/oggvorbis_plugin.c
+++ b/src/inputPlugins/oggvorbis_plugin.c
@@ -275,7 +275,7 @@ static int oggvorbis_decode(InputStream * inStream)
while (1) {
if (dc.seek) {
if (0 == ov_time_seek_page(&vf, dc.seekWhere)) {
- clearOutputBuffer();
+ ob_clear();
chunkpos = 0;
} else
dc.seekError = 1;
@@ -292,7 +292,7 @@ static int oggvorbis_decode(InputStream * inStream)
dc.audioFormat.sampleRate = vi->rate;
if (dc.state == DECODE_STATE_START) {
getOutputAudioFormat(&(dc.audioFormat),
- &(cb.audioFormat));
+ &(ob.audioFormat));
dc.state = DECODE_STATE_DECODE;
}
comments = ov_comment(&vf, -1)->user_comments;
@@ -316,7 +316,7 @@ static int oggvorbis_decode(InputStream * inStream)
if ((test = ov_bitrate_instant(&vf)) > 0) {
bitRate = test / 1000;
}
- sendDataToOutputBuffer(inStream,
+ ob_send(inStream,
inStream->seekable,
chunk, chunkpos,
ov_pcm_tell(&vf) /
@@ -329,7 +329,7 @@ static int oggvorbis_decode(InputStream * inStream)
}
if (!dc.stop && chunkpos > 0) {
- sendDataToOutputBuffer(NULL, inStream->seekable,
+ ob_send(NULL, inStream->seekable,
chunk, chunkpos,
ov_time_tell(&vf), bitRate,
replayGainInfo);
@@ -340,7 +340,7 @@ static int oggvorbis_decode(InputStream * inStream)
ov_clear(&vf);
- flushOutputBuffer();
+ ob_flush();
return 0;
}
diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c
index 13f10a1e9..6ab3d4d7a 100644
--- a/src/inputPlugins/wavpack_plugin.c
+++ b/src/inputPlugins/wavpack_plugin.c
@@ -166,7 +166,7 @@ static void wavpack_decode(WavpackContext *wpc, int canseek,
samplesreq = sizeof(chunk) / (4 * dc.audioFormat.channels);
- getOutputAudioFormat(&(dc.audioFormat), &(cb.audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
dc.totalTime = (float)allsamples / dc.audioFormat.sampleRate;
dc.state = DECODE_STATE_DECODE;
@@ -179,7 +179,7 @@ static void wavpack_decode(WavpackContext *wpc, int canseek,
if (canseek) {
int where;
- clearOutputBuffer();
+ ob_clear();
where = dc.seekWhere *
dc.audioFormat.sampleRate;
@@ -210,14 +210,14 @@ static void wavpack_decode(WavpackContext *wpc, int canseek,
format_samples(Bps, chunk,
samplesgot * dc.audioFormat.channels);
- sendDataToOutputBuffer(NULL, 0, chunk,
+ ob_send(NULL, 0, chunk,
samplesgot * outsamplesize,
file_time, bitrate,
replayGainInfo);
}
} while (samplesgot == samplesreq);
- flushOutputBuffer();
+ ob_flush();
}
static char *wavpack_tag(WavpackContext *wpc, char *key)
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 1db523817..6732d0e7a 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -22,37 +22,37 @@
#include "normalize.h"
#include "playerData.h"
-void initOutputBuffer(unsigned int size)
+void ob_init(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(&ob.convState, 0, sizeof(ConvState));
+ ob.chunks = xmalloc(size * sizeof(*ob.chunks));
+ ob.size = size;
+ ob.begin = 0;
+ ob.end = 0;
+ ob.chunks[0].chunkSize = 0;
}
-void output_buffer_free(void)
+void ob_free(void)
{
- assert(cb.chunks != NULL);
- free(cb.chunks);
+ assert(ob.chunks != NULL);
+ free(ob.chunks);
}
-void clearOutputBuffer(void)
+void ob_clear(void)
{
- cb.end = cb.begin;
- cb.chunks[cb.end].chunkSize = 0;
+ ob.end = ob.begin;
+ ob.chunks[ob.end].chunkSize = 0;
}
/** return the index of the chunk after i */
static inline unsigned successor(unsigned i)
{
- assert(i <= cb.size);
+ assert(i <= ob.size);
++i;
- return i == cb.size ? 0 : i;
+ return i == ob.size ? 0 : i;
}
/**
@@ -61,13 +61,13 @@ static inline unsigned successor(unsigned i)
*/
static void output_buffer_expand(unsigned i)
{
- int was_empty = outputBufferEmpty();
+ int was_empty = ob_is_empty();
- assert(i == (cb.end + 1) % cb.size);
- assert(i != cb.end);
+ assert(i == (ob.end + 1) % ob.size);
+ assert(i != ob.end);
- cb.end = i;
- cb.chunks[i].chunkSize = 0;
+ ob.end = i;
+ ob.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,13 +75,13 @@ static void output_buffer_expand(unsigned i)
decoder_wakeup_player();
}
-void flushOutputBuffer(void)
+void ob_flush(void)
{
- OutputBufferChunk *chunk = outputBufferGetChunk(cb.end);
+ ob_chunk *chunk = ob_get_chunk(ob.end);
if (chunk->chunkSize > 0) {
- unsigned int next = successor(cb.end);
- if (next == cb.begin)
+ unsigned int next = successor(ob.end);
+ if (next == ob.begin)
/* all buffers are full; we have to wait for
the player to free one, so don't flush
right now */
@@ -91,54 +91,54 @@ void flushOutputBuffer(void)
}
}
-int outputBufferEmpty(void)
+int ob_is_empty(void)
{
- return cb.begin == cb.end;
+ return ob.begin == ob.end;
}
-void outputBufferShift(void)
+void ob_shift(void)
{
- assert(cb.begin != cb.end);
- assert(cb.begin < cb.size);
+ assert(ob.begin != ob.end);
+ assert(ob.begin < ob.size);
- cb.begin = successor(cb.begin);
+ ob.begin = successor(ob.begin);
}
-unsigned int outputBufferRelative(const unsigned i)
+unsigned int ob_relative(const unsigned i)
{
- if (i >= cb.begin)
- return i - cb.begin;
+ if (i >= ob.begin)
+ return i - ob.begin;
else
- return i + cb.size - cb.begin;
+ return i + ob.size - ob.begin;
}
-unsigned availableOutputBuffer(void)
+unsigned ob_available(void)
{
- return outputBufferRelative(cb.end);
+ return ob_relative(ob.end);
}
-int outputBufferAbsolute(const unsigned relative)
+int ob_absolute(const unsigned relative)
{
unsigned i, max;
- max = cb.end;
- if (max < cb.begin)
- max += cb.size;
- i = (unsigned)cb.begin + relative;
+ max = ob.end;
+ if (max < ob.begin)
+ max += ob.size;
+ i = (unsigned)ob.begin + relative;
if (i >= max)
return -1;
- if (i >= cb.size)
- i -= cb.size;
+ if (i >= ob.size)
+ i -= ob.size;
return (int)i;
}
-OutputBufferChunk * outputBufferGetChunk(const unsigned i)
+ob_chunk * ob_get_chunk(const unsigned i)
{
- assert(i < cb.size);
+ assert(i < ob.size);
- return &cb.chunks[i];
+ return &ob.chunks[i];
}
/**
@@ -154,14 +154,14 @@ static int tailChunk(InputStream * inStream,
int seekable, float data_time, mpd_uint16 bitRate)
{
unsigned int next;
- OutputBufferChunk *chunk;
+ ob_chunk *chunk;
- chunk = outputBufferGetChunk(cb.end);
+ chunk = ob_get_chunk(ob.end);
assert(chunk->chunkSize <= sizeof(chunk->data));
if (chunk->chunkSize == sizeof(chunk->data)) {
/* this chunk is full; allocate a new chunk */
- next = successor(cb.end);
- while (cb.begin == next) {
+ next = successor(ob.end);
+ while (ob.begin == next) {
/* all chunks are full of decoded data; wait
for the player to free one */
@@ -183,7 +183,7 @@ static int tailChunk(InputStream * inStream,
}
output_buffer_expand(next);
- chunk = outputBufferGetChunk(next);
+ chunk = ob_get_chunk(next);
assert(chunk->chunkSize == 0);
}
@@ -195,10 +195,10 @@ static int tailChunk(InputStream * inStream,
chunk->times = data_time;
}
- return cb.end;
+ return ob.end;
}
-int sendDataToOutputBuffer(InputStream * inStream,
+int ob_send(InputStream * inStream,
int seekable, void *dataIn,
size_t dataInLen, float data_time, mpd_uint16 bitRate,
ReplayGainInfo * replayGainInfo)
@@ -208,14 +208,14 @@ int sendDataToOutputBuffer(InputStream * inStream,
size_t datalen;
static char *convBuffer;
static size_t convBufferLen;
- OutputBufferChunk *chunk = NULL;
+ ob_chunk *chunk = NULL;
- if (cmpAudioFormat(&(cb.audioFormat), &(dc.audioFormat)) == 0) {
+ if (cmpAudioFormat(&(ob.audioFormat), &(dc.audioFormat)) == 0) {
data = dataIn;
datalen = dataInLen;
} else {
datalen = pcm_sizeOfConvBuffer(&(dc.audioFormat), dataInLen,
- &(cb.audioFormat));
+ &(ob.audioFormat));
if (datalen > convBufferLen) {
if (convBuffer != NULL)
free(convBuffer);
@@ -224,14 +224,14 @@ int sendDataToOutputBuffer(InputStream * inStream,
}
data = convBuffer;
datalen = pcm_convertAudioFormat(&(dc.audioFormat), dataIn,
- dataInLen, &(cb.audioFormat),
- data, &(cb.convState));
+ dataInLen, &(ob.audioFormat),
+ data, &(ob.convState));
}
if (replayGainInfo && (replayGainState != REPLAYGAIN_OFF))
- doReplayGain(replayGainInfo, data, datalen, &cb.audioFormat);
+ doReplayGain(replayGainInfo, data, datalen, &ob.audioFormat);
else if (normalizationEnabled)
- normalizeData(data, datalen, &cb.audioFormat);
+ normalizeData(data, datalen, &ob.audioFormat);
while (datalen) {
int chunk_index = tailChunk(inStream, seekable,
@@ -239,7 +239,7 @@ int sendDataToOutputBuffer(InputStream * inStream,
if (chunk_index < 0)
return chunk_index;
- chunk = outputBufferGetChunk(chunk_index);
+ chunk = ob_get_chunk(chunk_index);
dataToSend = sizeof(chunk->data) - chunk->chunkSize;
if (dataToSend > datalen)
@@ -252,14 +252,14 @@ int sendDataToOutputBuffer(InputStream * inStream,
}
if (chunk != NULL && chunk->chunkSize == sizeof(chunk->data))
- flushOutputBuffer();
+ ob_flush();
return 0;
}
-void output_buffer_skip(unsigned num)
+void ob_skip(unsigned num)
{
- int i = outputBufferAbsolute(num);
+ int i = ob_absolute(num);
if (i >= 0)
- cb.begin = i;
+ ob.begin = i;
}
diff --git a/src/outputBuffer.h b/src/outputBuffer.h
index b0287192e..6e9d7c49f 100644
--- a/src/outputBuffer.h
+++ b/src/outputBuffer.h
@@ -36,14 +36,14 @@ typedef struct _OutputBufferChunk {
mpd_uint16 bitRate;
float times;
char data[CHUNK_SIZE];
-} OutputBufferChunk;
+} ob_chunk;
/**
* A ring set of buffers where the decoder appends data after the end,
* and the player consumes data from the beginning.
*/
typedef struct _OutputBuffer {
- OutputBufferChunk *chunks;
+ ob_chunk *chunks;
unsigned int size;
@@ -57,45 +57,45 @@ typedef struct _OutputBuffer {
ConvState convState;
} OutputBuffer;
-void initOutputBuffer(unsigned int size);
+void ob_init(unsigned int size);
-void output_buffer_free(void);
+void ob_free(void);
-void clearOutputBuffer(void);
+void ob_clear(void);
-void flushOutputBuffer(void);
+void ob_flush(void);
/** is the buffer empty? */
-int outputBufferEmpty(void);
+int ob_is_empty(void);
-void outputBufferShift(void);
+void ob_shift(void);
/**
* what is the position of the specified chunk number, relative to
* the first chunk in use?
*/
-unsigned int outputBufferRelative(const unsigned i);
+unsigned int ob_relative(const unsigned i);
/** determine the number of decoded chunks */
-unsigned availableOutputBuffer(void);
+unsigned ob_available(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 unsigned relative);
+int ob_absolute(const unsigned relative);
-OutputBufferChunk * outputBufferGetChunk(const unsigned i);
+ob_chunk * ob_get_chunk(const unsigned i);
/* we send inStream for buffering the inputStream while waiting to
send the next chunk */
-int sendDataToOutputBuffer(InputStream * inStream,
+int ob_send(InputStream * inStream,
int seekable,
void *data,
size_t datalen,
float data_time,
mpd_uint16 bitRate, ReplayGainInfo * replayGainInfo);
-void output_buffer_skip(unsigned num);
+void ob_skip(unsigned num);
#endif
diff --git a/src/playerData.c b/src/playerData.c
index 5ac7c4785..56dee348c 100644
--- a/src/playerData.c
+++ b/src/playerData.c
@@ -29,7 +29,7 @@ unsigned int buffered_before_play;
static PlayerData playerData_pd;
PlayerControl pc;
DecoderControl dc;
-OutputBuffer cb; /* rename this to 'ob' */
+OutputBuffer ob;
void initPlayerData(void)
{
@@ -77,7 +77,7 @@ void initPlayerData(void)
playerData_pd.audioDeviceStates = xmalloc(device_array_size);
- initOutputBuffer(buffered_chunks);
+ ob_init(buffered_chunks);
notifyInit(&pc.notify);
pc.error = PLAYER_ERROR_NOERROR;
@@ -104,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();
+ ob_free();
free(playerData_pd.audioDeviceStates);
}
diff --git a/src/playerData.h b/src/playerData.h
index 80423717d..fccc758da 100644
--- a/src/playerData.h
+++ b/src/playerData.h
@@ -28,7 +28,7 @@
extern unsigned int buffered_before_play;
extern PlayerControl pc;
extern DecoderControl dc;
-extern OutputBuffer cb; /* rename this to 'ob' */
+extern OutputBuffer ob;
typedef struct _PlayerData {
mpd_uint8 *audioDeviceStates;