From c42d9377589180f6d40ce61f9c317aa678b8ab14 Mon Sep 17 00:00:00 2001 From: Marco Zuehlke Date: Fri, 20 Jun 2003 20:57:28 +0000 Subject: the new logging macros, for details see README.logging CVS patchset: 5077 CVS date: 2003/06/20 20:57:28 --- src/xine-engine/audio_out.c | 234 +++++++++++++++---------------------- src/xine-engine/xine.c | 275 ++++++++++++++++++-------------------------- src/xine-utils/xineutils.h | 78 ++++++++++++- 3 files changed, 279 insertions(+), 308 deletions(-) (limited to 'src') diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 0e3937993..0cfbd4625 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2000-2003 the xine project * * This file is part of xine, a free video player. @@ -17,28 +17,30 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.130 2003/06/17 18:53:14 tmattern Exp $ - * + * $Id: audio_out.c,v 1.131 2003/06/20 20:57:28 andruil Exp $ + * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe * 20-8-2001 First implementation of Audio sync and Audio driver separation. * (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk - * + */ + +/* * General Programming Guidelines: - * New concept of an "audio_frame". - * An audio_frame consists of all the samples required to fill every + * An audio_frame consists of all the samples required to fill every * audio channel to a full amount of bits. - * So, it does not mater how many bits per sample, or how many audio channels + * So, it does not mater how many bits per sample, or how many audio channels * are being used, the number of audio_frames is the same. * E.g. 16 bit stereo is 4 bytes, but one frame. * 16 bit 5.1 surround is 12 bytes, but one frame. - * The purpose of this is to make the audio_sync code a lot more readable, + * The purpose of this is to make the audio_sync code a lot more readable, * rather than having to multiply by the amount of channels all the time * when dealing with audio_bytes instead of audio_frames. * - * The number of samples passed to/from the audio driver is also sent + * The number of samples passed to/from the audio driver is also sent * in units of audio_frames. - * + * * Currently, James has tested with OSS: Standard stereo out, SPDIF PCM, SPDIF AC3 * ALSA: Standard stereo out * No testing has been done of ALSA SPDIF AC3 or any 4,5,5.1 channel output. @@ -77,17 +79,19 @@ #define XINE_ENABLE_EXPERIMENTAL_FEATURES +/********** logging **********/ +#define LOG_MODULE "audio_out" +/* #define LOG_VERBOSE */ + +/* #define LOG */ +#define LOG_RESAMPLE_SYNC 0 + #include "xine_internal.h" #include "xineutils.h" #include "audio_out.h" #include "resample.h" #include "metronom.h" -/* -#define LOG - -#define LOG_RESAMPLE_SYNC -*/ #define NUM_AUDIO_BUFFERS 32 #define AUDIO_BUF_SIZE 32768 @@ -420,10 +424,9 @@ static void ao_fill_gap (aos_t *this, int64_t pts_len) { num_frames = pts_len * this->frames_per_kpts / 1024; - if (this->xine->verbosity >= XINE_VERBOSITY_LOG) - - printf ("audio_out: inserting %d 0-frames to fill a gap of %" PRId64 " pts\n", - num_frames, pts_len); + xprintf (this->xine, XINE_VERBOSITY_LOG, + "inserting %d 0-frames to fill a gap of %" PRId64 " pts\n", + num_frames, pts_len); if ((this->output.mode == AO_CAP_MODE_A52) || (this->output.mode == AO_CAP_MODE_AC5)) { write_pause_burst(this,num_frames); @@ -515,17 +518,12 @@ static void audio_filter_compress (aos_t *this, int16_t *mem, int num_frames) { } else f_max = 1.0; -#ifdef LOG - printf ("audio_out: max=%d f_max=%f compression_factor=%f\n", - maxs, f_max, this->compression_factor); -#endif - + lprintf ("max=%d f_max=%f compression_factor=%f\n", maxs, f_max, this->compression_factor); + /* apply it */ for (i=0; icompression_factor * this->amp_factor; } } @@ -540,12 +538,11 @@ static void audio_filter_amp (aos_t *this, int16_t *mem, int num_frames) { return; for (i=0; iamp_factor; } } -static void audio_filter_equalize (aos_t *this, +static void audio_filter_equalize (aos_t *this, int16_t *data, int num_frames) { int index, band, channel; int halflength, length; @@ -563,10 +560,10 @@ static void audio_filter_equalize (aos_t *this, for (index = 0; index < halflength; index+=2) { for (channel = 0; channel < num_channels; channel++) { - + /* Convert the PCM sample to a fixed fraction */ scaledpcm[channel] = ((int)data[index+channel]) << (FP_FRBITS-16-1); - + out[channel] = 0; /* For each band */ for (band = 0; band < EQ_BANDS; band++) { @@ -574,15 +571,15 @@ static void audio_filter_equalize (aos_t *this, this->eq_data_history[band][channel].x[this->eq_i] = scaledpcm[channel]; l = (int64_t)iir_cf[band].alpha * (int64_t)(this->eq_data_history[band][channel].x[this->eq_i] - this->eq_data_history[band][channel].x[this->eq_k]) + (int64_t)iir_cf[band].gamma * (int64_t)this->eq_data_history[band][channel].y[this->eq_j] - - (int64_t)iir_cf[band].beta * (int64_t)this->eq_data_history[band][channel].y[this->eq_k]; + - (int64_t)iir_cf[band].beta * (int64_t)this->eq_data_history[band][channel].y[this->eq_k]; this->eq_data_history[band][channel].y[this->eq_i] = (int)(l >> FP_FRBITS); l = (int64_t)this->eq_data_history[band][channel].y[this->eq_i] * (int64_t)this->eq_gain[band]; out[channel] += (int)(l >> FP_FRBITS); - } + } /* Volume scaling adjustment by 2^-2 */ out[channel] += (scaledpcm[channel] >> 2); - + /* Adjust the fixed point fraction value to a PCM sample */ /* Scale back to a 16bit signed int */ out[channel] >>= (FP_FRBITS-16); @@ -594,8 +591,8 @@ static void audio_filter_equalize (aos_t *this, data[index+channel] = 32767; else data[index+channel] = out[channel]; - } - + } + this->eq_i++; this->eq_j++; this->eq_k++; if (this->eq_i == 3) this->eq_i = 0; else if (this->eq_j == 3) this->eq_j = 0; @@ -614,11 +611,11 @@ static audio_buffer_t* prepare_samples( aos_t *this, audio_buffer_t *buf) { if (this->input.bits == 16) { - if (this->do_equ) + if (this->do_equ) audio_filter_equalize (this, buf->mem, buf->num_frames); if (this->do_compress) audio_filter_compress (this, buf->mem, buf->num_frames); - if (this->do_amp) + if (this->do_amp) audio_filter_amp (this, buf->mem, buf->num_frames); } @@ -633,20 +630,18 @@ static audio_buffer_t* prepare_samples( aos_t *this, audio_buffer_t *buf) { /* Truncate to an integer */ num_output_frames = acc_output_frames; - + /* Keep track of the amount truncated */ this->output_frame_excess = acc_output_frames - (double) num_output_frames; if ( this->output_frame_excess != 0 && !this->do_resample && !this->resample_sync_method) this->output_frame_excess = 0; - -#ifdef LOG - printf ("audio_out: outputting %d frames\n", num_output_frames); -#endif + + lprintf ("outputting %d frames\n", num_output_frames); /* convert 8 bit samples as needed */ if ( this->input.bits == 8 && - (this->resample_sync_method || this->do_resample || + (this->resample_sync_method || this->do_resample || this->output.bits != 8 || this->input.mode != this->output.mode) ) { ensure_buffer_size(this->frame_buf[1], 2*mode_channels(this->input.mode), buf->num_frames ); @@ -656,7 +651,7 @@ static audio_buffer_t* prepare_samples( aos_t *this, audio_buffer_t *buf) { } /* check if resampling may be skipped */ - if ( (this->resample_sync_method || this->do_resample) && + if ( (this->resample_sync_method || this->do_resample) && buf->num_frames != num_output_frames ) { switch (this->input.mode) { case AO_CAP_MODE_MONO: @@ -695,7 +690,7 @@ static audio_buffer_t* prepare_samples( aos_t *this, audio_buffer_t *buf) { break; } } - + /* mode conversion */ if ( this->input.mode != this->output.mode ) { switch (this->input.mode) { @@ -794,17 +789,14 @@ static int resample_rate_adjust(aos_t *this, int64_t gap, audio_buffer_t *buf) { info->reduce_gap = 1; this->resample_sync_factor = (avg_gap < 0) ? 0.995 : 1.005; -#ifdef LOG_RESAMPLE_SYNC - printf("audio_out: sample rate adjusted to reduce gap: gap=%" PRId64 "\n", avg_gap); -#endif + llprintf (LOG_RESAMPLE_SYNC, + "sample rate adjusted to reduce gap: gap=%" PRId64 "\n", avg_gap); return 0; } else if (info->reduce_gap && abs(avg_gap) < 50) { info->reduce_gap = 0; info->valid = 0; -#ifdef LOG_RESAMPLE_SYNC - printf("audio_out: gap successfully reduced\n"); -#endif + llprintf (LOG_RESAMPLE_SYNC, "gap successfully reduced\n"); return 0; } else if (info->reduce_gap) { @@ -825,7 +817,7 @@ static int resample_rate_adjust(aos_t *this, int64_t gap, audio_buffer_t *buf) { int64_t gap_diff = avg_gap - info->last_avg_gap; if (gap_diff < RESAMPLE_MAX_GAP_DIFF) { -#ifdef LOG_RESAMPLE_SYNC +#if LOG_RESAMPLE_SYNC int num_frames; /* if we are already resampling to a different output rate, consider @@ -892,15 +884,10 @@ static void *ao_loop (void *this_gen) { */ if (!in_buf) { - -#ifdef LOG - printf ("audio_out:loop: get buf from fifo\n"); -#endif + lprintf ("loop: get buf from fifo\n"); in_buf = fifo_remove (this->out_fifo); bufs_since_sync++; -#ifdef LOG - printf ("audio_out: got a buffer\n"); -#endif + lprintf ("got a buffer\n"); } pthread_mutex_lock(&this->flush_audio_driver_lock); @@ -931,22 +918,16 @@ static void *ao_loop (void *this_gen) { cur_time = this->clock->get_current_time (this->clock); if (in_buf->vpts < cur_time ) { -#ifdef LOG - printf ("audio_out:loop: next fifo\n"); -#endif + lprintf ("loop: next fifo\n"); fifo_append (this->free_fifo, in_buf); in_buf = NULL; continue; } } -#ifdef LOG - printf ("audio_out:loop:pause: I feel sleepy (%d buffers).\n", this->out_fifo->num_buffers); -#endif + lprintf ("loop:pause: I feel sleepy (%d buffers).\n", this->out_fifo->num_buffers); xine_usec_sleep (10000); -#ifdef LOG - printf ("audio_out:loop:pause: I wake up.\n"); -#endif + lprintf ("loop:pause: I wake up.\n"); continue; } @@ -983,11 +964,8 @@ static void *ao_loop (void *this_gen) { */ hw_vpts = cur_time; - -#ifdef LOG - printf ("audio_out: current delay is %" PRId64 ", current time is %" PRId64 "\n", - delay, cur_time); -#endif + lprintf ("current delay is %" PRId64 ", current time is %" PRId64 "\n", delay, cur_time); + /* External A52 decoder delay correction */ if ((this->output.mode==AO_CAP_MODE_A52) || (this->output.mode==AO_CAP_MODE_AC5)) delay += this->passthrough_offset; @@ -999,10 +977,8 @@ static void *ao_loop (void *this_gen) { * calculate gap: */ gap = in_buf->vpts - hw_vpts; -#ifdef LOG - printf ("audio_out: hw_vpts : %" PRId64 " buffer_vpts : %" PRId64 " gap : %" PRId64 "\n", - hw_vpts, in_buf->vpts, gap); -#endif + lprintf ("hw_vpts : %" PRId64 " buffer_vpts : %" PRId64 " gap : %" PRId64 "\n", + hw_vpts, in_buf->vpts, gap); if (this->resample_sync_method) { /* Correct sound card drift via resampling. If gap is too big to @@ -1023,15 +999,11 @@ static void *ao_loop (void *this_gen) { if (gap < (-1 * AO_MAX_GAP) || !in_buf->num_frames ) { /* drop package */ -#ifdef LOG - printf ("audio_out:loop: drop package, next fifo\n"); -#endif + lprintf ("loop: drop package, next fifo\n"); fifo_append (this->free_fifo, in_buf); -#ifdef LOG - printf ("audio_out: audio package (vpts = %" PRId64 ", gap = %" PRId64 ") dropped\n", - in_buf->vpts, gap); -#endif + lprintf ("audio package (vpts = %" PRId64 ", gap = %" PRId64 ") dropped\n", + in_buf->vpts, gap); in_buf = NULL; @@ -1044,9 +1016,7 @@ static void *ao_loop (void *this_gen) { bufs_since_sync >= SYNC_BUF_INTERVAL && !this->resample_sync_method ) { xine_stream_t *stream; -#ifdef LOG - printf ("audio_out: audio_loop: ADJ_VPTS\n"); -#endif + lprintf ("audio_loop: ADJ_VPTS\n"); pthread_mutex_lock(&this->streams_lock); for (stream = xine_list_first_content(this->streams); stream; stream = xine_list_next_content(this->streams)) { @@ -1083,18 +1053,13 @@ static void *ao_loop (void *this_gen) { } #endif -#ifdef LOG - printf ("audio_out: loop: writing %d samples to sound device\n", - out_buf->num_frames); -#endif + lprintf ("loop: writing %d samples to sound device\n", out_buf->num_frames); pthread_mutex_lock( &this->driver_lock ); this->driver->write (this->driver, out_buf->mem, out_buf->num_frames ); pthread_mutex_unlock( &this->driver_lock ); -#ifdef LOG - printf ("audio_out:loop: next buf from fifo\n"); -#endif + lprintf ("loop: next buf from fifo\n"); fifo_append (this->free_fifo, in_buf); in_buf = NULL; } @@ -1118,9 +1083,7 @@ int xine_get_next_audio_frame (xine_audio_port_t *this_gen, audio_buffer_t *in_buf, *out_buf; xine_stream_t *stream; -#ifdef LOG - printf ("audio_audio: get_next_audio_frame\n"); -#endif + lprintf ("get_next_audio_frame\n"); do { stream = xine_list_first_content(this->streams); @@ -1208,22 +1171,22 @@ static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mod if( this->input.bits == 8 && !(this->driver->get_capabilities(this->driver) & AO_CAP_8BITS) ) { bits = 16; - if (this->xine->verbosity >= XINE_VERBOSITY_LOG) - printf("audio_out: 8 bits not supported by driver, converting to 16 bits.\n"); + xprintf (this->xine, XINE_VERBOSITY_LOG, + "8 bits not supported by driver, converting to 16 bits.\n"); } - + /* provide mono->stereo and stereo->mono conversions */ - if( this->input.mode == AO_CAP_MODE_MONO && + if( this->input.mode == AO_CAP_MODE_MONO && !(this->driver->get_capabilities(this->driver) & AO_CAP_MODE_MONO) ) { mode = AO_CAP_MODE_STEREO; - if (this->xine->verbosity >= XINE_VERBOSITY_LOG) - printf("audio_out: mono not supported by driver, converting to stereo.\n"); + xprintf (this->xine, XINE_VERBOSITY_LOG, + "mono not supported by driver, converting to stereo.\n"); } - if( this->input.mode == AO_CAP_MODE_STEREO && + if( this->input.mode == AO_CAP_MODE_STEREO && !(this->driver->get_capabilities(this->driver) & AO_CAP_MODE_STEREO) ) { mode = AO_CAP_MODE_MONO; - if (this->xine->verbosity >= XINE_VERBOSITY_LOG) - printf("audio_out: stereo not supported by driver, converting to mono.\n"); + xprintf (this->xine, XINE_VERBOSITY_LOG, + "stereo not supported by driver, converting to mono.\n"); } pthread_mutex_lock( &this->driver_lock ); @@ -1234,13 +1197,11 @@ static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mod output_sample_rate = this->input.rate; if ( output_sample_rate == 0) { - if (this->xine->verbosity >= XINE_VERBOSITY_LOG) - printf("audio_out: open failed!\n"); + xprintf (this->xine, XINE_VERBOSITY_LOG, "open failed!\n"); return 0; }; - if (this->xine->verbosity >= XINE_VERBOSITY_LOG) - printf("audio_out: output sample rate %d\n", output_sample_rate); + xprintf (this->xine, XINE_VERBOSITY_LOG, "output sample rate %d\n", output_sample_rate); this->last_audio_vpts = 0; this->output.mode = mode; @@ -1258,18 +1219,17 @@ static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mod this->do_resample = this->output.rate != this->input.rate; } - if (this->do_resample && this->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf("audio_out: will resample audio from %d to %d\n", - this->input.rate, this->output.rate); + if (this->do_resample) + xprintf (this->xine, XINE_VERBOSITY_DEBUG, + "will resample audio from %d to %d\n", this->input.rate, this->output.rate); this->frame_rate_factor = ((double)(this->output.rate)) / ((double)(this->input.rate)); - /* FIXME: If this->frames_per_kpts line goes after this->audio_step line, xine crashes with FPE, when compiled with gcc 3.0.1!!! Why? */ + /* FIXME: If this->frames_per_kpts line goes after this->audio_step line, + * xine crashes with FPE, when compiled with gcc 3.0.1!!! Why? */ this->frames_per_kpts = (this->output.rate * 1024) / 90000; this->audio_step = ((int64_t)90000 * (int64_t)32768) / (int64_t)this->input.rate; -#ifdef LOG - printf ("audio_out : audio_step %" PRId64 " pts per 32768 frames\n", this->audio_step); -#endif - + + lprintf ("audio_step %" PRId64 " pts per 32768 frames\n", this->audio_step); return this->output.rate; } @@ -1350,7 +1310,7 @@ static void ao_put_buffer (xine_audio_port_t *this_gen, if( stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] != this->input.bits || stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] != this->input.rate || stream->stream_info[XINE_STREAM_INFO_AUDIO_MODE] != this->input.mode ) { - printf("audio_out: audio format have changed\n"); + lprintf("audio format have changed\n"); ao_change_settings(this, stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS], stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE], @@ -1366,11 +1326,9 @@ static void ao_put_buffer (xine_audio_port_t *this_gen, buf->num_frames); buf->extra_info->vpts = buf->vpts; -#ifdef LOG - printf ("audio_out: ao_put_buffer, pts=%" PRId64 ", vpts=%" PRId64 ", flushmode=%d\n", - pts, buf->vpts, this->discard_buffers); -#endif - + lprintf ("ao_put_buffer, pts=%" PRId64 ", vpts=%" PRId64 ", flushmode=%d\n", + pts, buf->vpts, this->discard_buffers); + if (!this->discard_buffers) fifo_append (this->out_fifo, buf); else @@ -1378,9 +1336,7 @@ static void ao_put_buffer (xine_audio_port_t *this_gen, this->last_audio_vpts = buf->vpts; -#ifdef LOG - printf ("audio_out: ao_put_buffer done\n"); -#endif + lprintf ("ao_put_buffer done\n"); } static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { @@ -1388,8 +1344,7 @@ static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { aos_t *this = (aos_t *) this_gen; xine_stream_t *cur; - if (this->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("audio_out: ao_close \n"); + xprintf (this->xine, XINE_VERBOSITY_DEBUG, "ao_close\n"); /* unregister stream */ pthread_mutex_lock(&this->streams_lock); @@ -1404,8 +1359,7 @@ static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { /* close driver if no streams left */ if (!cur && !this->grab_only) { - if (this->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf("audio_out: no streams left, closing driver\n"); + xprintf (this->xine, XINE_VERBOSITY_DEBUG, "no streams left, closing driver\n"); if (this->audio_loop_running) { /* make sure there are no more buffers on queue */ @@ -1611,7 +1565,7 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value max_gain = this->eq_gain[i]; } - printf ("audio_out: eq min_gain=%d, max_gain=%d\n", min_gain, max_gain); + lprintf ("eq min_gain=%d, max_gain=%d\n", min_gain, max_gain); this->do_equ = ((min_gain != EQ_REAL(0.0)) || (max_gain != EQ_REAL(0.0))); @@ -1634,13 +1588,8 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value pthread_mutex_lock(&this->out_fifo->mutex); while ((buf = this->out_fifo->first)) { - -#ifdef LOG - printf ("audio_out: flushing out frame\n"); -#endif - + lprintf ("flushing out frame\n"); buf = fifo_remove_int (this->out_fifo); - fifo_append (this->free_fifo, buf); } pthread_mutex_unlock (&this->out_fifo->mutex); @@ -1688,8 +1637,8 @@ static void ao_flush (xine_audio_port_t *this_gen) { aos_t *this = (aos_t *) this_gen; audio_buffer_t *buf; - if (this->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("audio_out: ao_flush (loop running: %d)\n", this->audio_loop_running); + xprintf (this->xine, XINE_VERBOSITY_DEBUG, + "ao_flush (loop running: %d)\n", this->audio_loop_running); if( this->audio_loop_running ) { pthread_mutex_lock(&this->flush_audio_driver_lock); @@ -1735,9 +1684,7 @@ static int ao_status (xine_audio_port_t *this_gen, xine_stream_t *stream, static void ao_update_av_sync_method(void *this_gen, xine_cfg_entry_t *entry) { aos_t *this = (aos_t *) this_gen; -#ifdef LOG - printf ("audio_out: av_sync_method = %d\n", entry->num_value); -#endif + lprintf ("av_sync_method = %d\n", entry->num_value); this->av_sync_method_conf = entry->num_value; @@ -1922,8 +1869,7 @@ xine_audio_port_t *ao_new_port (xine_t *xine, ao_driver_t *driver, abort(); } else - if (this->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("audio_out: thread created\n"); + xprintf (this->xine, XINE_VERBOSITY_DEBUG, "thread created\n"); } return &this->ao; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 602a7cd81..be062b470 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -17,10 +17,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine.c,v 1.249 2003/05/20 13:58:10 mroi Exp $ - * + * $Id: xine.c,v 1.250 2003/06/20 20:57:28 andruil Exp $ + */ + +/* * top-level xine functions - * */ #ifdef HAVE_CONFIG_H @@ -41,6 +42,12 @@ #include #endif +/********** logging **********/ +#define LOG_MODULE "xine" +#define LOG_VERBOSE + +/* #define LOG */ + #include "xine_internal.h" #include "plugin_catalog.h" #include "audio_out.h" @@ -61,9 +68,6 @@ # include #endif /* WIN32 */ -/* -#define LOG -*/ void xine_handle_stream_end (xine_stream_t *stream, int non_user) { @@ -71,9 +75,9 @@ void xine_handle_stream_end (xine_stream_t *stream, int non_user) { return; stream->status = XINE_STATUS_STOP; - /* join thread if needed to fix resource leaks */ + /* join thread if needed to fix resource leaks */ xine_demux_stop_thread( stream ); - + if (non_user) { /* frontends will not be interested in receiving this event * if they have called xine_stop explicitly, so only send @@ -84,17 +88,17 @@ void xine_handle_stream_end (xine_stream_t *stream, int non_user) { event.data_length = 0; event.type = XINE_EVENT_UI_PLAYBACK_FINISHED; - + xine_event_send (stream, &event); } } void extra_info_reset( extra_info_t *extra_info ) { - memset( extra_info, 0, sizeof(extra_info_t) ); + memset( extra_info, 0, sizeof(extra_info_t) ); } void extra_info_merge( extra_info_t *dst, extra_info_t *src ) { - + if (!src->invalid) { if( src->input_pos ) dst->input_pos = src->input_pos; @@ -143,24 +147,20 @@ static void xine_stop_internal (xine_stream_t *stream) { int finished_count_audio = 0; int finished_count_video = 0; -#ifdef LOG - printf ("xine: xine_stop. status before = %d\n", stream->status); -#endif + lprintf ("status before = %d\n", stream->status); if (stream->status == XINE_STATUS_STOP) { -#ifdef LOG - printf ("xine: xine_stop ignored\n"); -#endif + lprintf ("ignored\n"); return; } - + /* make sure we're not in "paused" state */ xine_set_speed_internal (stream, XINE_SPEED_NORMAL); /* Don't change status if we're quitting */ if (stream->status != XINE_STATUS_QUIT) stream->status = XINE_STATUS_STOP; - + /* * stop demux */ @@ -174,19 +174,14 @@ static void xine_stop_internal (xine_stream_t *stream) { finished_count_video = stream->finished_count_video + 1; pthread_mutex_unlock (&stream->counter_lock); -#ifdef LOG - printf ("xine_stop: stopping demux\n"); -#endif + lprintf ("stopping demux\n"); if (stream->demux_plugin) { xine_demux_stop_thread( stream ); -#ifdef LOG - printf ("xine_stop: stop thread done\n"); -#endif + lprintf ("stop thread done\n"); + xine_demux_flush_engine( stream ); -#ifdef LOG - printf ("xine_stop: flush engine done\n"); -#endif + lprintf ("flush engine done\n"); /* * wait until engine has really stopped @@ -195,22 +190,16 @@ static void xine_stop_internal (xine_stream_t *stream) { #if 0 pthread_mutex_lock (&stream->counter_lock); while ((stream->finished_count_audiofinished_count_videofinished_count_videocounter_changed, &stream->counter_lock); } pthread_mutex_unlock (&stream->counter_lock); #endif } -#ifdef LOG - printf ("xine_stop: demux stopped\n"); -#endif - -#ifdef LOG - printf ("xine_stop: done\n"); -#endif + lprintf ("demux stopped\n"); + lprintf ("done\n"); } void xine_stop (xine_stream_t *stream) { @@ -253,11 +242,8 @@ static void xine_close_internal (xine_stream_t *stream) { xine_stop_internal( stream ); -#ifdef LOG - printf ("xine_close: disposing demux\n"); -#endif + lprintf ("disposing demux\n"); if (stream->demux_plugin) { - stream->demux_plugin->dispose (stream->demux_plugin); stream->demux_plugin = NULL; } @@ -288,7 +274,7 @@ void xine_close (xine_stream_t *stream) { pthread_mutex_lock (&stream->frontend_lock); xine_close_internal (stream); - + pthread_mutex_unlock (&stream->frontend_lock); } @@ -297,10 +283,10 @@ static int xine_stream_rewire_audio(xine_post_out_t *output, void *data) xine_stream_t *stream = (xine_stream_t *)output->data; xine_audio_port_t *new_port = (xine_audio_port_t *)data; buf_element_t *buf; - + if (!data) return 0; - + pthread_mutex_lock(&stream->next_audio_port_lock); stream->next_audio_port = new_port; if (stream->audio_fifo && @@ -312,7 +298,7 @@ static int xine_stream_rewire_audio(xine_post_out_t *output, void *data) /* wait till rewiring is finished */ pthread_cond_wait(&stream->next_audio_port_wired, &stream->next_audio_port_lock); pthread_mutex_unlock(&stream->next_audio_port_lock); - + return 1; } @@ -321,10 +307,10 @@ static int xine_stream_rewire_video(xine_post_out_t *output, void *data) xine_stream_t *stream = (xine_stream_t *)output->data; xine_video_port_t *new_port = (xine_video_port_t *)data; buf_element_t *buf; - + if (!data) return 0; - + pthread_mutex_lock(&stream->next_video_port_lock); stream->next_video_port = new_port; if (stream->video_fifo && @@ -336,26 +322,25 @@ static int xine_stream_rewire_video(xine_post_out_t *output, void *data) /* wait till rewiring is finished */ pthread_cond_wait(&stream->next_video_port_wired, &stream->next_video_port_lock); pthread_mutex_unlock(&stream->next_video_port_lock); - + return 1; } -xine_stream_t *xine_stream_new (xine_t *this, +xine_stream_t *xine_stream_new (xine_t *this, xine_audio_port_t *ao, xine_video_port_t *vo) { xine_stream_t *stream; int i; - if (this->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("xine: xine_stream_new\n"); + xprintf (this, XINE_VERBOSITY_DEBUG, "xine_stream_new\n"); /* * create a new stream object */ pthread_mutex_lock (&this->streams_lock); - + stream = (xine_stream_t *) xine_xmalloc (sizeof (xine_stream_t)) ; stream->current_extra_info = malloc( sizeof( extra_info_t ) ); stream->audio_decoder_extra_info = malloc( sizeof( extra_info_t ) ); @@ -490,9 +475,7 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { const char *stream_setup; -#ifdef LOG - printf ("xine: xine_open_internal '%s'...\n", mrl); -#endif + lprintf ("opening MRL '%s'...\n", mrl); /* * stop engine if necessary @@ -500,9 +483,7 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { xine_close_internal (stream); -#ifdef LOG - printf ("xine: engine should be stopped now\n"); -#endif + lprintf ("engine should be stopped now\n"); /* * look for a stream_setup in MRL and try finding an input plugin @@ -619,9 +600,7 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { free(demux_name); return 0; } -#ifdef LOG - printf ("xine: demux and input plugin found\n"); -#endif + lprintf ("demux and input plugin found\n"); stream->meta_info[XINE_META_INFO_SYSTEMLAYER] = strdup (stream->demux_plugin->demux_class->get_identifier(stream->demux_plugin->demux_class)); @@ -644,8 +623,7 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { stream->status = XINE_STATUS_STOP; return 0; } - if (stream->xine->verbosity >= XINE_VERBOSITY_LOG) - printf("xine: ignoring video\n"); + xprintf (stream->xine, XINE_VERBOSITY_LOG, "ignoring video\n"); continue; } if (strncasecmp(stream_setup, "noaudio", 7) == 0) { @@ -658,8 +636,7 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { stream->status = XINE_STATUS_STOP; return 0; } - if (stream->xine->verbosity >= XINE_VERBOSITY_LOG) - printf("xine: ignoring audio\n"); + xprintf (stream->xine, XINE_VERBOSITY_LOG, "ignoring audio\n"); continue; } if (strncasecmp(stream_setup, "nospu", 5) == 0) { @@ -672,8 +649,7 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { stream->status = XINE_STATUS_STOP; return 0; } - if (stream->xine->verbosity >= XINE_VERBOSITY_LOG) - printf("xine: ignoring subpicture\n"); + xprintf (stream->xine, XINE_VERBOSITY_LOG, "ignoring subpicture\n"); continue; } if (strncasecmp(stream_setup, "volume", 6) == 0) { @@ -744,8 +720,7 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { stream->slave = xine_stream_new (stream->xine, NULL, stream->video_out ); stream->slave_affection = XINE_MASTER_SLAVE_PLAY | XINE_MASTER_SLAVE_STOP; if( xine_open( stream->slave, subtitle_mrl ) ) { - if (stream->xine->verbosity >= XINE_VERBOSITY_LOG) - printf("xine: subtitle mrl opened\n"); + xprintf (stream->xine, XINE_VERBOSITY_LOG, "subtitle mrl opened '%s'\n", subtitle_mrl); stream->slave->master = stream; stream->slave_is_subtitle = 1; } else { @@ -806,10 +781,7 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { return 0; } - -#ifdef LOG - printf ("xine: demux and input plugin found\n"); -#endif + lprintf ("demux and input plugin found\n"); stream->meta_info[XINE_META_INFO_SYSTEMLAYER] = strdup (stream->demux_plugin->demux_class->get_identifier(stream->demux_plugin->demux_class)); @@ -842,8 +814,7 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { stream->demux_plugin->dispose (stream->demux_plugin); stream->demux_plugin = NULL; - if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("xine: demux disposed\n"); + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "demux disposed\n"); stream->input_plugin->dispose (stream->input_plugin); stream->input_plugin = NULL; @@ -857,17 +828,13 @@ static int xine_open_internal (xine_stream_t *stream, const char *mrl) { stream->status = XINE_STATUS_STOP; - if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("xine: return from xine_open_internal\n"); - + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "return from\n"); return 0; } xine_demux_control_headers_done (stream); -#ifdef LOG - printf ("xine: xine_open_internal done\n"); -#endif + lprintf ("done\n"); return 1; } @@ -877,9 +844,7 @@ int xine_open (xine_stream_t *stream, const char *mrl) { pthread_mutex_lock (&stream->frontend_lock); -#ifdef LOG - printf ("xine: xine_open %s\n", mrl); -#endif + lprintf ("open MRL:%s\n", mrl); ret = xine_open_internal (stream, mrl); @@ -895,8 +860,7 @@ static int xine_play_internal (xine_stream_t *stream, int start_pos, int start_t off_t pos, len; int demux_status; - if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("xine: xine_play\n"); + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "xine_play\n"); if (stream->xine->clock->speed != XINE_SPEED_NORMAL) xine_set_speed_internal (stream, XINE_SPEED_NORMAL); @@ -988,8 +952,7 @@ static int xine_play_internal (xine_stream_t *stream, int start_pos, int start_t } pthread_mutex_unlock (&stream->first_frame_lock); - if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("xine: xine_play_internal ...done\n"); + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "xine_play_internal ...done\n"); return 1; } @@ -1033,8 +996,7 @@ int xine_eject (xine_stream_t *stream) { void xine_dispose (xine_stream_t *stream) { - if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("xine: xine_dispose\n"); + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "xine_dispose\n"); stream->status = XINE_STATUS_QUIT; @@ -1050,14 +1012,10 @@ void xine_dispose (xine_stream_t *stream) { if(stream->broadcaster) close_broadcaster(stream->broadcaster); - if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("xine_exit: shutdown audio\n"); - + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "shutdown audio\n"); audio_decoder_shutdown (stream); - if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("xine_exit: shutdown video\n"); - + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "shutdown video\n"); video_decoder_shutdown (stream); stream->osd_renderer->close( stream->osd_renderer ); @@ -1089,8 +1047,7 @@ void xine_exit (xine_t *this) { int i; - if (this->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("xine_exit: bye!\n"); + xprintf (this, XINE_VERBOSITY_DEBUG, "xine_exit: bye!\n"); for (i = 0; i < XINE_LOG_NUM; i++) this->log_buffers[i]->dispose (this->log_buffers[i]); @@ -1099,15 +1056,14 @@ void xine_exit (xine_t *this) { if(this->clock) this->clock->exit (this->clock); - + if(this->config) this->config->dispose(this->config); - + #if defined(WIN32) WSACleanup(); #endif - pthread_mutex_destroy(&this->streams_lock); free (this); @@ -1135,7 +1091,7 @@ xine_t *xine_new (void) { */ bindtextdomain("xine-lib", XINE_LOCALEDIR); -#endif +#endif /* * config @@ -1143,14 +1099,14 @@ xine_t *xine_new (void) { this->config = xine_config_init (); - /* - * log buffers + /* + * log buffers */ for (i = 0; i < XINE_LOG_NUM; i++) this->log_buffers[i] = new_scratch_buffer (25); - - + + #ifdef WIN32 /* WinSock Library Init. */ i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data ); @@ -1181,9 +1137,9 @@ void xine_engine_set_param(xine_t *this, int param, int value) { case XINE_ENGINE_PARAM_VERBOSITY: this->verbosity = value; break; - + default: - printf("Unknown parameter %d\n", param); + lprintf("Unknown parameter %d\n", param); break; } } @@ -1199,7 +1155,7 @@ int xine_engine_get_param(xine_t *this, int param) { break; default: - printf("Unknown parameter %d\n", param); + lprintf("Unknown parameter %d\n", param); break; } } @@ -1215,29 +1171,29 @@ void xine_init (xine_t *this) { /* probe for optimized memcpy or config setting */ xine_probe_fast_memcpy (this->config); - - /* + + /* * plugins */ - + scan_plugins(this); /* * content detection strategy */ - this->demux_strategy = this->config->register_enum (this->config, - "misc.demux_strategy", + this->demux_strategy = this->config->register_enum (this->config, + "misc.demux_strategy", 0, - demux_strategies, + demux_strategies, "media format detection strategy", NULL, 10, NULL, NULL); /* - * keep track of all opened streams + * keep track of all opened streams */ this->streams = xine_list_new(); - + /* * start metronom clock */ @@ -1266,9 +1222,7 @@ void xine_select_spu_channel (xine_stream_t *stream, int channel) { stream->spu_channel = stream->spu_channel_user; stream->video_out->enable_ovl (stream->video_out, 1); } -#ifdef LOG - printf("xine-lib:xine_select_spu_channel:set to %d\n",stream->spu_channel); -#endif + lprintf("set to %d\n",stream->spu_channel); pthread_mutex_unlock (&stream->frontend_lock); } @@ -1277,11 +1231,11 @@ static int xine_get_current_position (xine_stream_t *stream) { off_t len; double share; - + pthread_mutex_lock (&stream->frontend_lock); if (!stream->input_plugin) { - printf ("xine: xine_get_current_position: no input source\n"); + lprintf ("no input source\n"); pthread_mutex_unlock (&stream->frontend_lock); return -1; } @@ -1289,15 +1243,15 @@ static int xine_get_current_position (xine_stream_t *stream) { if ( (!stream->video_decoder_plugin && !stream->audio_decoder_plugin) ) { if( stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] ) extra_info_merge( stream->current_extra_info, stream->video_decoder_extra_info ); - else + else extra_info_merge( stream->current_extra_info, stream->audio_decoder_extra_info ); } - + if ( stream->current_extra_info->seek_count != stream->video_seek_count ) { pthread_mutex_unlock (&stream->frontend_lock); - return -1; /* position not yet known */ + return -1; /* position not yet known */ } - + pthread_mutex_lock( &stream->current_extra_info_lock ); len = stream->current_extra_info->input_length; share = (double) stream->current_extra_info->input_pos; @@ -1313,9 +1267,9 @@ static int xine_get_current_position (xine_stream_t *stream) { } void xine_get_current_info (xine_stream_t *stream, extra_info_t *extra_info, int size) { - + pthread_mutex_lock( &stream->current_extra_info_lock ); - memcpy( extra_info, stream->current_extra_info, size ); + memcpy( extra_info, stream->current_extra_info, size ); pthread_mutex_unlock( &stream->current_extra_info_lock ); } @@ -1325,20 +1279,19 @@ int xine_get_status (xine_stream_t *stream) { } /* - * trick play + * trick play */ void xine_set_speed (xine_stream_t *stream, int speed) { pthread_mutex_lock (&stream->frontend_lock); - if (speed <= XINE_SPEED_PAUSE) + if (speed <= XINE_SPEED_PAUSE) speed = XINE_SPEED_PAUSE; - else if (speed > XINE_SPEED_FAST_4) + else if (speed > XINE_SPEED_FAST_4) speed = XINE_SPEED_FAST_4; - if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG) - printf ("xine: set_speed %d\n", speed); + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "set_speed %d\n", speed); xine_set_speed_internal (stream, speed); pthread_mutex_unlock (&stream->frontend_lock); @@ -1358,12 +1311,12 @@ static int xine_get_stream_length (xine_stream_t *stream) { /* pthread_mutex_lock( &stream->demux_lock ); */ if (stream->demux_plugin) { - int len = stream->demux_plugin->get_stream_length (stream->demux_plugin); + int len = stream->demux_plugin->get_stream_length (stream->demux_plugin); /* pthread_mutex_unlock( &stream->demux_lock ); */ return len; } - + /* pthread_mutex_unlock( &stream->demux_lock ); */ return 0; @@ -1371,14 +1324,14 @@ static int xine_get_stream_length (xine_stream_t *stream) { int xine_get_pos_length (xine_stream_t *stream, int *pos_stream, int *pos_time, int *length_time) { - + int pos = xine_get_current_position (stream); /* force updating extra_info */ - + if (pos == -1) return 0; - + if (pos_stream) - *pos_stream = pos; + *pos_stream = pos; if (pos_time) { pthread_mutex_lock( &stream->current_extra_info_lock ); *pos_time = stream->current_extra_info->input_time; @@ -1409,33 +1362,33 @@ int xine_get_current_frame (xine_stream_t *stream, int *width, int *height, if (img){ switch (frame->format) { - + case XINE_IMGFMT_YV12: memcpy (img, frame->base[0], frame->width*frame->height); - memcpy (img+frame->width*frame->height, frame->base[1], + memcpy (img+frame->width*frame->height, frame->base[1], frame->width*frame->height/4); - memcpy (img+frame->width*frame->height+frame->width*frame->height/4, - frame->base[2], + memcpy (img+frame->width*frame->height+frame->width*frame->height/4, + frame->base[2], frame->width*frame->height/4); break; - + case XINE_IMGFMT_YUY2: memcpy (img, frame->base[0], frame->width * frame->height * 2); break; - + default: printf ("xine: error, snapshot function not implemented for format 0x%x\n", frame->format); abort (); } - } + } return 1; } int xine_get_video_frame (xine_stream_t *stream, int timestamp, /* msec */ int *width, int *height, - int *ratio_code, + int *ratio_code, int *duration, /* msec */ int *format, uint8_t *img) { @@ -1443,7 +1396,7 @@ int xine_get_video_frame (xine_stream_t *stream, pthread_mutex_lock (&stream->frontend_lock); - if (stream->status != XINE_STATUS_STOP) + if (stream->status != XINE_STATUS_STOP) xine_stop_internal (stream); if (stream->demux_plugin->get_video_frame) @@ -1453,7 +1406,7 @@ int xine_get_video_frame (xine_stream_t *stream, format, img); else ret = 0; - + pthread_mutex_unlock (&stream->frontend_lock); return ret; @@ -1472,7 +1425,7 @@ int xine_get_spu_lang (xine_stream_t *stream, int channel, char *lang) { DEMUX_OPTIONAL_DATA_SPULANG) == DEMUX_OPTIONAL_SUCCESS) return 1; } - } + } /* No match, check with input plugin instead (e.g. DVD gets this * info from the IFO). @@ -1485,7 +1438,7 @@ int xine_get_spu_lang (xine_stream_t *stream, int channel, char *lang) { INPUT_OPTIONAL_DATA_SPULANG) == INPUT_OPTIONAL_SUCCESS) return 1; } - } + } return 0; } @@ -1501,7 +1454,7 @@ int xine_get_audio_lang (xine_stream_t *stream, int channel, char *lang) { return 1; } } - + if (stream->input_plugin) { if (stream->input_plugin->get_capabilities (stream->input_plugin) & INPUT_CAP_AUDIOLANG) { /* pass the channel number to the plugin in the data field */ @@ -1510,7 +1463,7 @@ int xine_get_audio_lang (xine_stream_t *stream, int channel, char *lang) { INPUT_OPTIONAL_DATA_AUDIOLANG) == INPUT_OPTIONAL_SUCCESS) return 1; } - } + } return 0; } @@ -1534,10 +1487,10 @@ int xine_get_log_section_count (xine_t *this) { const char *const *xine_get_log_names (xine_t *this) { static const char *log_sections[XINE_LOG_NUM + 1]; - log_sections[XINE_LOG_MSG] = _("messages"); + log_sections[XINE_LOG_MSG] = _("messages"); log_sections[XINE_LOG_PLUGIN] = _("plugin"); log_sections[XINE_LOG_NUM] = NULL; - + return log_sections; } @@ -1560,10 +1513,10 @@ void xine_log (xine_t *this, int buf, const char *format, ...) { } const char *const *xine_get_log (xine_t *this, int buf) { - + if(buf >= XINE_LOG_NUM) return NULL; - + return this->log_buffers[buf]->get_content (this->log_buffers[buf]); } @@ -1588,8 +1541,8 @@ int xine_stream_master_slave(xine_stream_t *master, xine_stream_t *slave, master->slave = slave; master->slave_affection = affection; /* respect transitivity: if our designated master already has a master - * of its own, we point to this master's master; if our master is a + * of its own, we point to this master's master; if our master is a * standalone stream, its master pointer will point to itself */ slave->master = master->master; return 1; -} +} diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h index 337c12a8e..a53dddca4 100644 --- a/src/xine-utils/xineutils.h +++ b/src/xine-utils/xineutils.h @@ -1,5 +1,5 @@ -/* - * Copyright (C) 2000-2002 the xine project +/* + * Copyright (C) 2000-2003 the xine project * * This file is part of xine, a free video player. * @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xineutils.h,v 1.53 2003/06/13 23:05:35 komadori Exp $ + * $Id: xineutils.h,v 1.54 2003/06/20 20:57:29 andruil Exp $ * */ #ifndef XINEUTILS_H @@ -881,6 +881,78 @@ void xine_print_trace(void); #endif +/****** logging with xine **********************************/ + +#ifndef LOG_MODULE + #define LOG_MODULE __FILE__ +#endif /* LOG_MODULE */ + +#define LOG_MODULE_STRING printf("%s: ", LOG_MODULE ); + +#ifdef LOG_VERBOSE + #define LONG_LOG_MODULE_STRING \ + printf("%s: (%s:%d) ", LOG_MODULE, __XINE_FUNCTION__, __LINE__ ); +#else + #define LONG_LOG_MODULE_STRING LOG_MODULE_STRING +#endif /* LOG_VERBOSE */ + +#ifdef LOG + #ifdef __GNUC__ + #define lprintf(fmt, args...) \ + do{ \ + LONG_LOG_MODULE_STRING \ + printf( fmt, ##args ); \ + }while(0) + #else + #define lprintf(fmt, ...) \ + do{ \ + LONG_LOG_MODULE_STRING \ + printf( fmt, __VA_ARGS__ ); \ + }while(0) + #endif /* __GNUC__ */ +#else + #ifdef __GNUC__ + #define lprintf(fmt, args...) ; + #else + #define lprintf(fmt, ...) ; + #endif /* __GNUC__ */ +#endif /* LOG */ + +#ifdef __GNUC__ + #define llprintf(cat, fmt, args...) \ + do{ \ + if(cat){ \ + LONG_LOG_MODULE_STRING \ + printf( fmt, ##args ); \ + } \ + }while(0) +#else + #define llprintf(cat, fmt, ...) \ + do{ \ + if(cat){ \ + LONG_LOG_MODULE_STRING \ + printf( fmt, __VA_ARGS__ ); \ + } \ + }while(0) +#endif /* __GNUC__ */ + +#ifdef __GNUC__ + #define xprintf(xine, verbose, fmt, args...) \ + do { \ + if((xine)->verbosity >= verbose){ \ + LOG_MODULE_STRING \ + printf(fmt, ##args); \ + } \ + } while(0) +#else + #define xprintf(xine, verbose, fmt, ...) \ + do { \ + if((xine)->verbosity >= verbose){ \ + LOG_MODULE_STRING \ + printf(fmt, __VA_ARGS__); \ + } \ + } while(0) +#endif /* __GNUC__ */ /******** double chained lists with builtin iterator *******/ -- cgit v1.2.3