fna-workbench

fna-workbench Git Source Tree


Root/src/Audio/NullDevice.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#region License
/* FNA - XNA4 Reimplementation for Desktop Platforms
 * Copyright 2009-2016 Ethan Lee and the MonoGame Team
 *
 * Released under the Microsoft Public License.
 * See LICENSE for details.
 */
#endregion
 
#region Using Statements
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
#endregion
 
namespace Microsoft.Xna.Framework.Audio
{
    /* This is a device that deliberately does as little as possible, allowing
     * for no sound without throwing NoAudioHardwareExceptions. This is not a
     * part of the XNA4 spec, however, so behavior here is entirely undefined!
     * -flibit
     */
    internal class NullDevice : IALDevice
    {
        private class NullBuffer : IALBuffer
        {
            public TimeSpan Duration
            {
                get
                {
                    // FIXME: Maybe read the PCM/ADPCM lengths? -flibit
                    return TimeSpan.Zero;
                }
            }
        }
 
        private class NullSource : IALSource
        {
        }
 
        private class NullReverb : IALReverb
        {
        }
 
        public void Update()
        {
            // No-op, duh.
        }
 
        public void Dispose()
        {
            // No-op, duh.
        }
 
        public ReadOnlyCollection<RendererDetail> GetDevices()
        {
            return new ReadOnlyCollection<RendererDetail>(
                new List<RendererDetail>()
            );
        }
 
        public ReadOnlyCollection<Microphone> GetCaptureDevices()
        {
            return new ReadOnlyCollection<Microphone>(
                new List<Microphone>()
            );
        }
 
        public IALBuffer GenBuffer()
        {
            return new NullBuffer();
        }
 
        public IALBuffer GenBuffer(
            byte[] data,
            uint sampleRate,
            uint channels,
            uint loopStart,
            uint loopEnd,
            bool isADPCM,
            uint formatParameter
        ) {
            return new NullBuffer();
        }
 
        public void DeleteBuffer(IALBuffer buffer)
        {
            // No-op, duh.
        }
 
        public void SetBufferData(
            IALBuffer buffer,
            AudioChannels channels,
            byte[] data,
            int offset,
            int count,
            int sampleRate
        ) {
            // No-op, duh.
        }
 
        public void SetBufferData(
            IALBuffer buffer,
            AudioChannels channels,
            float[] data,
            int offset,
            int count,
            int sampleRate
        ) {
            // No-op, duh.
        }
 
        public IALSource GenSource()
        {
            return new NullSource();
        }
 
        public IALSource GenSource(IALBuffer buffer)
        {
            return new NullSource();
        }
 
        public void StopAndDisposeSource(IALSource source)
        {
            // No-op, duh.
        }
 
        public void PlaySource(IALSource source)
        {
            // No-op, duh.
        }
 
        public void PauseSource(IALSource source)
        {
            // No-op, duh.
        }
 
        public void ResumeSource(IALSource source)
        {
            // No-op, duh.
        }
 
        public SoundState GetSourceState(IALSource source)
        {
            /* FIXME: This return value is highly volatile!
             * You can't necessarily do Stopped, because then stuff like Song
             * explodes, but SoundState.Playing doesn't make a whole lot of
             * sense either. This at least prevents annoyances like Song errors
             * from happening and, for the most part, claims to be "playing"
             * depending on how you ask for a source's state.
             * -flibit
             */
            return SoundState.Paused;
        }
 
        public void SetSourceVolume(IALSource source, float volume)
        {
            // No-op, duh.
        }
 
        public void SetSourceLooped(IALSource source, bool looped)
        {
            // No-op, duh.
        }
 
        public void SetSourcePan(IALSource source, float pan)
        {
            // No-op, duh.
        }
 
        public void SetSourcePosition(IALSource source, Vector3 pos)
        {
            // No-op, duh.
        }
 
        public void SetSourcePitch(IALSource source, float pitch, bool clamp)
        {
            // No-op, duh.
        }
 
        public void SetSourceReverb(IALSource source, IALReverb reverb)
        {
            // No-op, duh.
        }
 
        public void SetSourceLowPassFilter(IALSource source, float hfGain)
        {
            // No-op, duh.
        }
 
        public void SetSourceHighPassFilter(IALSource source, float lfGain)
        {
            // No-op, duh.
        }
 
        public void SetSourceBandPassFilter(IALSource source, float hfGain, float lfGain)
        {
            // No-op, duh.
        }
 
        public void QueueSourceBuffer(IALSource source, IALBuffer buffer)
        {
            // No-op, duh.
        }
 
        public void DequeueSourceBuffers(
            IALSource source,
            int buffersToDequeue,
            Queue<IALBuffer> errorCheck
        ) {
            // No-op, duh.
        }
 
        public int CheckProcessedBuffers(IALSource source)
        {
            return 0;
        }
 
        public void GetBufferData(
            IALSource source,
            IALBuffer[] buffer,
            float[] samples,
            AudioChannels channels
        ) {
            // No-op, duh.
        }
 
        public IALReverb GenReverb(DSPParameter[] parameters)
        {
            return new NullReverb();
        }
 
        public void DeleteReverb(IALReverb reverb)
        {
            // No-op, duh.
        }
 
        public void CommitReverbChanges(IALReverb reverb)
        {
            // No-op, duh.
        }
 
        public void SetReverbReflectionsDelay(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbDelay(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbPositionLeft(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbPositionRight(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbPositionLeftMatrix(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbPositionRightMatrix(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbEarlyDiffusion(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbLateDiffusion(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbLowEQGain(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbLowEQCutoff(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbHighEQGain(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbHighEQCutoff(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbRearDelay(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbRoomFilterFrequency(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbRoomFilterMain(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbRoomFilterHighFrequency(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbReflectionsGain(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbGain(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbDecayTime(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbDensity(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbRoomSize(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public void SetReverbWetDryMix(IALReverb reverb, float value)
        {
            // No-op, duh.
        }
 
        public IntPtr StartDeviceCapture(string name, int sampleRate, int bufSize)
        {
            return IntPtr.Zero;
        }
 
        public void StopDeviceCapture(IntPtr handle)
        {
            // No-op, duh.
        }
 
        public int CaptureSamples(IntPtr handle, IntPtr buffer, int count)
        {
            return 0;
        }
 
        public bool CaptureHasSamples(IntPtr handle)
        {
            return false;
        }
    }
}

Archive Download this file

Branches

Number of commits:
Page rendered in 0.11924s using 11 queries.