gdi32: Update pixel colours when the colour table changes.
[wine/multimedia.git] / dlls / winealsa.drv / alsa.h
blobbc21fbc4b970ae92f25f3b4f35192ccf2f1ccff1
1 /* Definition for ALSA drivers : wine multimedia system
3 * Copyright (C) 2002 Erich Pouech
4 * Copyright (C) 2002 Marco Pietrobono
5 * Copyright (C) 2003 Christian Costa
6 * Copyright (C) 2007 Maarten Lankhorst
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #ifndef __WINE_CONFIG_H
24 # error You must include config.h to use this header
25 #endif
27 #ifndef __ALSA_H
28 #define __ALSA_H
30 #ifdef interface
31 #undef interface
32 #endif
34 #define ALSA_PCM_NEW_HW_PARAMS_API
35 #define ALSA_PCM_NEW_SW_PARAMS_API
37 #ifdef HAVE_ALSA_ASOUNDLIB_H
38 #include <alsa/asoundlib.h>
39 #elif defined(HAVE_SYS_ASOUNDLIB_H)
40 #include <sys/asoundlib.h>
41 #endif
42 #ifdef HAVE_SYS_ERRNO_H
43 #include <sys/errno.h>
44 #endif
46 /* state diagram for waveOut writing:
48 * +---------+-------------+---------------+---------------------------------+
49 * | state | function | event | new state |
50 * +---------+-------------+---------------+---------------------------------+
51 * | | open() | | STOPPED |
52 * | PAUSED | write() | | PAUSED |
53 * | STOPPED | write() | <thrd create> | PLAYING |
54 * | PLAYING | write() | HEADER | PLAYING |
55 * | (other) | write() | <error> | |
56 * | (any) | pause() | PAUSING | PAUSED |
57 * | PAUSED | restart() | RESTARTING | PLAYING (if no thrd => STOPPED) |
58 * | (any) | reset() | RESETTING | STOPPED |
59 * | (any) | close() | CLOSING | CLOSED |
60 * +---------+-------------+---------------+---------------------------------+
63 /* states of the playing device */
64 #define WINE_WS_PLAYING 0
65 #define WINE_WS_PAUSED 1
66 #define WINE_WS_STOPPED 2
67 #define WINE_WS_CLOSED 3
69 /* events to be send to device */
70 enum win_wm_message {
71 WINE_WM_PAUSING = WM_USER + 1, WINE_WM_RESTARTING, WINE_WM_RESETTING, WINE_WM_HEADER,
72 WINE_WM_UPDATE, WINE_WM_BREAKLOOP, WINE_WM_CLOSING, WINE_WM_STARTING, WINE_WM_STOPPING
75 typedef struct {
76 enum win_wm_message msg; /* message identifier */
77 DWORD_PTR param; /* parameter for this message */
78 HANDLE hEvent; /* if message is synchronous, handle of event for synchro */
79 } ALSA_MSG;
81 /* implement an in-process message ring for better performance
82 * (compared to passing thru the server)
83 * this ring will be used by the input (resp output) record (resp playback) routine
85 typedef struct {
86 ALSA_MSG * messages;
87 int ring_buffer_size;
88 int msg_tosave;
89 int msg_toget;
90 /* Either pipe or event is used, but that is defined in alsa.c,
91 * since this is a global header we define both here */
92 int msg_pipe[2];
93 HANDLE msg_event;
94 CRITICAL_SECTION msg_crst;
95 } ALSA_MSG_RING;
97 typedef struct {
98 volatile int state; /* one of the WINE_WS_ manifest constants */
99 WAVEOPENDESC waveDesc;
100 WORD wFlags;
101 WAVEFORMATPCMEX format;
103 char* pcmname; /* string name of alsa PCM device */
104 char* ctlname; /* string name of alsa control device */
105 char interface_name[MAXPNAMELEN * 2];
107 snd_pcm_t* pcm; /* handle to ALSA playback device */
109 snd_pcm_hw_params_t * hw_params;
111 DWORD dwBufferSize; /* size of whole ALSA buffer in bytes */
112 LPWAVEHDR lpQueuePtr; /* start of queued WAVEHDRs (waiting to be notified) */
113 LPWAVEHDR lpPlayPtr; /* start of not yet fully played buffers */
115 LPWAVEHDR lpLoopPtr; /* pointer of first buffer in loop, if any */
116 DWORD dwLoops; /* private copy of loop counter */
118 DWORD dwPlayedTotal; /* number of bytes actually played since opening */
119 DWORD dwWrittenTotal; /* number of bytes written to ALSA buffer since opening */
121 /* synchronization stuff */
122 HANDLE hStartUpEvent;
123 HANDLE hThread;
124 DWORD dwThreadID;
125 ALSA_MSG_RING msgRing;
127 /* DirectSound stuff */
128 DSDRIVERDESC ds_desc;
129 DSDRIVERCAPS ds_caps;
131 /* Waveout only fields */
132 WAVEOUTCAPSW outcaps;
134 snd_hctl_t * hctl; /* control handle for the playback volume */
136 snd_pcm_sframes_t (*write)(snd_pcm_t *, const void *, snd_pcm_uframes_t );
138 DWORD dwPartialOffset; /* Offset of not yet written bytes in lpPlayPtr */
140 /* Wavein only fields */
142 WAVEINCAPSW incaps;
143 DWORD dwSupport;
145 snd_pcm_sframes_t (*read)(snd_pcm_t *, void *, snd_pcm_uframes_t );
147 DWORD dwPeriodSize; /* size of OSS buffer period */
148 DWORD dwTotalRecorded;
150 } WINE_WAVEDEV;
152 /*----------------------------------------------------------------------------
153 ** Global array of output and input devices, initialized via ALSA_WaveInit
155 #define WAVEDEV_ALLOC_EXTENT_SIZE 10
157 /* wavein.c */
158 extern WINE_WAVEDEV *WInDev DECLSPEC_HIDDEN;
159 extern DWORD ALSA_WidNumMallocedDevs DECLSPEC_HIDDEN;
160 extern DWORD ALSA_WidNumDevs DECLSPEC_HIDDEN;
162 /* waveout.c */
163 extern WINE_WAVEDEV *WOutDev DECLSPEC_HIDDEN;
164 extern DWORD ALSA_WodNumMallocedDevs DECLSPEC_HIDDEN;
165 extern DWORD ALSA_WodNumDevs DECLSPEC_HIDDEN;
167 /* alsa.c */
168 int ALSA_InitRingMessage(ALSA_MSG_RING* omr) DECLSPEC_HIDDEN;
169 int ALSA_DestroyRingMessage(ALSA_MSG_RING* omr) DECLSPEC_HIDDEN;
170 void ALSA_ResetRingMessage(ALSA_MSG_RING* omr) DECLSPEC_HIDDEN;
171 void ALSA_WaitRingMessage(ALSA_MSG_RING* omr, DWORD sleep) DECLSPEC_HIDDEN;
172 int ALSA_AddRingMessage(ALSA_MSG_RING* omr, enum win_wm_message msg, DWORD_PTR param, BOOL wait) DECLSPEC_HIDDEN;
173 int ALSA_RetrieveRingMessage(ALSA_MSG_RING* omr, enum win_wm_message *msg, DWORD_PTR *param, HANDLE *hEvent) DECLSPEC_HIDDEN;
174 int ALSA_CheckSetVolume(snd_hctl_t *hctl, int *out_left, int *out_right, int *out_min, int *out_max, int *out_step, int *new_left, int *new_right) DECLSPEC_HIDDEN;
176 const char * ALSA_getCmdString(enum win_wm_message msg) DECLSPEC_HIDDEN;
177 const char * ALSA_getMessage(UINT msg) DECLSPEC_HIDDEN;
178 const char * ALSA_getFormat(WORD wFormatTag) DECLSPEC_HIDDEN;
179 BOOL ALSA_NearMatch(int rate1, int rate2) DECLSPEC_HIDDEN;
180 DWORD ALSA_bytes_to_mmtime(LPMMTIME lpTime, DWORD position, WAVEFORMATPCMEX* format) DECLSPEC_HIDDEN;
181 void ALSA_TraceParameters(snd_pcm_hw_params_t * hw_params, snd_pcm_sw_params_t * sw, int full) DECLSPEC_HIDDEN;
182 int wine_snd_pcm_recover(snd_pcm_t *pcm, int err, int silent) DECLSPEC_HIDDEN;
183 void ALSA_copyFormat(LPWAVEFORMATEX wf1, LPWAVEFORMATPCMEX wf2) DECLSPEC_HIDDEN;
184 BOOL ALSA_supportedFormat(LPWAVEFORMATEX wf) DECLSPEC_HIDDEN;
186 /* dscapture.c */
187 DWORD widDsCreate(UINT wDevID, PIDSCDRIVER* drv) DECLSPEC_HIDDEN;
188 DWORD widDsDesc(UINT wDevID, PDSDRIVERDESC desc) DECLSPEC_HIDDEN;
190 /* dsoutput.c */
191 DWORD wodDsCreate(UINT wDevID, PIDSDRIVER* drv) DECLSPEC_HIDDEN;
192 DWORD wodDsDesc(UINT wDevID, PDSDRIVERDESC desc) DECLSPEC_HIDDEN;
194 /* waveinit.c */
195 extern void ALSA_WaveInit(void) DECLSPEC_HIDDEN;
197 #endif /* __ALSA_H */