~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.1.0/third_party/portaudio/src/common/pa_debugprint.c

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: pa_log.c $
 
3
 * Portable Audio I/O Library Multi-Host API front end
 
4
 * Validate function parameters and manage multiple host APIs.
 
5
 *
 
6
 * Based on the Open Source API proposed by Ross Bencina
 
7
 * Copyright (c) 1999-2006 Ross Bencina, Phil Burk
 
8
 *
 
9
 * Permission is hereby granted, free of charge, to any person obtaining
 
10
 * a copy of this software and associated documentation files
 
11
 * (the "Software"), to deal in the Software without restriction,
 
12
 * including without limitation the rights to use, copy, modify, merge,
 
13
 * publish, distribute, sublicense, and/or sell copies of the Software,
 
14
 * and to permit persons to whom the Software is furnished to do so,
 
15
 * subject to the following conditions:
 
16
 *
 
17
 * The above copyright notice and this permission notice shall be
 
18
 * included in all copies or substantial portions of the Software.
 
19
 *
 
20
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
21
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
22
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
23
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
 
24
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 
25
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
26
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
27
 */
 
28
 
 
29
/*
 
30
 * The text above constitutes the entire PortAudio license; however,
 
31
 * the PortAudio community also makes the following non-binding requests:
 
32
 *
 
33
 * Any person wishing to distribute modifications to the Software is
 
34
 * requested to send the modifications to the original developer so that
 
35
 * they can be incorporated into the canonical version. It is also
 
36
 * requested that these non-binding requests be included along with the
 
37
 * license above.
 
38
 */
 
39
 
 
40
/** @file
 
41
 @ingroup common_src
 
42
 
 
43
 @brief Implements log function.
 
44
 
 
45
    PaUtil_SetLogPrintFunction can be user called to replace the provided
 
46
        DefaultLogPrint function, which writes to stderr.
 
47
        One can NOT pass var_args across compiler/dll boundaries as it is not
 
48
        "byte code/abi portable". So the technique used here is to allocate a local
 
49
        a static array, write in it, then callback the user with a pointer to its
 
50
        start.
 
51
 
 
52
    @todo Consider allocating strdump using dynamic allocation.
 
53
    @todo Consider reentrancy and possibly corrupted strdump buffer.
 
54
*/
 
55
 
 
56
 
 
57
#include <stdio.h>
 
58
#include <stdarg.h>
 
59
 
 
60
#include "pa_debugprint.h"
 
61
 
 
62
 
 
63
 
 
64
static PaUtilLogCallback userCB=0;
 
65
 
 
66
 
 
67
void PaUtil_SetDebugPrintFunction(PaUtilLogCallback cb)
 
68
{
 
69
    userCB = cb;
 
70
}
 
71
 
 
72
/*
 
73
 If your platform doesn�t have vsnprintf, you are stuck with a
 
74
 VERY dangerous alternative, vsprintf (with no n)
 
75
 */
 
76
 
 
77
#if _MSC_VER
 
78
/* Some Windows Mobile SDKs don't define vsnprintf but all define _vsnprintf (hopefully).
 
79
   According to MSDN "vsnprintf is identical to _vsnprintf". So we use _vsnprintf with MSC.
 
80
*/
 
81
#define VSNPRINTF  _vsnprintf 
 
82
#else
 
83
#define VSNPRINTF  vsnprintf
 
84
#endif
 
85
 
 
86
#define SIZEDUMP 1024
 
87
 
 
88
static char strdump[SIZEDUMP];
 
89
 
 
90
void PaUtil_DebugPrint( const char *format, ... )
 
91
{
 
92
 
 
93
    if (userCB)
 
94
    {
 
95
        va_list ap;
 
96
        va_start( ap, format );
 
97
        VSNPRINTF( strdump, SIZEDUMP, format, ap );
 
98
        userCB(strdump);
 
99
        va_end( ap ); 
 
100
    }
 
101
    else
 
102
    {
 
103
        va_list ap;
 
104
        va_start( ap, format );
 
105
        vfprintf( stderr, format, ap );
 
106
        va_end( ap );
 
107
        fflush( stderr );
 
108
    }
 
109
 
 
110
}