/** @file
*
* VBox audio device:
* Windows audio driver
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include <Windows.h>
#include <mmsystem.h>
#include "VBoxDD.h"
#include "vl_vbox.h"
#include "audio.h"
#include "audio_int.h"
typedef struct OSSVoiceOut {
void *pcm_buf;
int fd;
int nfrags;
int fragsize;
int old_optr;
int default_bufsize;
int fStart;
int cBuffers;
int idxBuffer;
} OSSVoiceOut;
typedef struct OSSVoiceIn {
void *pcm_buf;
int fd;
int nfrags;
int fragsize;
int old_optr;
} OSSVoiceIn;
{
}
{
int samples;
if (live <= 0)
return;
if (err != MMSYSERR_NOERROR) {
return;
}
Log( ("winmmaudio: overrun\n"));
return;
}
Log(("winmm_run_out: current pos %08X room left=%08X, decr=%08x\n", mmtime.u.sample, samples, decr));
while (samples)
{
int rc;
if (!(oss->lpwh[oss->idxBuffer].dwFlags & WHDR_DONE) && (oss->lpwh[oss->idxBuffer].dwFlags & WHDR_INQUEUE))
{
break;
}
Log(("winmm_run_out: buffer=%d dst=%08x src=%08x convert_samples %08X\n", oss->idxBuffer, dst, src, convert_samples));
/* Update the size of the buffer */
if (rc != MMSYSERR_NOERROR)
{
break;
}
}
}
{
Log( ("WINMMAUD: winmm_fini_out\n"));
if (err != MMSYSERR_NOERROR) {
}
}
}
#ifdef DEBUG
void CALLBACK winmmBufferDone(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD dwParam1, DWORD dwParam2)
{
{
int bufidx;
}
return;
}
#endif
{
int i;
switch (fmt)
{
case AUD_FMT_U8:
case AUD_FMT_S8:
break;
case AUD_FMT_U16:
case AUD_FMT_S16:
break;
default:
AssertFailed();
return -1;
}
#ifdef DEBUG
#else
#endif
if (rc != MMSYSERR_NOERROR)
{
return -1;
}
{
AssertFailed();
return -1;
}
{
AssertFailed();
return -1;
}
{
if (rc != MMSYSERR_NOERROR)
{
return -1;
}
}
return 0;
}
{
switch (cmd) {
case VOICE_SETBUFSIZE:
{
int buflen, i;
{
{
if (rc != MMSYSERR_NOERROR)
{
return -1;
}
}
{
if (rc != MMSYSERR_NOERROR)
{
return -1;
}
}
}
break;
}
case VOICE_ENABLE:
{
Log( ("WINMMAUD: enabling voice\n"));
break;
}
case VOICE_DISABLE:
Log( ("WINMMAUD: disabling voice\n"));
if (rc != MMSYSERR_NOERROR) {
return -1;
}
break;
}
return 0;
}
{
return -1;
switch (fmt)
{
case AUD_FMT_U8:
case AUD_FMT_S8:
break;
case AUD_FMT_U16:
case AUD_FMT_S16:
break;
default:
AssertFailed();
return -1;
}
if (rc != MMSYSERR_NOERROR)
{
return -1;
}
return -1;
}
return 0;
}
{
if (err) {
}
}
}
{
#if 0
int i;
size_t read_samples = 0;
struct {
int add;
int len;
} bufs[2] = {
{ 0, 0 }
};
if (!dead) {
Log( ("WINMMAUD: empty tot=%d min=%d\n",
return;
}
}
else {
}
for (i = 0; i < 2; ++i) {
if (nread > 0) {
}
}
if (nread == -1) {
switch (errno) {
case EINTR:
case EAGAIN:
break;
default:
Log( ("WINMMAUD: Failed to read %d bytes (to %p): %s\n",
}
}
break;
}
}
}
#endif
}
{
}
{
(void) hw;
(void) cmd;
return 0;
}
#if 0
static int winmm_read_recsrc (int fd)
{
int recsrc;
if (err) {
Log( ("WINMMAUD: Failed to read record source mask\nReason: %s\n",
errstr ()));
return -1;
}
return recsrc;
}
{
if (err) {
Log( ("WINMMAUD: Failed to write record source mask\nReason: %s\n",
errstr ()));
return -1;
}
return 0;
}
static const char *winmm_mixer_names[] = SOUND_DEVICE_NAMES;
{
int vol;
if (err) {
Log( ("WINMMAUD: Failed to read %s volume\nReason: %s\n",
return -1;
}
}
{
if (err) {
Log( ("WINMMAUD: Failed to write %s volume\nReason: %s\n",
return -1;
}
return 0;
}
#endif
static void *winmm_audio_init (void)
{
#if 0
if (fd < 0) {
Log( ("WINMMAUD: Failed to open mixer `%s'\nReason: %s\n",
goto ret;
}
if (audio_state.allow_mixer_access) {
}
}
if (err) {
}
ret:
return &conf;
#endif
return (void *)1;
}
{
#if 0
if (fd < 0) {
Log( ("WINMMAUD: Failed to open mixer `%s'\nReason: %s\n",
return;
}
}
if (temp != -1)
}
if (err) {
}
#endif
}
#if 0
static int aud_to_winmm_record_source (audrecsource_t s)
{
switch (s) {
case AUD_REC_MIC: return SOUND_MASK_MIC;
case AUD_REC_CD: return SOUND_MASK_CD;
case AUD_REC_VIDEO: return SOUND_MASK_VIDEO;
case AUD_REC_LINE_IN: return SOUND_MASK_LINE;
case AUD_REC_PHONE: return SOUND_MASK_PHONEIN;
default:
Log( ("WINMMAUD: Unknown recording source %d using MIC\n", s));
return SOUND_MIXER_MIC;
}
}
static int winmm_to_aud_record_source (int s)
{
switch (s) {
case SOUND_MASK_MIC: return AUD_REC_MIC;
case SOUND_MASK_CD: return AUD_REC_CD;
case SOUND_MASK_VIDEO: return AUD_REC_VIDEO;
case SOUND_MASK_LINE1: return AUD_REC_AUX;
case SOUND_MASK_LINE: return AUD_REC_LINE_IN;
case SOUND_MASK_PHONEIN: return AUD_REC_PHONE;
default:
Log( ("WINMMAUD: Unknown OSS recording source %d using MIC\n", s));
return AUD_REC_MIC;
}
}
#endif
#if 0
{
#if 0
int ret = -1;
if (source == -1) {
Log( ("WINMMAUD: Unsupported recording source %s\n",
AUD_record_source_name (*lrs)));
return -1;
}
if (fd == -1) {
return -1;
}
if (err) {
Log( ("WINMMAUD: Failed to set recording source to %s\nReason: %s\n",
goto err;
}
ret = 0;
err:
Log( ("WINMMAUD: Failed to close mixer device\nReason: %s\n",
errstr ())));
}
return ret;
#else
return 0;
#endif
}
{
int vol;
int winmm_mixerctl, err;
int ret = -1;
if (fd == -1) {
return -1;
}
switch (m) {
case AUD_MIXER_VOLUME:
break;
case AUD_MIXER_PCM:
break;
case AUD_MIXER_LINE_IN:
break;
default:
Log( ("WINMMAUD: Unknown mixer control %d\n", m));
return -1;
}
if (err) {
goto err;
}
if (!*mute) {
}
ret = 0;
err:
Log( ("WINMMAUD: Failed to close mixer device\nReason: %s\n",
errstr ()));
}
return ret;
}
#endif
{
int ret = 0;
#if 0
switch (cmd) {
case SET_RECORD_SOURCE:
{
}
break;
case SET_VOLUME:
{
}
break;
default:
ret = -1;
break;
}
#endif
return ret;
}
};
"WINMM",
1,
sizeof (OSSVoiceOut),
sizeof (OSSVoiceIn)
};