~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject/third_party/portaudio/src/hostapi/dsound/pa_win_ds_dynlink.c

  • Committer: Jackson Doak
  • Date: 2013-07-10 21:04:46 UTC
  • mfrom: (20.1.3 sid)
  • Revision ID: noskcaj@ubuntu.com-20130710210446-y8f587vza807icr9
Properly merged from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Interface for dynamically loading directsound and providing a dummy
3
 
 * implementation if it isn't present.
4
 
 *
5
 
 * Author: Ross Bencina (some portions Phil Burk & Robert Marsanyi)
6
 
 *
7
 
 * For PortAudio Portable Real-Time Audio Library
8
 
 * For more information see: http://www.portaudio.com
9
 
 * Copyright (c) 1999-2006 Phil Burk, Robert Marsanyi and Ross Bencina
10
 
 *
11
 
 * Permission is hereby granted, free of charge, to any person obtaining
12
 
 * a copy of this software and associated documentation files
13
 
 * (the "Software"), to deal in the Software without restriction,
14
 
 * including without limitation the rights to use, copy, modify, merge,
15
 
 * publish, distribute, sublicense, and/or sell copies of the Software,
16
 
 * and to permit persons to whom the Software is furnished to do so,
17
 
 * subject to the following conditions:
18
 
 *
19
 
 * The above copyright notice and this permission notice shall be
20
 
 * included in all copies or substantial portions of the Software.
21
 
 *
22
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
 
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
 
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25
 
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26
 
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27
 
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
 
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
 
 */
30
 
 
31
 
/*
32
 
 * The text above constitutes the entire PortAudio license; however, 
33
 
 * the PortAudio community also makes the following non-binding requests:
34
 
 *
35
 
 * Any person wishing to distribute modifications to the Software is
36
 
 * requested to send the modifications to the original developer so that
37
 
 * they can be incorporated into the canonical version. It is also 
38
 
 * requested that these non-binding requests be included along with the 
39
 
 * license above.
40
 
 */
41
 
 
42
 
/**
43
 
 @file
44
 
 @ingroup hostapi_src
45
 
*/
46
 
 
47
 
#include "pa_win_ds_dynlink.h"
48
 
 
49
 
PaWinDsDSoundEntryPoints paWinDsDSoundEntryPoints = { 0, 0, 0, 0, 0, 0, 0 };
50
 
 
51
 
 
52
 
static HRESULT WINAPI DummyDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
53
 
{
54
 
    (void)rclsid; /* unused parameter */
55
 
    (void)riid; /* unused parameter */
56
 
    (void)ppv; /* unused parameter */
57
 
    return CLASS_E_CLASSNOTAVAILABLE;
58
 
}
59
 
 
60
 
static HRESULT WINAPI DummyDirectSoundCreate(LPGUID lpcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter)
61
 
{
62
 
    (void)lpcGuidDevice; /* unused parameter */
63
 
    (void)ppDS; /* unused parameter */
64
 
    (void)pUnkOuter; /* unused parameter */
65
 
    return E_NOTIMPL;
66
 
}
67
 
 
68
 
static HRESULT WINAPI DummyDirectSoundEnumerateW(LPDSENUMCALLBACKW lpDSEnumCallback, LPVOID lpContext)
69
 
{
70
 
    (void)lpDSEnumCallback; /* unused parameter */
71
 
    (void)lpContext; /* unused parameter */
72
 
    return E_NOTIMPL;
73
 
}
74
 
 
75
 
static HRESULT WINAPI DummyDirectSoundEnumerateA(LPDSENUMCALLBACKA lpDSEnumCallback, LPVOID lpContext)
76
 
{
77
 
    (void)lpDSEnumCallback; /* unused parameter */
78
 
    (void)lpContext; /* unused parameter */
79
 
    return E_NOTIMPL;
80
 
}
81
 
 
82
 
static HRESULT WINAPI DummyDirectSoundCaptureCreate(LPGUID lpcGUID, LPDIRECTSOUNDCAPTURE *lplpDSC, LPUNKNOWN pUnkOuter)
83
 
{
84
 
    (void)lpcGUID; /* unused parameter */
85
 
    (void)lplpDSC; /* unused parameter */
86
 
    (void)pUnkOuter; /* unused parameter */
87
 
    return E_NOTIMPL;
88
 
}
89
 
 
90
 
static HRESULT WINAPI DummyDirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW lpDSCEnumCallback, LPVOID lpContext)
91
 
{
92
 
    (void)lpDSCEnumCallback; /* unused parameter */
93
 
    (void)lpContext; /* unused parameter */
94
 
    return E_NOTIMPL;
95
 
}
96
 
 
97
 
static HRESULT WINAPI DummyDirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA lpDSCEnumCallback, LPVOID lpContext)
98
 
{
99
 
    (void)lpDSCEnumCallback; /* unused parameter */
100
 
    (void)lpContext; /* unused parameter */
101
 
    return E_NOTIMPL;
102
 
}
103
 
 
104
 
 
105
 
void PaWinDs_InitializeDSoundEntryPoints(void)
106
 
{
107
 
    paWinDsDSoundEntryPoints.hInstance_ = LoadLibrary("dsound.dll");
108
 
    if( paWinDsDSoundEntryPoints.hInstance_ != NULL )
109
 
    {
110
 
        paWinDsDSoundEntryPoints.DllGetClassObject =
111
 
                (HRESULT (WINAPI *)(REFCLSID, REFIID , LPVOID *))
112
 
                GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DllGetClassObject" );
113
 
        if( paWinDsDSoundEntryPoints.DllGetClassObject == NULL )
114
 
            paWinDsDSoundEntryPoints.DllGetClassObject = DummyDllGetClassObject;
115
 
 
116
 
        paWinDsDSoundEntryPoints.DirectSoundCreate =
117
 
                (HRESULT (WINAPI *)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN))
118
 
                GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCreate" );
119
 
        if( paWinDsDSoundEntryPoints.DirectSoundCreate == NULL )
120
 
            paWinDsDSoundEntryPoints.DirectSoundCreate = DummyDirectSoundCreate;
121
 
 
122
 
        paWinDsDSoundEntryPoints.DirectSoundEnumerateW =
123
 
                (HRESULT (WINAPI *)(LPDSENUMCALLBACKW, LPVOID))
124
 
                GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundEnumerateW" );
125
 
        if( paWinDsDSoundEntryPoints.DirectSoundEnumerateW == NULL )
126
 
            paWinDsDSoundEntryPoints.DirectSoundEnumerateW = DummyDirectSoundEnumerateW;
127
 
 
128
 
        paWinDsDSoundEntryPoints.DirectSoundEnumerateA =
129
 
                (HRESULT (WINAPI *)(LPDSENUMCALLBACKA, LPVOID))
130
 
                GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundEnumerateA" );
131
 
        if( paWinDsDSoundEntryPoints.DirectSoundEnumerateA == NULL )
132
 
            paWinDsDSoundEntryPoints.DirectSoundEnumerateA = DummyDirectSoundEnumerateA;
133
 
 
134
 
        paWinDsDSoundEntryPoints.DirectSoundCaptureCreate =
135
 
                (HRESULT (WINAPI *)(LPGUID, LPDIRECTSOUNDCAPTURE *, LPUNKNOWN))
136
 
                GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureCreate" );
137
 
        if( paWinDsDSoundEntryPoints.DirectSoundCaptureCreate == NULL )
138
 
            paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = DummyDirectSoundCaptureCreate;
139
 
 
140
 
        paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW =
141
 
                (HRESULT (WINAPI *)(LPDSENUMCALLBACKW, LPVOID))
142
 
                GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureEnumerateW" );
143
 
        if( paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW == NULL )
144
 
            paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = DummyDirectSoundCaptureEnumerateW;
145
 
 
146
 
        paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA =
147
 
                (HRESULT (WINAPI *)(LPDSENUMCALLBACKA, LPVOID))
148
 
                GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureEnumerateA" );
149
 
        if( paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA == NULL )
150
 
            paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = DummyDirectSoundCaptureEnumerateA;
151
 
    }
152
 
    else
153
 
    {
154
 
        /* initialize with dummy entry points to make live easy when ds isn't present */
155
 
        paWinDsDSoundEntryPoints.DirectSoundCreate = DummyDirectSoundCreate;
156
 
        paWinDsDSoundEntryPoints.DirectSoundEnumerateW = DummyDirectSoundEnumerateW;
157
 
        paWinDsDSoundEntryPoints.DirectSoundEnumerateA = DummyDirectSoundEnumerateA;
158
 
        paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = DummyDirectSoundCaptureCreate;
159
 
        paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = DummyDirectSoundCaptureEnumerateW;
160
 
        paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = DummyDirectSoundCaptureEnumerateA;
161
 
    }
162
 
}
163
 
 
164
 
 
165
 
void PaWinDs_TerminateDSoundEntryPoints(void)
166
 
{
167
 
    if( paWinDsDSoundEntryPoints.hInstance_ != NULL )
168
 
    {
169
 
        /* ensure that we crash reliably if the entry points arent initialised */
170
 
        paWinDsDSoundEntryPoints.DirectSoundCreate = 0;
171
 
        paWinDsDSoundEntryPoints.DirectSoundEnumerateW = 0;
172
 
        paWinDsDSoundEntryPoints.DirectSoundEnumerateA = 0;
173
 
        paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = 0;
174
 
        paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = 0;
175
 
        paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = 0;
176
 
 
177
 
        FreeLibrary( paWinDsDSoundEntryPoints.hInstance_ );
178
 
        paWinDsDSoundEntryPoints.hInstance_ = NULL;
179
 
    }
180
 
}
 
 
b'\\ No newline at end of file'