From 5f9207bdfc3cc667a49bc14f38daa4a1f90096da Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sun, 8 Jun 2014 21:51:48 +0200 Subject: flac: osx compile fixes --- plugins/flac/flac.c | 106 +++++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 50 deletions(-) (limited to 'plugins') diff --git a/plugins/flac/flac.c b/plugins/flac/flac.c index 016a3c6a..50e82739 100644 --- a/plugins/flac/flac.c +++ b/plugins/flac/flac.c @@ -30,6 +30,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include +#endif #include #include #include @@ -37,16 +40,19 @@ #include #include #include +#if HAVE_SYS_SYSLIMITS_H +#include +#endif #include "../../deadbeef.h" #include "../artwork/artwork.h" #include "../liboggedit/oggedit.h" -static DB_decoder_t plugin; -static DB_functions_t *deadbeef; + static DB_decoder_t plugin; + static DB_functions_t *deadbeef; -static DB_artwork_plugin_t *coverart_plugin = NULL; + static DB_artwork_plugin_t *coverart_plugin = NULL; -//#define trace(...) { fprintf(stderr, __VA_ARGS__); } + //#define trace(...) { fprintf(stderr, __VA_ARGS__); } #define trace(fmt,...) #define min(x,y) ((x)<(y)?(x):(y)) @@ -54,55 +60,55 @@ static DB_artwork_plugin_t *coverart_plugin = NULL; #define BUFFERSIZE 100000 -typedef struct { - DB_fileinfo_t info; - FLAC__StreamDecoder *decoder; - char *buffer; // this buffer always has float samples - int remaining; // bytes remaining in buffer from last read - int64_t startsample; - int64_t endsample; - int64_t currentsample; - int64_t totalsamples; - int flac_critical_error; - int init_stop_decoding; - int tagsize; - DB_FILE *file; - - // used only on insert - ddb_playlist_t *plt; - DB_playItem_t *after; - DB_playItem_t *last; - DB_playItem_t *it; - const char *fname; - int bitrate; - FLAC__StreamMetadata *flac_cue_sheet; -} flac_info_t; - -// callbacks -FLAC__StreamDecoderReadStatus flac_read_cb (const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) { - flac_info_t *info = (flac_info_t *)client_data; - size_t r = deadbeef->fread (buffer, 1, *bytes, info->file); - *bytes = r; - if (r == 0) { - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + typedef struct { + DB_fileinfo_t info; + FLAC__StreamDecoder *decoder; + char *buffer; // this buffer always has float samples + int remaining; // bytes remaining in buffer from last read + int64_t startsample; + int64_t endsample; + int64_t currentsample; + int64_t totalsamples; + int flac_critical_error; + int init_stop_decoding; + int tagsize; + DB_FILE *file; + + // used only on insert + ddb_playlist_t *plt; + DB_playItem_t *after; + DB_playItem_t *last; + DB_playItem_t *it; + const char *fname; + int bitrate; + FLAC__StreamMetadata *flac_cue_sheet; + } flac_info_t; + + // callbacks + FLAC__StreamDecoderReadStatus flac_read_cb (const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) { + flac_info_t *info = (flac_info_t *)client_data; + size_t r = deadbeef->fread (buffer, 1, *bytes, info->file); + *bytes = r; + if (r == 0) { + return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + } + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; } - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} FLAC__StreamDecoderSeekStatus flac_seek_cb (const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) { flac_info_t *info = (flac_info_t *)client_data; int r = deadbeef->fseek (info->file, absolute_byte_offset, SEEK_SET); if (r) { - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; } - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; + return FLAC__STREAM_DECODER_SEEK_STATUS_OK; } FLAC__StreamDecoderTellStatus flac_tell_cb (const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) { flac_info_t *info = (flac_info_t *)client_data; size_t r = deadbeef->ftell (info->file); *absolute_byte_offset = r; - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; + return FLAC__STREAM_DECODER_TELL_STATUS_OK; } FLAC__StreamDecoderLengthStatus flac_lenght_cb (const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) { @@ -111,7 +117,7 @@ FLAC__StreamDecoderLengthStatus flac_lenght_cb (const FLAC__StreamDecoder *decod deadbeef->fseek (info->file, 0, SEEK_END); *stream_length = deadbeef->ftell (info->file); deadbeef->fseek (info->file, pos, SEEK_SET); - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; + return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; } FLAC__bool flac_eof_cb (const FLAC__StreamDecoder *decoder, void *client_data) { @@ -546,7 +552,7 @@ static const char *metainfo[] = { }; static void -cflac_add_metadata (DB_playItem_t *it, char *s, int length) { +cflac_add_metadata (DB_playItem_t *it, const char *s, int length) { int m; for (m = 0; metainfo[m]; m += 2) { int l = strlen (metainfo[m]); @@ -612,7 +618,7 @@ cflac_init_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__Str for (int i = 0; i < vc->num_comments; i++) { const FLAC__StreamMetadata_VorbisComment_Entry *c = &vc->comments[i]; if (c->length > 0) { - char *s = c->entry; + const char *s = (const char *)c->entry; cflac_add_metadata (it, s, c->length); } } @@ -826,7 +832,7 @@ cflac_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) { else { const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet"); if (cuesheet) { - DB_playItem_t *last = deadbeef->plt_insert_cue_from_buffer (plt, after, it, cuesheet, strlen (cuesheet), info.totalsamples, info.info.fmt.samplerate); + DB_playItem_t *last = deadbeef->plt_insert_cue_from_buffer (plt, after, it, (const uint8_t *)cuesheet, strlen (cuesheet), info.totalsamples, info.info.fmt.samplerate); if (last) { cflac_free_temp (_info); deadbeef->pl_item_unref (it); @@ -896,7 +902,7 @@ cflac_read_metadata (DB_playItem_t *it) { for (int i = 0; i < vc->num_comments; i++) { const FLAC__StreamMetadata_VorbisComment_Entry *c = &vc->comments[i]; if (c->length > 0) { - char *s = c->entry; + const char *s = (const char *)c->entry; cflac_add_metadata (it, s, c->length); } } @@ -938,7 +944,7 @@ cflac_write_metadata_ogg (DB_playItem_t *it, FLAC__StreamMetadata_VorbisComment size_t num_tags = vc->num_comments; char **tags = calloc(num_tags+1, sizeof(char **)); for (size_t i = 0; i < num_tags; i++) - tags[i] = vc->comments[i].entry; + tags[i] = (char *)vc->comments[i].entry; const off_t file_size = oggedit_write_flac_metadata (deadbeef->fopen(fname), fname, 0, num_tags, tags); if (file_size <= 0) { trace ("cflac_write_metadata_ogg: oggedit_write_flac_metadata failed: code %d\n", file_size); @@ -999,10 +1005,10 @@ cflac_write_metadata (DB_playItem_t *it) { for (int i = 0; i < vc_comments; i++) { const FLAC__StreamMetadata_VorbisComment_Entry *c = &vc->comments[i]; if (c->length > 0) { - if (strncasecmp (c->entry, "replaygain_album_gain=", 22) - && strncasecmp (c->entry, "replaygain_album_peak=", 22) - && strncasecmp (c->entry, "replaygain_track_gain=", 22) - && strncasecmp (c->entry, "replaygain_track_peak=", 22)) { + if (strncasecmp ((const char *)c->entry, "replaygain_album_gain=", 22) + && strncasecmp ((const char *)c->entry, "replaygain_album_peak=", 22) + && strncasecmp ((const char *)c->entry, "replaygain_track_gain=", 22) + && strncasecmp ((const char *)c->entry, "replaygain_track_peak=", 22)) { FLAC__metadata_object_vorbiscomment_delete_comment (data, i); vc_comments--; i--; -- cgit v1.2.3