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>
58 #include "wine/library.h"
59 #include "wine/unicode.h"
60 #include "wine/debug.h"
62 WINE_DEFAULT_DEBUG_CHANNEL(wave);
66 WINE_WAVEDEV *WOutDev;
67 DWORD ALSA_WodNumMallocedDevs;
68 DWORD ALSA_WodNumDevs;
70 /**************************************************************************
71 * wodNotifyClient [internal]
73 static DWORD wodNotifyClient(WINE_WAVEDEV* wwo, WORD wMsg, DWORD dwParam1, DWORD dwParam2)
75 TRACE("wMsg = 0x%04x dwParm1 = %04X dwParam2 = %04X\n", wMsg, dwParam1, dwParam2);
81 if (wwo->wFlags != DCB_NULL &&
82 !DriverCallback(wwo->waveDesc.dwCallback, wwo->wFlags, (HDRVR)wwo->waveDesc.hWave,
83 wMsg, wwo->waveDesc.dwInstance, dwParam1, dwParam2)) {
84 WARN("can't notify client !\n");
85 return MMSYSERR_ERROR;
89 FIXME("Unknown callback message %u\n", wMsg);
90 return MMSYSERR_INVALPARAM;
92 return MMSYSERR_NOERROR;
95 /**************************************************************************
96 * wodUpdatePlayedTotal [internal]
99 static BOOL wodUpdatePlayedTotal(WINE_WAVEDEV* wwo, snd_pcm_status_t* ps)
101 snd_pcm_sframes_t delay = 0;
102 snd_pcm_state_t state;
104 state = snd_pcm_state(wwo->pcm);
105 snd_pcm_delay(wwo->pcm, &delay);
107 /* A delay < 0 indicates an underrun; for our purposes that's 0. */
108 if ( (state != SND_PCM_STATE_RUNNING && state != SND_PCM_STATE_PREPARED) || (delay < 0))
110 WARN("Unexpected state (%d) or delay (%ld) while updating Total Played, resetting\n", state, delay);
113 wwo->dwPlayedTotal = wwo->dwWrittenTotal - snd_pcm_frames_to_bytes(wwo->pcm, delay);
117 /**************************************************************************
118 * wodPlayer_BeginWaveHdr [internal]
120 * Makes the specified lpWaveHdr the currently playing wave header.
121 * If the specified wave header is a begin loop and we're not already in
122 * a loop, setup the loop.
124 static void wodPlayer_BeginWaveHdr(WINE_WAVEDEV* wwo, LPWAVEHDR lpWaveHdr)
126 wwo->lpPlayPtr = lpWaveHdr;
128 if (!lpWaveHdr) return;
130 if (lpWaveHdr->dwFlags & WHDR_BEGINLOOP) {
131 if (wwo->lpLoopPtr) {
132 WARN("Already in a loop. Discarding loop on this header (%p)\n", lpWaveHdr);
134 TRACE("Starting loop (%dx) with %p\n", lpWaveHdr->dwLoops, lpWaveHdr);
135 wwo->lpLoopPtr = lpWaveHdr;
136 /* Windows does not touch WAVEHDR.dwLoops,
137 * so we need to make an internal copy */
138 wwo->dwLoops = lpWaveHdr->dwLoops;
141 wwo->dwPartialOffset = 0;
144 /**************************************************************************
145 * wodPlayer_PlayPtrNext [internal]
147 * Advance the play pointer to the next waveheader, looping if required.
149 static LPWAVEHDR wodPlayer_PlayPtrNext(WINE_WAVEDEV* wwo)
151 LPWAVEHDR lpWaveHdr = wwo->lpPlayPtr;
153 wwo->dwPartialOffset = 0;
154 if ((lpWaveHdr->dwFlags & WHDR_ENDLOOP) && wwo->lpLoopPtr) {
155 /* We're at the end of a loop, loop if required */
156 if (--wwo->dwLoops > 0) {
157 wwo->lpPlayPtr = wwo->lpLoopPtr;
159 /* Handle overlapping loops correctly */
160 if (wwo->lpLoopPtr != lpWaveHdr && (lpWaveHdr->dwFlags & WHDR_BEGINLOOP)) {
161 FIXME("Correctly handled case ? (ending loop buffer also starts a new loop)\n");
162 /* shall we consider the END flag for the closing loop or for
163 * the opening one or for both ???
164 * code assumes for closing loop only
167 lpWaveHdr = lpWaveHdr->lpNext;
169 wwo->lpLoopPtr = NULL;
170 wodPlayer_BeginWaveHdr(wwo, lpWaveHdr);
173 /* We're not in a loop. Advance to the next wave header */
174 wodPlayer_BeginWaveHdr(wwo, lpWaveHdr = lpWaveHdr->lpNext);
180 /**************************************************************************
181 * wodPlayer_DSPWait [internal]
182 * Returns the number of milliseconds to wait for the DSP buffer to play a
185 static DWORD wodPlayer_DSPWait(const WINE_WAVEDEV *wwo)
187 /* time for one period to be played */
191 err = snd_pcm_hw_params_get_period_time(wwo->hw_params, &val, &dir);
195 /**************************************************************************
196 * wodPlayer_NotifyWait [internal]
197 * Returns the number of milliseconds to wait before attempting to notify
198 * completion of the specified wavehdr.
199 * This is based on the number of bytes remaining to be written in the
202 static DWORD wodPlayer_NotifyWait(const WINE_WAVEDEV* wwo, LPWAVEHDR lpWaveHdr)
206 if (lpWaveHdr->reserved < wwo->dwPlayedTotal) {
209 dwMillis = (lpWaveHdr->reserved - wwo->dwPlayedTotal) * 1000 / wwo->format.Format.nAvgBytesPerSec;
210 if (!dwMillis) dwMillis = 1;
217 /**************************************************************************
218 * wodPlayer_WriteMaxFrags [internal]
219 * Writes the maximum number of frames possible to the DSP and returns
220 * the number of frames written.
222 static int wodPlayer_WriteMaxFrags(WINE_WAVEDEV* wwo, DWORD* frames)
224 /* Only attempt to write to free frames */
225 LPWAVEHDR lpWaveHdr = wwo->lpPlayPtr;
226 DWORD dwLength = snd_pcm_bytes_to_frames(wwo->pcm, lpWaveHdr->dwBufferLength - wwo->dwPartialOffset);
227 int toWrite = min(dwLength, *frames);
230 TRACE("Writing wavehdr %p.%u[%u]\n", lpWaveHdr, wwo->dwPartialOffset, lpWaveHdr->dwBufferLength);
233 written = (wwo->write)(wwo->pcm, lpWaveHdr->lpData + wwo->dwPartialOffset, toWrite);
235 /* XRUN occurred. let's try to recover */
236 ALSA_XRUNRecovery(wwo, written);
237 written = (wwo->write)(wwo->pcm, lpWaveHdr->lpData + wwo->dwPartialOffset, toWrite);
241 ERR("Error in writing wavehdr. Reason: %s\n", snd_strerror(written));
247 wwo->dwPartialOffset += snd_pcm_frames_to_bytes(wwo->pcm, written);
248 if ( wwo->dwPartialOffset >= lpWaveHdr->dwBufferLength) {
249 /* this will be used to check if the given wave header has been fully played or not... */
250 wwo->dwPartialOffset = lpWaveHdr->dwBufferLength;
251 /* If we wrote all current wavehdr, skip to the next one */
252 wodPlayer_PlayPtrNext(wwo);
255 wwo->dwWrittenTotal += snd_pcm_frames_to_bytes(wwo->pcm, written);
256 TRACE("dwWrittenTotal=%u\n", wwo->dwWrittenTotal);
262 /**************************************************************************
263 * wodPlayer_NotifyCompletions [internal]
265 * Notifies and remove from queue all wavehdrs which have been played to
266 * the speaker (ie. they have cleared the ALSA buffer). If force is true,
267 * we notify all wavehdrs and remove them all from the queue even if they
268 * are unplayed or part of a loop.
270 static DWORD wodPlayer_NotifyCompletions(WINE_WAVEDEV* wwo, BOOL force)
274 /* Start from lpQueuePtr and keep notifying until:
275 * - we hit an unwritten wavehdr
276 * - we hit the beginning of a running loop
277 * - we hit a wavehdr which hasn't finished playing
281 lpWaveHdr = wwo->lpQueuePtr;
282 if (!lpWaveHdr) {TRACE("Empty queue\n"); break;}
285 if (lpWaveHdr == wwo->lpPlayPtr) {TRACE("play %p\n", lpWaveHdr); break;}
286 if (lpWaveHdr == wwo->lpLoopPtr) {TRACE("loop %p\n", lpWaveHdr); break;}
287 if (lpWaveHdr->reserved > wwo->dwPlayedTotal) {TRACE("still playing %p (%u/%u)\n", lpWaveHdr, lpWaveHdr->reserved, wwo->dwPlayedTotal);break;}
289 wwo->lpQueuePtr = lpWaveHdr->lpNext;
291 lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
292 lpWaveHdr->dwFlags |= WHDR_DONE;
294 wodNotifyClient(wwo, WOM_DONE, (DWORD)lpWaveHdr, 0);
296 return (lpWaveHdr && lpWaveHdr != wwo->lpPlayPtr && lpWaveHdr != wwo->lpLoopPtr) ?
297 wodPlayer_NotifyWait(wwo, lpWaveHdr) : INFINITE;
301 /**************************************************************************
302 * wodPlayer_Reset [internal]
304 * wodPlayer helper. Resets current output stream.
306 static void wodPlayer_Reset(WINE_WAVEDEV* wwo, BOOL reset)
309 TRACE("(%p)\n", wwo);
311 /* flush all possible output */
312 snd_pcm_drain(wwo->pcm);
314 wodUpdatePlayedTotal(wwo, NULL);
315 /* updates current notify list */
316 wodPlayer_NotifyCompletions(wwo, FALSE);
318 if ( (err = snd_pcm_drop(wwo->pcm)) < 0) {
319 FIXME("flush: %s\n", snd_strerror(err));
321 wwo->state = WINE_WS_STOPPED;
324 if ( (err = snd_pcm_prepare(wwo->pcm)) < 0 )
325 ERR("pcm prepare failed: %s\n", snd_strerror(err));
328 enum win_wm_message msg;
332 /* remove any buffer */
333 wodPlayer_NotifyCompletions(wwo, TRUE);
335 wwo->lpPlayPtr = wwo->lpQueuePtr = wwo->lpLoopPtr = NULL;
336 wwo->state = WINE_WS_STOPPED;
337 wwo->dwPlayedTotal = wwo->dwWrittenTotal = 0;
338 /* Clear partial wavehdr */
339 wwo->dwPartialOffset = 0;
341 /* remove any existing message in the ring */
342 EnterCriticalSection(&wwo->msgRing.msg_crst);
343 /* return all pending headers in queue */
344 while (ALSA_RetrieveRingMessage(&wwo->msgRing, &msg, ¶m, &ev))
346 if (msg != WINE_WM_HEADER)
348 FIXME("shouldn't have headers left\n");
352 ((LPWAVEHDR)param)->dwFlags &= ~WHDR_INQUEUE;
353 ((LPWAVEHDR)param)->dwFlags |= WHDR_DONE;
355 wodNotifyClient(wwo, WOM_DONE, param, 0);
357 ALSA_ResetRingMessage(&wwo->msgRing);
358 LeaveCriticalSection(&wwo->msgRing.msg_crst);
360 if (wwo->lpLoopPtr) {
361 /* complicated case, not handled yet (could imply modifying the loop counter */
362 FIXME("Pausing while in loop isn't correctly handled yet, except strange results\n");
363 wwo->lpPlayPtr = wwo->lpLoopPtr;
364 wwo->dwPartialOffset = 0;
365 wwo->dwWrittenTotal = wwo->dwPlayedTotal; /* this is wrong !!! */
368 DWORD sz = wwo->dwPartialOffset;
370 /* reset all the data as if we had written only up to lpPlayedTotal bytes */
371 /* compute the max size playable from lpQueuePtr */
372 for (ptr = wwo->lpQueuePtr; ptr != wwo->lpPlayPtr; ptr = ptr->lpNext) {
373 sz += ptr->dwBufferLength;
375 /* because the reset lpPlayPtr will be lpQueuePtr */
376 if (wwo->dwWrittenTotal > wwo->dwPlayedTotal + sz) ERR("grin\n");
377 wwo->dwPartialOffset = sz - (wwo->dwWrittenTotal - wwo->dwPlayedTotal);
378 wwo->dwWrittenTotal = wwo->dwPlayedTotal;
379 wwo->lpPlayPtr = wwo->lpQueuePtr;
381 wwo->state = WINE_WS_PAUSED;
385 /**************************************************************************
386 * wodPlayer_ProcessMessages [internal]
388 static void wodPlayer_ProcessMessages(WINE_WAVEDEV* wwo)
391 enum win_wm_message msg;
396 while (ALSA_RetrieveRingMessage(&wwo->msgRing, &msg, ¶m, &ev)) {
397 TRACE("Received %s %x\n", ALSA_getCmdString(msg), param);
400 case WINE_WM_PAUSING:
401 if ( snd_pcm_state(wwo->pcm) == SND_PCM_STATE_RUNNING )
403 if ( snd_pcm_hw_params_can_pause(wwo->hw_params) )
405 err = snd_pcm_pause(wwo->pcm, 1);
407 ERR("pcm_pause failed: %s\n", snd_strerror(err));
408 wwo->state = WINE_WS_PAUSED;
412 wodPlayer_Reset(wwo,FALSE);
417 case WINE_WM_RESTARTING:
418 if (wwo->state == WINE_WS_PAUSED)
420 if ( snd_pcm_state(wwo->pcm) == SND_PCM_STATE_PAUSED )
422 err = snd_pcm_pause(wwo->pcm, 0);
424 ERR("pcm_pause failed: %s\n", snd_strerror(err));
426 wwo->state = WINE_WS_PLAYING;
431 lpWaveHdr = (LPWAVEHDR)param;
433 /* insert buffer at the end of queue */
436 for (wh = &(wwo->lpQueuePtr); *wh; wh = &((*wh)->lpNext));
440 wodPlayer_BeginWaveHdr(wwo,lpWaveHdr);
441 if (wwo->state == WINE_WS_STOPPED)
442 wwo->state = WINE_WS_PLAYING;
444 case WINE_WM_RESETTING:
445 wodPlayer_Reset(wwo,TRUE);
449 wodUpdatePlayedTotal(wwo, NULL);
452 case WINE_WM_BREAKLOOP:
453 if (wwo->state == WINE_WS_PLAYING && wwo->lpLoopPtr != NULL) {
454 /* ensure exit at end of current loop */
459 case WINE_WM_CLOSING:
460 /* sanity check: this should not happen since the device must have been reset before */
461 if (wwo->lpQueuePtr || wwo->lpPlayPtr) ERR("out of sync\n");
463 wwo->state = WINE_WS_CLOSED;
466 /* shouldn't go here */
468 FIXME("unknown message %d\n", msg);
474 /**************************************************************************
475 * wodPlayer_FeedDSP [internal]
476 * Feed as much sound data as we can into the DSP and return the number of
477 * milliseconds before it will be necessary to feed the DSP again.
479 static DWORD wodPlayer_FeedDSP(WINE_WAVEDEV* wwo)
483 wodUpdatePlayedTotal(wwo, NULL);
484 availInQ = snd_pcm_avail_update(wwo->pcm);
486 /* no more room... no need to try to feed */
488 /* Feed from partial wavehdr */
489 if (wwo->lpPlayPtr && wwo->dwPartialOffset != 0) {
490 wodPlayer_WriteMaxFrags(wwo, &availInQ);
493 /* Feed wavehdrs until we run out of wavehdrs or DSP space */
494 if (wwo->dwPartialOffset == 0 && wwo->lpPlayPtr) {
496 TRACE("Setting time to elapse for %p to %u\n",
497 wwo->lpPlayPtr, wwo->dwWrittenTotal + wwo->lpPlayPtr->dwBufferLength);
498 /* note the value that dwPlayedTotal will return when this wave finishes playing */
499 wwo->lpPlayPtr->reserved = wwo->dwWrittenTotal + wwo->lpPlayPtr->dwBufferLength;
500 } while (wodPlayer_WriteMaxFrags(wwo, &availInQ) && wwo->lpPlayPtr && availInQ > 0);
504 return wodPlayer_DSPWait(wwo);
507 /**************************************************************************
508 * wodPlayer [internal]
510 static DWORD CALLBACK wodPlayer(LPVOID pmt)
512 WORD uDevID = (DWORD)pmt;
513 WINE_WAVEDEV* wwo = (WINE_WAVEDEV*)&WOutDev[uDevID];
514 DWORD dwNextFeedTime = INFINITE; /* Time before DSP needs feeding */
515 DWORD dwNextNotifyTime = INFINITE; /* Time before next wave completion */
518 wwo->state = WINE_WS_STOPPED;
519 SetEvent(wwo->hStartUpEvent);
522 /** Wait for the shortest time before an action is required. If there
523 * are no pending actions, wait forever for a command.
525 dwSleepTime = min(dwNextFeedTime, dwNextNotifyTime);
526 TRACE("waiting %ums (%u,%u)\n", dwSleepTime, dwNextFeedTime, dwNextNotifyTime);
527 ALSA_WaitRingMessage(&wwo->msgRing, dwSleepTime);
528 wodPlayer_ProcessMessages(wwo);
529 if (wwo->state == WINE_WS_PLAYING) {
530 dwNextFeedTime = wodPlayer_FeedDSP(wwo);
531 dwNextNotifyTime = wodPlayer_NotifyCompletions(wwo, FALSE);
532 if (dwNextFeedTime == INFINITE) {
533 /* FeedDSP ran out of data, but before giving up, */
534 /* check that a notification didn't give us more */
535 wodPlayer_ProcessMessages(wwo);
536 if (wwo->lpPlayPtr) {
537 TRACE("recovering\n");
538 dwNextFeedTime = wodPlayer_FeedDSP(wwo);
542 dwNextFeedTime = dwNextNotifyTime = INFINITE;
547 /**************************************************************************
548 * wodGetDevCaps [internal]
550 static DWORD wodGetDevCaps(WORD wDevID, LPWAVEOUTCAPSW lpCaps, DWORD dwSize)
552 TRACE("(%u, %p, %u);\n", wDevID, lpCaps, dwSize);
554 if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
556 if (wDevID >= ALSA_WodNumDevs) {
557 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
558 return MMSYSERR_BADDEVICEID;
561 memcpy(lpCaps, &WOutDev[wDevID].outcaps, min(dwSize, sizeof(*lpCaps)));
562 return MMSYSERR_NOERROR;
565 /**************************************************************************
568 static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
571 snd_pcm_t * pcm = NULL;
572 snd_hctl_t * hctl = NULL;
573 snd_pcm_hw_params_t * hw_params = NULL;
574 snd_pcm_sw_params_t * sw_params;
575 snd_pcm_access_t access;
576 snd_pcm_format_t format = -1;
578 unsigned int buffer_time = 500000;
579 unsigned int period_time = 10000;
580 snd_pcm_uframes_t buffer_size;
581 snd_pcm_uframes_t period_size;
587 snd_pcm_sw_params_alloca(&sw_params);
589 TRACE("(%u, %p, %08X);\n", wDevID, lpDesc, dwFlags);
590 if (lpDesc == NULL) {
591 WARN("Invalid Parameter !\n");
592 return MMSYSERR_INVALPARAM;
594 if (wDevID >= ALSA_WodNumDevs) {
595 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
596 return MMSYSERR_BADDEVICEID;
599 /* only PCM format is supported so far... */
600 if (!ALSA_supportedFormat(lpDesc->lpFormat)) {
601 WARN("Bad format: tag=%04X nChannels=%d nSamplesPerSec=%d !\n",
602 lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,
603 lpDesc->lpFormat->nSamplesPerSec);
604 return WAVERR_BADFORMAT;
607 if (dwFlags & WAVE_FORMAT_QUERY) {
608 TRACE("Query format: tag=%04X nChannels=%d nSamplesPerSec=%d !\n",
609 lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,
610 lpDesc->lpFormat->nSamplesPerSec);
611 return MMSYSERR_NOERROR;
614 wwo = &WOutDev[wDevID];
616 if (wwo->pcm != NULL) {
617 WARN("%d already allocated\n", wDevID);
618 return MMSYSERR_ALLOCATED;
621 if ((dwFlags & WAVE_DIRECTSOUND) && !(wwo->outcaps.dwSupport & WAVECAPS_DIRECTSOUND))
622 /* not supported, ignore it */
623 dwFlags &= ~WAVE_DIRECTSOUND;
625 flags = SND_PCM_NONBLOCK;
627 if ( (err = snd_pcm_open(&pcm, wwo->pcmname, SND_PCM_STREAM_PLAYBACK, flags)) < 0)
629 ERR("Error open: %s\n", snd_strerror(err));
630 return MMSYSERR_NOTENABLED;
635 err = snd_hctl_open(&hctl, wwo->ctlname, 0);
642 WARN("Could not open hctl for [%s]: %s\n", wwo->ctlname, snd_strerror(err));
647 wwo->wFlags = HIWORD(dwFlags & CALLBACK_TYPEMASK);
649 memcpy(&wwo->waveDesc, lpDesc, sizeof(WAVEOPENDESC));
650 ALSA_copyFormat(lpDesc->lpFormat, &wwo->format);
652 TRACE("Requested this format: %dx%dx%d %s\n",
653 wwo->format.Format.nSamplesPerSec,
654 wwo->format.Format.wBitsPerSample,
655 wwo->format.Format.nChannels,
656 ALSA_getFormat(wwo->format.Format.wFormatTag));
658 if (wwo->format.Format.wBitsPerSample == 0) {
659 WARN("Resetting zeroed wBitsPerSample\n");
660 wwo->format.Format.wBitsPerSample = 8 *
661 (wwo->format.Format.nAvgBytesPerSec /
662 wwo->format.Format.nSamplesPerSec) /
663 wwo->format.Format.nChannels;
666 #define EXIT_ON_ERROR(f,e,txt) do \
669 if ( (err = (f) ) < 0) \
671 WARN(txt ": %s\n", snd_strerror(err)); \
677 snd_pcm_hw_params_malloc(&hw_params);
680 retcode = MMSYSERR_NOMEM;
683 snd_pcm_hw_params_any(pcm, hw_params);
685 access = SND_PCM_ACCESS_MMAP_INTERLEAVED;
686 if ( ( err = snd_pcm_hw_params_set_access(pcm, hw_params, access ) ) < 0) {
687 WARN("mmap not available. switching to standard write.\n");
688 access = SND_PCM_ACCESS_RW_INTERLEAVED;
689 EXIT_ON_ERROR( snd_pcm_hw_params_set_access(pcm, hw_params, access ), MMSYSERR_INVALPARAM, "unable to set access for playback");
690 wwo->write = snd_pcm_writei;
693 wwo->write = snd_pcm_mmap_writei;
695 if ((err = snd_pcm_hw_params_set_channels(pcm, hw_params, wwo->format.Format.nChannels)) < 0) {
696 WARN("unable to set required channels: %d\n", wwo->format.Format.nChannels);
697 if (dwFlags & WAVE_DIRECTSOUND) {
698 if (wwo->format.Format.nChannels > 2)
699 wwo->format.Format.nChannels = 2;
700 else if (wwo->format.Format.nChannels == 2)
701 wwo->format.Format.nChannels = 1;
702 else if (wwo->format.Format.nChannels == 1)
703 wwo->format.Format.nChannels = 2;
704 /* recalculate block align and bytes per second */
705 wwo->format.Format.nBlockAlign = (wwo->format.Format.wBitsPerSample * wwo->format.Format.nChannels) / 8;
706 wwo->format.Format.nAvgBytesPerSec = wwo->format.Format.nSamplesPerSec * wwo->format.Format.nBlockAlign;
707 WARN("changed number of channels from %d to %d\n", lpDesc->lpFormat->nChannels, wwo->format.Format.nChannels);
709 EXIT_ON_ERROR( snd_pcm_hw_params_set_channels(pcm, hw_params, wwo->format.Format.nChannels ), WAVERR_BADFORMAT, "unable to set required channels" );
712 if ((wwo->format.Format.wFormatTag == WAVE_FORMAT_PCM) ||
713 ((wwo->format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
714 IsEqualGUID(&wwo->format.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM))) {
715 format = (wwo->format.Format.wBitsPerSample == 8) ? SND_PCM_FORMAT_U8 :
716 (wwo->format.Format.wBitsPerSample == 16) ? SND_PCM_FORMAT_S16_LE :
717 (wwo->format.Format.wBitsPerSample == 24) ? SND_PCM_FORMAT_S24_LE :
718 (wwo->format.Format.wBitsPerSample == 32) ? SND_PCM_FORMAT_S32_LE : -1;
719 } else if ((wwo->format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
720 IsEqualGUID(&wwo->format.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)){
721 format = (wwo->format.Format.wBitsPerSample == 32) ? SND_PCM_FORMAT_FLOAT_LE : -1;
722 } else if (wwo->format.Format.wFormatTag == WAVE_FORMAT_MULAW) {
723 FIXME("unimplemented format: WAVE_FORMAT_MULAW\n");
724 retcode = WAVERR_BADFORMAT;
726 } else if (wwo->format.Format.wFormatTag == WAVE_FORMAT_ALAW) {
727 FIXME("unimplemented format: WAVE_FORMAT_ALAW\n");
728 retcode = WAVERR_BADFORMAT;
730 } else if (wwo->format.Format.wFormatTag == WAVE_FORMAT_ADPCM) {
731 FIXME("unimplemented format: WAVE_FORMAT_ADPCM\n");
732 retcode = WAVERR_BADFORMAT;
735 ERR("invalid format: %0x04x\n", wwo->format.Format.wFormatTag);
736 retcode = WAVERR_BADFORMAT;
740 if ((err = snd_pcm_hw_params_set_format(pcm, hw_params, format)) < 0) {
741 WARN("unable to set required format: %s\n", snd_pcm_format_name(format));
742 if (dwFlags & WAVE_DIRECTSOUND) {
743 if ((wwo->format.Format.wFormatTag == WAVE_FORMAT_PCM) ||
744 ((wwo->format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
745 IsEqualGUID(&wwo->format.SubFormat, & KSDATAFORMAT_SUBTYPE_PCM))) {
746 if (wwo->format.Format.wBitsPerSample != 16) {
747 wwo->format.Format.wBitsPerSample = 16;
748 format = SND_PCM_FORMAT_S16_LE;
750 wwo->format.Format.wBitsPerSample = 8;
751 format = SND_PCM_FORMAT_U8;
753 /* recalculate block align and bytes per second */
754 wwo->format.Format.nBlockAlign = (wwo->format.Format.wBitsPerSample * wwo->format.Format.nChannels) / 8;
755 wwo->format.Format.nAvgBytesPerSec = wwo->format.Format.nSamplesPerSec * wwo->format.Format.nBlockAlign;
756 WARN("changed bits per sample from %d to %d\n", lpDesc->lpFormat->wBitsPerSample, wwo->format.Format.wBitsPerSample);
759 EXIT_ON_ERROR( snd_pcm_hw_params_set_format(pcm, hw_params, format), WAVERR_BADFORMAT, "unable to set required format" );
762 rate = wwo->format.Format.nSamplesPerSec;
764 err = snd_pcm_hw_params_set_rate_near(pcm, hw_params, &rate, &dir);
766 WARN("Rate %d Hz not available for playback: %s\n", wwo->format.Format.nSamplesPerSec, snd_strerror(rate));
767 retcode = WAVERR_BADFORMAT;
770 if (!ALSA_NearMatch(rate, wwo->format.Format.nSamplesPerSec)) {
771 if (dwFlags & WAVE_DIRECTSOUND) {
772 WARN("changed sample rate from %d Hz to %d Hz\n", wwo->format.Format.nSamplesPerSec, rate);
773 wwo->format.Format.nSamplesPerSec = rate;
774 /* recalculate bytes per second */
775 wwo->format.Format.nAvgBytesPerSec = wwo->format.Format.nSamplesPerSec * wwo->format.Format.nBlockAlign;
777 WARN("Rate doesn't match (requested %d Hz, got %d Hz)\n", wwo->format.Format.nSamplesPerSec, rate);
778 retcode = WAVERR_BADFORMAT;
783 /* give the new format back to direct sound */
784 if (dwFlags & WAVE_DIRECTSOUND) {
785 lpDesc->lpFormat->wFormatTag = wwo->format.Format.wFormatTag;
786 lpDesc->lpFormat->nChannels = wwo->format.Format.nChannels;
787 lpDesc->lpFormat->nSamplesPerSec = wwo->format.Format.nSamplesPerSec;
788 lpDesc->lpFormat->wBitsPerSample = wwo->format.Format.wBitsPerSample;
789 lpDesc->lpFormat->nBlockAlign = wwo->format.Format.nBlockAlign;
790 lpDesc->lpFormat->nAvgBytesPerSec = wwo->format.Format.nAvgBytesPerSec;
793 TRACE("Got this format: %dx%dx%d %s\n",
794 wwo->format.Format.nSamplesPerSec,
795 wwo->format.Format.wBitsPerSample,
796 wwo->format.Format.nChannels,
797 ALSA_getFormat(wwo->format.Format.wFormatTag));
800 EXIT_ON_ERROR( snd_pcm_hw_params_set_buffer_time_near(pcm, hw_params, &buffer_time, &dir), MMSYSERR_INVALPARAM, "unable to set buffer time");
802 EXIT_ON_ERROR( snd_pcm_hw_params_set_period_time_near(pcm, hw_params, &period_time, &dir), MMSYSERR_INVALPARAM, "unable to set period time");
804 EXIT_ON_ERROR( snd_pcm_hw_params(pcm, hw_params), MMSYSERR_INVALPARAM, "unable to set hw params for playback");
806 err = snd_pcm_hw_params_get_period_size(hw_params, &period_size, &dir);
807 err = snd_pcm_hw_params_get_buffer_size(hw_params, &buffer_size);
809 snd_pcm_sw_params_current(pcm, sw_params);
810 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");
811 EXIT_ON_ERROR( snd_pcm_sw_params_set_silence_size(pcm, sw_params, 0), MMSYSERR_ERROR, "unable to set silence size");
812 EXIT_ON_ERROR( snd_pcm_sw_params_set_avail_min(pcm, sw_params, period_size), MMSYSERR_ERROR, "unable to set avail min");
813 EXIT_ON_ERROR( snd_pcm_sw_params_set_xfer_align(pcm, sw_params, 1), MMSYSERR_ERROR, "unable to set xfer align");
814 EXIT_ON_ERROR( snd_pcm_sw_params_set_silence_threshold(pcm, sw_params, 0), MMSYSERR_ERROR, "unable to set silence threshold");
815 EXIT_ON_ERROR( snd_pcm_sw_params_set_xrun_mode(pcm, sw_params, SND_PCM_XRUN_NONE), MMSYSERR_ERROR, "unable to set xrun mode");
816 EXIT_ON_ERROR( snd_pcm_sw_params(pcm, sw_params), MMSYSERR_ERROR, "unable to set sw params for playback");
819 snd_pcm_prepare(pcm);
822 ALSA_TraceParameters(hw_params, sw_params, FALSE);
824 /* now, we can save all required data for later use... */
826 wwo->dwBufferSize = snd_pcm_frames_to_bytes(pcm, buffer_size);
827 wwo->lpQueuePtr = wwo->lpPlayPtr = wwo->lpLoopPtr = NULL;
828 wwo->dwPlayedTotal = wwo->dwWrittenTotal = 0;
829 wwo->dwPartialOffset = 0;
831 ALSA_InitRingMessage(&wwo->msgRing);
833 if (!(dwFlags & WAVE_DIRECTSOUND)) {
834 wwo->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
835 wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID));
837 SetThreadPriority(wwo->hThread, THREAD_PRIORITY_TIME_CRITICAL);
840 ERR("Thread creation for the wodPlayer failed!\n");
841 CloseHandle(wwo->hStartUpEvent);
842 retcode = MMSYSERR_NOMEM;
845 WaitForSingleObject(wwo->hStartUpEvent, INFINITE);
846 CloseHandle(wwo->hStartUpEvent);
848 wwo->hThread = INVALID_HANDLE_VALUE;
851 wwo->hStartUpEvent = INVALID_HANDLE_VALUE;
853 TRACE("handle=%p\n", pcm);
854 TRACE("wBitsPerSample=%u, nAvgBytesPerSec=%u, nSamplesPerSec=%u, nChannels=%u nBlockAlign=%u!\n",
855 wwo->format.Format.wBitsPerSample, wwo->format.Format.nAvgBytesPerSec,
856 wwo->format.Format.nSamplesPerSec, wwo->format.Format.nChannels,
857 wwo->format.Format.nBlockAlign);
861 if ( wwo->hw_params )
862 snd_pcm_hw_params_free(wwo->hw_params);
863 wwo->hw_params = hw_params;
865 return wodNotifyClient(wwo, WOM_OPEN, 0L, 0L);
874 snd_hctl_close(hctl);
878 snd_pcm_hw_params_free(hw_params);
880 if (wwo->msgRing.ring_buffer_size > 0)
881 ALSA_DestroyRingMessage(&wwo->msgRing);
887 /**************************************************************************
888 * wodClose [internal]
890 static DWORD wodClose(WORD wDevID)
892 DWORD ret = MMSYSERR_NOERROR;
895 TRACE("(%u);\n", wDevID);
897 if (wDevID >= ALSA_WodNumDevs) {
898 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
899 return MMSYSERR_BADDEVICEID;
902 if (WOutDev[wDevID].pcm == NULL) {
903 WARN("Requested to close already closed device %d!\n", wDevID);
904 return MMSYSERR_BADDEVICEID;
907 wwo = &WOutDev[wDevID];
908 if (wwo->lpQueuePtr) {
909 WARN("buffers still playing !\n");
910 ret = WAVERR_STILLPLAYING;
912 if (wwo->hThread != INVALID_HANDLE_VALUE) {
913 ALSA_AddRingMessage(&wwo->msgRing, WINE_WM_CLOSING, 0, TRUE);
915 ALSA_DestroyRingMessage(&wwo->msgRing);
918 snd_pcm_hw_params_free(wwo->hw_params);
919 wwo->hw_params = NULL;
922 snd_pcm_close(wwo->pcm);
927 snd_hctl_free(wwo->hctl);
928 snd_hctl_close(wwo->hctl);
932 ret = wodNotifyClient(wwo, WOM_CLOSE, 0L, 0L);
939 /**************************************************************************
940 * wodWrite [internal]
943 static DWORD wodWrite(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize)
945 TRACE("(%u, %p, %08X);\n", wDevID, lpWaveHdr, dwSize);
947 if (wDevID >= ALSA_WodNumDevs) {
948 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
949 return MMSYSERR_BADDEVICEID;
952 if (WOutDev[wDevID].pcm == NULL) {
953 WARN("Requested to write to closed device %d!\n", wDevID);
954 return MMSYSERR_BADDEVICEID;
957 if (lpWaveHdr->lpData == NULL || !(lpWaveHdr->dwFlags & WHDR_PREPARED))
958 return WAVERR_UNPREPARED;
960 if (lpWaveHdr->dwFlags & WHDR_INQUEUE)
961 return WAVERR_STILLPLAYING;
963 lpWaveHdr->dwFlags &= ~WHDR_DONE;
964 lpWaveHdr->dwFlags |= WHDR_INQUEUE;
965 lpWaveHdr->lpNext = 0;
967 ALSA_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_HEADER, (DWORD)lpWaveHdr, FALSE);
969 return MMSYSERR_NOERROR;
972 /**************************************************************************
973 * wodPause [internal]
975 static DWORD wodPause(WORD wDevID)
977 TRACE("(%u);!\n", wDevID);
979 if (wDevID >= ALSA_WodNumDevs) {
980 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
981 return MMSYSERR_BADDEVICEID;
984 if (WOutDev[wDevID].pcm == NULL) {
985 WARN("Requested to pause closed device %d!\n", wDevID);
986 return MMSYSERR_BADDEVICEID;
989 ALSA_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_PAUSING, 0, TRUE);
991 return MMSYSERR_NOERROR;
994 /**************************************************************************
995 * wodRestart [internal]
997 static DWORD wodRestart(WORD wDevID)
999 TRACE("(%u);\n", wDevID);
1001 if (wDevID >= ALSA_WodNumDevs) {
1002 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1003 return MMSYSERR_BADDEVICEID;
1006 if (WOutDev[wDevID].pcm == NULL) {
1007 WARN("Requested to restart closed device %d!\n", wDevID);
1008 return MMSYSERR_BADDEVICEID;
1011 if (WOutDev[wDevID].state == WINE_WS_PAUSED) {
1012 ALSA_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_RESTARTING, 0, TRUE);
1015 /* FIXME: is NotifyClient with WOM_DONE right ? (Comet Busters 1.3.3 needs this notification) */
1016 /* FIXME: Myst crashes with this ... hmm -MM
1017 return wodNotifyClient(wwo, WOM_DONE, 0L, 0L);
1020 return MMSYSERR_NOERROR;
1023 /**************************************************************************
1024 * wodReset [internal]
1026 static DWORD wodReset(WORD wDevID)
1028 TRACE("(%u);\n", wDevID);
1030 if (wDevID >= ALSA_WodNumDevs) {
1031 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1032 return MMSYSERR_BADDEVICEID;
1035 if (WOutDev[wDevID].pcm == NULL) {
1036 WARN("Requested to reset closed device %d!\n", wDevID);
1037 return MMSYSERR_BADDEVICEID;
1040 ALSA_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_RESETTING, 0, TRUE);
1042 return MMSYSERR_NOERROR;
1045 /**************************************************************************
1046 * wodGetPosition [internal]
1048 static DWORD wodGetPosition(WORD wDevID, LPMMTIME lpTime, DWORD uSize)
1052 TRACE("(%u, %p, %u);\n", wDevID, lpTime, uSize);
1054 if (wDevID >= ALSA_WodNumDevs) {
1055 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1056 return MMSYSERR_BADDEVICEID;
1059 if (WOutDev[wDevID].pcm == NULL) {
1060 WARN("Requested to get position of closed device %d!\n", wDevID);
1061 return MMSYSERR_BADDEVICEID;
1064 if (lpTime == NULL) return MMSYSERR_INVALPARAM;
1066 wwo = &WOutDev[wDevID];
1067 ALSA_AddRingMessage(&wwo->msgRing, WINE_WM_UPDATE, 0, TRUE);
1069 return ALSA_bytes_to_mmtime(lpTime, wwo->dwPlayedTotal, &wwo->format);
1072 /**************************************************************************
1073 * wodBreakLoop [internal]
1075 static DWORD wodBreakLoop(WORD wDevID)
1077 TRACE("(%u);\n", wDevID);
1079 if (wDevID >= ALSA_WodNumDevs) {
1080 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1081 return MMSYSERR_BADDEVICEID;
1084 if (WOutDev[wDevID].pcm == NULL) {
1085 WARN("Requested to breakloop of closed device %d!\n", wDevID);
1086 return MMSYSERR_BADDEVICEID;
1089 ALSA_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_BREAKLOOP, 0, TRUE);
1090 return MMSYSERR_NOERROR;
1093 /**************************************************************************
1094 * wodGetVolume [internal]
1096 static DWORD wodGetVolume(WORD wDevID, LPDWORD lpdwVol)
1104 TRACE("(%u, %p);\n", wDevID, lpdwVol);
1105 if (wDevID >= ALSA_WodNumDevs) {
1106 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1107 return MMSYSERR_BADDEVICEID;
1110 if (lpdwVol == NULL)
1111 return MMSYSERR_NOTENABLED;
1113 wwo = &WOutDev[wDevID];
1115 if (lpdwVol == NULL)
1116 return MMSYSERR_NOTENABLED;
1118 rc = ALSA_CheckSetVolume(wwo->hctl, &left, &right, &min, &max, NULL, NULL, NULL);
1119 if (rc == MMSYSERR_NOERROR)
1121 #define VOLUME_ALSA_TO_WIN(x) ( ( (((x)-min) * 65535) + (max-min)/2 ) /(max-min))
1122 wleft = VOLUME_ALSA_TO_WIN(left);
1123 wright = VOLUME_ALSA_TO_WIN(right);
1124 #undef VOLUME_ALSA_TO_WIN
1125 TRACE("left=%d,right=%d,converted to windows left %d, right %d\n", left, right, wleft, wright);
1126 *lpdwVol = MAKELONG( wleft, wright );
1129 TRACE("CheckSetVolume failed; rc %d\n", rc);
1134 /**************************************************************************
1135 * wodSetVolume [internal]
1137 DWORD wodSetVolume(WORD wDevID, DWORD dwParam)
1145 TRACE("(%u, %08X);\n", wDevID, dwParam);
1146 if (wDevID >= ALSA_WodNumDevs) {
1147 TRACE("Asked for device %d, but only %d known!\n", wDevID, ALSA_WodNumDevs);
1148 return MMSYSERR_BADDEVICEID;
1151 wwo = &WOutDev[wDevID];
1153 rc = ALSA_CheckSetVolume(wwo->hctl, NULL, NULL, &min, &max, NULL, NULL, NULL);
1154 if (rc == MMSYSERR_NOERROR)
1156 wleft = LOWORD(dwParam);
1157 wright = HIWORD(dwParam);
1158 #define VOLUME_WIN_TO_ALSA(x) ( ( ( ((x) * (max-min)) + 32767) / 65535) + min )
1159 left = VOLUME_WIN_TO_ALSA(wleft);
1160 right = VOLUME_WIN_TO_ALSA(wright);
1161 #undef VOLUME_WIN_TO_ALSA
1162 rc = ALSA_CheckSetVolume(wwo->hctl, NULL, NULL, NULL, NULL, NULL, &left, &right);
1163 if (rc == MMSYSERR_NOERROR)
1164 TRACE("set volume: wleft=%d, wright=%d, converted to alsa left %d, right %d\n", wleft, wright, left, right);
1166 TRACE("SetVolume failed; rc %d\n", rc);
1172 /**************************************************************************
1173 * wodGetNumDevs [internal]
1175 static DWORD wodGetNumDevs(void)
1177 return ALSA_WodNumDevs;
1180 /**************************************************************************
1181 * wodDevInterfaceSize [internal]
1183 static DWORD wodDevInterfaceSize(UINT wDevID, LPDWORD dwParam1)
1185 TRACE("(%u, %p)\n", wDevID, dwParam1);
1187 *dwParam1 = MultiByteToWideChar(CP_ACP, 0, WOutDev[wDevID].interface_name, -1,
1188 NULL, 0 ) * sizeof(WCHAR);
1189 return MMSYSERR_NOERROR;
1192 /**************************************************************************
1193 * wodDevInterface [internal]
1195 static DWORD wodDevInterface(UINT wDevID, PWCHAR dwParam1, DWORD dwParam2)
1197 if (dwParam2 >= MultiByteToWideChar(CP_ACP, 0, WOutDev[wDevID].interface_name, -1,
1198 NULL, 0 ) * sizeof(WCHAR))
1200 MultiByteToWideChar(CP_ACP, 0, WOutDev[wDevID].interface_name, -1,
1201 dwParam1, dwParam2 / sizeof(WCHAR));
1202 return MMSYSERR_NOERROR;
1204 return MMSYSERR_INVALPARAM;
1207 /**************************************************************************
1208 * wodMessage (WINEALSA.@)
1210 DWORD WINAPI ALSA_wodMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
1211 DWORD dwParam1, DWORD dwParam2)
1213 TRACE("(%u, %s, %08X, %08X, %08X);\n",
1214 wDevID, ALSA_getMessage(wMsg), dwUser, dwParam1, dwParam2);
1221 /* FIXME: Pretend this is supported */
1223 case WODM_OPEN: return wodOpen (wDevID, (LPWAVEOPENDESC)dwParam1, dwParam2);
1224 case WODM_CLOSE: return wodClose (wDevID);
1225 case WODM_GETDEVCAPS: return wodGetDevCaps (wDevID, (LPWAVEOUTCAPSW)dwParam1, dwParam2);
1226 case WODM_GETNUMDEVS: return wodGetNumDevs ();
1227 case WODM_GETPITCH: return MMSYSERR_NOTSUPPORTED;
1228 case WODM_SETPITCH: return MMSYSERR_NOTSUPPORTED;
1229 case WODM_GETPLAYBACKRATE: return MMSYSERR_NOTSUPPORTED;
1230 case WODM_SETPLAYBACKRATE: return MMSYSERR_NOTSUPPORTED;
1231 case WODM_WRITE: return wodWrite (wDevID, (LPWAVEHDR)dwParam1, dwParam2);
1232 case WODM_PAUSE: return wodPause (wDevID);
1233 case WODM_GETPOS: return wodGetPosition (wDevID, (LPMMTIME)dwParam1, dwParam2);
1234 case WODM_BREAKLOOP: return wodBreakLoop (wDevID);
1235 case WODM_PREPARE: return MMSYSERR_NOTSUPPORTED;
1236 case WODM_UNPREPARE: return MMSYSERR_NOTSUPPORTED;
1237 case WODM_GETVOLUME: return wodGetVolume (wDevID, (LPDWORD)dwParam1);
1238 case WODM_SETVOLUME: return wodSetVolume (wDevID, dwParam1);
1239 case WODM_RESTART: return wodRestart (wDevID);
1240 case WODM_RESET: return wodReset (wDevID);
1241 case DRV_QUERYDEVICEINTERFACESIZE: return wodDevInterfaceSize (wDevID, (LPDWORD)dwParam1);
1242 case DRV_QUERYDEVICEINTERFACE: return wodDevInterface (wDevID, (PWCHAR)dwParam1, dwParam2);
1243 case DRV_QUERYDSOUNDIFACE: return wodDsCreate (wDevID, (PIDSDRIVER*)dwParam1);
1244 case DRV_QUERYDSOUNDDESC: return wodDsDesc (wDevID, (PDSDRIVERDESC)dwParam1);
1247 FIXME("unknown message %d!\n", wMsg);
1249 return MMSYSERR_NOTSUPPORTED;
1252 #else /* HAVE_ALSA */
1254 /**************************************************************************
1255 * wodMessage (WINEALSA.@)
1257 DWORD WINAPI ALSA_wodMessage(WORD wDevID, WORD wMsg, DWORD dwUser,
1258 DWORD dwParam1, DWORD dwParam2)
1260 FIXME("(%u, %04X, %08X, %08X, %08X):stub\n", wDevID, wMsg, dwUser, dwParam1, dwParam2);
1261 return MMSYSERR_NOTENABLED;
1264 #endif /* HAVE_ALSA */