4 * Copyright 2002 Eric Pouech
5 * Copyright 2006 Jaroslav Kysela
6 * Copyright 2007 Maarten Lankhorst
8 * This file has a few shared generic subroutines shared among the alsa
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
44 #include "wine/library.h"
45 #include "wine/unicode.h"
46 #include "wine/debug.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(alsa
);
49 /* unless someone makes a wineserver kernel module, Unix pipes are faster than win32 events */
53 #define INIT_OMR(omr) do { if (pipe(omr->msg_pipe) < 0) { omr->msg_pipe[0] = omr->msg_pipe[1] = -1; } } while (0)
54 #define CLOSE_OMR(omr) do { close(omr->msg_pipe[0]); close(omr->msg_pipe[1]); } while (0)
55 #define SIGNAL_OMR(omr) do { int x = 0; write((omr)->msg_pipe[1], &x, sizeof(x)); } while (0)
56 #define CLEAR_OMR(omr) do { int x = 0; read((omr)->msg_pipe[0], &x, sizeof(x)); } while (0)
57 #define RESET_OMR(omr) do { } while (0)
58 #define WAIT_OMR(omr, sleep) \
59 do { struct pollfd pfd; pfd.fd = (omr)->msg_pipe[0]; \
60 pfd.events = POLLIN; poll(&pfd, 1, sleep); } while (0)
62 #define INIT_OMR(omr) do { omr->msg_event = CreateEventW(NULL, FALSE, FALSE, NULL); } while (0)
63 #define CLOSE_OMR(omr) do { CloseHandle(omr->msg_event); } while (0)
64 #define SIGNAL_OMR(omr) do { SetEvent((omr)->msg_event); } while (0)
65 #define CLEAR_OMR(omr) do { } while (0)
66 #define RESET_OMR(omr) do { ResetEvent((omr)->msg_event); } while (0)
67 #define WAIT_OMR(omr, sleep) \
68 do { WaitForSingleObject((omr)->msg_event, sleep); } while (0)
71 #define ALSA_RING_BUFFER_INCREMENT 64
73 /******************************************************************
74 * ALSA_InitRingMessage
76 * Initialize the ring of messages for passing between driver's caller and playback/record
79 int ALSA_InitRingMessage(ALSA_MSG_RING
* omr
)
84 omr
->ring_buffer_size
= ALSA_RING_BUFFER_INCREMENT
;
85 omr
->messages
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,omr
->ring_buffer_size
* sizeof(ALSA_MSG
));
87 InitializeCriticalSection(&omr
->msg_crst
);
88 omr
->msg_crst
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": ALSA_MSG_RING.msg_crst");
92 /******************************************************************
93 * ALSA_DestroyRingMessage
96 int ALSA_DestroyRingMessage(ALSA_MSG_RING
* omr
)
99 HeapFree(GetProcessHeap(),0,omr
->messages
);
100 omr
->ring_buffer_size
= 0;
101 omr
->msg_crst
.DebugInfo
->Spare
[0] = 0;
102 DeleteCriticalSection(&omr
->msg_crst
);
105 /******************************************************************
106 * ALSA_ResetRingMessage
109 void ALSA_ResetRingMessage(ALSA_MSG_RING
* omr
)
114 /******************************************************************
115 * ALSA_WaitRingMessage
118 void ALSA_WaitRingMessage(ALSA_MSG_RING
* omr
, DWORD sleep
)
120 WAIT_OMR(omr
, sleep
);
123 /******************************************************************
124 * ALSA_AddRingMessage
126 * Inserts a new message into the ring (should be called from DriverProc derived routines)
128 int ALSA_AddRingMessage(ALSA_MSG_RING
* omr
, enum win_wm_message msg
, DWORD_PTR param
, BOOL wait
)
130 HANDLE hEvent
= INVALID_HANDLE_VALUE
;
132 EnterCriticalSection(&omr
->msg_crst
);
133 if ((omr
->msg_toget
== ((omr
->msg_tosave
+ 1) % omr
->ring_buffer_size
)))
135 int old_ring_buffer_size
= omr
->ring_buffer_size
;
136 omr
->ring_buffer_size
+= ALSA_RING_BUFFER_INCREMENT
;
137 omr
->messages
= HeapReAlloc(GetProcessHeap(),0,omr
->messages
, omr
->ring_buffer_size
* sizeof(ALSA_MSG
));
138 /* Now we need to rearrange the ring buffer so that the new
139 buffers just allocated are in between omr->msg_tosave and
142 if (omr
->msg_tosave
< omr
->msg_toget
)
144 memmove(&(omr
->messages
[omr
->msg_toget
+ ALSA_RING_BUFFER_INCREMENT
]),
145 &(omr
->messages
[omr
->msg_toget
]),
146 sizeof(ALSA_MSG
)*(old_ring_buffer_size
- omr
->msg_toget
)
148 omr
->msg_toget
+= ALSA_RING_BUFFER_INCREMENT
;
153 hEvent
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
154 if (hEvent
== INVALID_HANDLE_VALUE
)
156 ERR("can't create event !?\n");
157 LeaveCriticalSection(&omr
->msg_crst
);
160 if (omr
->msg_toget
!= omr
->msg_tosave
&& omr
->messages
[omr
->msg_toget
].msg
!= WINE_WM_HEADER
)
161 FIXME("two fast messages in the queue!!!! toget = %d(%s), tosave=%d(%s)\n",
162 omr
->msg_toget
,ALSA_getCmdString(omr
->messages
[omr
->msg_toget
].msg
),
163 omr
->msg_tosave
,ALSA_getCmdString(omr
->messages
[omr
->msg_tosave
].msg
));
165 /* fast messages have to be added at the start of the queue */
166 omr
->msg_toget
= (omr
->msg_toget
+ omr
->ring_buffer_size
- 1) % omr
->ring_buffer_size
;
168 omr
->messages
[omr
->msg_toget
].msg
= msg
;
169 omr
->messages
[omr
->msg_toget
].param
= param
;
170 omr
->messages
[omr
->msg_toget
].hEvent
= hEvent
;
174 omr
->messages
[omr
->msg_tosave
].msg
= msg
;
175 omr
->messages
[omr
->msg_tosave
].param
= param
;
176 omr
->messages
[omr
->msg_tosave
].hEvent
= INVALID_HANDLE_VALUE
;
177 omr
->msg_tosave
= (omr
->msg_tosave
+ 1) % omr
->ring_buffer_size
;
179 LeaveCriticalSection(&omr
->msg_crst
);
180 /* signal a new message */
184 /* wait for playback/record thread to have processed the message */
185 WaitForSingleObject(hEvent
, INFINITE
);
191 /******************************************************************
192 * ALSA_RetrieveRingMessage
194 * Get a message from the ring. Should be called by the playback/record thread.
196 int ALSA_RetrieveRingMessage(ALSA_MSG_RING
* omr
, enum win_wm_message
*msg
,
197 DWORD_PTR
*param
, HANDLE
*hEvent
)
199 EnterCriticalSection(&omr
->msg_crst
);
201 if (omr
->msg_toget
== omr
->msg_tosave
) /* buffer empty ? */
203 LeaveCriticalSection(&omr
->msg_crst
);
207 *msg
= omr
->messages
[omr
->msg_toget
].msg
;
208 omr
->messages
[omr
->msg_toget
].msg
= 0;
209 *param
= omr
->messages
[omr
->msg_toget
].param
;
210 *hEvent
= omr
->messages
[omr
->msg_toget
].hEvent
;
211 omr
->msg_toget
= (omr
->msg_toget
+ 1) % omr
->ring_buffer_size
;
213 LeaveCriticalSection(&omr
->msg_crst
);
217 /*======================================================================*
218 * Utility functions *
219 *======================================================================*/
221 /* These strings used only for tracing */
222 const char * ALSA_getCmdString(enum win_wm_message msg
)
224 #define MSG_TO_STR(x) case x: return #x
226 MSG_TO_STR(WINE_WM_PAUSING
);
227 MSG_TO_STR(WINE_WM_RESTARTING
);
228 MSG_TO_STR(WINE_WM_RESETTING
);
229 MSG_TO_STR(WINE_WM_HEADER
);
230 MSG_TO_STR(WINE_WM_UPDATE
);
231 MSG_TO_STR(WINE_WM_BREAKLOOP
);
232 MSG_TO_STR(WINE_WM_CLOSING
);
233 MSG_TO_STR(WINE_WM_STARTING
);
234 MSG_TO_STR(WINE_WM_STOPPING
);
237 return wine_dbg_sprintf("UNKNOWN(0x%08x)", msg
);
240 const char * ALSA_getMessage(UINT msg
)
242 #define MSG_TO_STR(x) case x: return #x
244 MSG_TO_STR(DRVM_INIT
);
245 MSG_TO_STR(DRVM_EXIT
);
246 MSG_TO_STR(DRVM_ENABLE
);
247 MSG_TO_STR(DRVM_DISABLE
);
248 MSG_TO_STR(WIDM_OPEN
);
249 MSG_TO_STR(WIDM_CLOSE
);
250 MSG_TO_STR(WIDM_ADDBUFFER
);
251 MSG_TO_STR(WIDM_PREPARE
);
252 MSG_TO_STR(WIDM_UNPREPARE
);
253 MSG_TO_STR(WIDM_GETDEVCAPS
);
254 MSG_TO_STR(WIDM_GETNUMDEVS
);
255 MSG_TO_STR(WIDM_GETPOS
);
256 MSG_TO_STR(WIDM_RESET
);
257 MSG_TO_STR(WIDM_START
);
258 MSG_TO_STR(WIDM_STOP
);
259 MSG_TO_STR(WODM_OPEN
);
260 MSG_TO_STR(WODM_CLOSE
);
261 MSG_TO_STR(WODM_WRITE
);
262 MSG_TO_STR(WODM_PAUSE
);
263 MSG_TO_STR(WODM_GETPOS
);
264 MSG_TO_STR(WODM_BREAKLOOP
);
265 MSG_TO_STR(WODM_PREPARE
);
266 MSG_TO_STR(WODM_UNPREPARE
);
267 MSG_TO_STR(WODM_GETDEVCAPS
);
268 MSG_TO_STR(WODM_GETNUMDEVS
);
269 MSG_TO_STR(WODM_GETPITCH
);
270 MSG_TO_STR(WODM_SETPITCH
);
271 MSG_TO_STR(WODM_GETPLAYBACKRATE
);
272 MSG_TO_STR(WODM_SETPLAYBACKRATE
);
273 MSG_TO_STR(WODM_GETVOLUME
);
274 MSG_TO_STR(WODM_SETVOLUME
);
275 MSG_TO_STR(WODM_RESTART
);
276 MSG_TO_STR(WODM_RESET
);
277 MSG_TO_STR(DRV_QUERYDEVICEINTERFACESIZE
);
278 MSG_TO_STR(DRV_QUERYDEVICEINTERFACE
);
279 MSG_TO_STR(DRV_QUERYDSOUNDIFACE
);
280 MSG_TO_STR(DRV_QUERYDSOUNDDESC
);
283 return wine_dbg_sprintf("UNKNOWN(0x%04x)", msg
);
286 const char * ALSA_getFormat(WORD wFormatTag
)
288 #define FMT_TO_STR(x) case x: return #x
290 FMT_TO_STR(WAVE_FORMAT_PCM
);
291 FMT_TO_STR(WAVE_FORMAT_EXTENSIBLE
);
292 FMT_TO_STR(WAVE_FORMAT_MULAW
);
293 FMT_TO_STR(WAVE_FORMAT_ALAW
);
294 FMT_TO_STR(WAVE_FORMAT_ADPCM
);
297 return wine_dbg_sprintf("UNKNOWN(0x%04x)", wFormatTag
);
300 /* Allow 1% deviation for sample rates (some ES137x cards) */
301 BOOL
ALSA_NearMatch(int rate1
, int rate2
)
303 return (((100 * (rate1
- rate2
)) / rate1
) == 0);
306 DWORD
ALSA_bytes_to_mmtime(LPMMTIME lpTime
, DWORD position
, WAVEFORMATPCMEX
* format
)
308 TRACE("wType=%04X wBitsPerSample=%u nSamplesPerSec=%u nChannels=%u nAvgBytesPerSec=%u\n",
309 lpTime
->wType
, format
->Format
.wBitsPerSample
, format
->Format
.nSamplesPerSec
,
310 format
->Format
.nChannels
, format
->Format
.nAvgBytesPerSec
);
311 TRACE("Position in bytes=%u\n", position
);
313 switch (lpTime
->wType
) {
315 lpTime
->u
.sample
= position
/ (format
->Format
.wBitsPerSample
/ 8 * format
->Format
.nChannels
);
316 TRACE("TIME_SAMPLES=%u\n", lpTime
->u
.sample
);
319 lpTime
->u
.ms
= 1000.0 * position
/ (format
->Format
.wBitsPerSample
/ 8 * format
->Format
.nChannels
* format
->Format
.nSamplesPerSec
);
320 TRACE("TIME_MS=%u\n", lpTime
->u
.ms
);
323 lpTime
->u
.smpte
.fps
= 30;
324 position
= position
/ (format
->Format
.wBitsPerSample
/ 8 * format
->Format
.nChannels
);
325 position
+= (format
->Format
.nSamplesPerSec
/ lpTime
->u
.smpte
.fps
) - 1; /* round up */
326 lpTime
->u
.smpte
.sec
= position
/ format
->Format
.nSamplesPerSec
;
327 position
-= lpTime
->u
.smpte
.sec
* format
->Format
.nSamplesPerSec
;
328 lpTime
->u
.smpte
.min
= lpTime
->u
.smpte
.sec
/ 60;
329 lpTime
->u
.smpte
.sec
-= 60 * lpTime
->u
.smpte
.min
;
330 lpTime
->u
.smpte
.hour
= lpTime
->u
.smpte
.min
/ 60;
331 lpTime
->u
.smpte
.min
-= 60 * lpTime
->u
.smpte
.hour
;
332 lpTime
->u
.smpte
.fps
= 30;
333 lpTime
->u
.smpte
.frame
= position
* lpTime
->u
.smpte
.fps
/ format
->Format
.nSamplesPerSec
;
334 TRACE("TIME_SMPTE=%02u:%02u:%02u:%02u\n",
335 lpTime
->u
.smpte
.hour
, lpTime
->u
.smpte
.min
,
336 lpTime
->u
.smpte
.sec
, lpTime
->u
.smpte
.frame
);
339 WARN("Format %d not supported, using TIME_BYTES !\n", lpTime
->wType
);
340 lpTime
->wType
= TIME_BYTES
;
343 lpTime
->u
.cb
= position
;
344 TRACE("TIME_BYTES=%u\n", lpTime
->u
.cb
);
347 return MMSYSERR_NOERROR
;
350 void ALSA_copyFormat(LPWAVEFORMATEX wf1
, LPWAVEFORMATPCMEX wf2
)
352 unsigned int iLength
;
354 ZeroMemory(wf2
, sizeof(wf2
));
355 if (wf1
->wFormatTag
== WAVE_FORMAT_PCM
)
356 iLength
= sizeof(PCMWAVEFORMAT
);
357 else if (wf1
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
)
358 iLength
= sizeof(WAVEFORMATPCMEX
);
360 iLength
= sizeof(WAVEFORMATEX
) + wf1
->cbSize
;
361 memcpy(wf2
, wf1
, iLength
);
364 BOOL
ALSA_supportedFormat(LPWAVEFORMATEX wf
)
368 if (wf
->nSamplesPerSec
<DSBFREQUENCY_MIN
||wf
->nSamplesPerSec
>DSBFREQUENCY_MAX
)
371 if (wf
->wFormatTag
== WAVE_FORMAT_PCM
) {
372 if (wf
->nChannels
==1||wf
->nChannels
==2) {
373 if (wf
->wBitsPerSample
==8||wf
->wBitsPerSample
==16)
376 } else if (wf
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
) {
377 WAVEFORMATEXTENSIBLE
* wfex
= (WAVEFORMATEXTENSIBLE
*)wf
;
379 if (wf
->cbSize
== 22 &&
380 (IsEqualGUID(&wfex
->SubFormat
, &KSDATAFORMAT_SUBTYPE_PCM
) ||
381 IsEqualGUID(&wfex
->SubFormat
, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
))) {
382 if (wf
->nChannels
>=1 && wf
->nChannels
<=6) {
383 if (wf
->wBitsPerSample
==wfex
->Samples
.wValidBitsPerSample
) {
384 if (wf
->wBitsPerSample
==8||wf
->wBitsPerSample
==16||
385 wf
->wBitsPerSample
==24||wf
->wBitsPerSample
==32) {
389 WARN("wBitsPerSample != wValidBitsPerSample not supported yet\n");
392 WARN("only KSDATAFORMAT_SUBTYPE_PCM and KSDATAFORMAT_SUBTYPE_IEEE_FLOAT "
395 WARN("only WAVE_FORMAT_PCM and WAVE_FORMAT_EXTENSIBLE supported\n");
400 /*======================================================================*
401 * Low level WAVE implementation *
402 *======================================================================*/
404 /**************************************************************************
405 * ALSA_CheckSetVolume [internal]
407 * Helper function for Alsa volume queries. This tries to simplify
408 * the process of managing the volume. All parameters are optional
409 * (pass NULL to ignore or not use).
410 * Return values are MMSYSERR_NOERROR on success, or !0 on failure;
411 * error codes are normalized into the possible documented return
412 * values from waveOutGetVolume.
414 int ALSA_CheckSetVolume(snd_hctl_t
*hctl
, int *out_left
, int *out_right
,
415 int *out_min
, int *out_max
, int *out_step
,
416 int *new_left
, int *new_right
)
418 int rc
= MMSYSERR_NOERROR
;
420 snd_hctl_elem_t
* elem
= NULL
;
421 snd_ctl_elem_info_t
* eleminfop
= NULL
;
422 snd_ctl_elem_value_t
* elemvaluep
= NULL
;
423 snd_ctl_elem_id_t
* elemidp
= NULL
;
426 #define EXIT_ON_ERROR(f,txt,exitcode) do \
429 if ( (err = (f) ) < 0) \
431 ERR(txt " failed: %s\n", snd_strerror(err)); \
438 return MMSYSERR_NOTSUPPORTED
;
440 /* Allocate areas to return information about the volume */
441 EXIT_ON_ERROR(snd_ctl_elem_id_malloc(&elemidp
), "snd_ctl_elem_id_malloc", MMSYSERR_NOMEM
);
442 EXIT_ON_ERROR(snd_ctl_elem_value_malloc (&elemvaluep
), "snd_ctl_elem_value_malloc", MMSYSERR_NOMEM
);
443 EXIT_ON_ERROR(snd_ctl_elem_info_malloc (&eleminfop
), "snd_ctl_elem_info_malloc", MMSYSERR_NOMEM
);
444 snd_ctl_elem_id_clear(elemidp
);
445 snd_ctl_elem_value_clear(elemvaluep
);
446 snd_ctl_elem_info_clear(eleminfop
);
448 /* Setup and find an element id that exactly matches the characteristic we want
449 ** FIXME: It is probably short sighted to hard code and fixate on PCM Playback Volume */
450 snd_ctl_elem_id_set_name(elemidp
, "PCM Playback Volume");
451 snd_ctl_elem_id_set_interface(elemidp
, SND_CTL_ELEM_IFACE_MIXER
);
452 elem
= snd_hctl_find_elem(hctl
, elemidp
);
455 /* Read and return volume information */
456 EXIT_ON_ERROR(snd_hctl_elem_info(elem
, eleminfop
), "snd_hctl_elem_info", MMSYSERR_NOTSUPPORTED
);
457 value_count
= snd_ctl_elem_info_get_count(eleminfop
);
458 if (out_min
|| out_max
|| out_step
)
460 if (!snd_ctl_elem_info_is_readable(eleminfop
))
462 ERR("snd_ctl_elem_info_is_readable returned false; cannot return info\n");
463 rc
= MMSYSERR_NOTSUPPORTED
;
468 *out_min
= snd_ctl_elem_info_get_min(eleminfop
);
471 *out_max
= snd_ctl_elem_info_get_max(eleminfop
);
474 *out_step
= snd_ctl_elem_info_get_step(eleminfop
);
477 if (out_left
|| out_right
)
479 EXIT_ON_ERROR(snd_hctl_elem_read(elem
, elemvaluep
), "snd_hctl_elem_read", MMSYSERR_NOTSUPPORTED
);
482 *out_left
= snd_ctl_elem_value_get_integer(elemvaluep
, 0);
486 if (value_count
== 1)
487 *out_right
= snd_ctl_elem_value_get_integer(elemvaluep
, 0);
488 else if (value_count
== 2)
489 *out_right
= snd_ctl_elem_value_get_integer(elemvaluep
, 1);
492 ERR("Unexpected value count %d from snd_ctl_elem_info_get_count while getting volume info\n", value_count
);
500 if (new_left
|| new_right
)
502 EXIT_ON_ERROR(snd_hctl_elem_read(elem
, elemvaluep
), "snd_hctl_elem_read", MMSYSERR_NOTSUPPORTED
);
504 snd_ctl_elem_value_set_integer(elemvaluep
, 0, *new_left
);
507 if (value_count
== 1)
508 snd_ctl_elem_value_set_integer(elemvaluep
, 0, *new_right
);
509 else if (value_count
== 2)
510 snd_ctl_elem_value_set_integer(elemvaluep
, 1, *new_right
);
513 ERR("Unexpected value count %d from snd_ctl_elem_info_get_count while setting volume info\n", value_count
);
519 EXIT_ON_ERROR(snd_hctl_elem_write(elem
, elemvaluep
), "snd_hctl_elem_write", MMSYSERR_NOTSUPPORTED
);
524 ERR("Could not find 'PCM Playback Volume' element\n");
525 rc
= MMSYSERR_NOTSUPPORTED
;
534 snd_ctl_elem_value_free(elemvaluep
);
536 snd_ctl_elem_info_free(eleminfop
);
538 snd_ctl_elem_id_free(elemidp
);
544 /**************************************************************************
545 * wine_snd_pcm_recover [internal]
547 * Code slightly modified from alsa-lib v1.0.23 snd_pcm_recover implementation.
548 * used to recover from XRUN errors (buffer underflow/overflow)
550 int wine_snd_pcm_recover(snd_pcm_t
*pcm
, int err
, int silent
)
554 if (err
== -EINTR
) /* nothing to do, continue */
558 if (snd_pcm_stream(pcm
) == SND_PCM_STREAM_PLAYBACK
)
563 ERR("%s occurred\n", s
);
564 err
= snd_pcm_prepare(pcm
);
566 ERR("cannot recover from %s, prepare failed: %s\n", s
, snd_strerror(err
));
571 if (err
== -ESTRPIPE
) {
572 while ((err
= snd_pcm_resume(pcm
)) == -EAGAIN
)
573 /* wait until suspend flag is released */
576 err
= snd_pcm_prepare(pcm
);
578 ERR("cannot recover from suspend, prepare failed: %s\n", snd_strerror(err
));
587 /**************************************************************************
588 * ALSA_TraceParameters [internal]
590 * used to trace format changes, hw and sw parameters
592 void ALSA_TraceParameters(snd_pcm_hw_params_t
* hw_params
, snd_pcm_sw_params_t
* sw
, int full
)
595 snd_pcm_format_t format
;
596 snd_pcm_access_t access
;
598 #define X(x) ((x)? "true" : "false")
600 TRACE("FLAGS: sampleres=%s overrng=%s pause=%s resume=%s syncstart=%s batch=%s block=%s double=%s "
601 "halfd=%s joint=%s\n",
602 X(snd_pcm_hw_params_can_mmap_sample_resolution(hw_params
)),
603 X(snd_pcm_hw_params_can_overrange(hw_params
)),
604 X(snd_pcm_hw_params_can_pause(hw_params
)),
605 X(snd_pcm_hw_params_can_resume(hw_params
)),
606 X(snd_pcm_hw_params_can_sync_start(hw_params
)),
607 X(snd_pcm_hw_params_is_batch(hw_params
)),
608 X(snd_pcm_hw_params_is_block_transfer(hw_params
)),
609 X(snd_pcm_hw_params_is_double(hw_params
)),
610 X(snd_pcm_hw_params_is_half_duplex(hw_params
)),
611 X(snd_pcm_hw_params_is_joint_duplex(hw_params
)));
614 err
= snd_pcm_hw_params_get_access(hw_params
, &access
);
617 TRACE("access=%s\n", snd_pcm_access_name(access
));
621 snd_pcm_access_mask_t
* acmask
;
623 acmask
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, snd_pcm_access_mask_sizeof());
624 snd_pcm_hw_params_get_access_mask(hw_params
, acmask
);
625 for ( access
= SND_PCM_ACCESS_MMAP_INTERLEAVED
; access
<= SND_PCM_ACCESS_LAST
; access
++)
626 if (snd_pcm_access_mask_test(acmask
, access
))
627 TRACE("access=%s\n", snd_pcm_access_name(access
));
628 HeapFree( GetProcessHeap(), 0, acmask
);
631 err
= snd_pcm_hw_params_get_format(hw_params
, &format
);
634 TRACE("format=%s\n", snd_pcm_format_name(format
));
639 snd_pcm_format_mask_t
* fmask
;
641 fmask
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, snd_pcm_format_mask_sizeof());
642 snd_pcm_hw_params_get_format_mask(hw_params
, fmask
);
643 for ( format
= SND_PCM_FORMAT_S8
; format
<= SND_PCM_FORMAT_LAST
; format
++)
644 if ( snd_pcm_format_mask_test(fmask
, format
) )
645 TRACE("format=%s\n", snd_pcm_format_name(format
));
646 HeapFree( GetProcessHeap(), 0, fmask
);
652 err
= snd_pcm_hw_params_get_channels(hw_params
, &val
);
654 unsigned int min
= 0;
655 unsigned int max
= 0;
656 err
= snd_pcm_hw_params_get_channels_min(hw_params
, &min
),
657 err
= snd_pcm_hw_params_get_channels_max(hw_params
, &max
);
658 TRACE("channels_min=%u, channels_min_max=%u\n", min
, max
);
660 TRACE("channels=%d\n", val
);
665 snd_pcm_uframes_t val
=0;
666 err
= snd_pcm_hw_params_get_buffer_size(hw_params
, &val
);
668 snd_pcm_uframes_t min
= 0;
669 snd_pcm_uframes_t max
= 0;
670 err
= snd_pcm_hw_params_get_buffer_size_min(hw_params
, &min
),
671 err
= snd_pcm_hw_params_get_buffer_size_max(hw_params
, &max
);
672 TRACE("buffer_size_min=%lu, buffer_size_min_max=%lu\n", min
, max
);
674 TRACE("buffer_size=%lu\n", val
);
681 unsigned int val=0; \
682 err = snd_pcm_hw_params_get_##x(hw_params,&val, &dir); \
684 unsigned int min = 0; \
685 unsigned int max = 0; \
686 err = snd_pcm_hw_params_get_##x##_min(hw_params, &min, &dir); \
687 err = snd_pcm_hw_params_get_##x##_max(hw_params, &max, &dir); \
688 TRACE(#x "_min=%u " #x "_max=%u\n", min, max); \
690 TRACE(#x "=%d\n", val); \
699 snd_pcm_uframes_t val
=0;
700 err
= snd_pcm_hw_params_get_period_size(hw_params
, &val
, &dir
);
702 snd_pcm_uframes_t min
= 0;
703 snd_pcm_uframes_t max
= 0;
704 err
= snd_pcm_hw_params_get_period_size_min(hw_params
, &min
, &dir
),
705 err
= snd_pcm_hw_params_get_period_size_max(hw_params
, &max
, &dir
);
706 TRACE("period_size_min=%lu, period_size_min_max=%lu\n", min
, max
);
708 TRACE("period_size=%lu\n", val
);
721 /**************************************************************************
722 * DriverProc (WINEALSA.@)
724 LRESULT CALLBACK
ALSA_DriverProc(DWORD_PTR dwDevID
, HDRVR hDriv
, UINT wMsg
,
725 LPARAM dwParam1
, LPARAM dwParam2
)
727 /* EPP TRACE("(%08lX, %04X, %08lX, %08lX, %08lX)\n", */
728 /* EPP dwDevID, hDriv, wMsg, dwParam1, dwParam2); */
738 case DRV_QUERYCONFIGURE
:
740 case DRV_CONFIGURE
: MessageBoxA(0, "ALSA MultiMedia Driver !", "ALSA Driver", MB_OK
); return 1;