~ubuntu-branches/ubuntu/trusty/vdpau-video/trusty-proposed

« back to all changes in this revision

Viewing changes to src/debug.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-09-22 11:35:45 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20110922113545-037dkroelik2be0y
Tags: 0.7.3-0ubuntu1
New upstream version, fix FTBFS with libav 0.7. Closes: #614485, LP: #756021.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *  debug.c - Debugging utilities
3
3
 *
4
 
 *  vdpau-video (C) 2009-2010 Splitted-Desktop Systems
 
4
 *  vdpau-video (C) 2009-2011 Splitted-Desktop Systems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
23
23
#include "utils.h"
24
24
#include <stdarg.h>
25
25
 
 
26
static void do_vfprintf(FILE *fp, const char *msg, va_list args)
 
27
{
 
28
    /* XXX: use another printf() function, e.g. a valgrind one to
 
29
       maintain correct control flow */
 
30
    vfprintf(fp, msg, args);
 
31
}
 
32
 
 
33
static void do_fprintf(FILE *fp, const char *msg, ...)
 
34
{
 
35
    va_list args;
 
36
 
 
37
    va_start(args, msg);
 
38
    do_vfprintf(fp, msg, args);
 
39
    va_end(args);
 
40
}
 
41
 
26
42
void vdpau_error_message(const char *msg, ...)
27
43
{
28
44
    va_list args;
29
45
 
30
 
    fprintf(stderr, "%s: error: ", PACKAGE_NAME);
 
46
    do_fprintf(stderr, "%s: error: ", PACKAGE_NAME);
31
47
    va_start(args, msg);
32
 
    vfprintf(stderr, msg, args);
 
48
    do_vfprintf(stderr, msg, args);
33
49
    va_end(args);
34
50
}
35
51
 
37
53
{
38
54
    va_list args;
39
55
 
40
 
    fprintf(stderr, "%s: ", PACKAGE_NAME);
41
 
    va_start(args, msg);
42
 
    vfprintf(stderr, msg, args);
 
56
    do_fprintf(stdout, "%s: ", PACKAGE_NAME);
 
57
    va_start(args, msg);
 
58
    do_vfprintf(stdout, msg, args);
 
59
    va_end(args);
 
60
}
 
61
 
 
62
static int debug_enabled(void)
 
63
{
 
64
    static int g_debug_enabled = -1;
 
65
    if (g_debug_enabled < 0) {
 
66
        if (getenv_yesno("VDPAU_VIDEO_DEBUG", &g_debug_enabled) < 0)
 
67
            g_debug_enabled = 0;
 
68
    }
 
69
    return g_debug_enabled;
 
70
}
 
71
 
 
72
void debug_message(const char *msg, ...)
 
73
{
 
74
    va_list args;
 
75
 
 
76
    if (!debug_enabled())
 
77
        return;
 
78
 
 
79
    do_fprintf(stdout, "%s: ", PACKAGE_NAME);
 
80
    va_start(args, msg);
 
81
    do_vfprintf(stdout, msg, args);
43
82
    va_end(args);
44
83
}
45
84