1 | /* |
---|
2 | * null output. Context writes, we sleep. |
---|
3 | */ |
---|
4 | #include "al_siteconfig.h" |
---|
5 | |
---|
6 | #include <AL/al.h> |
---|
7 | #include <fcntl.h> |
---|
8 | #include <stdio.h> |
---|
9 | #include <stdlib.h> |
---|
10 | #include <string.h> |
---|
11 | #include <sys/stat.h> |
---|
12 | #include <sys/time.h> |
---|
13 | #include <sys/types.h> |
---|
14 | #include <unistd.h> |
---|
15 | |
---|
16 | #include "al_main.h" |
---|
17 | #include "al_debug.h" |
---|
18 | |
---|
19 | #include "backends/alc_backend.h" |
---|
20 | |
---|
21 | static void *bogus_handle = (void *) 0x4ABAD1; |
---|
22 | static ALuint sleep_usec (ALuint speed, ALuint chunk); |
---|
23 | static ALint nullspeed; |
---|
24 | |
---|
25 | static void * |
---|
26 | grab_write_null (void) |
---|
27 | { |
---|
28 | return bogus_handle; |
---|
29 | } |
---|
30 | |
---|
31 | static void * |
---|
32 | grab_read_null (void) |
---|
33 | { |
---|
34 | return NULL; |
---|
35 | } |
---|
36 | |
---|
37 | void * |
---|
38 | alcBackendOpenNull_ (ALC_OpenMode mode) |
---|
39 | { |
---|
40 | return mode == ALC_OPEN_INPUT_ ? grab_read_null () : grab_write_null (); |
---|
41 | } |
---|
42 | |
---|
43 | static ALboolean |
---|
44 | set_write_null (UNUSED (void *handle), UNUSED (ALuint *bufsiz), |
---|
45 | UNUSED (ALenum *fmt), ALuint *speed) |
---|
46 | { |
---|
47 | nullspeed = *speed; |
---|
48 | return AL_TRUE; |
---|
49 | } |
---|
50 | |
---|
51 | static ALboolean |
---|
52 | set_read_null (UNUSED (void *handle), UNUSED (ALuint *bufsiz), |
---|
53 | UNUSED (ALenum *fmt), UNUSED (ALuint *speed)) |
---|
54 | { |
---|
55 | |
---|
56 | return AL_TRUE; |
---|
57 | } |
---|
58 | |
---|
59 | ALboolean |
---|
60 | alcBackendSetAttributesNull_ (ALC_OpenMode mode, void *handle, ALuint *bufsiz, |
---|
61 | ALenum *fmt, ALuint *speed) |
---|
62 | { |
---|
63 | return mode == ALC_OPEN_INPUT_ ? |
---|
64 | set_read_null (handle, bufsiz, fmt, speed) : |
---|
65 | set_write_null (handle, bufsiz, fmt, speed); |
---|
66 | } |
---|
67 | |
---|
68 | void |
---|
69 | null_blitbuffer (UNUSED (void *handle), |
---|
70 | UNUSED (void *dataptr), int bytes_to_write) |
---|
71 | { |
---|
72 | _alMicroSleep (sleep_usec (nullspeed, bytes_to_write)); |
---|
73 | } |
---|
74 | |
---|
75 | void |
---|
76 | release_null (UNUSED (void *handle)) |
---|
77 | { |
---|
78 | } |
---|
79 | |
---|
80 | static ALuint |
---|
81 | sleep_usec (ALuint speed, ALuint chunk) |
---|
82 | { |
---|
83 | return 1000000.0 * chunk / speed; |
---|
84 | } |
---|
85 | |
---|
86 | void |
---|
87 | pause_null (UNUSED (void *handle)) |
---|
88 | { |
---|
89 | } |
---|
90 | |
---|
91 | void |
---|
92 | resume_null (UNUSED (void *handle)) |
---|
93 | { |
---|
94 | } |
---|
95 | |
---|
96 | ALsizei |
---|
97 | capture_null (UNUSED (void *handle), UNUSED (void *capture_buffer), |
---|
98 | UNUSED (int bufsiz)) |
---|
99 | { |
---|
100 | return 0; |
---|
101 | } |
---|
102 | |
---|
103 | ALfloat |
---|
104 | get_nullchannel (UNUSED (void *handle), UNUSED (ALuint channel)) |
---|
105 | { |
---|
106 | return 0.0; |
---|
107 | } |
---|
108 | |
---|
109 | int |
---|
110 | set_nullchannel (UNUSED (void *handle), UNUSED (ALuint channel), |
---|
111 | UNUSED (ALfloat volume)) |
---|
112 | { |
---|
113 | return 0; |
---|
114 | } |
---|