diff options
| author | Calvin Morrison <calvin@pobox.com> | 2026-05-15 10:10:04 -0400 |
|---|---|---|
| committer | Calvin Morrison <calvin@pobox.com> | 2026-05-15 10:10:04 -0400 |
| commit | e776bc768cf9afca1867200e25d64d315cd72a3e (patch) | |
| tree | 6745527b939c9d37147d7dc98e8664437ee433f6 /src/model/pulsemodel.h | |
| parent | 4e602e78cdfc210ab7781668df2a88afb923258b (diff) | |
Full mixer implementation — tray, popup, prefs, devices tab with port indicators
Adds the complete tmix feature set built since the initial skeleton:
balance knob, level meters, KLed mute button, system tray with scroll-wheel
volume and recording indicator, tray popup, preferences dialog, right-click
context menus, single-instance enforcement, scroll area, window geometry
persistence, and Devices tab with PA card profile switcher and live port
availability indicators (2-column layout, in-place updates on plug/unplug).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/model/pulsemodel.h')
| -rw-r--r-- | src/model/pulsemodel.h | 66 |
1 files changed, 63 insertions, 3 deletions
diff --git a/src/model/pulsemodel.h b/src/model/pulsemodel.h index b96f2b1..52e379f 100644 --- a/src/model/pulsemodel.h +++ b/src/model/pulsemodel.h @@ -2,6 +2,8 @@ #include <tqobject.h> #include <tqptrlist.h> +#include <tqmap.h> +#include <tqvaluelist.h> #include <pulse/pulseaudio.h> @@ -9,6 +11,38 @@ class PulseDevice; +// ---- card data structures --------------------------------------------------- + +struct PulseCardProfile { + TQString name; + TQString description; + bool available; +}; + +struct PulseCardPort { + TQString name; + TQString description; + int available; // pa_port_available_t: 0=unknown, 1=no, 2=yes + int direction; // PA_DIRECTION_INPUT=1, PA_DIRECTION_OUTPUT=2 + uint32_t type; // pa_device_port_type_t + TQString availabilityGroup; +}; + +struct PulseCardInfo { + uint32_t index; + TQString name; + TQString description; + TQString activeProfile; + TQString vendor; // device.vendor.name + TQString product; // device.product.name + TQString formFactor; // device.form_factor + TQString busType; // device.bus (pci/usb/etc) + TQValueList<PulseCardProfile> profiles; + TQValueList<PulseCardPort> ports; +}; + +// ---- model ------------------------------------------------------------------ + class PulseModel : public TQObject { TQ_OBJECT @@ -21,6 +55,16 @@ public: void close(); TQPtrList<AudioDevice> devices( AudioDevice::Category cat ) const; + AudioDevice *defaultOutput() const; + AudioDevice *defaultInput() const; + + void setDefaultOutput( AudioDevice *dev ); + void setDefaultInput( AudioDevice *dev ); + void moveSinkInputToSink( AudioDevice *playbackDev, AudioDevice *outputDev ); + + TQValueList<PulseCardInfo> cards() const { return m_cards; } + const PulseCardInfo *card( uint32_t index ) const; + void setCardProfile( uint32_t cardIndex, const TQString &profileName ); protected: void customEvent( TQCustomEvent *e ); @@ -28,14 +72,22 @@ protected: signals: void deviceAdded( AudioDevice *dev ); void deviceRemoved( AudioDevice *dev ); - void ready(); // emitted once initial enumeration is complete + void defaultOutputChanged( AudioDevice *dev ); + void defaultInputChanged( AudioDevice *dev ); + void ready(); + + void cardAdded( uint32_t index ); + void cardRemoved( uint32_t index ); + void cardUpdated( uint32_t index ); private: static void contextStateCb( pa_context *c, void *userdata ); + static void serverInfoCb( pa_context *c, const pa_server_info *info, void *userdata ); static void sinkInfoCb( pa_context *c, const pa_sink_info *info, int eol, void *userdata ); static void sourceInfoCb( pa_context *c, const pa_source_info *info, int eol, void *userdata ); static void sinkInputInfoCb( pa_context *c, const pa_sink_input_info *info, int eol, void *userdata ); static void sourceOutputInfoCb( pa_context *c, const pa_source_output_info *info, int eol, void *userdata ); + static void cardInfoCb( pa_context *c, const pa_card_info *info, int eol, void *userdata ); static void subscribeCb( pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata ); void enumerateAll(); @@ -48,11 +100,19 @@ private: pa_threaded_mainloop *m_mainloop; pa_context *m_context; - // Keyed by PA index within each category — stable objects, updated in place. TQPtrList<PulseDevice> m_sinks; TQPtrList<PulseDevice> m_sources; TQPtrList<PulseDevice> m_sinkInputs; TQPtrList<PulseDevice> m_sourceOutputs; - PulseDevice *findDevice( TQPtrList<PulseDevice> &list, uint32_t paIndex ); + TQMap<TQString, PulseDevice*> m_sinksByName; + TQMap<TQString, PulseDevice*> m_sourcesByName; + TQString m_defaultSinkName; + TQString m_defaultSourceName; + TQMap<uint32_t, uint32_t> m_sourceOutputToSource; // soIdx → sourceIdx + + TQValueList<PulseCardInfo> m_cards; + + PulseDevice *findDevice( TQPtrList<PulseDevice> &list, uint32_t paIndex ); + PulseCardInfo *findCard( uint32_t index ); }; |
