music_pipe: no CamelCase

Rename all variables and struct members.
This commit is contained in:
Max Kellermann 2008-11-02 16:57:16 +01:00
parent 8490c1b4cf
commit 5347cca29d
4 changed files with 29 additions and 29 deletions

View File

@ -58,9 +58,9 @@ void cross_fade_apply(struct music_chunk *a, const struct music_chunk *b,
assert(current_chunk <= num_chunks); assert(current_chunk <= num_chunks);
size = b->chunkSize > a->chunkSize size = b->length > a->length
? a->chunkSize ? a->length
: b->chunkSize; : b->length;
pcm_mix(a->data, pcm_mix(a->data,
b->data, b->data,
@ -68,14 +68,14 @@ void cross_fade_apply(struct music_chunk *a, const struct music_chunk *b,
format, format,
((float)current_chunk) / num_chunks); ((float)current_chunk) / num_chunks);
if (b->chunkSize > a->chunkSize) { if (b->length > a->length) {
/* the second buffer is larger than the first one: /* the second buffer is larger than the first one:
there is unmixed rest at the end. Copy it over. there is unmixed rest at the end. Copy it over.
The output buffer API guarantees that there is The output buffer API guarantees that there is
enough room in a->data. */ enough room in a->data. */
memcpy(a->data + a->chunkSize, memcpy(a->data + a->length,
b->data + a->chunkSize, b->data + a->length,
b->chunkSize - a->chunkSize); b->length - a->length);
a->chunkSize = b->chunkSize; a->length = b->length;
} }
} }

View File

