# HG changeset patch # User Yoshiki Yazawa # Date 1196951124 -32400 # Node ID 9a869d4bb0d3be30be09250448260022933a1e19 # Parent 137187e7a379daa904326c9dc03a71ee865afcb3 make use of AUDDBG() for debug print out. diff -r 137187e7a379 -r 9a869d4bb0d3 src/madplug/configure.c --- a/src/madplug/configure.c Thu Dec 06 22:52:00 2007 +0900 +++ b/src/madplug/configure.c Thu Dec 06 23:25:24 2007 +0900 @@ -37,9 +37,8 @@ { ConfigDb *db; const gchar *text = NULL; -#ifdef DEBUG - g_message("saving"); -#endif + + AUDDBG("saving"); audmad_config.fast_play_time_calc = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fast_playback)); diff -r 137187e7a379 -r 9a869d4bb0d3 src/madplug/decoder.c --- a/src/madplug/decoder.c Thu Dec 06 22:52:00 2007 +0900 +++ b/src/madplug/decoder.c Thu Dec 06 23:25:24 2007 +0900 @@ -196,10 +196,8 @@ info->fileinfo_request = FALSE; } -#ifdef DEBUG - g_message("f: scan_file"); - g_message("scan_file frames = %d", info->frames); -#endif /* DEBUG */ + AUDDBG("f: scan_file"); + AUDDBG("scan_file frames = %d", info->frames); while (1) { remainder = stream.bufend - stream.next_frame; @@ -216,9 +214,7 @@ BUFFER_SIZE - remainder); if (len <= 0) { -#ifdef DEBUG - g_message("scan_file: len <= 0 len = %d", len); -#endif + AUDDBG("scan_file: len <= 0 len = %d", len); break; } @@ -230,12 +226,10 @@ break; } if (!MAD_RECOVERABLE(stream.error)) { -#ifdef DEBUG - g_message("(fatal) error decoding header %d: %s", + AUDDBG("(fatal) error decoding header %d: %s", info->frames, mad_stream_errorstr(&stream)); - g_message("remainder = %d", remainder); - g_message("len = %d", len); -#endif /* DEBUG */ + AUDDBG("remainder = %d", remainder); + AUDDBG("len = %d", len); break; } if (stream.error == MAD_ERROR_LOSTSYNC) { @@ -244,31 +238,27 @@ stream.bufend - stream.this_frame); if (tagsize > 0) { -#ifdef DEBUG - g_message("skipping id3_tag: %d", tagsize); -#endif /* DEBUG */ + AUDDBG("skipping id3_tag: %d", tagsize); mad_stream_skip(&stream, tagsize); continue; } } -#ifdef DEBUG - g_message("(recovered) error decoding header %d: %s", + + AUDDBG("(recovered) error decoding header %d: %s", info->frames, mad_stream_errorstr(&stream)); - g_message("remainder = %d", remainder); - g_message("len = %d", len); -#endif /* DEBUG */ + AUDDBG("remainder = %d", remainder); + AUDDBG("len = %d", len); + continue; } info->frames++; -#ifdef DEBUG #ifdef DEBUG_INTENSIVELY - g_message("header bitrate = %ld", header.bitrate); - g_message("duration = %ul", + AUDDBG("header bitrate = %ld", header.bitrate); + AUDDBG("duration = %ul", mad_timer_count(header.duration, MAD_UNITS_MILLISECONDS)); - g_message("size = %d", stream.next_frame - stream.this_frame); -#endif + AUDDBG("size = %d", stream.next_frame - stream.this_frame); #endif if(aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1) mad_timer_add(&info->duration, header.duration); @@ -290,40 +280,34 @@ if (audmad_config.use_xing) { frame.header = header; if (mad_frame_decode(&frame, &stream) == -1) { -#ifdef DEBUG - g_message("xing frame decode failed"); -#endif + AUDDBG("xing frame decode failed"); goto no_xing; } if (xing_parse(&info->xing, stream.anc_ptr, stream.anc_bitlen) == 0) { -#ifdef DEBUG - g_message("xing header found "); -#endif /* DEBUG */ + AUDDBG("xing header found "); has_xing = TRUE; info->vbr = TRUE; /* otherwise xing header would have been 'Info' */ -#ifdef DEBUG - g_message("xing: bytes = %ld frames = %ld", info->xing.bytes, info->xing.frames); -#endif + AUDDBG("xing: bytes = %ld frames = %ld", info->xing.bytes, info->xing.frames); + /* we have enough info to calculate bitrate and duration */ if(info->xing.bytes && info->xing.frames) { xing_bitrate = 8 * (double)info->xing.bytes * 38 / (double)info->xing.frames; //38fps in MPEG1. -#ifdef DEBUG +#ifdef AUD_DEBUG { gint tmp = (gint)(info->xing.bytes * 8 / xing_bitrate); - g_message("xing: bitrate = %4.1f kbps", xing_bitrate / 1000); - g_message("xing: duration = %d:%02d", tmp / 60, tmp % 60); + AUDDBG("xing: bitrate = %4.1f kbps", xing_bitrate / 1000); + AUDDBG("xing: duration = %d:%02d", tmp / 60, tmp % 60); } #endif } continue; } -#ifdef DEBUG +#ifdef AUD_DEBUG else { - g_message("no usable xing header"); + AUDDBG("no usable xing header"); continue; } - #endif } /* xing */ @@ -347,16 +331,16 @@ no_xing: if (fast && info->frames >= N_AVERAGE_FRAMES) { float frame_size = ((double) data_used) / N_AVERAGE_FRAMES; -#ifdef DEBUG - g_message("bitrate = %ld samplerate = %d", header.bitrate, header.samplerate); - g_message("data_used = %d info->frames = %d info->size = %d tagsize = %d frame_size = %lf", + + AUDDBG("bitrate = %ld samplerate = %d", header.bitrate, header.samplerate); + AUDDBG("data_used = %d info->frames = %d info->size = %d tagsize = %d frame_size = %lf", data_used, info->frames, info->size, tagsize, frame_size); -#endif + if(info->size != 0) info->frames = (info->size - tagsize) / frame_size; -#ifdef DEBUG - g_message("info->frames = %d", info->frames); -#endif + + AUDDBG("info->frames = %d", info->frames); + if(aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1) { if(xing_bitrate > 0.0) { /* calc duration with xing info */ @@ -376,15 +360,15 @@ info->duration.seconds = length / 1000; info->duration.fraction = length % 1000; } -#ifdef DEBUG - g_message("using fast playtime calculation"); - g_message("data used = %d [tagsize=%d framesize=%f]", +#ifdef AUD_DEBUG + AUDDBG("using fast playtime calculation"); + AUDDBG("data used = %d [tagsize=%d framesize=%f]", data_used, tagsize, frame_size); - g_message("frames = %d, frequency = %d, channels = %d", + AUDDBG("frames = %d, frequency = %d, channels = %d", info->frames, info->freq, info->channels); long millis = mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS); - g_message("duration = %ld:%02ld", millis / 1000 / 60, (millis / 1000) % 60); + AUDDBG("duration = %ld:%02ld", millis / 1000 / 60, (millis / 1000) % 60); #endif /* DEBUG */ break; } @@ -408,10 +392,9 @@ mad_stream_finish(&stream); xing_finish(&info->xing); -#ifdef DEBUG - g_message("scan_file: info->frames = %d", info->frames); - g_message("e: scan_file"); -#endif /* DEBUG */ + AUDDBG("scan_file: info->frames = %d", info->frames); + AUDDBG("e: scan_file"); + return (info->frames != 0 || info->remote == TRUE); } @@ -445,9 +428,7 @@ /* track info is passed in as thread argument */ struct mad_info_t *info = (struct mad_info_t *) arg; -#ifdef DEBUG - g_message("f: decode"); -#endif /* DEBUG */ + AUDDBG("f: decode"); /* init mad stuff */ mad_frame_init(&frame); @@ -456,15 +437,11 @@ mad_synth_init(&synth); if(!info->playback){ -#ifdef DEBUG - g_message("decode: playback == NULL"); -#endif + AUDDBG("decode: playback == NULL"); return NULL; } -#ifdef DEBUG - g_message("decode: fmt = %d freq = %d channels = %d", info->fmt, info->freq, info->channels); -#endif + AUDDBG("decode: fmt = %d freq = %d channels = %d", info->fmt, info->freq, info->channels); if(check_audio_param(info) == FALSE) return NULL; @@ -489,16 +466,13 @@ info->playback->set_params(info->playback, info->title, (tlen == 0 || info->size <= 0) ? -1 : tlen, info->bitrate, info->freq, info->channels); -#ifdef DEBUG - g_message("decode: tlen = %d", tlen); -#endif + + AUDDBG("decode: tlen = %d", tlen); /* main loop */ do { if (!info->playback->playing) { -#ifdef DEBUG - g_message("decode: stop signaled"); -#endif /* DEBUG */ + AUDDBG("decode: stop signaled"); break; } if (seek_skip) @@ -513,9 +487,7 @@ input_process_remote_metadata(info); if (len <= 0) { -#ifdef DEBUG - g_message("finished decoding"); -#endif /* DEBUG */ + AUDDBG("finished decoding"); break; } len += remainder; @@ -529,9 +501,9 @@ mad_stream_buffer(&stream, buffer, len); if (seek_skip) { -#ifdef DEBUG - g_message("skipping: %d", seek_skip); -#endif + + AUDDBG("skipping: %d", seek_skip); + int skip = 2; do { if (mad_frame_decode(&frame, &stream) == 0) { @@ -553,9 +525,9 @@ while (info->playback->playing) { if (info->seek != -1 && info->size > 0) { -#ifdef DEBUG - g_message("seeking: %ld", info->seek); -#endif + + AUDDBG("seeking: %ld", info->seek); + int new_position; gulong milliseconds = mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS); @@ -568,9 +540,9 @@ if(new_position < 0) new_position = 0; -#ifdef DEBUG - g_message("seeking to: %d bytes", new_position); -#endif + + AUDDBG("seeking to: %d bytes", new_position); + if (aud_vfs_fseek(info->infile, new_position, SEEK_SET) == -1) audmad_error("failed to seek to: %d", new_position); mad_frame_mute(&frame); @@ -597,21 +569,20 @@ continue; } } -#ifdef DEBUG - g_message("(recovered) error decoding header %d: %s", + + AUDDBG("(recovered) error decoding header %d: %s", info->current_frame, mad_stream_errorstr(&stream)); -#endif /* DEBUG */ + continue; } info->bitrate = frame.header.bitrate; if (!audmad_config.show_avg_vbr_bitrate && info->vbr && (iteration % 40 == 0)) { -#ifdef DEBUG + #ifdef DEBUG_INTENSIVELY - g_message("decode vbr tlen = %d", tlen); -#endif + AUDDBG("decode vbr tlen = %d", tlen); #endif info->playback->set_params(info->playback, info->title, (tlen == 0 || info->size <= 0) ? -1 : tlen, @@ -622,11 +593,11 @@ if (mad_frame_decode(&frame, &stream) == -1) { if (!MAD_RECOVERABLE(stream.error)) break; -#ifdef DEBUG - g_message("(recovered) error decoding frame %d: %s", + + AUDDBG("(recovered) error decoding frame %d: %s", info->current_frame, mad_stream_errorstr(&stream)); -#endif /* DEBUG */ + } info->current_frame++; @@ -634,22 +605,22 @@ if (info->freq != frame.header.samplerate || info->channels != (guint) MAD_NCHANNELS(&frame.header)) { -#ifdef DEBUG - g_message("change in audio type detected"); - g_message("old: frequency = %d, channels = %d", info->freq, + + AUDDBG("change in audio type detected"); + AUDDBG("old: frequency = %d, channels = %d", info->freq, info->channels); - g_message("new: frequency = %d, channels = %d", + AUDDBG("new: frequency = %d, channels = %d", frame.header.samplerate, (guint) MAD_NCHANNELS(&frame.header)); -#endif /* DEBUG */ + info->freq = frame.header.samplerate; info->channels = MAD_NCHANNELS(&frame.header); if(audmad_config.force_reopen_audio && check_audio_param(info)) { gint current_time = info->playback->output->output_time(); -#ifdef DEBUG - g_message("re-opening audio due to change in audio type"); -#endif + + AUDDBG("re-opening audio due to change in audio type"); + info->playback->output->close_audio(); if (!info->playback->output->open_audio(info->fmt, info->freq, info->channels)) { @@ -688,10 +659,9 @@ info->playback->output->buffer_free(); info->playback->output->buffer_free(); while (info->playback->output->buffer_playing()) { -#ifdef DEBUG - g_message("f: buffer_playing=%d", - info->playback->output->buffer_playing()); -#endif + + AUDDBG("f: buffer_playing=%d", info->playback->output->buffer_playing()); + g_get_current_time(&sleeptime); g_time_val_add(&sleeptime, 500000); @@ -704,9 +674,8 @@ } } -#ifdef DEBUG - g_message("e: decode"); -#endif /* DEBUG */ + + AUDDBG("e: decode"); aud_tuple_free(info->tuple); info->tuple = NULL; diff -r 137187e7a379 -r 9a869d4bb0d3 src/madplug/input.c --- a/src/madplug/input.c Thu Dec 06 22:52:00 2007 +0900 +++ b/src/madplug/input.c Thu Dec 06 23:25:24 2007 +0900 @@ -71,9 +71,8 @@ */ gboolean input_init(struct mad_info_t * info, const char *url, VFSFile *fd) { -#ifdef DEBUG - g_message("f: input_init"); -#endif + AUDDBG("f: input_init"); + memset(info, 0, sizeof(struct mad_info_t)); // all fields are cleared to 0 --yaz info->fmt = FMT_S16_LE; @@ -100,9 +99,8 @@ } } else{ -#ifdef DEBUG - printf("input_init: aud_vfs_dup\n"); -#endif + AUDDBG("input_init: aud_vfs_dup\n"); + info->infile = aud_vfs_dup(fd); } @@ -114,10 +112,9 @@ info->fileinfo_request = FALSE; -#ifdef DEBUG - g_message("i: info->size = %lu", (long unsigned int)info->size); - g_message("e: input_init"); -#endif + AUDDBG("i: info->size = %lu", (long unsigned int)info->size); + AUDDBG("e: input_init"); + return TRUE; } @@ -223,18 +220,16 @@ tp++; } if(is_num) { -#ifdef DEBUG - printf("is_num!\n"); -#endif + AUDDBG("is_num!\n"); + tmp = g_malloc0(BYTES(end - ptr + 1)); memcpy(tmp, ptr, BYTES(end - ptr)); *(tmp + (end - ptr)) = 0; //terminate ptr += end - ptr; genre = (id3_ucs4_t *)id3_genre_name((const id3_ucs4_t *)tmp); -#ifdef DEBUG - printf("genre length = %d\n", mad_ucs4len(genre)); -#endif + AUDDBG("genre length = %d\n", mad_ucs4len(genre)); + g_free(tmp); tmp = NULL; @@ -246,11 +241,10 @@ *(ret + ret_len) = 0; //terminate } else { // plain text -#ifdef DEBUG - printf("plain!\n"); - printf("ret_len = %d\n", ret_len); - printf("end - ptr = %d\n", BYTES(end - ptr)); -#endif + AUDDBG("plain!\n"); + AUDDBG("ret_len = %d\n", ret_len); + AUDDBG("end - ptr = %d\n", BYTES(end - ptr)); + memcpy(ret + BYTES(ret_len), ptr, BYTES(end - ptr)); ret_len = ret_len + (end - ptr); *(ret + ret_len) = 0; //terminate @@ -316,9 +310,8 @@ } g_free((void *)string); -#ifdef DEBUG - g_print("i: string = %s\n", rtn); -#endif + AUDDBG("i: string = %s\n", rtn); + return rtn; } @@ -352,9 +345,8 @@ Tuple *tuple; glong curpos = 0; -#ifdef DEBUG - g_message("f: input_read_tag"); -#endif + AUDDBG("f: input_read_tag"); + if (info->tuple != NULL) aud_tuple_free(info->tuple); @@ -370,17 +362,13 @@ } if (!info->id3file) { -#ifdef DEBUG - g_message("read_tag: no id3file"); -#endif + AUDDBG("read_tag: no id3file"); return; } info->tag = id3_file_tag(info->id3file); if (!info->tag) { -#ifdef DEBUG - g_message("read_tag: no tag"); -#endif + AUDDBG("read_tag: no tag"); return; } @@ -413,9 +401,7 @@ string = input_id3_get_string(info->tag, "TLEN"); if (string) { aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string)); -#ifdef DEBUG - g_message("input_read_tag: TLEN = %d", atoi(string)); -#endif + AUDDBG("input_read_tag: TLEN = %d", atoi(string)); g_free(string); string = NULL; } else @@ -433,9 +419,7 @@ aud_vfs_fseek(info->infile, curpos, SEEK_SET); } -#ifdef DEBUG - g_message("e: input_read_tag"); -#endif + AUDDBG("e: input_read_tag"); } void input_process_remote_metadata(struct mad_info_t *info) @@ -444,12 +428,10 @@ if(info->remote && mad_timer_count(info->duration, MAD_UNITS_SECONDS) <= 0){ gchar *tmp = NULL; -#ifdef DEBUG + #ifdef DEBUG_INTENSIVELY - g_message("process_remote_meta"); + AUDDBG("process_remote_meta"); #endif -#endif - g_free(info->title); info->title = NULL; aud_tuple_disassociate(info->tuple, FIELD_TITLE, NULL); @@ -516,9 +498,9 @@ */ gboolean input_get_info(struct mad_info_t *info, gboolean fast_scan) { -#ifdef DEBUG +#ifdef AUD_DEBUG gchar *tmp = g_filename_to_utf8(info->filename, -1, NULL, NULL, NULL); - g_message("f: input_get_info: %s, fast_scan = %s", tmp, fast_scan ? "TRUE" : "FALSE"); + AUDDBG("f: input_get_info: %s, fast_scan = %s", tmp, fast_scan ? "TRUE" : "FALSE"); g_free(tmp); #endif /* DEBUG */ @@ -531,9 +513,7 @@ /* scan mp3 file, decoding headers */ if (scan_file(info, fast_scan) == FALSE) { -#ifdef DEBUG - g_message("input_get_info: scan_file failed"); -#endif + AUDDBG("input_get_info: scan_file failed"); return FALSE; } @@ -550,9 +530,7 @@ info->title = g_strdup(info->filename); //XXX info->filename is uri. --yaz } -#ifdef DEBUG - g_message("e: input_get_info"); -#endif /* DEBUG */ + AUDDBG("e: input_get_info"); return TRUE; } @@ -570,10 +548,8 @@ int buffer_size) { int len = 0; -#ifdef DEBUG #ifdef DEBUG_INTENSIVELY - g_message ("f: input_get_data: %d", buffer_size); -#endif + AUDDBG ("f: input_get_data: %d", buffer_size); #endif /* simply read to data from the file */ len = aud_vfs_fread(buffer, 1, buffer_size, info->infile); //aud_vfs_fread returns num of elements. @@ -582,11 +558,10 @@ info->playback->eof = TRUE; } -#ifdef DEBUG #ifdef DEBUG_INTENSIVELY - g_message ("e: input_get_data: size=%d offset=%d", len, info->offset); + AUDDBG ("e: input_get_data: size=%d offset=%d", len, info->offset); #endif -#endif + info->offset += len; return len; } @@ -596,9 +571,7 @@ */ gboolean input_term(struct mad_info_t * info) { -#ifdef DEBUG - g_message("f: input_term"); -#endif + AUDDBG("f: input_term"); if (info->title) g_free(info->title); @@ -634,8 +607,8 @@ /* set everything to zero in case it gets used again. */ memset(info, 0, sizeof(struct mad_info_t)); -#ifdef DEBUG - g_message("e: input_term"); -#endif + + AUDDBG("e: input_term"); + return TRUE; } diff -r 137187e7a379 -r 9a869d4bb0d3 src/madplug/plugin.c --- a/src/madplug/plugin.c Thu Dec 06 22:52:00 2007 +0900 +++ b/src/madplug/plugin.c Thu Dec 06 23:25:24 2007 +0900 @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* #define AUD_DEBUG 1 */ + #include "config.h" #include "plugin.h" #include "input.h" @@ -102,19 +104,15 @@ else x = 0; config->pregain_scale = (x != 0) ? pow(10.0, x / 20) : 1; -#ifdef DEBUG - g_message("pregain=[%s] -> %g -> %g", text, x, config->pregain_scale); -#endif + AUDDBG("pregain=[%s] -> %g -> %g", text, x, config->pregain_scale); text = config->replaygain.default_db; if ( text != NULL ) x = g_strtod(text, NULL); else x = 0; config->replaygain.default_scale = (x != 0) ? pow(10.0, x / 20) : 1; -#ifdef DEBUG - g_message("RG.default=[%s] -> %g -> %g", text, x, + AUDDBG("RG.default=[%s] -> %g -> %g", text, x, config->replaygain.default_scale); -#endif } static void audmad_init() @@ -405,9 +403,7 @@ static void audmad_stop(InputPlayback *playback) { -#ifdef DEBUG - g_message("f: audmad_stop"); -#endif + AUDDBG("f: audmad_stop"); g_mutex_lock(mad_mutex); info.playback = playback; g_mutex_unlock(mad_mutex); @@ -419,20 +415,15 @@ g_mutex_unlock(mad_mutex); g_cond_signal(mad_cond); -#ifdef DEBUG - g_message("waiting for thread"); -#endif + AUDDBG("waiting for thread"); g_thread_join(decode_thread); -#ifdef DEBUG - g_message("thread done"); -#endif + AUDDBG("thread done"); + input_term(&info); decode_thread = NULL; } -#ifdef DEBUG - g_message("e: audmad_stop"); -#endif + AUDDBG("e: audmad_stop"); } static void audmad_play_file(InputPlayback *playback) @@ -440,10 +431,10 @@ gboolean rtn; gchar *url = playback->filename; -#ifdef DEBUG +#ifdef AUD_DEBUG { gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); - g_message("playing %s", tmp); + AUDDBG("playing %s", tmp); g_free(tmp); } #endif /* DEBUG */ @@ -503,16 +494,14 @@ audmad_get_song_info(char *url, char **title, int *length) { struct mad_info_t myinfo; -#ifdef DEBUG +#ifdef AUD_DEBUG gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); - g_message("f: audmad_get_song_info: %s", tmp); + AUDDBG("f: audmad_get_song_info: %s", tmp); g_free(tmp); #endif /* DEBUG */ if (input_init(&myinfo, url, NULL) == FALSE) { -#ifdef DEBUG - g_message("error initialising input"); -#endif + AUDDBG("error initialising input"); return; } @@ -531,23 +520,17 @@ *length = -1; } input_term(&myinfo); -#ifdef DEBUG - g_message("e: audmad_get_song_info"); -#endif /* DEBUG */ + AUDDBG("e: audmad_get_song_info"); } static gboolean audmad_fill_info(struct mad_info_t *info, VFSFile *fd) { if (fd == NULL || info == NULL) return FALSE; -#ifdef DEBUG - g_message("f: audmad_fill_info(): %s", fd->uri); -#endif + AUDDBG("f: audmad_fill_info(): %s", fd->uri); if (input_init(info, fd->uri, fd) == FALSE) { -#ifdef DEBUG - g_message("audmad_fill_info(): error initialising input"); -#endif + AUDDBG("audmad_fill_info(): error initialising input"); return FALSE; } @@ -637,9 +620,9 @@ gboolean local_fd = FALSE; int length; -#ifdef DEBUG +#ifdef AUD_DEBUG string = aud_str_to_utf8(filename); - g_message("f: mad: audmad_get_song_tuple: %s", string); + AUDDBG("f: mad: audmad_get_song_tuple: %s", string); g_free(string); string = NULL; #endif @@ -651,9 +634,9 @@ gchar *tmp = NULL; tuple = aud_tuple_new_from_filename(filename); -#ifdef DEBUG +#ifdef AUD_DEBUG if(info.playback) - g_message("info.playback->playing = %d",info.playback->playing); + AUDDBG("info.playback->playing = %d",info.playback->playing); #endif tmp = aud_vfs_get_metadata(info.infile ? info.infile : fd, "track-name"); if(tmp){ @@ -678,21 +661,14 @@ tmp = NULL; } -#ifdef DEBUG - g_message("audmad_get_song_tuple: track_name = %s", aud_tuple_get_string(tuple, -1, "track-name")); - g_message("audmad_get_song_tuple: stream_name = %s", aud_tuple_get_string(tuple, -1, "stream-name")); -#endif + AUDDBG("audmad_get_song_tuple: track_name = %s", aud_tuple_get_string(tuple, -1, "track-name")); + AUDDBG("audmad_get_song_tuple: stream_name = %s", aud_tuple_get_string(tuple, -1, "stream-name")); aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); aud_tuple_associate_int(tuple, FIELD_MTIME, NULL, 0); // this indicates streaming -#ifdef DEBUG - g_message("get_song_tuple: remote: tuple"); -#endif + AUDDBG("get_song_tuple: remote: tuple"); return tuple; } -#ifdef DEBUG - g_message("get_song_tuple: remote: NULL"); -#endif -// return NULL; + AUDDBG("get_song_tuple: remote: NULL"); } /* info.remote */ // if !fd, pre-open the file with aud_vfs_fopen() and reuse fd. @@ -704,9 +680,7 @@ } if (!audmad_fill_info(&myinfo, fd)) { -#ifdef DEBUG - g_message("get_song_tuple: error obtaining info\n"); -#endif + AUDDBG("get_song_tuple: error obtaining info\n"); if (local_fd) aud_vfs_fclose(fd); return NULL; } @@ -755,9 +729,7 @@ // genre __set_and_free(tuple, FIELD_GENRE, NULL, input_id3_get_string(tag, ID3_FRAME_GENRE)); __set_and_free(tuple, FIELD_COMMENT, NULL, input_id3_get_string(tag, ID3_FRAME_COMMENT)); -#ifdef DEBUG - g_message("genre = %s", aud_tuple_get_string(tuple, FIELD_GENRE, NULL)); -#endif + AUDDBG("genre = %s", aud_tuple_get_string(tuple, FIELD_GENRE, NULL)); } id3_file_close(id3file); } // id3file @@ -787,9 +759,7 @@ if(local_fd) aud_vfs_fclose(fd); -#ifdef DEBUG - g_message("e: mad: audmad_get_song_tuple"); -#endif + AUDDBG("e: mad: audmad_get_song_tuple"); return tuple; } diff -r 137187e7a379 -r 9a869d4bb0d3 src/madplug/plugin.h --- a/src/madplug/plugin.h Thu Dec 06 22:52:00 2007 +0900 +++ b/src/madplug/plugin.h Thu Dec 06 23:25:24 2007 +0900 @@ -22,7 +22,7 @@ #ifndef AUD_MAD_H #define AUD_MAD_H -/* #define DEBUG 1 */ +/* #define AUD_DEBUG 1 */ /* #define DEBUG_INTENSIVELY 1 */ /* #define DEBUG_DITHER 1 */ diff -r 137187e7a379 -r 9a869d4bb0d3 src/madplug/replaygain.c --- a/src/madplug/replaygain.c Thu Dec 06 22:52:00 2007 +0900 +++ b/src/madplug/replaygain.c Thu Dec 06 23:25:24 2007 +0900 @@ -92,10 +92,9 @@ free(buff); return 8; } -#ifdef DEBUG - printf("ver = %ld\n", Read_LE_Uint32(tp->Version)); - printf("taglen = %ld\n", TagLen); -#endif + + AUDDBG("ver = %ld\n", Read_LE_Uint32(tp->Version)); + AUDDBG("taglen = %ld\n", TagLen); TagCount = Read_LE_Uint32(tp->TagCount); end = buff + TagLen - sizeof(T); @@ -204,14 +203,11 @@ char *value; struct id3_frame *frame; -#ifdef DEBUG - g_message("f: ReadId3v2TXXX"); -#endif + AUDDBG("f: ReadId3v2TXXX"); + /* tag must be read before! */ if (! file_info->tag ) { -#ifdef DEBUG - g_message("id3v2 not found"); -#endif + AUDDBG("id3v2 not found"); return 0; } @@ -259,9 +255,7 @@ VFSFile *fp; glong curpos = 0; -#ifdef DEBUG - g_message("f: read_replaygain"); -#endif + AUDDBG("f: read_replaygain"); file_info->has_replaygain = FALSE; file_info->replaygain_album_scale = -1; @@ -270,11 +264,11 @@ file_info->mp3gain_minmax = -77; if (ReadId3v2TXXX(file_info)) { -#ifdef DEBUG - g_message("found ReplayGain info in id3v2 tag"); +#ifdef AUD_DEBUG + AUDDBG("found ReplayGain info in id3v2 tag"); gchar *tmp = g_filename_to_utf8(file_info->filename, -1, NULL, NULL, NULL); - g_message("RG album scale= %g, RG track scale = %g, in %s", + AUDDBG("RG album scale= %g, RG track scale = %g, in %s", file_info->replaygain_album_scale, file_info->replaygain_track_scale, tmp); g_free(tmp); @@ -322,15 +316,15 @@ offs, res); } } -#ifdef DEBUG +#ifdef AUD_DEBUG else - g_message("replaygain: not found"); + AUDDBG("replaygain: not found"); #endif } -#ifdef DEBUG +#ifdef AUD_DEBUG if (res == 0) { // got APE tags, show the result gchar *tmp = g_filename_to_utf8(file_info->filename, -1, NULL, NULL, NULL); - g_message("RG album scale= %g, RG track scale = %g, in %s", + AUDDBG("RG album scale= %g, RG track scale = %g, in %s", file_info->replaygain_album_scale, file_info->replaygain_track_scale, tmp); g_free(tmp); @@ -346,7 +340,5 @@ aud_vfs_fclose(fp); -#ifdef DEBUG - g_message("e: read_replaygain"); -#endif + AUDDBG("e: read_replaygain"); } diff -r 137187e7a379 -r 9a869d4bb0d3 src/madplug/tuple.c --- a/src/madplug/tuple.c Thu Dec 06 22:52:00 2007 +0900 +++ b/src/madplug/tuple.c Thu Dec 06 23:25:24 2007 +0900 @@ -35,7 +35,6 @@ #include #include -/* yaz */ #include static void @@ -56,9 +55,7 @@ */ if (strlen(data) == 0) { while ((frame = id3_tag_findframe(tag, frame_name, 0))) { -#ifdef DEBUG - fprintf(stderr, "madplug: detachframe\n"); -#endif + AUDDBG("madplug: detachframe\n"); id3_tag_detachframe(tag, frame); } return; @@ -66,9 +63,7 @@ frame = id3_tag_findframe(tag, frame_name, 0); if (!frame) { -#ifdef DEBUG - printf("frame_new\n"); -#endif + AUDDBG("frame_new\n"); frame = id3_frame_new(frame_name); id3_tag_attachframe(tag, frame); } @@ -93,9 +88,7 @@ g_free(ucs4); if(index == -1) { /* unknown genre. remove TCON frame. */ -#ifdef DEBUG - fprintf(stderr, "madplug: remove genre frame\n"); -#endif + AUDDBG("madplug: remove genre frame\n"); id3_tag_detachframe(tag, frame); } else { /* meaningful genre */ @@ -132,9 +125,7 @@ val = aud_tuple_get_int(tuple, fieldn, NULL); if(val > 0) { text2 = g_strdup_printf("%d", val); -#ifdef DEBUG - fprintf(stderr, "madplug: updating field:\"%s\"=\"%s\", enc %s\n", field, text2, encoding); -#endif + AUDDBG("madplug: updating field:\"%s\"=\"%s\", enc %s\n", field, text2, encoding); update_id3_frame(id3tag, field, text2, 0); g_free(text2); } else { @@ -144,9 +135,7 @@ } else if(aud_tuple_get_value_type(tuple, fieldn, NULL) == TUPLE_STRING) { text = (char*)aud_tuple_get_string(tuple, fieldn, NULL); text2 = g_convert(text, strlen(text), encoding, "UTF-8", NULL, NULL, NULL); -#ifdef DEBUG - fprintf(stderr, "madplug: updating field:\"%s\"=\"%s\", enc %s\n", field, text2, encoding); -#endif + AUDDBG("madplug: updating field:\"%s\"=\"%s\", enc %s\n", field, text2, encoding); update_id3_frame(id3tag, field, text2, sjis); g_free(text2); } @@ -164,9 +153,7 @@ id3tag = id3_file_tag(id3file); if (!id3tag) { -#ifdef DEBUG - fprintf(stderr, "no id3tag\n. append new tag.\n"); -#endif + AUDDBG("no id3tag\n. append new tag.\n"); id3tag = id3_tag_new(); id3_tag_clearframes(id3tag); id3tag->options |= ID3_TAG_OPTION_APPENDEDTAG | ID3_TAG_OPTION_ID3V1; @@ -183,15 +170,11 @@ update_id3_frame_from_tuple(id3tag, ID3_FRAME_GENRE, tuple, FIELD_GENRE, audmad_config.sjis); if(!id3_tag_findframe(id3tag, "TLEN", 0) && input_init(&songinfo, fd->uri, fd) && !songinfo.remote) { -#ifdef DEBUG - fprintf(stderr, "update TLEN frame\n"); -#endif + AUDDBG("update TLEN frame\n"); songinfo.fileinfo_request = FALSE; /* we don't need to read tuple again */ input_get_info(&songinfo, FALSE); text = g_strdup_printf("%ld", mad_timer_count(songinfo.duration, MAD_UNITS_MILLISECONDS)); -#ifdef DEBUG - fprintf(stderr, "TLEN: \"%s\"\n", text); -#endif + AUDDBG("TLEN: \"%s\"\n", text); update_id3_frame(id3tag, "TLEN", text, 0); g_free(text); input_term(&songinfo);