File: nmixer.h

package info (click to toggle)
mp3blaster 2-0b16-1.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,012 kB
  • ctags: 1,241
  • sloc: cpp: 12,228; ansic: 1,557; sh: 362; makefile: 107
file content (133 lines) | stat: -rw-r--r-- 2,823 bytes parent folder | download
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
/* A soundmixer for linux with a nice text-interface for those non-X-ers.
 * (C)1998 Bram Avontuur (brama@stack.nl)
 */
#ifndef _LIBMIXER_H
#define _LIBMIXER_H

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif

#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_NCURSES_CURSES_H
#include <ncurses/curses.h>
#elif HAVE_CURSES_H
#include <curses.h>
#else
#error "Can't find any ncurses include file!"
#endif
#ifdef HAVE_NASPLAYER
#include <audio/audiolib.h>
#endif

#define MIXER_DEVICE "/dev/mixer"
#define MYMIN(x, y) ((x) < (y) ? (x) : (y))
#define MYVERSION "<<NMixer "VERSION">>"

#define BOTH_CHANNELS 0x11
#define RIGHT_CHANNEL 0x10
#define LEFT_CHANNEL  0x01

struct volume
{
	short left;
	short right;
}; 

class baseMixer
{
public:
	virtual ~baseMixer();
	baseMixer(baseMixer *next);
	int *GetDevices(int *num);
	bool SetMixer(int device, struct volume *vol);
	bool GetMixer(int device, struct volume *vol);
	const char *GetMixerLabel(int device);
protected:
	void AddDevice(int device);
	virtual bool Set(int device, struct volume *vol) = 0;
	virtual bool Get(int device, struct volume *vol) = 0;
	virtual const char *Label(int device) = 0;
	int *devs, num_devs;
private:
	baseMixer *next;
	int mixerID;
};

class OSSMixer : public baseMixer
{
public:
	OSSMixer(baseMixer *next = 0);
	~OSSMixer();
protected:
	bool Set(int device, struct volume *vol);
	bool Get(int device, struct volume *vol);
	const char *Label(int device);
private:
	int mixer;
};

#ifdef HAVE_NASPLAYER
class NASMixer : public baseMixer
{
public:
	NASMixer(baseMixer *next = 0);
	~NASMixer();
protected:
	bool Set(int device, struct volume *vol);
	bool Get(int device, struct volume *vol);
	const char *Label(int device);
private:
	AuServer *aud;
	AuDeviceAttributes *ada;
	int num_ada;
};
#endif

class NMixer
{
public:
	NMixer(WINDOW* mixwin, const char *mixdev=NULL, int yoffset=0,
		int nrlines=0, int *pairs=0, int bgcolor=0);
	~NMixer();

	short NMixerInit();
	void DrawScrollbar(short i, int spos);
	void ChangeBar(short bar, short amount, short absolute, short channels,
		short update=1);
	void RedrawBars();
	short ProcessKey(int key);
	/* functions for each well-known mixertype */
	void SetMixer(int device, struct volume value, short update=1);
	bool GetMixer(int device, struct volume *vol);
	
private:
	baseMixer *mixers;
	const int *supported;
	char *mixdev;
	int
		yoffset,
		nrlines,
		maxx, maxy,
		nrbars,
		*cpairs,
		bgcolor;
	WINDOW
		*mixwin;
	short
		currentbar,
		minbar, /* index-nr. of topmost on-screen bar. */
		maxspos, /* index-nr. of bottommost on-screen bar. */
		currentspos; /* index-nr. of screen-position of current bar */
};
#endif