summaryrefslogtreecommitdiffstats
path: root/kmix/mixdevice.h
blob: 3a719e5dec2561f6432312685f95358eb45dbd36 (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
#ifndef MixDevice_h
#define MixDevice_h

#include "volume.h"
#include <tqstring.h>
#include <tdeconfig.h>
#include <tqobject.h>
#include <tqptrlist.h>

// ! @todo : CONSIDER MERGING OF MixDevice and Volume classes:
//           Not easy possible, because Volume is used in the driver backends

/* !! @todo : Add 2 fields:
 * bool update_from_Hardware;
 * bool update_from_UI;
 * They will show whether there are pending changes from both sides.
 * Updates will be faster and more reliable by this.
 */
class MixDevice : public TQObject
{
     TQ_OBJECT
  

   public:
      // For each ChannelType a special icon exists
      enum ChannelType {AUDIO = 1, BASS, CD, EXTERNAL, MICROPHONE,
                        MIDI, RECMONITOR, TREBLE, UNKNOWN, VOLUME,
                        VIDEO, SURROUND, HEADPHONE, DIGITAL, AC97,
			SURROUND_BACK, SURROUND_LFE, SURROUND_CENTERFRONT, SURROUND_CENTERBACK
     };


      // The DeviceCategory tells the type of the device
      // It is used in bitmasks, so you must use values of 2^n .
      enum DeviceCategory { UNDEFINED= 0x00, SLIDER=0x01, SWITCH=0x02, ENUM=0x04, ALL=0xff };


      MixDevice(int num, Volume &vol, bool recordable, bool mute,
                                TQString name, ChannelType type = UNKNOWN, DeviceCategory category =
SLIDER );
      MixDevice(const MixDevice &md);
      ~MixDevice();

      int num()                    { return _num; };
      TQString   name()         { return _name; };
      /**
       * Returns an unique ID of this MixDevice. By default the number
       * 'num' from the constructor is returned. It is recommended that
       * a better ID is set directly after constructing the MixDevice using
       * the setUniqueID().
       */
      TQString&   getPK();
      /**
       * Set a suitable PK for this MixDevice. It is used in looking up
       * the keys in kmixrc. It is advised to set a nice name, like
       * 'PCM_2', which would mean "2nd PCM device of the sound card".
       */
      void setPK(TQString &id);
      bool isRecordable()    { return _recordable; };
      bool isRecSource()    { return _recSource; };
      bool isSwitch()        { return _switch; } // !! change to _category == MixDevice::SWITCH
      bool isEnum()          { return _category == MixDevice::ENUM; }
      bool isMuted()         { return _volume.isMuted(); };
      bool hasMute()         { return _mute; }

      void setMuted(bool value)            { _volume.setMuted( value ); };
      void setVolume( int channel, int volume );
      void setRecSource( bool rec ) { _recSource = rec; }
      long getVolume(Volume::ChannelID chid);
      Volume& getVolume();
      long maxVolume();
      long minVolume();

      void setEnumId(int);
      unsigned int enumId();
      TQPtrList<TQString>& enumValues();

      void read( TDEConfig *config, const TQString& grp );
      void write( TDEConfig *config, const TQString& grp );

      void setType( ChannelType channeltype ) { _type = channeltype; };
      ChannelType type() { return _type; };

      DeviceCategory category() { return _category; };

   signals:
      void newVolume( int num, Volume volume );

   protected:
      Volume _volume;
      ChannelType _type;
      // The DeviceCategory tells, how "important" a MixDevice is.
      // The driver (e.g. mixer_oss.cpp) must set this value. It is
      // used for deciding what Sliders to show and for distributing
      // the sliders. It is advised to use the following categories:
      // BASIC:     Master, PCM
      // PRIMARY:   CD, Headphone, Microphone, Line
      // SECONDARY: All others
      // SWITCH:    All devices which only have a On/Off-Switch
      int _num; // ioctl() device number of mixer
      bool _recordable; // Can it be recorded?
      bool _switch; // On/Off switch // !! remove
      bool _mute; // Available mute option
      bool _recSource; // Current rec status
      DeviceCategory _category; //  category
      TQString _name;   // Ascii channel name
      TQString _pk;     // Primary key, used as part in config file keys
      // A MixDevice, that is an ENUM, has these _enumValues
      TQPtrList<TQString> _enumValues;
      int _enumCurrentId;

};

#endif