aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decoder/_flac_common.c83
-rw-r--r--src/decoder/_flac_common.h28
-rw-r--r--src/decoder/flac_plugin.c173
-rw-r--r--src/decoder/oggflac_plugin.c106
-rw-r--r--src/decoder_list.c8
5 files changed, 208 insertions, 190 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c
index e7aff545d..459c4606d 100644
--- a/src/decoder/_flac_common.c
+++ b/src/decoder/_flac_common.c
@@ -26,20 +26,22 @@
#include <FLAC/format.h>
#include <FLAC/metadata.h>
-void init_FlacData(FlacData * data, struct decoder * decoder,
- struct input_stream *inStream)
+void
+flac_data_init(struct flac_data *data, struct decoder * decoder,
+ struct input_stream *input_stream)
{
data->time = 0;
data->position = 0;
- data->bitRate = 0;
+ data->bit_rate = 0;
data->decoder = decoder;
- data->inStream = inStream;
- data->replayGainInfo = NULL;
+ data->input_stream = input_stream;
+ data->replay_gain_info = NULL;
data->tag = NULL;
}
-static int flacFindVorbisCommentFloat(const FLAC__StreamMetadata * block,
- const char *cmnt, float *fl)
+static int
+flac_find_float_comment(const FLAC__StreamMetadata *block,
+ const char *cmnt, float *fl)
{
int offset =
FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, cmnt);
@@ -65,28 +67,29 @@ static int flacFindVorbisCommentFloat(const FLAC__StreamMetadata * block,
}
/* replaygain stuff by AliasMrJones */
-static void flacParseReplayGain(const FLAC__StreamMetadata * block,
- FlacData * data)
+static void
+flac_parse_replay_gain(const FLAC__StreamMetadata *block,
+ struct flac_data *data)
{
int found = 0;
- if (data->replayGainInfo)
- replay_gain_info_free(data->replayGainInfo);
+ if (data->replay_gain_info)
+ replay_gain_info_free(data->replay_gain_info);
- data->replayGainInfo = replay_gain_info_new();
+ data->replay_gain_info = replay_gain_info_new();
- found |= flacFindVorbisCommentFloat(block, "replaygain_album_gain",
- &data->replayGainInfo->tuples[REPLAY_GAIN_ALBUM].gain);
- found |= flacFindVorbisCommentFloat(block, "replaygain_album_peak",
- &data->replayGainInfo->tuples[REPLAY_GAIN_ALBUM].peak);
- found |= flacFindVorbisCommentFloat(block, "replaygain_track_gain",
- &data->replayGainInfo->tuples[REPLAY_GAIN_TRACK].gain);
- found |= flacFindVorbisCommentFloat(block, "replaygain_track_peak",
- &data->replayGainInfo->tuples[REPLAY_GAIN_TRACK].peak);
+ found |= flac_find_float_comment(block, "replaygain_album_gain",
+ &data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain);
+ found |= flac_find_float_comment(block, "replaygain_album_peak",
+ &data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak);
+ found |= flac_find_float_comment(block, "replaygain_track_gain",
+ &data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain);
+ found |= flac_find_float_comment(block, "replaygain_track_peak",
+ &data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak);
if (!found) {
- replay_gain_info_free(data->replayGainInfo);
- data->replayGainInfo = NULL;
+ replay_gain_info_free(data->replay_gain_info);
+ data->replay_gain_info = NULL;
}
}
@@ -95,16 +98,17 @@ static void flacParseReplayGain(const FLAC__StreamMetadata * block,
static const char *VORBIS_COMMENT_TRACK_KEY = "tracknumber";
static const char *VORBIS_COMMENT_DISC_KEY = "discnumber";
-static unsigned int commentMatchesAddToTag(const
- FLAC__StreamMetadata_VorbisComment_Entry
- * entry, unsigned int itemType,
- struct tag ** tag)
+static unsigned int
+flac_copy_vorbis_comment(const
+ FLAC__StreamMetadata_VorbisComment_Entry * entry,
+ enum tag_type type,
+ struct tag ** tag)
{
const char *str;
size_t slen;
int vlen;
- switch (itemType) {
+ switch (type) {
case TAG_ITEM_TRACK:
str = VORBIS_COMMENT_TRACK_KEY;
break;
@@ -112,7 +116,7 @@ static unsigned int commentMatchesAddToTag(const
str = VORBIS_COMMENT_DISC_KEY;
break;
default:
- str = mpdTagItemKeys[itemType];
+ str = mpdTagItemKeys[type];
}
slen = strlen(str);
vlen = entry->length - slen - 1;
@@ -122,7 +126,7 @@ static unsigned int commentMatchesAddToTag(const
if (!*tag)
*tag = tag_new();
- tag_add_item_n(*tag, itemType,
+ tag_add_item_n(*tag, type,
(char *)(entry->entry + slen + 1), vlen);
return 1;
@@ -131,8 +135,9 @@ static unsigned int commentMatchesAddToTag(const
return 0;
}
-struct tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block,
- struct tag * tag)
+struct tag *
+flac_vorbis_comments_to_tag(const FLAC__StreamMetadata * block,
+ struct tag * tag)
{
unsigned int i, j;
FLAC__StreamMetadata_VorbisComment_Entry *comments;
@@ -141,7 +146,7 @@ struct tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block,
for (i = block->data.vorbis_comment.num_comments; i != 0; --i) {
for (j = TAG_NUM_OF_ITEM_TYPES; j--;) {
- if (commentMatchesAddToTag(comments, j, &tag))
+ if (flac_copy_vorbis_comment(comments, j, &tag))
break;
}
comments++;
@@ -151,7 +156,7 @@ struct tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block,
}
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
- FlacData * data)
+ struct flac_data *data)
{
const FLAC__StreamMetadata_StreamInfo *si = &(block->data.stream_info);
@@ -163,7 +168,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
data->total_time = ((float)si->total_samples) / (si->sample_rate);
break;
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- flacParseReplayGain(block, data);
+ flac_parse_replay_gain(block, data);
default:
break;
}
@@ -171,7 +176,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
void flac_error_common_cb(const char *plugin,
const FLAC__StreamDecoderErrorStatus status,
- G_GNUC_UNUSED FlacData * data)
+ struct flac_data *data)
{
if (decoder_get_command(data->decoder) == DECODE_COMMAND_STOP)
return;
@@ -272,7 +277,7 @@ static void flac_convert(unsigned char *dest,
}
FLAC__StreamDecoderWriteStatus
-flac_common_write(FlacData *data, const FLAC__Frame * frame,
+flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
const FLAC__int32 *const buf[])
{
unsigned int c_samp;
@@ -300,11 +305,11 @@ flac_common_write(FlacData *data, const FLAC__Frame * frame,
num_channels, bytes_per_sample, buf,
c_samp, c_samp + num_samples);
- cmd = decoder_data(data->decoder, data->inStream,
+ cmd = decoder_data(data->decoder, data->input_stream,
data->chunk,
num_samples * bytes_per_channel,
- data->time, data->bitRate,
- data->replayGainInfo);
+ data->time, data->bit_rate,
+ data->replay_gain_info);
switch (cmd) {
case DECODE_COMMAND_NONE:
case DECODE_COMMAND_START:
diff --git a/src/decoder/_flac_common.h b/src/decoder/_flac_common.h
index c2e1f4315..08b84c337 100644
--- a/src/decoder/_flac_common.h
+++ b/src/decoder/_flac_common.h
@@ -141,33 +141,37 @@ typedef size_t flac_read_status_size_t;
#define FLAC_CHUNK_SIZE 4080
-typedef struct {
+struct flac_data {
unsigned char chunk[FLAC_CHUNK_SIZE];
float time;
- unsigned int bitRate;
+ unsigned int bit_rate;
struct audio_format audio_format;
float total_time;
FLAC__uint64 position;
struct decoder *decoder;
- struct input_stream *inStream;
- struct replay_gain_info *replayGainInfo;
+ struct input_stream *input_stream;
+ struct replay_gain_info *replay_gain_info;
struct tag *tag;
-} FlacData;
+};
/* initializes a given FlacData struct */
-void init_FlacData(FlacData * data, struct decoder * decoder,
- struct input_stream *inStream);
+void
+flac_data_init(struct flac_data *data, struct decoder * decoder,
+ struct input_stream *input_stream);
+
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
- FlacData * data);
+ struct flac_data *data);
+
void flac_error_common_cb(const char *plugin,
FLAC__StreamDecoderErrorStatus status,
- FlacData * data);
+ struct flac_data *data);
-struct tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block,
- struct tag *tag);
+struct tag *
+flac_vorbis_comments_to_tag(const FLAC__StreamMetadata * block,
+ struct tag *tag);
FLAC__StreamDecoderWriteStatus
-flac_common_write(FlacData *data, const FLAC__Frame * frame,
+flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
const FLAC__int32 *const buf[]);
#endif /* _FLAC_COMMON_H */
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c
index 089d4185c..9ccb0f002 100644
--- a/src/decoder/flac_plugin.c
+++ b/src/decoder/flac_plugin.c
@@ -25,20 +25,21 @@
/* this code was based on flac123, from flac-tools */
-static flac_read_status flacRead(G_GNUC_UNUSED const flac_decoder * flacDec,
- FLAC__byte buf[],
- flac_read_status_size_t *bytes,
- void *fdata)
+static flac_read_status
+flac_read_cb(G_GNUC_UNUSED const flac_decoder *fd,
+ FLAC__byte buf[], flac_read_status_size_t *bytes,
+ void *fdata)
{
- FlacData *data = (FlacData *) fdata;
+ struct flac_data *data = fdata;
size_t r;
- r = decoder_read(data->decoder, data->inStream, (void *)buf, *bytes);
+ r = decoder_read(data->decoder, data->input_stream,
+ (void *)buf, *bytes);
*bytes = r;
if (r == 0) {
if (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE ||
- input_stream_eof(data->inStream))
+ input_stream_eof(data->input_stream))
return flac_read_status_eof;
else
return flac_read_status_abort;
@@ -47,56 +48,58 @@ static flac_read_status flacRead(G_GNUC_UNUSED const flac_decoder * flacDec,
return flac_read_status_continue;
}
-static flac_seek_status flacSeek(G_GNUC_UNUSED const flac_decoder * flacDec,
- FLAC__uint64 offset,
- void *fdata)
+static flac_seek_status
+flac_seek_cb(G_GNUC_UNUSED const flac_decoder *fd,
+ FLAC__uint64 offset, void *fdata)
{
- FlacData *data = (FlacData *) fdata;
+ struct flac_data *data = (struct flac_data *) fdata;
- if (!input_stream_seek(data->inStream, offset, SEEK_SET))
+ if (!input_stream_seek(data->input_stream, offset, SEEK_SET))
return flac_seek_status_error;
return flac_seek_status_ok;
}
-static flac_tell_status flacTell(G_GNUC_UNUSED const flac_decoder * flacDec,
- FLAC__uint64 * offset,
- void *fdata)
+static flac_tell_status
+flac_tell_cb(G_GNUC_UNUSED const flac_decoder *fd,
+ FLAC__uint64 * offset, void *fdata)
{
- FlacData *data = (FlacData *) fdata;
+ struct flac_data *data = (struct flac_data *) fdata;
- *offset = (long)(data->inStream->offset);
+ *offset = (long)(data->input_stream->offset);
return flac_tell_status_ok;
}
-static flac_length_status flacLength(G_GNUC_UNUSED const flac_decoder * flacDec,
- FLAC__uint64 * length,
- void *fdata)
+static flac_length_status
+flac_length_cb(G_GNUC_UNUSED const flac_decoder *fd,
+ FLAC__uint64 * length, void *fdata)
{
- FlacData *data = (FlacData *) fdata;
+ struct flac_data *data = (struct flac_data *) fdata;
- if (data->inStream->size < 0)
+ if (data->input_stream->size < 0)
return flac_length_status_unsupported;
- *length = (size_t) (data->inStream->size);
+ *length = (size_t) (data->input_stream->size);
return flac_length_status_ok;
}
-static FLAC__bool flacEOF(G_GNUC_UNUSED const flac_decoder * flacDec, void *fdata)
+static FLAC__bool
+flac_eof_cb(G_GNUC_UNUSED const flac_decoder *fd, void *fdata)
{
- FlacData *data = (FlacData *) fdata;
+ struct flac_data *data = (struct flac_data *) fdata;
return (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE &&
decoder_get_command(data->decoder) != DECODE_COMMAND_SEEK) ||
- input_stream_eof(data->inStream);
+ input_stream_eof(data->input_stream);
}
-static void flacError(G_GNUC_UNUSED const flac_decoder *dec,
- FLAC__StreamDecoderErrorStatus status, void *fdata)
+static void
+flac_error_cb(G_GNUC_UNUSED const flac_decoder *fd,
+ FLAC__StreamDecoderErrorStatus status, void *fdata)
{
- flac_error_common_cb("flac", status, (FlacData *) fdata);
+ flac_error_common_cb("flac", status, (struct flac_data *) fdata);
}
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
@@ -196,16 +199,15 @@ static void flacPrintErroredState(FLAC__StreamDecoderState state)
static void flacMetadata(G_GNUC_UNUSED const flac_decoder * dec,
const FLAC__StreamMetadata * block, void *vdata)
{
- flac_metadata_common_cb(block, (FlacData *) vdata);
+ flac_metadata_common_cb(block, (struct flac_data *) vdata);
}
-static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec,
- const FLAC__Frame * frame,
- const FLAC__int32 * const buf[],
- void *vdata)
+static FLAC__StreamDecoderWriteStatus
+flac_write_cb(const flac_decoder *dec, const FLAC__Frame *frame,
+ const FLAC__int32 *const buf[], void *vdata)
{
FLAC__uint32 samples = frame->header.blocksize;
- FlacData *data = (FlacData *) vdata;
+ struct flac_data *data = (struct flac_data *) vdata;
float timeChange;
FLAC__uint64 newPosition = 0;
@@ -216,7 +218,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec,
if (data->position && newPosition >= data->position) {
assert(timeChange >= 0);
- data->bitRate =
+ data->bit_rate =
((newPosition - data->position) * 8.0 / timeChange)
/ 1000 + 0.5;
}
@@ -226,13 +228,13 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec,
}
static struct tag *
-flacMetadataDup(const char *file, bool *vorbisCommentFound)
+flac_tag_load(const char *file, bool *vorbis_comment_found)
{
struct tag *ret = NULL;
FLAC__Metadata_SimpleIterator *it;
FLAC__StreamMetadata *block = NULL;
- *vorbisCommentFound = false;
+ *vorbis_comment_found = false;
it = FLAC__metadata_simple_iterator_new();
if (!FLAC__metadata_simple_iterator_init(it, file, 1, 0)) {
@@ -265,10 +267,10 @@ flacMetadataDup(const char *file, bool *vorbisCommentFound)
if (!block)
break;
if (block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
- ret = copyVorbisCommentBlockToMpdTag(block, ret);
+ ret = flac_vorbis_comments_to_tag(block, ret);
if (ret)
- *vorbisCommentFound = true;
+ *vorbis_comment_found = true;
} else if (block->type == FLAC__METADATA_TYPE_STREAMINFO) {
if (!ret)
ret = tag_new();
@@ -283,17 +285,18 @@ flacMetadataDup(const char *file, bool *vorbisCommentFound)
return ret;
}
-static struct tag *flacTagDup(const char *file)
+static struct tag *
+flac_tag_dup(const char *file)
{
struct tag *ret = NULL;
- bool foundVorbisComment = false;
+ bool vorbis_comment_found = false;
- ret = flacMetadataDup(file, &foundVorbisComment);
+ ret = flac_tag_load(file, &vorbis_comment_found);
if (!ret) {
g_debug("Failed to grab information from: %s\n", file);
return NULL;
}
- if (!foundVorbisComment) {
+ if (!vorbis_comment_found) {
struct tag *temp = tag_id3_load(file);
if (temp) {
temp->time = ret->time;
@@ -306,19 +309,20 @@ static struct tag *flacTagDup(const char *file)
}
static void
-flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
+flac_decode_internal(struct decoder * decoder,
+ struct input_stream *input_stream,
bool is_ogg)
{
- flac_decoder *flacDec;
- FlacData data;
+ flac_decoder *flac_dec;
+ struct flac_data data;
const char *err = NULL;
- if (!(flacDec = flac_new()))
+ if (!(flac_dec = flac_new()))
return;
- init_FlacData(&data, decoder, inStream);
+ flac_data_init(&data, decoder, input_stream);
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
- if(!FLAC__stream_decoder_set_metadata_respond(flacDec, FLAC__METADATA_TYPE_VORBIS_COMMENT))
+ if(!FLAC__stream_decoder_set_metadata_respond(flac_dec, FLAC__METADATA_TYPE_VORBIS_COMMENT))
{
g_debug("Failed to set metadata respond\n");
}
@@ -326,22 +330,26 @@ flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
if (is_ogg) {
- if (!flac_ogg_init(flacDec, flacRead, flacSeek, flacTell,
- flacLength, flacEOF, flacWrite, flacMetadata,
- flacError, (void *)&data)) {
+ if (!flac_ogg_init(flac_dec, flac_read_cb,
+ flac_seek_cb, flac_tell_cb,
+ flac_length_cb, flac_eof_cb,
+ flac_write_cb, flacMetadata,
+ flac_error_cb, (void *)&data)) {
err = "doing Ogg init()";
goto fail;
}
} else {
- if (!flac_init(flacDec, flacRead, flacSeek, flacTell,
- flacLength, flacEOF, flacWrite, flacMetadata,
- flacError, (void *)&data)) {
+ if (!flac_init(flac_dec, flac_read_cb,
+ flac_seek_cb, flac_tell_cb,
+ flac_length_cb, flac_eof_cb,
+ flac_write_cb, flacMetadata,
+ flac_error_cb, (void *)&data)) {
err = "doing init()";
goto fail;
}
}
- if (!flac_process_metadata(flacDec)) {
+ if (!flac_process_metadata(flac_dec)) {
err = "problem reading metadata";
goto fail;
}
@@ -355,44 +363,44 @@ flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
}
decoder_initialized(decoder, &data.audio_format,
- inStream->seekable, data.total_time);
+ input_stream->seekable, data.total_time);
while (true) {
- if (!flac_process_single(flacDec))
+ if (!flac_process_single(flac_dec))
break;
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
- FLAC__uint64 sampleToSeek = decoder_seek_where(decoder) *
+ FLAC__uint64 seek_sample = decoder_seek_where(decoder) *
data.audio_format.sample_rate + 0.5;
- if (flac_seek_absolute(flacDec, sampleToSeek)) {
- data.time = ((float)sampleToSeek) /
+ if (flac_seek_absolute(flac_dec, seek_sample)) {
+ data.time = ((float)seek_sample) /
data.audio_format.sample_rate;
data.position = 0;
decoder_command_finished(decoder);
} else
decoder_seek_error(decoder);
- } else if (flac_get_state(flacDec) == flac_decoder_eof)
+ } else if (flac_get_state(flac_dec) == flac_decoder_eof)
break;
}
if (decoder_get_command(decoder) != DECODE_COMMAND_STOP) {
- flacPrintErroredState(flac_get_state(flacDec));
- flac_finish(flacDec);
+ flacPrintErroredState(flac_get_state(flac_dec));
+ flac_finish(flac_dec);
}
fail:
- if (data.replayGainInfo)
- replay_gain_info_free(data.replayGainInfo);
+ if (data.replay_gain_info)
+ replay_gain_info_free(data.replay_gain_info);
- if (flacDec)
- flac_delete(flacDec);
+ if (flac_dec)
+ flac_delete(flac_dec);
if (err)
g_warning("%s\n", err);
}
static void
-flac_decode(struct decoder * decoder, struct input_stream *inStream)
+flac_decode(struct decoder * decoder, struct input_stream *input_stream)
{
- flac_decode_internal(decoder, inStream, false);
+ flac_decode_internal(decoder, input_stream, false);
}
#ifndef HAVE_OGGFLAC
@@ -410,7 +418,8 @@ oggflac_init(void)
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
-static struct tag *oggflac_tag_dup(const char *file)
+static struct tag *
+oggflac_tag_dup(const char *file)
{
struct tag *ret = NULL;
FLAC__Metadata_Iterator *it;
@@ -425,7 +434,7 @@ static struct tag *oggflac_tag_dup(const char *file)
if (!(block = FLAC__metadata_iterator_get_block(it)))
break;
if (block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
- ret = copyVorbisCommentBlockToMpdTag(block, ret);
+ ret = flac_vorbis_comments_to_tag(block, ret);
} else if (block->type == FLAC__METADATA_TYPE_STREAMINFO) {
if (!ret)
ret = tag_new();
@@ -441,16 +450,16 @@ out:
}
static void
-oggflac_decode(struct decoder *decoder, struct input_stream *inStream)
+oggflac_decode(struct decoder *decoder, struct input_stream *input_stream)
{
- if (ogg_stream_type_detect(inStream) != FLAC)
+ if (ogg_stream_type_detect(input_stream) != FLAC)
return;
/* rewind the stream, because ogg_stream_type_detect() has
moved it */
- input_stream_seek(inStream, 0, SEEK_SET);
+ input_stream_seek(input_stream, 0, SEEK_SET);
- flac_decode_internal(decoder, inStream, true);
+ flac_decode_internal(decoder, input_stream, true);
}
static const char *const oggflac_suffixes[] = { "ogg", "oga", NULL };
@@ -463,7 +472,7 @@ static const char *const oggflac_mime_types[] = {
#endif /* FLAC_API_VERSION_CURRENT >= 7 */
-const struct decoder_plugin oggflacPlugin = {
+const struct decoder_plugin oggflac_decoder_plugin = {
.name = "oggflac",
.init = oggflac_init,
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
@@ -476,15 +485,15 @@ const struct decoder_plugin oggflacPlugin = {
#endif /* HAVE_OGGFLAC */
-static const char *const flacSuffixes[] = { "flac", NULL };
+static const char *const flac_suffixes[] = { "flac", NULL };
static const char *const flac_mime_types[] = {
"audio/x-flac", "application/x-flac", NULL
};
-const struct decoder_plugin flacPlugin = {
+const struct decoder_plugin flac_decoder_plugin = {
.name = "flac",
.stream_decode = flac_decode,
- .tag_dup = flacTagDup,
- .suffixes = flacSuffixes,
+ .tag_dup = flac_tag_dup,
+ .suffixes = flac_suffixes,
.mime_types = flac_mime_types
};
diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c
index c5693c585..237f826d3 100644
--- a/src/decoder/oggflac_plugin.c
+++ b/src/decoder/oggflac_plugin.c
@@ -26,11 +26,11 @@
#include <OggFLAC/seekable_stream_decoder.h>
#include <unistd.h>
-static void oggflac_cleanup(FlacData * data,
+static void oggflac_cleanup(struct flac_data *data,
OggFLAC__SeekableStreamDecoder * decoder)
{
- if (data->replayGainInfo)
- replay_gain_info_free(data->replayGainInfo);
+ if (data->replay_gain_info)
+ replay_gain_info_free(data->replay_gain_info);
if (decoder)
OggFLAC__seekable_stream_decoder_delete(decoder);
}
@@ -42,13 +42,14 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(G_GNUC_UNUSED const
unsigned *bytes,
void *fdata)
{
- FlacData *data = (FlacData *) fdata;
+ struct flac_data *data = (struct flac_data *) fdata;
size_t r;
- r = decoder_read(data->decoder, data->inStream, (void *)buf, *bytes);
+ r = decoder_read(data->decoder, data->input_stream,
+ (void *)buf, *bytes);
*bytes = r;
- if (r == 0 && !input_stream_eof(data->inStream) &&
+ if (r == 0 && !input_stream_eof(data->input_stream) &&
decoder_get_command(data->decoder) == DECODE_COMMAND_NONE)
return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
@@ -61,9 +62,9 @@ static OggFLAC__SeekableStreamDecoderSeekStatus of_seek_cb(G_GNUC_UNUSED const
FLAC__uint64 offset,
void *fdata)
{
- FlacData *data = (FlacData *) fdata;
+ struct flac_data *data = (struct flac_data *) fdata;
- if (!input_stream_seek(data->inStream, offset, SEEK_SET))
+ if (!input_stream_seek(data->input_stream, offset, SEEK_SET))
return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
@@ -75,9 +76,9 @@ static OggFLAC__SeekableStreamDecoderTellStatus of_tell_cb(G_GNUC_UNUSED const
FLAC__uint64 *
offset, void *fdata)
{
- FlacData *data = (FlacData *) fdata;
+ struct flac_data *data = (struct flac_data *) fdata;
- *offset = (long)(data->inStream->offset);
+ *offset = (long)(data->input_stream->offset);
return OggFLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
}
@@ -89,12 +90,12 @@ static OggFLAC__SeekableStreamDecoderLengthStatus of_length_cb(G_GNUC_UNUSED con
length,
void *fdata)
{
- FlacData *data = (FlacData *) fdata;
+ struct flac_data *data = (struct flac_data *) fdata;
- if (data->inStream->size < 0)
+ if (data->input_stream->size < 0)
return OggFLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR;
- *length = (size_t) (data->inStream->size);
+ *length = (size_t) (data->input_stream->size);
return OggFLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
}
@@ -102,17 +103,17 @@ static OggFLAC__SeekableStreamDecoderLengthStatus of_length_cb(G_GNUC_UNUSED con
static FLAC__bool of_EOF_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDecoder * decoder,
void *fdata)
{
- FlacData *data = (FlacData *) fdata;
+ struct flac_data *data = (struct flac_data *) fdata;
return (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE &&
decoder_get_command(data->decoder) != DECODE_COMMAND_SEEK) ||
- input_stream_eof(data->inStream);
+ input_stream_eof(data->input_stream);
}
static void of_error_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDecoder * decoder,
FLAC__StreamDecoderErrorStatus status, void *fdata)
{
- flac_error_common_cb("oggflac", status, (FlacData *) fdata);
+ flac_error_common_cb("oggflac", status, (struct flac_data *) fdata);
}
static void oggflacPrintErroredState(OggFLAC__SeekableStreamDecoderState state)
@@ -146,19 +147,17 @@ static void oggflacPrintErroredState(OggFLAC__SeekableStreamDecoderState state)
}
}
-static FLAC__StreamDecoderWriteStatus oggflacWrite(G_GNUC_UNUSED const
- OggFLAC__SeekableStreamDecoder
- * decoder,
- const FLAC__Frame * frame,
- const FLAC__int32 *
- const buf[], void *vdata)
+static FLAC__StreamDecoderWriteStatus
+oggflac_write_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDecoder *decoder,
+ const FLAC__Frame *frame, const FLAC__int32 *const buf[],
+ void *vdata)
{
- FlacData *data = (FlacData *) vdata;
+ struct flac_data *data = (struct flac_data *) vdata;
FLAC__uint32 samples = frame->header.blocksize;
- float timeChange;
+ float time_change;
- timeChange = ((float)samples) / frame->header.sample_rate;
- data->time += timeChange;
+ time_change = ((float)samples) / frame->header.sample_rate;
+ data->time += time_change;
return flac_common_write(data, frame, buf);
}
@@ -167,7 +166,7 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(G_GNUC_UNUSED const
static void of_metadata_dup_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDecoder * decoder,
const FLAC__StreamMetadata * block, void *vdata)
{
- FlacData *data = (FlacData *) vdata;
+ struct flac_data *data = (struct flac_data *) vdata;
switch (block->type) {
case FLAC__METADATA_TYPE_STREAMINFO:
@@ -178,7 +177,7 @@ static void of_metadata_dup_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDecode
block->data.stream_info.sample_rate + 0.5;
return;
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- copyVorbisCommentBlockToMpdTag(block, data->tag);
+ flac_vorbis_comments_to_tag(block, data->tag);
default:
break;
}
@@ -189,12 +188,12 @@ static void of_metadata_decode_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDec
const FLAC__StreamMetadata * block,
void *vdata)
{
- flac_metadata_common_cb(block, (FlacData *) vdata);
+ flac_metadata_common_cb(block, (struct flac_data *) vdata);
}
-static OggFLAC__SeekableStreamDecoder
- * full_decoder_init_and_read_metadata(FlacData * data,
- unsigned int metadata_only)
+static OggFLAC__SeekableStreamDecoder *
+full_decoder_init_and_read_metadata(struct flac_data *data,
+ unsigned int metadata_only)
{
OggFLAC__SeekableStreamDecoder *decoder = NULL;
unsigned int s = 1;
@@ -223,7 +222,7 @@ static OggFLAC__SeekableStreamDecoder
s &= OggFLAC__seekable_stream_decoder_set_eof_callback(decoder,
of_EOF_cb);
s &= OggFLAC__seekable_stream_decoder_set_write_callback(decoder,
- oggflacWrite);
+ oggflac_write_cb);
s &= OggFLAC__seekable_stream_decoder_set_metadata_respond(decoder,
FLAC__METADATA_TYPE_VORBIS_COMMENT);
s &= OggFLAC__seekable_stream_decoder_set_error_callback(decoder,
@@ -256,41 +255,42 @@ fail:
}
/* public functions: */
-static struct tag *oggflac_TagDup(const char *file)
+static struct tag *
+oggflac_tag_dup(const char *file)
{
- struct input_stream inStream;
+ struct input_stream input_stream;
OggFLAC__SeekableStreamDecoder *decoder;
- FlacData data;
+ struct flac_data data;
- if (!input_stream_open(&inStream, file))
+ if (!input_stream_open(&input_stream, file))
return NULL;
- if (ogg_stream_type_detect(&inStream) != FLAC) {
- input_stream_close(&inStream);
+ if (ogg_stream_type_detect(&input_stream) != FLAC) {
+ input_stream_close(&input_stream);
return NULL;
}
- init_FlacData(&data, NULL, &inStream);
+ flac_data_init(&data, NULL, &input_stream);
/* errors here won't matter,
* data.tag will be set or unset, that's all we care about */
decoder = full_decoder_init_and_read_metadata(&data, 1);
oggflac_cleanup(&data, decoder);
- input_stream_close(&inStream);
+ input_stream_close(&input_stream);
return data.tag;
}
static void
-oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
+oggflac_decode(struct decoder * mpd_decoder, struct input_stream *input_stream)
{
OggFLAC__SeekableStreamDecoder *decoder = NULL;
- FlacData data;
+ struct flac_data data;
- if (ogg_stream_type_detect(inStream) != FLAC)
+ if (ogg_stream_type_detect(input_stream) != FLAC)
return;
- init_FlacData(&data, mpd_decoder, inStream);
+ flac_data_init(&data, mpd_decoder, input_stream);
if (!(decoder = full_decoder_init_and_read_metadata(&data, 0))) {
goto fail;
@@ -305,7 +305,7 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
}
decoder_initialized(mpd_decoder, &data.audio_format,
- inStream->seekable, data.total_time);
+ input_stream->seekable, data.total_time);
while (true) {
OggFLAC__seekable_stream_decoder_process_single(decoder);
@@ -314,11 +314,11 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *inStream)
break;
}
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK) {
- FLAC__uint64 sampleToSeek = decoder_seek_where(mpd_decoder) *
+ FLAC__uint64 seek_sample = decoder_seek_where(mpd_decoder) *
data.audio_format.sample_rate + 0.5;
if (OggFLAC__seekable_stream_decoder_seek_absolute
- (decoder, sampleToSeek)) {
- data.time = ((float)sampleToSeek) /
+ (decoder, seek_sample)) {
+ data.time = ((float)seek_sample) /
data.audio_format.sample_rate;
data.position = 0;
decoder_command_finished(mpd_decoder);
@@ -337,7 +337,7 @@ fail:
oggflac_cleanup(&data, decoder);
}
-static const char *const oggflac_Suffixes[] = { "ogg", "oga", NULL };
+static const char *const oggflac_suffixes[] = { "ogg", "oga", NULL };
static const char *const oggflac_mime_types[] = {
"audio/x-flac+ogg",
"application/ogg",
@@ -345,10 +345,10 @@ static const char *const oggflac_mime_types[] = {
NULL
};
-const struct decoder_plugin oggflacPlugin = {
+const struct decoder_plugin oggflac_decoder_plugin = {
.name = "oggflac",
.stream_decode = oggflac_decode,
- .tag_dup = oggflac_TagDup,
- .suffixes = oggflac_Suffixes,
+ .tag_dup = oggflac_tag_dup,
+ .suffixes = oggflac_suffixes,
.mime_types = oggflac_mime_types
};
diff --git a/src/decoder_list.c b/src/decoder_list.c
index 43f954b4c..c6f8555d4 100644
--- a/src/decoder_list.c
+++ b/src/decoder_list.c
@@ -25,8 +25,8 @@
extern const struct decoder_plugin mp3Plugin;
extern const struct decoder_plugin vorbis_decoder_plugin;
-extern const struct decoder_plugin flacPlugin;
-extern const struct decoder_plugin oggflacPlugin;
+extern const struct decoder_plugin flac_decoder_plugin;
+extern const struct decoder_plugin oggflac_decoder_plugin;
extern const struct decoder_plugin audiofilePlugin;
extern const struct decoder_plugin mp4_plugin;
extern const struct decoder_plugin aacPlugin;
@@ -44,10 +44,10 @@ static const struct decoder_plugin *const decoder_plugins[] = {
&vorbis_decoder_plugin,
#endif
#if defined(HAVE_FLAC) || defined(HAVE_OGGFLAC)
- &oggflacPlugin,
+ &oggflac_decoder_plugin,
#endif
#ifdef HAVE_FLAC
- &flacPlugin,
+ &flac_decoder_plugin,
#endif
#ifdef HAVE_AUDIOFILE
&audiofilePlugin,