ddraw: Remove some unused structure definitions in the private ddraw header.
[wine] / dlls / wineoss.drv / audio.h
1 /*
2  * Sample Wine Driver for Open Sound System (featured in Linux and FreeBSD)
3  *
4  * Copyright 1994 Martin Ayotte
5  *           1999 Eric Pouech (async playing in waveOut/waveIn)
6  *           2000 Eric Pouech (loops in waveOut)
7  *           2002 Eric Pouech (full duplex)
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23
24 #ifndef __WINE_CONFIG_H
25 # error You must include config.h to use this header
26 #endif
27
28 /* unless someone makes a wineserver kernel module, Unix pipes are faster than win32 events */
29 #define USE_PIPE_SYNC
30
31 #define MAX_WAVEDRV     (6)
32 #define MAX_CHANNELS    6
33
34 /* states of the playing device */
35 #define WINE_WS_PLAYING         0
36 #define WINE_WS_PAUSED          1
37 #define WINE_WS_STOPPED         2
38 #define WINE_WS_CLOSED          3
39
40 /* events to be send to device */
41 enum win_wm_message {
42     WINE_WM_PAUSING = WM_USER + 1, WINE_WM_RESTARTING, WINE_WM_RESETTING, WINE_WM_HEADER,
43     WINE_WM_UPDATE, WINE_WM_BREAKLOOP, WINE_WM_CLOSING, WINE_WM_STARTING, WINE_WM_STOPPING
44 };
45
46 #ifdef USE_PIPE_SYNC
47 #define SIGNAL_OMR(omr) do { int x = 0; write((omr)->msg_pipe[1], &x, sizeof(x)); } while (0)
48 #define CLEAR_OMR(omr) do { int x = 0; read((omr)->msg_pipe[0], &x, sizeof(x)); } while (0)
49 #define RESET_OMR(omr) do { } while (0)
50 #define WAIT_OMR(omr, sleep) \
51   do { struct pollfd pfd; pfd.fd = (omr)->msg_pipe[0]; \
52        pfd.events = POLLIN; poll(&pfd, 1, sleep); } while (0)
53 #else
54 #define SIGNAL_OMR(omr) do { SetEvent((omr)->msg_event); } while (0)
55 #define CLEAR_OMR(omr) do { } while (0)
56 #define RESET_OMR(omr) do { ResetEvent((omr)->msg_event); } while (0)
57 #define WAIT_OMR(omr, sleep) \
58   do { WaitForSingleObject((omr)->msg_event, sleep); } while (0)
59 #endif
60
61 typedef struct {
62     enum win_wm_message         msg;    /* message identifier */
63     DWORD_PTR                   param;  /* parameter for this message */
64     HANDLE                      hEvent; /* if message is synchronous, handle of event for synchro */
65 } OSS_MSG;
66
67 /* implement an in-process message ring for better performance
68  * (compared to passing thru the server)
69  * this ring will be used by the input (resp output) record (resp playback) routine
70  */
71 #define OSS_RING_BUFFER_INCREMENT       64
72 typedef struct {
73     int                         ring_buffer_size;
74     OSS_MSG                     * messages;
75     int                         msg_tosave;
76     int                         msg_toget;
77 #ifdef USE_PIPE_SYNC
78     int                         msg_pipe[2];
79 #else
80     HANDLE                      msg_event;
81 #endif
82     CRITICAL_SECTION            msg_crst;
83 } OSS_MSG_RING;
84
85 typedef struct tagOSS_DEVICE {
86     char*                       dev_name;
87     char*                       mixer_name;
88     char*                       interface_name;
89     unsigned                    open_count;
90     WAVEOUTCAPSW                out_caps;
91     WAVEOUTCAPSW                duplex_out_caps;
92     WAVEINCAPSW                 in_caps;
93     DWORD                       in_caps_support;
94     unsigned                    open_access;
95     int                         fd;
96     DWORD                       owner_tid;
97     int                         sample_rate;
98     int                         channels;
99     int                         format;
100     unsigned                    audio_fragment;
101     BOOL                        full_duplex;
102     BOOL                        bTriggerSupport;
103     BOOL                        bOutputEnabled;
104     BOOL                        bInputEnabled;
105     DSDRIVERDESC                ds_desc;
106     DSDRIVERCAPS                ds_caps;
107     DSCDRIVERCAPS               dsc_caps;
108 } OSS_DEVICE;
109
110 typedef struct {
111     OSS_DEVICE ossdev;
112     volatile int                state;                  /* one of the WINE_WS_ manifest constants */
113     WAVEOPENDESC                waveDesc;
114     WORD                        wFlags;
115     WAVEFORMATPCMEX             waveFormat;
116     DWORD                       volume;
117
118     /* OSS information */
119     DWORD                       dwFragmentSize;         /* size of OSS buffer fragment */
120     DWORD                       dwBufferSize;           /* size of whole OSS buffer in bytes */
121     LPWAVEHDR                   lpQueuePtr;             /* start of queued WAVEHDRs (waiting to be notified) */
122     LPWAVEHDR                   lpPlayPtr;              /* start of not yet fully played buffers */
123     DWORD                       dwPartialOffset;        /* Offset of not yet written bytes in lpPlayPtr */
124
125     LPWAVEHDR                   lpLoopPtr;              /* pointer of first buffer in loop, if any */
126     DWORD                       dwLoops;                /* private copy of loop counter */
127
128     DWORD                       dwPlayedTotal;          /* number of bytes actually played since opening */
129     DWORD                       dwWrittenTotal;         /* number of bytes written to OSS buffer since opening */
130     BOOL                        bNeedPost;              /* whether audio still needs to be physically started */
131
132     /* synchronization stuff */
133     HANDLE                      hStartUpEvent;
134     HANDLE                      hThread;
135     DWORD                       dwThreadID;
136     OSS_MSG_RING                msgRing;
137
138     /* make accommodation for the inaccuracy of OSS when reporting buffer size remaining by using the clock instead of GETOSPACE */
139     DWORD                       dwProjectedFinishTime;
140
141 } WINE_WAVEOUT;
142
143 typedef struct {
144     OSS_DEVICE ossdev;
145     volatile int                state;
146     DWORD                       dwFragmentSize;         /* OpenSound '/dev/dsp' give us that size */
147     WAVEOPENDESC                waveDesc;
148     WORD                        wFlags;
149     WAVEFORMATPCMEX             waveFormat;
150     LPWAVEHDR                   lpQueuePtr;
151     DWORD                       dwTotalRecorded;
152     DWORD                       dwTotalRead;
153
154     /* synchronization stuff */
155     HANDLE                      hThread;
156     DWORD                       dwThreadID;
157     HANDLE                      hStartUpEvent;
158     OSS_MSG_RING                msgRing;
159 } WINE_WAVEIN;
160
161 extern WINE_WAVEOUT     WOutDev[MAX_WAVEDRV] DECLSPEC_HIDDEN;
162 extern WINE_WAVEIN      WInDev[MAX_WAVEDRV] DECLSPEC_HIDDEN;
163 extern unsigned         numOutDev DECLSPEC_HIDDEN;
164 extern unsigned         numInDev DECLSPEC_HIDDEN;
165
166 extern int getEnables(OSS_DEVICE *ossdev) DECLSPEC_HIDDEN;
167 extern void copy_format(LPWAVEFORMATEX wf1, LPWAVEFORMATPCMEX wf2) DECLSPEC_HIDDEN;
168
169 extern DWORD OSS_OpenDevice(OSS_DEVICE* ossdev, unsigned req_access,
170                             int* frag, int strict_format,
171                             int sample_rate, int stereo, int fmt) DECLSPEC_HIDDEN;
172
173 extern void OSS_CloseDevice(OSS_DEVICE* ossdev) DECLSPEC_HIDDEN;
174
175 extern DWORD wodSetVolume(WORD wDevID, DWORD dwParam) DECLSPEC_HIDDEN;
176
177 /* dscapture.c */
178 extern DWORD widDsCreate(UINT wDevID, PIDSCDRIVER* drv) DECLSPEC_HIDDEN;
179 extern DWORD widDsDesc(UINT wDevID, PDSDRIVERDESC desc) DECLSPEC_HIDDEN;
180
181 /* dsrender.c */
182 extern DWORD wodDsCreate(UINT wDevID, PIDSDRIVER* drv) DECLSPEC_HIDDEN;
183 extern DWORD wodDsDesc(UINT wDevID, PDSDRIVERDESC desc) DECLSPEC_HIDDEN;