Commit 8258a518 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

winealsa.drv: Remove wave, mixer, and dsound driver code.

parent 55542281
MODULE = winealsa.drv
IMPORTS = dxguid uuid winmm ole32 user32 advapi32
IMPORTS = uuid winmm ole32
EXTRALIBS = @ALSALIBS@
C_SRCS = \
alsa.c \
dscapture.c \
dsoutput.c \
midi.c \
mixer.c \
mmdevdrv.c \
wavein.c \
waveinit.c \
waveout.c
mmdevdrv.c
@MAKE_DLL_RULES@
/* Definition for ALSA drivers : wine multimedia system
*
* Copyright (C) 2002 Erich Pouech
* Copyright (C) 2002 Marco Pietrobono
* Copyright (C) 2003 Christian Costa
* Copyright (C) 2007 Maarten Lankhorst
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
#endif
#ifndef __ALSA_H
#define __ALSA_H
#ifdef interface
#undef interface
#endif
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
#ifdef HAVE_ALSA_ASOUNDLIB_H
#include <alsa/asoundlib.h>
#elif defined(HAVE_SYS_ASOUNDLIB_H)
#include <sys/asoundlib.h>
#endif
#ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h>
#endif
/* state diagram for waveOut writing:
*
* +---------+-------------+---------------+---------------------------------+
* | state | function | event | new state |
* +---------+-------------+---------------+---------------------------------+
* | | open() | | STOPPED |
* | PAUSED | write() | | PAUSED |
* | STOPPED | write() | <thrd create> | PLAYING |
* | PLAYING | write() | HEADER | PLAYING |
* | (other) | write() | <error> | |
* | (any) | pause() | PAUSING | PAUSED |
* | PAUSED | restart() | RESTARTING | PLAYING (if no thrd => STOPPED) |
* | (any) | reset() | RESETTING | STOPPED |
* | (any) | close() | CLOSING | CLOSED |
* +---------+-------------+---------------+---------------------------------+
*/
/* states of the playing device */
#define WINE_WS_PLAYING 0
#define WINE_WS_PAUSED 1
#define WINE_WS_STOPPED 2
#define WINE_WS_CLOSED 3
/* events to be send to device */
enum win_wm_message {
WINE_WM_PAUSING = WM_USER + 1, WINE_WM_RESTARTING, WINE_WM_RESETTING, WINE_WM_HEADER,
WINE_WM_UPDATE, WINE_WM_BREAKLOOP, WINE_WM_CLOSING, WINE_WM_STARTING, WINE_WM_STOPPING
};
typedef struct {
enum win_wm_message msg; /* message identifier */
DWORD_PTR param; /* parameter for this message */
HANDLE hEvent; /* if message is synchronous, handle of event for synchro */
} ALSA_MSG;
/* implement an in-process message ring for better performance
* (compared to passing thru the server)
* this ring will be used by the input (resp output) record (resp playback) routine
*/
typedef struct {
ALSA_MSG * messages;
int ring_buffer_size;
int msg_tosave;
int msg_toget;
/* Either pipe or event is used, but that is defined in alsa.c,
* since this is a global header we define both here */
int msg_pipe[2];
HANDLE msg_event;
CRITICAL_SECTION msg_crst;
} ALSA_MSG_RING;
typedef struct {
volatile int state; /* one of the WINE_WS_ manifest constants */
WAVEOPENDESC waveDesc;
WORD wFlags;
WAVEFORMATPCMEX format;
char* pcmname; /* string name of alsa PCM device */
char* ctlname; /* string name of alsa control device */
char interface_name[MAXPNAMELEN * 2];
snd_pcm_t* pcm; /* handle to ALSA playback device */
snd_pcm_hw_params_t * hw_params;
DWORD dwBufferSize; /* size of whole ALSA buffer in bytes */
LPWAVEHDR lpQueuePtr; /* start of queued WAVEHDRs (waiting to be notified) */
LPWAVEHDR lpPlayPtr; /* start of not yet fully played buffers */
LPWAVEHDR lpLoopPtr; /* pointer of first buffer in loop, if any */
DWORD dwLoops; /* private copy of loop counter */
DWORD dwPlayedTotal; /* number of bytes actually played since opening */
DWORD dwWrittenTotal; /* number of bytes written to ALSA buffer since opening */
/* synchronization stuff */
HANDLE hStartUpEvent;
HANDLE hThread;
DWORD dwThreadID;
ALSA_MSG_RING msgRing;
/* DirectSound stuff */
DSDRIVERDESC ds_desc;
DSDRIVERCAPS ds_caps;
/* Waveout only fields */
WAVEOUTCAPSW outcaps;
snd_hctl_t * hctl; /* control handle for the playback volume */
snd_pcm_sframes_t (*write)(snd_pcm_t *, const void *, snd_pcm_uframes_t );
DWORD dwPartialOffset; /* Offset of not yet written bytes in lpPlayPtr */
/* Wavein only fields */
WAVEINCAPSW incaps;
DWORD dwSupport;
snd_pcm_sframes_t (*read)(snd_pcm_t *, void *, snd_pcm_uframes_t );
DWORD dwPeriodSize; /* size of OSS buffer period */
DWORD dwTotalRecorded;
} WINE_WAVEDEV;
/*----------------------------------------------------------------------------
** Global array of output and input devices, initialized via ALSA_WaveInit
*/
#define WAVEDEV_ALLOC_EXTENT_SIZE 10
/* wavein.c */
extern WINE_WAVEDEV *WInDev DECLSPEC_HIDDEN;
extern DWORD ALSA_WidNumMallocedDevs DECLSPEC_HIDDEN;
extern DWORD ALSA_WidNumDevs DECLSPEC_HIDDEN;
/* waveout.c */
extern WINE_WAVEDEV *WOutDev DECLSPEC_HIDDEN;
extern DWORD ALSA_WodNumMallocedDevs DECLSPEC_HIDDEN;
extern DWORD ALSA_WodNumDevs DECLSPEC_HIDDEN;
/* alsa.c */
int ALSA_InitRingMessage(ALSA_MSG_RING* omr) DECLSPEC_HIDDEN;
int ALSA_DestroyRingMessage(ALSA_MSG_RING* omr) DECLSPEC_HIDDEN;
void ALSA_ResetRingMessage(ALSA_MSG_RING* omr) DECLSPEC_HIDDEN;
void ALSA_WaitRingMessage(ALSA_MSG_RING* omr, DWORD sleep) DECLSPEC_HIDDEN;
int ALSA_AddRingMessage(ALSA_MSG_RING* omr, enum win_wm_message msg, DWORD_PTR param, BOOL wait) DECLSPEC_HIDDEN;
int ALSA_RetrieveRingMessage(ALSA_MSG_RING* omr, enum win_wm_message *msg, DWORD_PTR *param, HANDLE *hEvent) DECLSPEC_HIDDEN;
int ALSA_CheckSetVolume(snd_hctl_t *hctl, int *out_left, int *out_right, int *out_min, int *out_max, int *out_step, int *new_left, int *new_right) DECLSPEC_HIDDEN;
const char * ALSA_getCmdString(enum win_wm_message msg) DECLSPEC_HIDDEN;
const char * ALSA_getMessage(UINT msg) DECLSPEC_HIDDEN;
const char * ALSA_getFormat(WORD wFormatTag) DECLSPEC_HIDDEN;
BOOL ALSA_NearMatch(int rate1, int rate2) DECLSPEC_HIDDEN;
DWORD ALSA_bytes_to_mmtime(LPMMTIME lpTime, DWORD position, WAVEFORMATPCMEX* format) DECLSPEC_HIDDEN;
void ALSA_TraceParameters(snd_pcm_hw_params_t * hw_params, snd_pcm_sw_params_t * sw, int full) DECLSPEC_HIDDEN;
int wine_snd_pcm_recover(snd_pcm_t *pcm, int err, int silent) DECLSPEC_HIDDEN;
void ALSA_copyFormat(LPWAVEFORMATEX wf1, LPWAVEFORMATPCMEX wf2) DECLSPEC_HIDDEN;
BOOL ALSA_supportedFormat(LPWAVEFORMATEX wf) DECLSPEC_HIDDEN;
/* dscapture.c */
DWORD widDsCreate(UINT wDevID, PIDSCDRIVER* drv) DECLSPEC_HIDDEN;
DWORD widDsDesc(UINT wDevID, PDSDRIVERDESC desc) DECLSPEC_HIDDEN;
/* dsoutput.c */
DWORD wodDsCreate(UINT wDevID, PIDSDRIVER* drv) DECLSPEC_HIDDEN;
DWORD wodDsDesc(UINT wDevID, PDSDRIVERDESC desc) DECLSPEC_HIDDEN;
/* waveinit.c */
extern void ALSA_WaveInit(void) DECLSPEC_HIDDEN;
#endif /* __ALSA_H */
......@@ -51,9 +51,10 @@
#include "mmreg.h"
#include "dsound.h"
#include "dsdriver.h"
#include "alsa.h"
#include "wine/debug.h"
#include <alsa/asoundlib.h>
WINE_DEFAULT_DEBUG_CHANNEL(midi);
#ifndef SND_SEQ_PORT_TYPE_PORT
......@@ -1390,4 +1391,29 @@ DWORD WINAPI ALSA_modMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
return MMSYSERR_NOTSUPPORTED;
}
/*-----------------------------------------------------------------------*/
/**************************************************************************
* DriverProc (WINEALSA.@)
*/
LRESULT CALLBACK ALSA_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
LPARAM dwParam1, LPARAM dwParam2)
{
/* EPP TRACE("(%08lX, %04X, %08lX, %08lX, %08lX)\n", */
/* EPP dwDevID, hDriv, wMsg, dwParam1, dwParam2); */
switch(wMsg) {
case DRV_LOAD:
case DRV_FREE:
case DRV_OPEN:
case DRV_CLOSE:
case DRV_ENABLE:
case DRV_DISABLE:
case DRV_QUERYCONFIGURE:
case DRV_CONFIGURE:
return 1;
case DRV_INSTALL:
case DRV_REMOVE:
return DRV_SUCCESS;
default:
return 0;
}
}
......@@ -37,9 +37,9 @@
#include "devpkey.h"
#include "dshow.h"
#include "dsound.h"
#include "endpointvolume.h"
#include "initguid.h"
#include "endpointvolume.h"
#include "audioclient.h"
#include "audiopolicy.h"
#include "dsdriver.h"
......@@ -158,7 +158,6 @@ static const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl;
static const IChannelAudioVolumeVtbl ChannelAudioVolume_Vtbl;
static const IAudioSessionManager2Vtbl AudioSessionManager2_Vtbl;
int wine_snd_pcm_recover(snd_pcm_t *pcm, int err, int silent);
static AudioSessionWrapper *AudioSessionWrapper_Create(ACImpl *client);
static inline ACImpl *impl_from_IAudioClient(IAudioClient *iface)
......@@ -237,6 +236,49 @@ int WINAPI AUDDRV_GetPriority(void)
return Priority_Neutral;
}
/**************************************************************************
* wine_snd_pcm_recover [internal]
*
* Code slightly modified from alsa-lib v1.0.23 snd_pcm_recover implementation.
* used to recover from XRUN errors (buffer underflow/overflow)
*/
static int wine_snd_pcm_recover(snd_pcm_t *pcm, int err, int silent)
{
if (err > 0)
err = -err;
if (err == -EINTR) /* nothing to do, continue */
return 0;
if (err == -EPIPE) {
const char *s;
if (snd_pcm_stream(pcm) == SND_PCM_STREAM_PLAYBACK)
s = "underrun";
else
s = "overrun";
if (!silent)
ERR("%s occurred\n", s);
err = snd_pcm_prepare(pcm);
if (err < 0) {
ERR("cannot recover from %s, prepare failed: %s\n", s, snd_strerror(err));
return err;
}
return 0;
}
if (err == -ESTRPIPE) {
while ((err = snd_pcm_resume(pcm)) == -EAGAIN)
/* wait until suspend flag is released */
poll(NULL, 0, 1000);
if (err < 0) {
err = snd_pcm_prepare(pcm);
if (err < 0) {
ERR("cannot recover from suspend, prepare failed: %s\n", snd_strerror(err));
return err;
}
}
return 0;
}
return err;
}
static BOOL alsa_try_open(const char *devnode, snd_pcm_stream_t stream)
{
snd_pcm_t *handle;
......
......@@ -2,9 +2,6 @@
@ stdcall -private DriverProc(long long long long long) ALSA_DriverProc
@ stdcall -private midMessage(long long long long long) ALSA_midMessage
@ stdcall -private modMessage(long long long long long) ALSA_modMessage
@ stdcall -private mxdMessage(long long long long long) ALSA_mxdMessage
@ stdcall -private widMessage(long long long long long) ALSA_widMessage
@ stdcall -private wodMessage(long long long long long) ALSA_wodMessage
# MMDevAPI driver functions
@ stdcall -private GetPriority() AUDDRV_GetPriority
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment