Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/openal-0.0.8/src/backends/alc_backend_null.c @ 17

Last change on this file since 17 was 17, checked in by landauf, 16 years ago

added openal

File size: 2.0 KB
Line 
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
21static void *bogus_handle = (void *) 0x4ABAD1;
22static ALuint sleep_usec (ALuint speed, ALuint chunk);
23static ALint nullspeed;
24
25static void *
26grab_write_null (void)
27{
28  return bogus_handle;
29}
30
31static void *
32grab_read_null (void)
33{
34  return NULL;
35}
36
37void *
38alcBackendOpenNull_ (ALC_OpenMode mode)
39{
40  return mode == ALC_OPEN_INPUT_ ? grab_read_null () : grab_write_null ();
41}
42
43static ALboolean
44set_write_null (UNUSED (void *handle), UNUSED (ALuint *bufsiz),
45                UNUSED (ALenum *fmt), ALuint *speed)
46{
47  nullspeed = *speed;
48  return AL_TRUE;
49}
50
51static ALboolean
52set_read_null (UNUSED (void *handle), UNUSED (ALuint *bufsiz),
53               UNUSED (ALenum *fmt), UNUSED (ALuint *speed))
54{
55
56  return AL_TRUE;
57}
58
59ALboolean
60alcBackendSetAttributesNull_ (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
68void
69null_blitbuffer (UNUSED (void *handle),
70                 UNUSED (void *dataptr), int bytes_to_write)
71{
72  _alMicroSleep (sleep_usec (nullspeed, bytes_to_write));
73}
74
75void
76release_null (UNUSED (void *handle))
77{
78}
79
80static ALuint
81sleep_usec (ALuint speed, ALuint chunk)
82{
83  return 1000000.0 * chunk / speed;
84}
85
86void
87pause_null (UNUSED (void *handle))
88{
89}
90
91void
92resume_null (UNUSED (void *handle))
93{
94}
95
96ALsizei
97capture_null (UNUSED (void *handle), UNUSED (void *capture_buffer),
98              UNUSED (int bufsiz))
99{
100  return 0;
101}
102
103ALfloat
104get_nullchannel (UNUSED (void *handle), UNUSED (ALuint channel))
105{
106  return 0.0;
107}
108
109int
110set_nullchannel (UNUSED (void *handle), UNUSED (ALuint channel),
111                 UNUSED (ALfloat volume))
112{
113  return 0;
114}
Note: See TracBrowser for help on using the repository browser.