2 * Sample Wine Driver for Advanced Linux Sound System (ALSA)
3 * Based on version <final> of the ALSA API
5 * Copyright 2002 Eric Pouech
6 * 2002 Marco Pietrobono
7 * 2003 Christian Costa : WaveIn support
8 * 2006-2007 Maarten Lankhorst
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 /*======================================================================*
26 * Low level WAVE OUT implementation *
27 *======================================================================*/
30 #include "wine/port.h"
42 #ifdef HAVE_SYS_IOCTL_H
43 # include <sys/ioctl.h>
45 #ifdef HAVE_SYS_MMAN_H
46 # include <sys/mman.h>
57 #include "wine/library.h"
58 #include "wine/unicode.h"
59 #include "wine/debug.h"
61 WINE_DEFAULT_DEBUG_CHANNEL(wave);
65 WINE_WAVEDEV *WOutDev;
66 DWORD ALSA_WodNumMallocedDevs;
67 DWORD ALSA_WodNumDevs;
69 /**************************************************************************
70 * wodNotifyClient [internal]
72 static DWORD wodNotifyClient(WINE_WAVEDEV* wwo, WORD wMsg, DWORD dwParam1, DWORD dwParam2)
74 TRACE("wMsg = 0x%04x dwParm1 = %04X dwParam2 = %04X\n", wMsg, dwParam1, dwParam2);
80 if (wwo->wFlags != DCB_NULL &&
81 !DriverCallback(wwo->waveDesc.dwCallback, wwo->wFlags, (HDRVR)wwo->waveDesc.hWave,
82 wMsg, wwo->waveDesc.dwInstance, dwParam1, dwParam2)) {
83 WARN("can't notify client !\n");
84 return MMSYSERR_ERROR;
88 FIXME("Unknown callback message %u\n", wMsg);
89 return MMSYSERR_INVALPARAM;
91 return MMSYSERR_NOERROR;
94 /**************************************************************************
95 * wodUpdatePlayedTotal [internal]
98 static BOOL wodUpdatePlayedTotal(WINE_WAVEDEV* wwo, snd_pcm_status_t* ps)
100 snd_pcm_sframes_t delay = 0;
101 snd_pcm_state_t state;
103 state = snd_pcm_state(wwo->pcm);
104 snd_pcm_delay(wwo->pcm, &delay);
106 /* A delay < 0 indicates an underrun; for our purposes that's 0. */
107 if ( (state != SND_PCM_STATE_RUNNING && state != SND_PCM_STATE_PREPARED) || (delay < 0))
109 WARN("Unexpected state (%d) or delay (%ld) while updating Total Played, resetting\n", state, delay);
112 wwo->dwPlayedTotal = wwo->dwWrittenTotal - snd_pcm_frames_to_bytes(wwo->pcm, delay);
116 /**************************************************************************
117 * wodPlayer_BeginWaveHdr [internal]
119 * Makes the specified lpWaveHdr the currently playing wave header.
120 * If the specified wave header is a begin loop and we're not already in
121 * a loop, setup the loop.
123 static void wodPlayer_BeginWaveHdr(WINE_WAVEDEV* wwo, LPWAVEHDR lpWaveHdr)
125 wwo->lpPlayPtr = lpWaveHdr;
127 if (!lpWaveHdr) return;
129 if (lpWaveHdr->dwFlags & WHDR_BEGINLOOP) {
130 if (wwo->lpLoopPtr) {
131 WARN("Already in a loop. Discarding loop on this header (%p)\n", lpWaveHdr);
133 TRACE("Starting loop (%dx) with %p\n", lpWaveHdr->dwLoops, lpWaveHdr);
134 wwo->lpLoopPtr = lpWaveHdr;
135 /* Windows does not touch WAVEHDR.dwLoops,
136 * so we need to make an internal copy */
137 wwo->dwLoops = lpWaveHdr->dwLoops;
140 wwo->dwPartialOffset = 0;
143 /**************************************************************************
144 * wodPlayer_PlayPtrNext [internal]
146 * Advance the play pointer to the next waveheader, looping if required.
148 static LPWAVEHDR wodPlayer_PlayPtrNext(WINE_WAVEDEV* wwo)
150 LPWAVEHDR lpWaveHdr = wwo->lpPlayPtr;
152 wwo->dwPartialOffset = 0;
153 if ((lpWaveHdr->dwFlags & WHDR_ENDLOOP) && wwo->lpLoopPtr) {
154 /* We're at the end of a loop, loop if required */
155 if (--wwo->dwLoops > 0) {
156 wwo->lpPlayPtr = wwo->lpLoopPtr;
158 /* Handle overlapping loops correctly */
159 if (wwo->lpLoopPtr != lpWaveHdr && (lpWaveHdr->dwFlags & WHDR_BEGINLOOP)) {
160 FIXME("Correctly handled case ? (ending loop buffer also starts a new loop)\n");
161 /* shall we consider the END flag for the closing loop or for
162 * the opening one or for both ???
163 * code assumes for closing loop only
166 lpWaveHdr = lpWaveHdr->lpNext;
168 wwo->lpLoopPtr = NULL;
169 wodPlayer_BeginWaveHdr(wwo, lpWaveHdr);
172 /* We're not in a loop. Advance to the next wave header */
173 wodPlayer_BeginWaveHdr(wwo, lpWaveHdr = lpWaveHdr->lpNext);
179 /**************************************************************************
180 * wodPlayer_DSPWait [internal]
181 * Returns the number of milliseconds to wait for the DSP buffer to play a
184 static DWORD wodPlayer_DSPWait(const WINE_WAVEDEV *wwo)
186 /* time for one period to be played */
190 err = snd_pcm_hw_params_get_period_time(wwo->hw_params, &val, &dir);
194 /**************************************************************************
195 * wodPlayer_NotifyWait [internal]
196 * Returns the number of milliseconds to wait before attempting to notify
197 * completion of the specified wavehdr.
198 * This is based on the number of bytes remaining to be written in the
201 static DWORD wodPlayer_NotifyWait(const WINE_WAVEDEV* wwo, LPWAVEHDR lpWaveHdr)
205 if (lpWaveHdr->reserved < wwo->dwPlayedTotal) {
208 dwMillis = (lpWaveHdr->reserved - wwo->dwPlayedTotal) * 1000 / wwo->format.Format.nAvgBytesPerSec;
209 if (!dwMillis) dwMillis = 1;
216 /**************************************************************************
217 * wodPlayer_WriteMaxFrags [internal]
218 * Writes the maximum number of frames possible to the DSP and returns
219 * the number of frames written.
221 static int wodPlayer_WriteMaxFrags(WINE_WAVEDEV* wwo, DWORD* frames)
223 /* Only attempt to write to free frames */
224 LPWAVEHDR lpWaveHdr = wwo->lpPlayPtr;
225 DWORD dwLength = snd_pcm_bytes_to_frames(wwo->pcm, lpWaveHdr->dwBufferLength - wwo->dwPartialOffset);
226 int toWrite = min(dwLength, *frames);
229 TRACE("Writing wavehdr %p.%u[%u]\n", lpWaveHdr, wwo->dwPartialOffset, lpWaveHdr->dwBufferLength);
232 written = (wwo->write)(wwo->pcm, lpWaveHdr->lpData + wwo->dwPartialOffset, toWrite);
234 /* XRUN occurred. let's try to recover */
235 ALSA_XRUNRecovery(wwo, written);
236 written = (wwo->write)(wwo->pcm, lpWaveHdr->lpData + wwo->dwPartialOffset, toWrite);
240 ERR("Error in writing wavehdr. Reason: %s\n", snd_strerror(written));
246 wwo->dwPartialOffset += snd_pcm_frames_to_bytes(wwo->pcm, written);
247 if ( wwo->dwPartialOffset >= lpWaveHdr->dwBufferLength) {
248 /* this will be used to check if the given wave header has been fully played or not... */
249 wwo->dwPartialOffset = lpWaveHdr->dwBufferLength;
250 /* If we wrote all current wavehdr, skip to the next one */
251 wodPlayer_PlayPtrNext(wwo);
254 wwo->dwWrittenTotal += snd_pcm_frames_to_bytes(wwo->pcm, written);
255 TRACE("dwWrittenTotal=%u\n", wwo->dwWrittenTotal);
261 /**************************************************************************
262 * wodPlayer_NotifyCompletions [internal]
264 * Notifies and remove from queue all wavehdrs which have been played to
265 * the speaker (ie. they have cleared the ALSA buffer). If force is true,
266 * we notify all wavehdrs and remove them all from the queue even if they
267 * are unplayed or part of a loop.
269 static DWORD wodPlayer_NotifyCompletions(WINE_WAVEDEV* wwo, BOOL force)
273 /* Start from lpQueuePtr and keep notifying until:
274 * - we hit an unwritten wavehdr
275 * - we hit the beginning of a running loop
276 * - we hit a wavehdr which hasn't finished playing
280 lpWaveHdr = wwo->lpQueuePtr;
281 if (!lpWaveHdr) {TRACE("Empty queue\n"); break;}
284 if (lpWaveHdr == wwo->lpPlayPtr) {TRACE("play %p\n", lpWaveHdr); break;}
285 if (lpWaveHdr == wwo->lpLoopPtr) {TRACE("loop %p\n", lpWaveHdr); break;}
286 if (lpWaveHdr->reserved > wwo->dwPlayedTotal) {TRACE("still playing %p (%u/%u)\n", lpWaveHdr, lpWaveHdr->reserved, wwo->dwPlayedTotal);break;}
288 wwo->lpQueuePtr = lpWaveHdr->lpNext;
290 lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
291 lpWaveHdr->dwFlags |= WHDR_DONE;
293 wodNotifyClient(wwo, WOM_DONE, (DWORD)lpWaveHdr, 0);
295 return (lpWaveHdr && lpWaveHdr != wwo->lpPlayPtr && lpWaveHdr != wwo->lpLoopPtr) ?
296 wodPlayer_NotifyWait(wwo, lpWaveHdr) : INFINITE;
300 /**************************************************************************
301 * wodPlayer_Reset [internal]
303 * wodPlayer helper. Resets current output stream.
305 static void wodPlayer_Reset(WINE_WAVEDEV* wwo, BOOL reset)
308 TRACE("(%p)\n", wwo);
310 /* flush all possible output */
311 snd_pcm_drain(wwo->pcm);
313 wodUpdatePlayedTotal(wwo, NULL);
314 /* updates current notify list */
315 wodPlayer_NotifyCompletions(wwo, FALSE);
317 if ( (err = snd_pcm_drop(wwo->pcm)) < 0) {
318 FIXME("flush: %s\n", snd_strerror(err));
320 wwo->state = WINE_WS_STOPPED;
323 if ( (err = snd_pcm_prepare(wwo->pcm)) < 0 )
324 ERR("pcm prepare failed: %s\n", snd_strerror(err));
327 enum win_wm_message msg;
331 /* remove any buffer */
332 wodPlayer_NotifyCompletions(wwo, TRUE);
334 wwo->lpPlayPtr = wwo->lpQueuePtr = wwo->lpLoopPtr = NULL;
335 wwo->state = WINE_WS_STOPPED;
336 wwo->dwPlayedTotal = wwo->dwWrittenTotal = 0;
337 /* Clear partial wavehdr */
338 wwo->dwPartialOffset = 0;
340 /* remove any existing message in the ring */
341 EnterCriticalSection(&wwo->msgRing.msg_crst);
342 /* return all pending headers in queue */
343 while (ALSA_RetrieveRingMessage(&wwo->msgRing, &msg, ¶m, &ev))
345 if (msg != WINE_WM_HEADER)
347 FIXME("shouldn't have headers left\n");
351 ((LPWAVEHDR)param)->dwFlags &= ~WHDR_INQUEUE;
352 ((LPWAVEHDR)param)->dwFlags |= WHDR_DONE;
354 wodNotifyClient(wwo, WOM_DONE, param, 0);
356 ALSA_ResetRingMessage(&wwo->msgRing);
357 LeaveCriticalSection(&wwo->msgRing.msg_crst);
359 if (wwo->lpLoopPtr) {
360 /* complicated case, not handled yet (could imply modifying the loop counter */
361 FIXME("Pausing while in loop isn't correctly handled yet, except strange results\n");
362 wwo->lpPlayPtr = wwo->lpLoopPtr;
363 wwo->dwPartialOffset = 0;
364 wwo->dwWrittenTotal = wwo->dwPlayedTotal; /* this is wrong !!! */
367 DWORD sz = wwo->dwPartialOffset;
369 /* reset all the data as if we had written only up to lpPlayedTotal bytes */
370 /* compute the max size playable from lpQueuePtr */
371 for (ptr = wwo->lpQueuePtr; ptr != wwo->lpPlayPtr; ptr = ptr->lpNext) {
372 sz += ptr->dwBufferLength;
374 /* because the reset lpPlayPtr will be lpQueuePtr */
375 if (wwo->dwWrittenTotal > wwo->dwPlayedTotal + sz) ERR("grin\n");
376 wwo->dwPartialOffset = sz - (wwo->dwWrittenTotal - wwo->dwPlayedTotal);
377 wwo->dwWrittenTotal = wwo->dwPlayedTotal;
378 wwo->lpPlayPtr = wwo->lpQueuePtr;
380 wwo->state = WINE_WS_PAUSED;
384 /**************************************************************************
385 * wodPlayer_ProcessMessages [internal]
387 static void wodPlayer_ProcessMessages(WINE_WAVEDEV* wwo)
390 enum win_wm_message msg;
395 while (ALSA_RetrieveRingMessage(&wwo->msgRing, &msg, ¶m, &ev)) {
396 TRACE("Received %s %x\n", ALSA_getCmdString(msg), param);
399 case WINE_WM_PAUSING:
400 if ( snd_pcm_state(wwo->pcm) == SND_PCM_STATE_RUNNING )
402 if ( snd_pcm_hw_params_can_pause(wwo->hw_params) )
404 err = snd_pcm_pause(wwo->pcm, 1);
406 ERR("pcm_pause failed: %s\n", snd_strerror(err));
407 wwo->state = WINE_WS_PAUSED;
411 wodPlayer_Reset(wwo,FALSE);
416 case WINE_WM_RESTARTING:
417 if (wwo->state == WINE_WS_PAUSED)
419 if ( snd_pcm_state(wwo->pcm) == SND_PCM_STATE_PAUSED )
421 err = snd_pcm_pause(wwo->pcm, 0);
423 ERR("pcm_pause failed: %s\n", snd_strerror(err));
425 wwo->state = WINE_WS_PLAYING;
430 lpWaveHdr = (LPWAVEHDR)param;
432 /* insert buffer at the end of queue */
435 for (wh = &(wwo->lpQueuePtr); *wh; wh = &((*wh)->lpNext));
439 wodPlayer_BeginWaveHdr(wwo,lpWaveHdr);
440 if (wwo->state == WINE_WS_STOPPED)
441 wwo->state = WINE_WS_PLAYING;
443 case WINE_WM_RESETTING:
444 wodPlayer_Reset(wwo,TRUE);
448 wodUpdatePlayedTotal(wwo, NULL);
451 case WINE_WM_BREAKLOOP:
452 if (wwo->state == WINE_WS_PLAYING && wwo->lpLoopPtr != NULL) {
453 /* ensure exit at end of current loop */
458 case WINE_WM_CLOSING:
459 /* sanity check: this should not happen since the device must have been reset before */
460 if (wwo->lpQueuePtr || wwo->lpPlayPtr) ERR("out of sync\n");
462 wwo->state = WINE_WS_CLOSED;
465 /* shouldn't go here */
467 FIXME("unknown message %d\n", msg);
473 /**************************************************************************
474 * wodPlayer_FeedDSP [internal]
475 * Feed as much sound data as we can into the DSP and return the number of
476 * milliseconds before it will be necessary to feed the DSP again.
478 static DWORD wodPlayer_FeedDSP(WINE_WAVEDEV* wwo)
482 wodUpdatePlayedTotal(wwo, NULL);
483 availInQ = snd_pcm_avail_update(wwo->pcm);
485 /* no more room... no need to try to feed */
487 /* Feed from partial wavehdr */
488 if (wwo->lpPlayPtr && wwo->dwPartialOffset != 0) {
489 wodPlayer_WriteMaxFrags(wwo, &availInQ);
492 /* Feed wavehdrs until we run out of wavehdrs or DSP space */
493 if (wwo->dwPartialOffset == 0 && wwo->lpPlayPtr) {
495 TRACE("Setting time to elapse for %p to %u\n",
496 wwo->lpPlayPtr, wwo->dwWrittenTotal + wwo->lpPlayPtr->dwBufferLength);
497 /* note the value that dwPlayedTotal will return when this wave finishes playing */
498 wwo->lpPlayPtr->reserved = wwo->dwWrittenTotal + wwo->lpPlayPtr->dwBufferLength;
499 } while (wodPlayer_WriteMaxFrags(wwo, &availInQ) && wwo->lpPlayPtr && availInQ > 0);
503 return wodPlayer_DSPWait(wwo);
506 /**************************************************************************
507 * wodPlayer [internal]
509 static DWORD CALLBACK wodPlayer(LPVOID pmt)
511 WORD uDevID = (DWORD)pmt;
512 WINE_WAVEDEV* wwo = (WINE_WAVEDEV*)&WOutDev[uDevID];
513 DWORD dwNextFeedTime = INFINITE; /* Time before DSP needs feeding */
514 DWORD dwNextNotifyTime = INFINITE; /* Time before next wave completion */
517 wwo->state = WINE_WS_STOPPED;
518 SetEvent(wwo->hStartUpEvent);
521 /** Wait for the shortest time before an action is required. If there
522 * are no pending actions, wait forever for a command.
524 dwSleepTime = min(dwNextFeedTime, dwNextNotifyTime);
525 TRACE("waiting %ums (%u,%u)\n", dwSleepTime, dwNextFeedTime, dwNextNotifyTime);
526 ALSA_WaitRingMessage(&wwo->msgRing, dwSleepTime);
527 wodPlayer_ProcessMessages(wwo);
528 if (wwo->state == WINE_WS_PLAYING) {
529 dwNextFeedTime = wodPlayer_FeedDSP(wwo);
530 dwNextNotifyTime = wodPlayer_NotifyCompletions(wwo, FALSE);
531 if (dwNextFeedTime == INFINITE) {
532 /* FeedDSP ran out of data, but before giving up, */
533 /* check that a notification didn't give us more */
534 wodPlayer_ProcessMessages(wwo);
535 if (wwo->lpPlayPtr) {
536 TRACE("recovering\n");
537 dwNextFeedTime = wodPlayer_FeedDSP(wwo);
541 dwNextFeedTime = dwNextNotifyTime = INFINITE;
546 /**************************************************************************
547 * wodGetDevCaps [internal]
549 static DWORD wodGetDevCaps(WORD wDevID, LPWAVEOUTCAPSW lpCaps, DWORD dwSize)
551 TRACE("(%u, %p, %u);\n", wDevID, lpCaps, dwSize);
553 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
555 if (wDevID >= ALSA_WodNumDevs) {
556 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
557 return MMSYSERR_BADDEVICEID;
560 memcpy(lpCaps, &WOutDev[wDevID].outcaps, min(dwSize, sizeof(*lpCaps)));
561 return MMSYSERR_NOERROR;
564 /**************************************************************************
567 static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
570 snd_pcm_t * pcm = NULL;
571 snd_hctl_t * hctl = NULL;
572 snd_pcm_hw_params_t * hw_params = NULL;
573 snd_pcm_sw_params_t * sw_params;
574 snd_pcm_access_t access;
575 snd_pcm_format_t format = -1;
577 unsigned int buffer_time = 500000;
578 unsigned int period_time = 10000;
579 snd_pcm_uframes_t buffer_size;
580 snd_pcm_uframes_t period_size;
586 snd_pcm_sw_params_alloca(&sw_params);
588 TRACE("(%u, %p, %08X);\n", wDevID, lpDesc, dwFlags);
589 if (lpDesc == NULL) {
590 WARN("Invalid Parameter !\n");
591 return MMSYSERR_INVALPARAM;
593 if (wDevID >= ALSA_WodNumDevs) {
594 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
595 return MMSYSERR_BADDEVICEID;
598 /* only PCM format is supported so far... */
599 if (!ALSA_supportedFormat(lpDesc->lpFormat)) {
600 WARN("Bad format: tag=%04X nChannels=%d nSamplesPerSec=%d !\n",
601 lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,
602 lpDesc->lpFormat->nSamplesPerSec);
603 return WAVERR_BADFORMAT;
606 if (dwFlags & WAVE_FORMAT_QUERY) {
607 TRACE("Query format: tag=%04X nChannels=%d nSamplesPerSec=%d !\n",
608 lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,
609 lpDesc->lpFormat->nSamplesPerSec);
610 return MMSYSERR_NOERROR;
613 wwo = &WOutDev[wDevID];
615 if (wwo->pcm != NULL) {
616 WARN("%d already allocated\n", wDevID);
617 return MMSYSERR_ALLOCATED;
620 if ((dwFlags & WAVE_DIRECTSOUND) && !(wwo->outcaps.dwSupport & WAVECAPS_DIRECTSOUND))
621 /* not supported, ignore it */
622 dwFlags &= ~WAVE_DIRECTSOUND;
624 flags = SND_PCM_NONBLOCK;
626 if ( (err = snd_pcm_open(&pcm, wwo->pcmname, SND_PCM_STREAM_PLAYBACK, flags)) < 0)
628 ERR("Error open: %s\n", snd_strerror(err));
629 return MMSYSERR_NOTENABLED;
634 err = snd_hctl_open(&hctl, wwo->ctlname, 0);
641 WARN("Could not open hctl for [%s]: %s\n", wwo->ctlname, snd_strerror(err));
646 wwo->wFlags = HIWORD(dwFlags & CALLBACK_TYPEMASK);
648 memcpy(&wwo->waveDesc, lpDesc, sizeof(WAVEOPENDESC));
649 ALSA_copyFormat(lpDesc->lpFormat, &wwo->format);
651 TRACE("Requested this format: %dx%dx%d %s\n",
652 wwo->format.Format.nSamplesPerSec,
653 wwo->format.Format.wBitsPerSample,
654 wwo->format.Format.nChannels,
655 ALSA_getFormat(wwo->format.Format.wFormatTag));
657 if (wwo->format.Format.wBitsPerSample == 0) {
658 WARN("Resetting zeroed wBitsPerSample\n");
659 wwo->format.Format.wBitsPerSample = 8 *
660 (wwo->format.Format.nAvgBytesPerSec /
661 wwo->format.Format.nSamplesPerSec) /
662 wwo->format.Format.nChannels;
665 #define EXIT_ON_ERROR(f,e,txt) do \
668 if ( (err = (f) ) < 0) \
670 WARN(txt ": %s\n", snd_strerror(err)); \
676 snd_pcm_hw_params_malloc(&hw_params);
679 retcode = MMSYSERR_NOMEM;
682 snd_pcm_hw_params_any(pcm, hw_params);
684 access = SND_PCM_ACCESS_MMAP_INTERLEAVED;
685 if ( ( err = snd_pcm_hw_params_set_access(pcm, hw_params, access ) ) < 0) {
686 WARN("mmap not available. switching to standard write.\n");
687 access = SND_PCM_ACCESS_RW_INTERLEAVED;
688 EXIT_ON_ERROR( snd_pcm_hw_params_set_access(pcm, hw_params, access ), MMSYSERR_INVALPARAM, "unable to set access for playback");
689 wwo->write = snd_pcm_writei;
692 wwo->write = snd_pcm_mmap_writei;
694 if ((err = snd_pcm_hw_params_set_channels(pcm, hw_params, wwo->format.Format.nChannels)) < 0) {
695 WARN("unable to set required channels: %d\n", wwo->format.Format.nChannels);
696 if (dwFlags & WAVE_DIRECTSOUND) {
697 if (wwo->format.Format.nChannels > 2)
698 wwo->format.Format.nChannels = 2;
699 else if (wwo->format.Format.nChannels == 2)
700 wwo->format.Format.nChannels = 1;
701 else if (wwo->format.Format.nChannels == 1)
702 wwo->format.Format.nChannels = 2;
703 /* recalculate block align and bytes per second */
704 wwo->format.Format.nBlockAlign = (wwo->format.Format.wBitsPerSample * wwo->format.Format.nChannels) / 8;
705 wwo->format.Format.nAvgBytesPerSec = wwo->format.Format.nSamplesPerSec * wwo->format.Format.nBlockAlign;
706 WARN("changed number of channels from %d to %d\n", lpDesc->lpFormat->nChannels, wwo->format.Format.nChannels);
708 EXIT_ON_ERROR( snd_pcm_hw_params_set_channels(pcm, hw_params, wwo->format.Format.nChannels ), WAVERR_BADFORMAT, "unable to set required channels" );
711 if ((wwo->format.Format.wFormatTag == WAVE_FORMAT_PCM) ||
712 ((wwo->format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
713 IsEqualGUID(&wwo->format.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM))) {
714 format = (wwo->format.Format.wBitsPerSample == 8) ? SND_PCM_FORMAT_U8 :
715 (wwo->format.Format.wBitsPerSample == 16) ? SND_PCM_FORMAT_S16_LE :
716 (wwo->format.Format.wBitsPerSample == 24) ? SND_PCM_FORMAT_S24_LE :
717 (wwo->format.Format.wBitsPerSample == 32) ? SND_PCM_FORMAT_S32_LE : -1;
718 } else if ((wwo->format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
719 IsEqualGUID(&wwo->format.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)){
720 format = (wwo->format.Format.wBitsPerSample == 32) ? SND_PCM_FORMAT_FLOAT_LE : -1;
721 } else if (wwo->format.Format.wFormatTag == WAVE_FORMAT_MULAW) {
722 FIXME("unimplemented format: WAVE_FORMAT_MULAW\n");
723 retcode = WAVERR_BADFORMAT;
725 } else if (wwo->format.Format.wFormatTag == WAVE_FORMAT_ALAW) {
726 FIXME("unimplemented format: WAVE_FORMAT_ALAW\n");
727 retcode = WAVERR_BADFORMAT;
729 } else if (wwo->format.Format.wFormatTag == WAVE_FORMAT_ADPCM) {
730 FIXME("unimplemented format: WAVE_FORMAT_ADPCM\n");
731 retcode = WAVERR_BADFORMAT;
734 ERR("invalid format: %0x04x\n", wwo->format.Format.wFormatTag);
735 retcode = WAVERR_BADFORMAT;
739 if ((err = snd_pcm_hw_params_set_format(pcm, hw_params, format)) < 0) {
740 WARN("unable to set required format: %s\n", snd_pcm_format_name(format));
741 if (dwFlags & WAVE_DIRECTSOUND) {
742 if ((wwo->format.Format.wFormatTag == WAVE_FORMAT_PCM) ||
743 ((wwo->format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
744 IsEqualGUID(&wwo->format.SubFormat, & KSDATAFORMAT_SUBTYPE_PCM))) {
745 if (wwo->format.Format.wBitsPerSample != 16) {
746 wwo->format.Format.wBitsPerSample = 16;
747 format = SND_PCM_FORMAT_S16_LE;
749 wwo->format.Format.wBitsPerSample = 8;
750 format = SND_PCM_FORMAT_U8;
752 /* recalculate block align and bytes per second */
753 wwo->format.Format.nBlockAlign = (wwo->format.Format.wBitsPerSample * wwo->format.Format.nChannels) / 8;
754 wwo->format.Format.nAvgBytesPerSec = wwo->format.Format.nSamplesPerSec * wwo->format.Format.nBlockAlign;
755 WARN("changed bits per sample from %d to %d\n", lpDesc->lpFormat->wBitsPerSample, wwo->format.Format.wBitsPerSample);
758 EXIT_ON_ERROR( snd_pcm_hw_params_set_format(pcm, hw_params, format), WAVERR_BADFORMAT, "unable to set required format" );
761 rate = wwo->format.Format.nSamplesPerSec;
763 err = snd_pcm_hw_params_set_rate_near(pcm, hw_params, &rate, &dir);
765 WARN("Rate %d Hz not available for playback: %s\n", wwo->format.Format.nSamplesPerSec, snd_strerror(rate));
766 retcode = WAVERR_BADFORMAT;
769 if (!ALSA_NearMatch(rate, wwo->format.Format.nSamplesPerSec)) {
770 if (dwFlags & WAVE_DIRECTSOUND) {
771 WARN("changed sample rate from %d Hz to %d Hz\n", wwo->format.Format.nSamplesPerSec, rate);
772 wwo->format.Format.nSamplesPerSec = rate;
773 /* recalculate bytes per second */
774 wwo->format.Format.nAvgBytesPerSec = wwo->format.Format.nSamplesPerSec * wwo->format.Format.nBlockAlign;
776 WARN("Rate doesn't match (requested %d Hz, got %d Hz)\n", wwo->format.Format.nSamplesPerSec, rate);
777 retcode = WAVERR_BADFORMAT;
782 /* give the new format back to direct sound */
783 if (dwFlags & WAVE_DIRECTSOUND) {
784 lpDesc->lpFormat->wFormatTag = wwo->format.Format.wFormatTag;
785 lpDesc->lpFormat->nChannels = wwo->format.Format.nChannels;
786 lpDesc->lpFormat->nSamplesPerSec = wwo->format.Format.nSamplesPerSec;
787 lpDesc->lpFormat->wBitsPerSample = wwo->format.Format.wBitsPerSample;
788 lpDesc->lpFormat->nBlockAlign = wwo->format.Format.nBlockAlign;
789 lpDesc->lpFormat->nAvgBytesPerSec = wwo->format.Format.nAvgBytesPerSec;
792 TRACE("Got this format: %dx%dx%d %s\n",
793 wwo->format.Format.nSamplesPerSec,
794 wwo->format.Format.wBitsPerSample,
795 wwo->format.Format.nChannels,
796 ALSA_getFormat(wwo->format.Format.wFormatTag));
799 EXIT_ON_ERROR( snd_pcm_hw_params_set_buffer_time_near(pcm, hw_params, &buffer_time, &dir), MMSYSERR_INVALPARAM, "unable to set buffer time");
801 EXIT_ON_ERROR( snd_pcm_hw_params_set_period_time_near(pcm, hw_params, &period_time, &dir), MMSYSERR_INVALPARAM, "unable to set period time");
803 EXIT_ON_ERROR( snd_pcm_hw_params(pcm, hw_params), MMSYSERR_INVALPARAM, "unable to set hw params for playback");
805 err = snd_pcm_hw_params_get_period_size(hw_params, &period_size, &dir);
806 err = snd_pcm_hw_params_get_buffer_size(hw_params, &buffer_size);
808 snd_pcm_sw_params_current(pcm, sw_params);
809 EXIT_ON_ERROR( snd_pcm_sw_params_set_start_threshold(pcm, sw_params, dwFlags & WAVE_DIRECTSOUND ? INT_MAX : 1 ), MMSYSERR_ERROR, "unable to set start threshold");
810 EXIT_ON_ERROR( snd_pcm_sw_params_set_silence_size(pcm, sw_params, 0), MMSYSERR_ERROR, "unable to set silence size");
811 EXIT_ON_ERROR( snd_pcm_sw_params_set_avail_min(pcm, sw_params, period_size), MMSYSERR_ERROR, "unable to set avail min");
812 EXIT_ON_ERROR( snd_pcm_sw_params_set_xfer_align(pcm, sw_params, 1), MMSYSERR_ERROR, "unable to set xfer align");
813 EXIT_ON_ERROR( snd_pcm_sw_params_set_silence_threshold(pcm, sw_params, 0), MMSYSERR_ERROR, "unable to set silence threshold");
814 EXIT_ON_ERROR( snd_pcm_sw_params_set_xrun_mode(pcm, sw_params, SND_PCM_XRUN_NONE), MMSYSERR_ERROR, "unable to set xrun mode");
815 EXIT_ON_ERROR( snd_pcm_sw_params(pcm, sw_params), MMSYSERR_ERROR, "unable to set sw params for playback");
818 snd_pcm_prepare(pcm);
821 ALSA_TraceParameters(hw_params, sw_params, FALSE);
823 /* now, we can save all required data for later use... */
825 wwo->dwBufferSize = snd_pcm_frames_to_bytes(pcm, buffer_size);
826 wwo->lpQueuePtr = wwo->lpPlayPtr = wwo->lpLoopPtr = NULL;
827 wwo->dwPlayedTotal = wwo->dwWrittenTotal = 0;
828 wwo->dwPartialOffset = 0;
830 ALSA_InitRingMessage(&wwo->msgRing);
832 if (!(dwFlags & WAVE_DIRECTSOUND)) {
833 wwo->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
834 wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID));
836 SetThreadPriority(wwo->hThread, THREAD_PRIORITY_TIME_CRITICAL);
839 ERR("Thread creation for the wodPlayer failed!\n");
840 CloseHandle(wwo->hStartUpEvent);
841 retcode = MMSYSERR_NOMEM;
844 WaitForSingleObject(wwo->hStartUpEvent, INFINITE);
845 CloseHandle(wwo->hStartUpEvent);
847 wwo->hThread = INVALID_HANDLE_VALUE;
850 wwo->hStartUpEvent = INVALID_HANDLE_VALUE;
852 TRACE("handle=%p\n", pcm);
853 TRACE("wBitsPerSample=%u, nAvgBytesPerSec=%u, nSamplesPerSec=%u, nChannels=%u nBlockAlign=%u!\n",
854 wwo->format.Format.wBitsPerSample, wwo->format.Format.nAvgBytesPerSec,
855 wwo->format.Format.nSamplesPerSec, wwo->format.Format.nChannels,
856 wwo->format.Format.nBlockAlign);
860 if ( wwo->hw_params )
861 snd_pcm_hw_params_free(wwo->hw_params);
862 wwo->hw_params = hw_params;
864 return wodNotifyClient(wwo, WOM_OPEN, 0L, 0L);
873 snd_hctl_close(hctl);
877 snd_pcm_hw_params_free(hw_params);
879 if (wwo->msgRing.ring_buffer_size > 0)
880 ALSA_DestroyRingMessage(&wwo->msgRing);
886 /**************************************************************************
887 * wodClose [internal]
889 static DWORD wodClose(WORD wDevID)
891 DWORD ret = MMSYSERR_NOERROR;
894 TRACE("(%u);\n", wDevID);
896 if (wDevID >= ALSA_WodNumDevs) {
897 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
898 return MMSYSERR_BADDEVICEID;
901 if (WOutDev[wDevID].pcm == NULL) {
902 WARN("Requested to close already closed device %d!\n", wDevID);
903 return MMSYSERR_BADDEVICEID;
906 wwo = &WOutDev[wDevID];
907 if (wwo->lpQueuePtr) {
908 WARN("buffers still playing !\n");
909 ret = WAVERR_STILLPLAYING;
911 if (wwo->hThread != INVALID_HANDLE_VALUE) {
912 ALSA_AddRingMessage(&wwo->msgRing, WINE_WM_CLOSING, 0, TRUE);
914 ALSA_DestroyRingMessage(&wwo->msgRing);
917 snd_pcm_hw_params_free(wwo->hw_params);
918 wwo->hw_params = NULL;
921 snd_pcm_close(wwo->pcm);
926 snd_hctl_free(wwo->hctl);
927 snd_hctl_close(wwo->hctl);
931 ret = wodNotifyClient(wwo, WOM_CLOSE, 0L, 0L);
938 /**************************************************************************
939 * wodWrite [internal]
942 static DWORD wodWrite(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize)
944 TRACE("(%u, %p, %08X);\n", wDevID, lpWaveHdr, dwSize);
946 if (wDevID >= ALSA_WodNumDevs) {
947 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
948 return MMSYSERR_BADDEVICEID;
951 if (WOutDev[wDevID].pcm == NULL) {
952 WARN("Requested to write to closed device %d!\n", wDevID);
953 return MMSYSERR_BADDEVICEID;
956 if (lpWaveHdr->lpData == NULL || !(lpWaveHdr->dwFlags & WHDR_PREPARED))
957 return WAVERR_UNPREPARED;
959 if (lpWaveHdr->dwFlags & WHDR_INQUEUE)
960 return WAVERR_STILLPLAYING;
962 lpWaveHdr->dwFlags &= ~WHDR_DONE;
963 lpWaveHdr->dwFlags |= WHDR_INQUEUE;
964 lpWaveHdr->lpNext = 0;
966 ALSA_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_HEADER, (DWORD)lpWaveHdr, FALSE);
968 return MMSYSERR_NOERROR;
971 /**************************************************************************
972 * wodPause [internal]
974 static DWORD wodPause(WORD wDevID)
976 TRACE("(%u);!\n", wDevID);
978 if (wDevID >= ALSA_WodNumDevs) {
979 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
980 return MMSYSERR_BADDEVICEID;
983 if (WOutDev[wDevID].pcm == NULL) {
984 WARN("Requested to pause closed device %d!\n", wDevID);
985 return MMSYSERR_BADDEVICEID;
988 ALSA_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_PAUSING, 0, TRUE);
990 return MMSYSERR_NOERROR;
993 /**************************************************************************
994 * wodRestart [internal]
996 static DWORD wodRestart(WORD wDevID)
998 TRACE("(%u);\n", wDevID);
1000 if (wDevID >= ALSA_WodNumDevs) {
1001 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1002 return MMSYSERR_BADDEVICEID;
1005 if (WOutDev[wDevID].pcm == NULL) {
1006 WARN("Requested to restart closed device %d!\n", wDevID);
1007 return MMSYSERR_BADDEVICEID;
1010 if (WOutDev[wDevID].state == WINE_WS_PAUSED) {
1011 ALSA_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_RESTARTING, 0, TRUE);
1014 /* FIXME: is NotifyClient with WOM_DONE right ? (Comet Busters 1.3.3 needs this notification) */
1015 /* FIXME: Myst crashes with this ... hmm -MM
1016 return wodNotifyClient(wwo, WOM_DONE, 0L, 0L);
1019 return MMSYSERR_NOERROR;
1022 /**************************************************************************
1023 * wodReset [internal]
1025 static DWORD wodReset(WORD wDevID)
1027 TRACE("(%u);\n", wDevID);
1029 if (wDevID >= ALSA_WodNumDevs) {
1030 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1031 return MMSYSERR_BADDEVICEID;
1034 if (WOutDev[wDevID].pcm == NULL) {
1035 WARN("Requested to reset closed device %d!\n", wDevID);
1036 return MMSYSERR_BADDEVICEID;
1039 ALSA_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_RESETTING, 0, TRUE);
1041 return MMSYSERR_NOERROR;
1044 /**************************************************************************
1045 * wodGetPosition [internal]
1047 static DWORD wodGetPosition(WORD wDevID, LPMMTIME lpTime, DWORD uSize)
1051 TRACE("(%u, %p, %u);\n", wDevID, lpTime, uSize);
1053 if (wDevID >= ALSA_WodNumDevs) {
1054 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1055 return MMSYSERR_BADDEVICEID;
1058 if (WOutDev[wDevID].pcm == NULL) {
1059 WARN("Requested to get position of closed device %d!\n", wDevID);
1060 return MMSYSERR_BADDEVICEID;
1063 if (lpTime == NULL) return MMSYSERR_INVALPARAM;
1065 wwo = &WOutDev[wDevID];
1066 ALSA_AddRingMessage(&wwo->msgRing, WINE_WM_UPDATE, 0, TRUE);
1068 return ALSA_bytes_to_mmtime(lpTime, wwo->dwPlayedTotal, &wwo->format);
1071 /**************************************************************************
1072 * wodBreakLoop [internal]
1074 static DWORD wodBreakLoop(WORD wDevID)
1076 TRACE("(%u);\n", wDevID);
1078 if (wDevID >= ALSA_WodNumDevs) {
1079 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1080 return MMSYSERR_BADDEVICEID;
1083 if (WOutDev[wDevID].pcm == NULL) {
1084 WARN("Requested to breakloop of closed device %d!\n", wDevID);
1085 return MMSYSERR_BADDEVICEID;
1088 ALSA_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_BREAKLOOP, 0, TRUE);
1089 return MMSYSERR_NOERROR;
1092 /**************************************************************************
1093 * wodGetVolume [internal]
1095 static DWORD wodGetVolume(WORD wDevID, LPDWORD lpdwVol)
1103 TRACE("(%u, %p);\n", wDevID, lpdwVol);
1104 if (wDevID >= ALSA_WodNumDevs) {
1105 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1106 return MMSYSERR_BADDEVICEID;
1109 if (lpdwVol == NULL)
1110 return MMSYSERR_NOTENABLED;
1112 wwo = &WOutDev[wDevID];
1114 if (lpdwVol == NULL)
1115 return MMSYSERR_NOTENABLED;
1117 rc = ALSA_CheckSetVolume(wwo->hctl, &left, &right, &min, &max, NULL, NULL, NULL);
1118 if (rc == MMSYSERR_NOERROR)
1120 #define VOLUME_ALSA_TO_WIN(x) ( ( (((x)-min) * 65535) + (max-min)/2 ) /(max-min))
1121 wleft = VOLUME_ALSA_TO_WIN(left);
1122 wright = VOLUME_ALSA_TO_WIN(right);
1123 #undef VOLUME_ALSA_TO_WIN
1124 TRACE("left=%d,right=%d,converted to windows left %d, right %d\n", left, right, wleft, wright);
1125 *lpdwVol = MAKELONG( wleft, wright );
1128 TRACE("CheckSetVolume failed; rc %d\n", rc);
1133 /**************************************************************************
1134 * wodSetVolume [internal]
1136 DWORD wodSetVolume(WORD wDevID, DWORD dwParam)
1144 TRACE("(%u, %08X);\n", wDevID, dwParam);
1145 if (wDevID >= ALSA_WodNumDevs) {
1146 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1147 return MMSYSERR_BADDEVICEID;
1150 wwo = &WOutDev[wDevID];
1152 rc = ALSA_CheckSetVolume(wwo->hctl, NULL, NULL, &min, &max, NULL, NULL, NULL);
1153 if (rc == MMSYSERR_NOERROR)
1155 wleft = LOWORD(dwParam);
1156 wright = HIWORD(dwParam);
1157 #define VOLUME_WIN_TO_ALSA(x) ( ( ( ((x) * (max-min)) + 32767) / 65535) + min )
1158 left = VOLUME_WIN_TO_ALSA(wleft);
1159 right = VOLUME_WIN_TO_ALSA(wright);
1160 #undef VOLUME_WIN_TO_ALSA
1161 rc = ALSA_CheckSetVolume(wwo->hctl, NULL, NULL, NULL, NULL, NULL, &left, &right);
1162 if (rc == MMSYSERR_NOERROR)
1163 TRACE("set volume: wleft=%d, wright=%d, converted to alsa left %d, right %d\n", wleft, wright, left, right);
1165 TRACE("SetVolume failed; rc %d\n", rc);
1171 /**************************************************************************
1172 * wodGetNumDevs [internal]
1174 static DWORD wodGetNumDevs(void)
1176 return ALSA_WodNumDevs;
1179 /**************************************************************************
1180 * wodDevInterfaceSize [internal]
1182 static DWORD wodDevInterfaceSize(UINT wDevID, LPDWORD dwParam1)
1184 TRACE("(%u, %p)\n", wDevID, dwParam1);
1186 *dwParam1 = MultiByteToWideChar(CP_ACP, 0, WOutDev[wDevID].interface_name, -1,
1187 NULL, 0 ) * sizeof(WCHAR);
1188 return MMSYSERR_NOERROR;
1191 /**************************************************************************
1192 * wodDevInterface [internal]
1194 static DWORD wodDevInterface(UINT wDevID, PWCHAR dwParam1, DWORD dwParam2)
1196 if (dwParam2 >= MultiByteToWideChar(CP_ACP, 0, WOutDev[wDevID].interface_name, -1,
1197 NULL, 0 ) * sizeof(WCHAR))
1199 MultiByteToWideChar(CP_ACP, 0, WOutDev[wDevID].interface_name, -1,
1200 dwParam1, dwParam2 / sizeof(WCHAR));
1201 return MMSYSERR_NOERROR;
1203 return MMSYSERR_INVALPARAM;
1206 /**************************************************************************
1207 * wodMessage (WINEALSA.@)
1209 DWORD WINAPI ALSA_wodMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
1210 DWORD dwParam1, DWORD dwParam2)
1212 TRACE("(%u, %s, %08X, %08X, %08X);\n",
1213 wDevID, ALSA_getMessage(wMsg), dwUser, dwParam1, dwParam2);
1220 /* FIXME: Pretend this is supported */
1222 case WODM_OPEN: return wodOpen (wDevID, (LPWAVEOPENDESC)dwParam1, dwParam2);
1223 case WODM_CLOSE: return wodClose (wDevID);
1224 case WODM_GETDEVCAPS: return wodGetDevCaps (wDevID, (LPWAVEOUTCAPSW)dwParam1, dwParam2);
1225 case WODM_GETNUMDEVS: return wodGetNumDevs ();
1226 case WODM_GETPITCH: return MMSYSERR_NOTSUPPORTED;
1227 case WODM_SETPITCH: return MMSYSERR_NOTSUPPORTED;
1228 case WODM_GETPLAYBACKRATE: return MMSYSERR_NOTSUPPORTED;
1229 case WODM_SETPLAYBACKRATE: return MMSYSERR_NOTSUPPORTED;
1230 case WODM_WRITE: return wodWrite (wDevID, (LPWAVEHDR)dwParam1, dwParam2);
1231 case WODM_PAUSE: return wodPause (wDevID);
1232 case WODM_GETPOS: return wodGetPosition (wDevID, (LPMMTIME)dwParam1, dwParam2);
1233 case WODM_BREAKLOOP: return wodBreakLoop (wDevID);
1234 case WODM_PREPARE: return MMSYSERR_NOTSUPPORTED;
1235 case WODM_UNPREPARE: return MMSYSERR_NOTSUPPORTED;
1236 case WODM_GETVOLUME: return wodGetVolume (wDevID, (LPDWORD)dwParam1);
1237 case WODM_SETVOLUME: return wodSetVolume (wDevID, dwParam1);
1238 case WODM_RESTART: return wodRestart (wDevID);
1239 case WODM_RESET: return wodReset (wDevID);
1240 case DRV_QUERYDEVICEINTERFACESIZE: return wodDevInterfaceSize (wDevID, (LPDWORD)dwParam1);
1241 case DRV_QUERYDEVICEINTERFACE: return wodDevInterface (wDevID, (PWCHAR)dwParam1, dwParam2);
1242 case DRV_QUERYDSOUNDIFACE: return wodDsCreate (wDevID, (PIDSDRIVER*)dwParam1);
1243 case DRV_QUERYDSOUNDDESC: return wodDsDesc (wDevID, (PDSDRIVERDESC)dwParam1);
1246 FIXME("unknown message %d!\n", wMsg);
1248 return MMSYSERR_NOTSUPPORTED;
1251 #else /* HAVE_ALSA */
1253 /**************************************************************************
1254 * wodMessage (WINEALSA.@)
1256 DWORD WINAPI ALSA_wodMessage(WORD wDevID, WORD wMsg, DWORD dwUser,
1257 DWORD dwParam1, DWORD dwParam2)
1259 FIXME("(%u, %04X, %08X, %08X, %08X):stub\n", wDevID, wMsg, dwUser, dwParam1, dwParam2);
1260 return MMSYSERR_NOTENABLED;
1263 #endif /* HAVE_ALSA */