/*
* This file is part of uniaud.dll.
*
* Copyright (c) 2010 Mensys BV
* Copyright (c) 2007 Vlad Stelmahovsky aka Vladest
*
* 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 3 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 and the GNU General Public License along with this library.
* If not, see .
*/
#define INCL_DOS
#define INCL_DOSERRORS
#include
#include
#include
#include
#include "internal.h"
UniaudCardInstance UniInst[MAX_CARDS] = {0};
int cards_num = 0;
int DebugMode = 0;
int DriverOpen(void)
{
HFILE hFile = 0;
ULONG usAction;
if(DosOpen((PSZ)"ALSA32$", &hFile, &usAction, 0,
FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READWRITE |
OPEN_SHARE_DENYNONE | OPEN_FLAGS_WRITE_THROUGH,
NULL ) == NO_ERROR)
return (int)hFile;
return -UNIAUD_ALSA32OPEN_ERROR;
}
int uniaud_get_card_info(int card_id, UniaudCardInfo *info)
{
HFILE hFile = 0;
//ULONG usAction;
ULONG id_len;
ULONG len;
ULONG rc;
/* checking cards range */
if (card_id < 0 || card_id >= cards_num) // counting cards from 0
return -UNIAUD_INVALID_CARD;
if ((int)(hFile = DriverOpen()) >= 0)
{
rc = DosDevIOCtl(hFile, CAT_IOCTL_OSS32, IOCTL_OSS32_CARD_INFO,
&card_id, sizeof(card_id), &id_len,
&info, sizeof(info), &len);
DosClose(hFile);
if (rc != 0)
return -UNIAUD_ERROR_IN_DRIVER;
return UNIAUD_NO_ERROR;
}
else
return -UNIAUD_ALSA32OPEN_ERROR;
}
static int _uniaud_get_cards(void)
{
HFILE hFile = 0;
//ULONG usAction;
ULONG len;
//ULONG id_len;
ULONG rc;
int cards = 0;
if ((int)(hFile = DriverOpen()) >= 0)
{
rc = DosDevIOCtl(hFile, CAT_IOCTL_OSS32, IOCTL_OSS32_CARDS_NUM,
NULL, 0, NULL,
&cards, sizeof(cards), &len);
DosClose(hFile);
if (rc != 0)
return -UNIAUD_ERROR_IN_DRIVER;
return cards;
}
else
return -UNIAUD_ALSA32OPEN_ERROR;
}
int uniaud_get_cards(void)
{
return cards_num;
}
int uniaud_get_version(void)
{
HFILE hFile = 0;
//ULONG usAction;
ULONG len;
ULONG rc;
int ver = 0;
if ((int)(hFile = DriverOpen()) >= 0)
{
rc = DosDevIOCtl(hFile, CAT_IOCTL_OSS32, IOCTL_OSS32_VERSION,
NULL, 0, NULL, &ver, sizeof(ver), &len);
DosClose(hFile);
if (rc != 0)
return -UNIAUD_ERROR_IN_DRIVER;
return ver;
}
else
return -UNIAUD_ALSA32OPEN_ERROR;
}
//#pragma linkage (_DLL_InitTerm, system)
unsigned long APIENTRY LibMain( unsigned long hModule, unsigned long ulFlag )
{
int i;
PSZ pszTmpLoc;
if(ulFlag == 0) { /* initialize */
if (!DosScanEnv("UNIAUDLIB", &pszTmpLoc)) {
if (stricmp(pszTmpLoc, "DEBUG") == 0) DebugMode = 1;
}
i = uniaud_get_version();
if (DebugMode) printf("Uniaud version %i detected.\n", i);
if (i < 113) return 0;
cards_num = _uniaud_get_cards();
if (DebugMode) printf("%i cards detected\n", cards_num);
for (i=0;i 0) {
UniInst[i].ctls_list = (UniaudControl *) _uniaud_mixer_get_ctl_list(i);
if (!UniInst[i].ctls_list) {
//printf("no list at %i\n", i);
//return 0;
}
} else {
//printf("ctls num: %i at %i\n", UniInst[i].ctls_num, i);
//return 0;
}
}
} else { /* terminate */
}
return 1;
}