Mercurial > audlegacy-plugins
diff src/demac/plugin.c @ 2516:d3597870a64f
switch to AUDDBG
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Sun, 06 Apr 2008 17:30:22 +0400 |
parents | ed6c81bd9016 |
children | bd3a24b39058 |
line wrap: on
line diff
--- a/src/demac/plugin.c Thu Apr 03 14:48:48 2008 +0300 +++ b/src/demac/plugin.c Sun Apr 06 17:30:22 2008 +0400 @@ -67,7 +67,7 @@ static InputPlugin demac_ip; static GtkWidget *about_window = NULL; -#ifdef DEBUG +#ifdef AUD_DEBUG # include "crc.c" #endif @@ -118,14 +118,12 @@ APEDecoderContext *dec = NULL; int decoded_bytes; int pkt_size, bytes_used; -#ifdef DEBUG +#ifdef AUD_DEBUG uint32_t frame_crc; #endif if ((vfd = aud_vfs_fopen(pb->filename, "r")) == NULL) { -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: Error opening URI: %s\n", pb->filename); -#endif + AUDDBG("** demac: plugin.c: Error opening URI: %s\n", pb->filename); pb->error = TRUE; goto cleanup; } @@ -133,32 +131,24 @@ ctx = calloc(sizeof(APEContext), 1); if(ape_read_header(ctx, vfd, 0) < 0) { pb->error = TRUE; -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: Cannot parse APE header or unsupported format: %s\n", pb->filename); -#endif + AUDDBG("** demac: plugin.c: Cannot parse APE header or unsupported format: %s\n", pb->filename); goto cleanup; } dec = calloc(sizeof(APEDecoderContext), 1); if(ape_decode_init(dec, ctx) < 0) { pb->error = TRUE; -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: Error initializing decoder\n"); -#endif + AUDDBG("** demac: plugin.c: Error initializing decoder\n"); goto cleanup; } frame_buf = malloc(ctx->max_packet_size); -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: Duration: %u msec\n", ctx->duration); -#endif + AUDDBG("** demac: plugin.c: Duration: %u msec\n", ctx->duration); if(!pb->output->open_audio(FMT_S16_LE, ctx->samplerate, ctx->channels)) { pb->error = TRUE; -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: Cannot open audio.\n"); -#endif + AUDDBG("** demac: plugin.c: Cannot open audio.\n"); goto cleanup; } @@ -199,17 +189,12 @@ } ape_read_packet(ctx, vfd, frame_buf, &pkt_size); -#ifdef DEBUG +#ifdef AUD_DEBUG assert(pkt_size <= ctx->max_packet_size); frame_crc = ape_initcrc(); #endif bytes_used = 0; -/*#ifdef DEBUG - fprintf(stderr, "frame %d, %d samples, offset %d, size %d\n", ctx->currentframe-1, - *((uint32_t*)frame_buf), *((uint32_t*)(frame_buf+4)), pkt_size); -#endif*/ - /* Decode the frame a chunk at a time */ while (playing && (bytes_used != pkt_size) && (local_seek_to == -1)) { @@ -230,17 +215,17 @@ /* Write audio data */ pb->pass_audio(pb, FMT_S16_LE, ctx->channels, decoded_bytes, wav, &playing); -#if DEBUG +#ifdef AUD_DEBUG frame_crc = ape_updatecrc(wav, decoded_bytes, frame_crc); #endif } -#if DEBUG +#ifdef AUD_DEBUG frame_crc = ape_finishcrc(frame_crc); if (dec->CRC != frame_crc) { - fprintf(stderr, "** demac: plugin.c: CRC error in frame %d\n", ctx->currentframe-1); + AUDDBG("** demac: plugin.c: CRC error in frame %d\n", ctx->currentframe-1); } #endif } @@ -259,9 +244,7 @@ if(ctx) {ape_read_close(ctx); free(ctx);} if(vfd) aud_vfs_fclose(vfd); -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: decoding loop finished\n"); -#endif + AUDDBG("** demac: plugin.c: decoding loop finished\n"); return NULL; } @@ -276,15 +259,9 @@ g_mutex_lock(demac_mutex); pb->playing = 0; g_mutex_unlock(demac_mutex); -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: waiting for thread finished\n"); -#endif - //g_thread_join(pb->thread); - /* pb->thread is useless if input plugin initialized from **terrible** cue-sheet plugin */ + AUDDBG("** demac: plugin.c: waiting for thread finished\n"); g_thread_join(pb_thread); -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: thread finished\n"); -#endif + AUDDBG("** demac: plugin.c: thread finished\n"); } } @@ -297,9 +274,7 @@ } Tuple *demac_probe_for_tuple (gchar *uri, VFSFile *vfd) { -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: demac_probe_for_tuple()\n"); -#endif + AUDDBG("** demac: plugin.c: demac_probe_for_tuple()\n"); Tuple *tpl = aud_tuple_new_from_filename(uri); gchar codec_string[32]; @@ -325,9 +300,7 @@ ape_read_header(ctx, vfd, 1); aud_tuple_associate_int(tpl, FIELD_LENGTH, NULL, ctx->duration); g_sprintf(codec_string, "Monkey's Audio v%4.2f", (float)ctx->fileversion/1000.0); -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: Codec: %s\n", codec_string); -#endif + AUDDBG("** demac: plugin.c: Codec: %s\n", codec_string); aud_tuple_associate_string(tpl, FIELD_CODEC, NULL, codec_string); aud_tuple_associate_string(tpl, FIELD_QUALITY, NULL, "lossless"); aud_tuple_associate_string(tpl, FIELD_MIMETYPE, NULL, "audio/x-ape"); @@ -341,9 +314,7 @@ } Tuple *demac_get_tuple(char *filename) { -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: demac_get_tuple()\n"); -#endif + AUDDBG("** demac: plugin.c: demac_get_tuple()\n"); VFSFile *vfd; if ((vfd = aud_vfs_fopen(filename, "r")) == NULL) { @@ -359,9 +330,7 @@ g_mutex_lock(demac_mutex); seek_to_msec = millisecond; g_mutex_unlock(demac_mutex); -#ifdef DEBUG - fprintf(stderr, "** demac: plugin.c: seeking to %u msec\n", millisecond); -#endif + AUDDBG("** demac: plugin.c: seeking to %u msec\n", millisecond); } static void demac_seek (InputPlayback *pb, gint time) {