summaryrefslogtreecommitdiff
path: root/src/model/alsadevice.h
diff options
context:
space:
mode:
authorCalvin Morrison <calvin@pobox.com>2026-05-22 10:16:15 -0400
committerCalvin Morrison <calvin@pobox.com>2026-05-22 10:16:15 -0400
commitcdf72828e599a63fca4a0f1ceeb3145fba581aa3 (patch)
tree16ee02f0ce1e317a09fd4c2a3f9fbdc04aadfe60 /src/model/alsadevice.h
parentb30b234afa3ec18156e432b9f2a7ad2ca80cc672 (diff)
parentd9876849f0208291cc7010522e85593703ff52bd (diff)
Merge branch 'and-the-oss-you-rode-in-on'
Diffstat (limited to 'src/model/alsadevice.h')
-rw-r--r--src/model/alsadevice.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/model/alsadevice.h b/src/model/alsadevice.h
new file mode 100644
index 0000000..cc26801
--- /dev/null
+++ b/src/model/alsadevice.h
@@ -0,0 +1,67 @@
+#pragma once
+
+#include <tqobject.h>
+#include <tqstring.h>
+#include <tqstringlist.h>
+#include <alsa/asoundlib.h>
+
+class AlsaDevice : public TQObject
+{
+ TQ_OBJECT
+public:
+ enum Category { Output, Input, Neutral };
+ enum Type { Slider, Switch, Enum };
+
+ AlsaDevice( Category cat, int cardIndex, snd_mixer_elem_t *elem,
+ const TQString &cardName, TQObject *parent = 0 );
+
+ TQString name() const { return m_name; }
+ TQString cardName() const { return m_cardName; }
+ int cardIndex() const { return m_cardIndex; }
+ Category category() const { return m_category; }
+ Type type() const { return m_type; }
+
+ // Slider
+ int volume() const { return m_volume; }
+ bool muted() const { return m_muted; }
+ int pan() const { return m_pan; }
+ bool stereo() const { return m_stereo; }
+ bool hasMute() const { return m_hasMute; }
+ void setVolume( int v );
+ void setMuted( bool m );
+ void setPan( int p );
+
+ // Enum
+ TQStringList enumValues() const { return m_enumValues; }
+ int enumId() const { return m_enumId; }
+ void setEnumId( int id );
+
+ void syncFromAlsa();
+ static int elemCallback( snd_mixer_elem_t *elem, unsigned int mask );
+
+signals:
+ void volumeChanged( int v );
+ void muteChanged( bool m );
+ void panChanged( int p );
+ void enumChanged( int id );
+
+private:
+ long toAlsaVol( int pct ) const;
+ void pushVolume();
+
+ Category m_category;
+ Type m_type;
+ int m_cardIndex;
+ snd_mixer_elem_t *m_elem;
+ TQString m_name;
+ TQString m_cardName;
+ bool m_stereo;
+ bool m_hasMute;
+ long m_volMin;
+ long m_volMax;
+ int m_volume;
+ bool m_muted;
+ int m_pan;
+ TQStringList m_enumValues;
+ int m_enumId;
+};