summaryrefslogtreecommitdiff
path: root/setedit/extra/mixer.c
blob: c187a0460a3f3041ccd55750cd32696941cf47a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include <configed.h>
#include "mixer.h"

#ifdef HAVE_MIXER

#define drvNone   -1
#define drvFailed -2

static int Driver=drvNone,DriverOld=drvNone;

const char sMxVol[]  =" Vol ";
const char sMxBass[] ="Bass ";
const char sMxTrebl[]="Trebl";
const char sMxSynth[]="Synth";
const char sMxWave[] ="Wave ";
const char sMxSpkr[] ="Spkr ";
const char sMxLine[] ="Line ";
const char sMxMic[]  =" Mic ";
const char sMxCD[]   =" CD  ";
const char sMxMix[]  =" Mix ";
const char sMxWave2[]="Wave2";
const char sMxRec[]  =" Rec ";
const char sMxIGain[]="IGain";
const char sMxOGain[]="OGain";
const char sMxLine1[]="Line1";
const char sMxLine2[]="Line2";
const char sMxLine3[]="Line3";

const char lMxVol[]  ="master vol";
const char lMxBass[] ="bass";
const char lMxTrebl[]="treble";
const char lMxSynth[]="synthetized";
const char lMxWave[] ="wave";
const char lMxSpkr[] ="speaker";
const char lMxLine[] ="line";
const char lMxMic[]  ="mic";
const char lMxCD[]   ="cd";
const char lMxMix[]  ="mixer";
const char lMxWave2[]="wave 2";
const char lMxRec[]  ="record";
const char lMxIGain[]="input gain";
const char lMxOGain[]="output gain";
const char lMxLine1[]="line 1";
const char lMxLine2[]="line 2";
const char lMxLine3[]="line 3";

typedef struct
{
 int  (*Init)();
 void (*DeInit)();
 int  (*Set)(int id, int left, int right);
 int  (*Read)(int id, int *left, int *right);
 const BOARD_MIXER *(*GetElements)(int *cant);
 void (*GetName)(char *buffer, int size);
} stDriver;

#define MaxNameLen 80
static char DrvName[MaxNameLen];

stDriver Drivers[]=
{
#ifdef SECompf_djgpp
 { SBMixerInit,  SBMixerDeInit,  SBSetMixerValue,
   SBReadMixerValue, SBGetElements, SBGetName }
#endif

#ifdef SEOSf_Linux
 { LinuxMixerInit, LinuxMixerDeInit, LinuxSetMixerValue,
   LinuxReadMixerValue, LinuxGetElements, LinuxMixerGetName }
#endif
};

#define NumDrivers (sizeof(Drivers)/sizeof(stDriver))

int MixerInit()
{
 int i;
 if (Driver>=0) return 1;
 if (Driver!=drvFailed && DriverOld>=0)
   {
    if (Drivers[DriverOld].Init())
      {
       Driver=DriverOld;
       return 1;
      }
    DriverOld=drvFailed;
   }
 for (i=0; i<NumDrivers; i++)
     if (Drivers[i].Init())
       {
        Driver=i;
        return 1;
       }
 Driver=drvFailed;
 return 0;
}

void MixerDeInit()
{
 if (Driver<0) return;
 Drivers[Driver].DeInit();
 DriverOld=Driver;
 Driver=drvNone;
}

int SetMixerValue(int id, int left, int right)
{
 if (Driver<0) return 0;
 return Drivers[Driver].Set(id,left,right);
}

int ReadMixerValue(int id, int *left, int *right)
{
 if (Driver<0) return 0;
 return Drivers[Driver].Read(id,left,right);
}

const BOARD_MIXER *GetElements(int *cant)
{
 if (Driver<0) return 0;
 return Drivers[Driver].GetElements(cant);
}

const char *GetMixerName()
{
 if (Driver<0) return 0;
 Drivers[Driver].GetName(DrvName,MaxNameLen);
 return DrvName;
}
#else  // HAVE_MIXER
int  MixerInit() { return 0; }
int  SetMixerValue(int id, int left, int right)
{ if (id | left | right) id=0; return 0; }
void MixerDeInit() {}
const BOARD_MIXER *GetElements(int *cant)
{
 *cant=0;
 return 0;
}
#endif // HAVE_MIXER