shell32: Make the tests of the value returned from function SHGetFileInfoA more stric...
[wine.git] / dlls / wineoss.drv / audio.h
blob1038a8f5062a800754dde8c6120149b98c0a7506
1 /*
2 * Sample Wine Driver for Open Sound System (featured in Linux and FreeBSD)
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)
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.
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.
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
24 #ifndef __WINE_CONFIG_H
25 # error You must include config.h to use this header
26 #endif
28 #ifdef HAVE_OSS
30 /* unless someone makes a wineserver kernel module, Unix pipes are faster than win32 events */
31 #define USE_PIPE_SYNC
33 #define MAX_WAVEDRV (6)
34 #define MAX_CHANNELS 6
36 /* states of the playing device */
37 #define WINE_WS_PLAYING 0
38 #define WINE_WS_PAUSED 1
39 #define WINE_WS_STOPPED 2
40 #define WINE_WS_CLOSED 3
42 /* events to be send to device */
43 enum win_wm_message {
44 WINE_WM_PAUSING = WM_USER + 1, WINE_WM_RESTARTING, WINE_WM_RESETTING, WINE_WM_HEADER,
45 WINE_WM_UPDATE, WINE_WM_BREAKLOOP, WINE_WM_CLOSING, WINE_WM_STARTING, WINE_WM_STOPPING
48 #ifdef USE_PIPE_SYNC
49 #define SIGNAL_OMR(omr) do { int x = 0; write((omr)->msg_pipe[1], &x, sizeof(x)); } while (0)
50 #define CLEAR_OMR(omr) do { int x = 0; read((omr)->msg_pipe[0], &x, sizeof(x)); } while (0)
51 #define RESET_OMR(omr) do { } while (0)
52 #define WAIT_OMR(omr, sleep) \
53 do { struct pollfd pfd; pfd.fd = (omr)->msg_pipe[0]; \
54 pfd.events = POLLIN; poll(&pfd, 1, sleep); } while (0)
55 #else
56 #define SIGNAL_OMR(omr) do { SetEvent((omr)->msg_event); } while (0)
57 #define CLEAR_OMR(omr) do { } while (0)
58 #define RESET_OMR(omr) do { ResetEvent((omr)->msg_event); } while (0)
59 #define WAIT_OMR(omr, sleep) \
60 do { WaitForSingleObject((omr)->msg_event, sleep); } while (0)
61 #endif
63 typedef struct {
64 enum win_wm_message msg; /* message identifier */
65 DWORD_PTR param; /* parameter for this message */
66 HANDLE hEvent; /* if message is synchronous, handle of event for synchro */
67 } OSS_MSG;
69 /* implement an in-process message ring for better performance
70 * (compared to passing thru the server)
71 * this ring will be used by the input (resp output) record (resp playback) routine
73 #define OSS_RING_BUFFER_INCREMENT 64
74 typedef struct {
75 int ring_buffer_size;
76 OSS_MSG * messages;
77 int msg_tosave;
78 int msg_toget;
79 #ifdef USE_PIPE_SYNC
80 int msg_pipe[2];
81 #else
82 HANDLE msg_event;
83 #endif
84 CRITICAL_SECTION msg_crst;
85 } OSS_MSG_RING;
87 typedef struct tagOSS_DEVICE {
88 char* dev_name;
89 char* mixer_name;
90 char* interface_name;
91 unsigned open_count;
92 WAVEOUTCAPSW out_caps;
93 WAVEOUTCAPSW duplex_out_caps;
94 WAVEINCAPSW in_caps;
95 DWORD in_caps_support;
96 unsigned open_access;
97 int fd;
98 DWORD owner_tid;
99 int sample_rate;
100 int channels;
101 int format;
102 unsigned audio_fragment;
103 BOOL full_duplex;
104 BOOL bTriggerSupport;
105 BOOL bOutputEnabled;
106 BOOL bInputEnabled;
107 DSDRIVERDESC ds_desc;
108 DSDRIVERCAPS ds_caps;
109 DSCDRIVERCAPS dsc_caps;
110 } OSS_DEVICE;
112 typedef struct {
113 OSS_DEVICE ossdev;
114 volatile int state; /* one of the WINE_WS_ manifest constants */
115 WAVEOPENDESC waveDesc;
116 WORD wFlags;
117 WAVEFORMATPCMEX waveFormat;
118 DWORD volume;
120 /* OSS information */
121 DWORD dwFragmentSize; /* size of OSS buffer fragment */
122 DWORD dwBufferSize; /* size of whole OSS buffer in bytes */
123 LPWAVEHDR lpQueuePtr; /* start of queued WAVEHDRs (waiting to be notified) */
124 LPWAVEHDR lpPlayPtr; /* start of not yet fully played buffers */
125 DWORD dwPartialOffset; /* Offset of not yet written bytes in lpPlayPtr */
127 LPWAVEHDR lpLoopPtr; /* pointer of first buffer in loop, if any */
128 DWORD dwLoops; /* private copy of loop counter */
130 DWORD dwPlayedTotal; /* number of bytes actually played since opening */
131 DWORD dwWrittenTotal; /* number of bytes written to OSS buffer since opening */
132 BOOL bNeedPost; /* whether audio still needs to be physically started */
134 /* synchronization stuff */
135 HANDLE hStartUpEvent;
136 HANDLE hThread;
137 DWORD dwThreadID;
138 OSS_MSG_RING msgRing;
140 /* make accommodation for the inaccuracy of OSS when reporting buffer size remaining by using the clock instead of GETOSPACE */
141 DWORD dwProjectedFinishTime;
143 } WINE_WAVEOUT;
145 typedef struct {
146 OSS_DEVICE ossdev;
147 volatile int state;
148 DWORD dwFragmentSize; /* OpenSound '/dev/dsp' give us that size */
149 WAVEOPENDESC waveDesc;
150 WORD wFlags;
151 WAVEFORMATPCMEX waveFormat;
152 LPWAVEHDR lpQueuePtr;
153 DWORD dwTotalRecorded;
154 DWORD dwTotalRead;
156 /* synchronization stuff */
157 HANDLE hThread;
158 DWORD dwThreadID;
159 HANDLE hStartUpEvent;
160 OSS_MSG_RING msgRing;
161 } WINE_WAVEIN;
163 extern WINE_WAVEOUT WOutDev[MAX_WAVEDRV];
164 extern WINE_WAVEIN WInDev[MAX_WAVEDRV];
165 extern unsigned numOutDev;
166 extern unsigned numInDev;
168 extern int getEnables(OSS_DEVICE *ossdev);
169 extern void copy_format(LPWAVEFORMATEX wf1, LPWAVEFORMATPCMEX wf2);
171 extern DWORD OSS_OpenDevice(OSS_DEVICE* ossdev, unsigned req_access,
172 int* frag, int strict_format,
173 int sample_rate, int stereo, int fmt);
175 extern void OSS_CloseDevice(OSS_DEVICE* ossdev);
177 extern DWORD wodSetVolume(WORD wDevID, DWORD dwParam);
179 /* dscapture.c */
180 extern DWORD widDsCreate(UINT wDevID, PIDSCDRIVER* drv);
181 extern DWORD widDsDesc(UINT wDevID, PDSDRIVERDESC desc);
183 /* dsrender.c */
184 extern DWORD wodDsCreate(UINT wDevID, PIDSDRIVER* drv);
185 extern DWORD wodDsDesc(UINT wDevID, PDSDRIVERDESC desc);
187 #endif /* HAVE_OSS */