@ -37,7 +37,7 @@ music_pipe_init(unsigned int size, struct notify *notify)
music_pipe.end = 0; music_pipe.end = 0;
music_pipe.lazy = false; music_pipe.lazy = false;
music_pipe.notify = notify; music_pipe.notify = notify;
music_pipe.chunks[0].chunkSize = 0; music_pipe.chunks[0].length = 0;
} }
void music_pipe_free(void) void music_pipe_free(void)
@ -49,7 +49,7 @@ void music_pipe_free(void)
void music_pipe_clear(void) void music_pipe_clear(void)
{ {
music_pipe.end = music_pipe.begin; music_pipe.end = music_pipe.begin;
music_pipe.chunks[music_pipe.end].chunkSize = 0; music_pipe.chunks[music_pipe.end].length = 0;
} }
/** return the index of the chunk after i */ /** return the index of the chunk after i */
@ -73,7 +73,7 @@ static void output_buffer_expand(unsigned i)
assert(i != music_pipe.end); assert(i != music_pipe.end);
music_pipe.end = i; music_pipe.end = i;
music_pipe.chunks[i].chunkSize = 0; music_pipe.chunks[i].length = 0;
if (was_empty) if (was_empty)
/* if the buffer was empty, the player thread might be /* if the buffer was empty, the player thread might be
waiting for us; wake it up now that another decoded waiting for us; wake it up now that another decoded
@ -85,7 +85,7 @@ void music_pipe_flush(void)
{ {
struct music_chunk *chunk = music_pipe_get_chunk(music_pipe.end); struct music_chunk *chunk = music_pipe_get_chunk(music_pipe.end);
if (chunk->chunkSize > 0) { if (chunk->length > 0) {
unsigned int next = successor(music_pipe.end); unsigned int next = successor(music_pipe.end);
if (next == music_pipe.begin) if (next == music_pipe.begin)
/* all buffers are full; we have to wait for /* all buffers are full; we have to wait for
@ -161,8 +161,8 @@ tail_chunk(size_t frame_size)
struct music_chunk *chunk; struct music_chunk *chunk;
chunk = music_pipe_get_chunk(music_pipe.end); chunk = music_pipe_get_chunk(music_pipe.end);
assert(chunk->chunkSize <= sizeof(chunk->data)); assert(chunk->length <= sizeof(chunk->data));
if (chunk->chunkSize + frame_size > sizeof(chunk->data)) { if (chunk->length + frame_size > sizeof(chunk->data)) {
/* this chunk is full; allocate a new chunk */ /* this chunk is full; allocate a new chunk */
next = successor(music_pipe.end); next = successor(music_pipe.end);
if (music_pipe.begin == next) if (music_pipe.begin == next)
@ -171,7 +171,7 @@ tail_chunk(size_t frame_size)
output_buffer_expand(next); output_buffer_expand(next);
chunk = music_pipe_get_chunk(next); chunk = music_pipe_get_chunk(next);
assert(chunk->chunkSize == 0); assert(chunk->length == 0);
} }
return chunk; return chunk;
@ -181,7 +181,7 @@ static size_t
music_chunk_append(struct music_chunk *chunk, const void *data, size_t length, music_chunk_append(struct music_chunk *chunk, const void *data, size_t length,
size_t frame_size) size_t frame_size)
{ {
size_t rest = sizeof(chunk->data) - chunk->chunkSize; size_t rest = sizeof(chunk->data) - chunk->length;
assert(rest >= frame_size); assert(rest >= frame_size);
@ -192,15 +192,15 @@ music_chunk_append(struct music_chunk *chunk, const void *data, size_t length,
length /= frame_size; length /= frame_size;
length *= frame_size; length *= frame_size;
memcpy(chunk->data + chunk->chunkSize, data, length); memcpy(chunk->data + chunk->length, data, length);
chunk->chunkSize += length; chunk->length += length;
return length; return length;
} }
size_t music_pipe_append(const void *data0, size_t datalen, size_t music_pipe_append(const void *data0, size_t datalen,
const struct audio_format *audio_format, const struct audio_format *audio_format,
float data_time, uint16_t bitRate) float data_time, uint16_t bit_rate)
{ {
const unsigned char *data = data0; const unsigned char *data = data0;
const size_t frame_size = audio_format_frame_size(audio_format); const size_t frame_size = audio_format_frame_size(audio_format);
@ -215,11 +215,11 @@ size_t music_pipe_append(const void *data0, size_t datalen,
if (chunk == NULL) if (chunk == NULL)
return ret; return ret;
if (chunk->chunkSize == 0) { if (chunk->length == 0) {
/* if the chunk is empty, nobody has set bitRate and /* if the chunk is empty, nobody has set bitRate and
times yet */ times yet */
chunk->bitRate = bitRate; chunk->bit_rate = bit_rate;
chunk->times = data_time; chunk->times = data_time;
} }
@ -232,7 +232,7 @@ size_t music_pipe_append(const void *data0, size_t datalen,
ret += nbytes; ret += nbytes;
} }
if (chunk != NULL && chunk->chunkSize == sizeof(chunk->data)) if (chunk != NULL && chunk->length == sizeof(chunk->data))
music_pipe_flush(); music_pipe_flush();
return ret; return ret;

View File

@ -29,8 +29,8 @@
struct audio_format; struct audio_format;
struct music_chunk { struct music_chunk {
uint16_t chunkSize; uint16_t length;
uint16_t bitRate; uint16_t bit_rate;
float times; float times;
char data[CHUNK_SIZE]; char data[CHUNK_SIZE];
}; };
@ -136,7 +136,7 @@ music_pipe_peek(void)
*/ */
size_t music_pipe_append(const void *data, size_t datalen, size_t music_pipe_append(const void *data, size_t datalen,
const struct audio_format *audio_format, const struct audio_format *audio_format,
float data_time, uint16_t bitRate); float data_time, uint16_t bit_rate);
void music_pipe_skip(unsigned num); void music_pipe_skip(unsigned num);

View File

@ -211,15 +211,15 @@ playChunk(struct music_chunk *chunk, const struct audio_format *format,
double sizeToTime) double sizeToTime)
{ {
pc.elapsedTime = chunk->times; pc.elapsedTime = chunk->times;
pc.bitRate = chunk->bitRate; pc.bitRate = chunk->bit_rate;
pcm_volume(chunk->data, chunk->chunkSize, pcm_volume(chunk->data, chunk->length,
format, pc.softwareVolume); format, pc.softwareVolume);
if (!playAudio(chunk->data, chunk->chunkSize)) if (!playAudio(chunk->data, chunk->length))
return -1; return -1;
pc.totalPlayTime += sizeToTime * chunk->chunkSize; pc.totalPlayTime += sizeToTime * chunk->length;
return 0; return 0;
} }