Commit 77ae49ce authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

wineoss: Move AUXDM_GETVOLUME and AUXDM_SETVOLUME to the unixlib.

parent d088c3a1
...@@ -18,16 +18,7 @@ ...@@ -18,16 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
...@@ -42,125 +33,6 @@ ...@@ -42,125 +33,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(mmaux); WINE_DEFAULT_DEBUG_CHANNEL(mmaux);
#define MIXER_DEV "/dev/mixer"
/*-----------------------------------------------------------------------*/
/**************************************************************************
* AUX_GetVolume [internal]
*/
static DWORD AUX_GetVolume(WORD wDevID, LPDWORD lpdwVol)
{
int mixer, volume, left, right, cmd;
TRACE("(%04X, %p);\n", wDevID, lpdwVol);
if (lpdwVol == NULL) return MMSYSERR_NOTENABLED;
if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
WARN("mixer device not available !\n");
return MMSYSERR_NOTENABLED;
}
switch(wDevID) {
case 0:
TRACE("SOUND_MIXER_READ_PCM !\n");
cmd = SOUND_MIXER_READ_PCM;
break;
case 1:
TRACE("SOUND_MIXER_READ_SYNTH !\n");
cmd = SOUND_MIXER_READ_SYNTH;
break;
case 2:
TRACE("SOUND_MIXER_READ_CD !\n");
cmd = SOUND_MIXER_READ_CD;
break;
case 3:
TRACE("SOUND_MIXER_READ_LINE !\n");
cmd = SOUND_MIXER_READ_LINE;
break;
case 4:
TRACE("SOUND_MIXER_READ_MIC !\n");
cmd = SOUND_MIXER_READ_MIC;
break;
case 5:
TRACE("SOUND_MIXER_READ_VOLUME !\n");
cmd = SOUND_MIXER_READ_VOLUME;
break;
default:
WARN("invalid device id=%04X !\n", wDevID);
close(mixer);
return MMSYSERR_NOTENABLED;
}
if (ioctl(mixer, cmd, &volume) == -1) {
WARN("unable to read mixer !\n");
close(mixer);
return MMSYSERR_NOTENABLED;
}
close(mixer);
left = LOBYTE(LOWORD(volume));
right = HIBYTE(LOWORD(volume));
TRACE("left=%d right=%d !\n", left, right);
*lpdwVol = MAKELONG((left * 0xFFFFL) / 100, (right * 0xFFFFL) / 100);
return MMSYSERR_NOERROR;
}
/**************************************************************************
* AUX_SetVolume [internal]
*/
static DWORD AUX_SetVolume(WORD wDevID, DWORD dwParam)
{
int mixer;
int volume, left, right;
int cmd;
TRACE("(%04X, %08X);\n", wDevID, dwParam);
left = (LOWORD(dwParam) * 100) >> 16;
right = (HIWORD(dwParam) * 100) >> 16;
volume = (right << 8) | left;
if ((mixer = open(MIXER_DEV, O_RDWR)) < 0) {
WARN("mixer device not available !\n");
return MMSYSERR_NOTENABLED;
}
switch(wDevID) {
case 0:
TRACE("SOUND_MIXER_WRITE_PCM !\n");
cmd = SOUND_MIXER_WRITE_PCM;
break;
case 1:
TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
cmd = SOUND_MIXER_WRITE_SYNTH;
break;
case 2:
TRACE("SOUND_MIXER_WRITE_CD !\n");
cmd = SOUND_MIXER_WRITE_CD;
break;
case 3:
TRACE("SOUND_MIXER_WRITE_LINE !\n");
cmd = SOUND_MIXER_WRITE_LINE;
break;
case 4:
TRACE("SOUND_MIXER_WRITE_MIC !\n");
cmd = SOUND_MIXER_WRITE_MIC;
break;
case 5:
TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
cmd = SOUND_MIXER_WRITE_VOLUME;
break;
default:
WARN("invalid device id=%04X !\n", wDevID);
close(mixer);
return MMSYSERR_NOTENABLED;
}
if (ioctl(mixer, cmd, &volume) == -1) {
WARN("unable to set mixer !\n");
close(mixer);
return MMSYSERR_NOTENABLED;
}
close(mixer);
return MMSYSERR_NOERROR;
}
/************************************************************************** /**************************************************************************
* auxMessage (WINEOSS.2) * auxMessage (WINEOSS.2)
*/ */
...@@ -173,13 +45,6 @@ DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser, ...@@ -173,13 +45,6 @@ DWORD WINAPI OSS_auxMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n", TRACE("(%04X, %04X, %08lX, %08lX, %08lX);\n",
wDevID, wMsg, dwUser, dwParam1, dwParam2); wDevID, wMsg, dwUser, dwParam1, dwParam2);
switch (wMsg) {
case AUXDM_GETVOLUME:
return AUX_GetVolume(wDevID, (LPDWORD)dwParam1);
case AUXDM_SETVOLUME:
return AUX_SetVolume(wDevID, dwParam1);
}
params.dev_id = wDevID; params.dev_id = wDevID;
params.msg = wMsg; params.msg = wMsg;
params.user = dwUser; params.user = dwUser;
......
...@@ -1444,6 +1444,121 @@ static UINT aux_get_devcaps(WORD dev_id, AUXCAPSW *caps, UINT size) ...@@ -1444,6 +1444,121 @@ static UINT aux_get_devcaps(WORD dev_id, AUXCAPSW *caps, UINT size)
return MMSYSERR_NOERROR; return MMSYSERR_NOERROR;
} }
static UINT aux_get_volume(WORD dev_id, UINT *vol)
{
int mixer, volume, left, right, cmd;
TRACE("(%04X, %p);\n", dev_id, vol);
if (vol == NULL) return MMSYSERR_NOTENABLED;
if ((mixer = open(MIXER_DEV, O_RDWR)) < 0)
{
WARN("mixer device not available !\n");
return MMSYSERR_NOTENABLED;
}
switch(dev_id)
{
case 0:
TRACE("SOUND_MIXER_READ_PCM !\n");
cmd = SOUND_MIXER_READ_PCM;
break;
case 1:
TRACE("SOUND_MIXER_READ_SYNTH !\n");
cmd = SOUND_MIXER_READ_SYNTH;
break;
case 2:
TRACE("SOUND_MIXER_READ_CD !\n");
cmd = SOUND_MIXER_READ_CD;
break;
case 3:
TRACE("SOUND_MIXER_READ_LINE !\n");
cmd = SOUND_MIXER_READ_LINE;
break;
case 4:
TRACE("SOUND_MIXER_READ_MIC !\n");
cmd = SOUND_MIXER_READ_MIC;
break;
case 5:
TRACE("SOUND_MIXER_READ_VOLUME !\n");
cmd = SOUND_MIXER_READ_VOLUME;
break;
default:
WARN("invalid device id=%04X !\n", dev_id);
close(mixer);
return MMSYSERR_NOTENABLED;
}
if (ioctl(mixer, cmd, &volume) == -1)
{
WARN("unable to read mixer !\n");
close(mixer);
return MMSYSERR_NOTENABLED;
}
close(mixer);
left = LOBYTE(LOWORD(volume));
right = HIBYTE(LOWORD(volume));
TRACE("left=%d right=%d !\n", left, right);
*vol = MAKELONG((left * 0xFFFFL) / 100, (right * 0xFFFFL) / 100);
return MMSYSERR_NOERROR;
}
static UINT aux_set_volume(WORD dev_id, UINT vol)
{
int mixer;
int volume, left, right;
int cmd;
TRACE("(%04X, %08X);\n", dev_id, vol);
left = (LOWORD(vol) * 100) >> 16;
right = (HIWORD(vol) * 100) >> 16;
volume = (right << 8) | left;
if ((mixer = open(MIXER_DEV, O_RDWR)) < 0)
{
WARN("mixer device not available !\n");
return MMSYSERR_NOTENABLED;
}
switch(dev_id)
{
case 0:
TRACE("SOUND_MIXER_WRITE_PCM !\n");
cmd = SOUND_MIXER_WRITE_PCM;
break;
case 1:
TRACE("SOUND_MIXER_WRITE_SYNTH !\n");
cmd = SOUND_MIXER_WRITE_SYNTH;
break;
case 2:
TRACE("SOUND_MIXER_WRITE_CD !\n");
cmd = SOUND_MIXER_WRITE_CD;
break;
case 3:
TRACE("SOUND_MIXER_WRITE_LINE !\n");
cmd = SOUND_MIXER_WRITE_LINE;
break;
case 4:
TRACE("SOUND_MIXER_WRITE_MIC !\n");
cmd = SOUND_MIXER_WRITE_MIC;
break;
case 5:
TRACE("SOUND_MIXER_WRITE_VOLUME !\n");
cmd = SOUND_MIXER_WRITE_VOLUME;
break;
default:
WARN("invalid device id=%04X !\n", dev_id);
close(mixer);
return MMSYSERR_NOTENABLED;
}
if (ioctl(mixer, cmd, &volume) == -1)
{
WARN("unable to set mixer !\n");
close(mixer);
return MMSYSERR_NOTENABLED;
}
close(mixer);
return MMSYSERR_NOERROR;
}
static NTSTATUS aux_message(void *args) static NTSTATUS aux_message(void *args)
{ {
struct aux_message_params *params = args; struct aux_message_params *params = args;
...@@ -1468,6 +1583,12 @@ static NTSTATUS aux_message(void *args) ...@@ -1468,6 +1583,12 @@ static NTSTATUS aux_message(void *args)
TRACE("return %d;\n", num_aux); TRACE("return %d;\n", num_aux);
*params->err = num_aux; *params->err = num_aux;
break; break;
case AUXDM_GETVOLUME:
*params->err = aux_get_volume(params->dev_id, (UINT *)params->param_1);
break;
case AUXDM_SETVOLUME:
*params->err = aux_set_volume(params->dev_id, params->param_1);
break;
default: default:
WARN("unknown message !\n"); WARN("unknown message !\n");
*params->err = MMSYSERR_NOTSUPPORTED; *params->err = MMSYSERR_NOTSUPPORTED;
......
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