File indexing completed on 2023-12-03 04:47:01

0001 /*
0002     SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 #ifndef CONTEXT_P_H
0007 #define CONTEXT_P_H
0008 
0009 #include "maps.h"
0010 #include "operation.h"
0011 #include <QTimer>
0012 #include <functional>
0013 #include <pulse/context.h>
0014 #include <pulse/ext-stream-restore.h>
0015 #include <pulse/glib-mainloop.h>
0016 #include <pulse/introspect.h>
0017 #include <qglobal.h>
0018 
0019 namespace PulseAudioQt
0020 {
0021 class Server;
0022 
0023 class ContextPrivate
0024 {
0025 public:
0026     explicit ContextPrivate(Context *q);
0027     virtual ~ContextPrivate();
0028 
0029     // Don't forget to add things to reset().
0030     SinkMap m_sinks;
0031     SinkInputMap m_sinkInputs;
0032     SourceMap m_sources;
0033     SourceOutputMap m_sourceOutputs;
0034     ClientMap m_clients;
0035     CardMap m_cards;
0036     ModuleMap m_modules;
0037     StreamRestoreMap m_streamRestores;
0038     Server *m_server;
0039 
0040     pa_context *m_context;
0041     pa_glib_mainloop *m_mainloop;
0042 
0043     QString m_newDefaultSink;
0044     QString m_newDefaultSource;
0045 
0046     int m_references;
0047 
0048     QTimer m_connectTimer;
0049     int m_connectTries;
0050 
0051     static QString s_applicationId;
0052 
0053     void subscribeCallback(pa_context *context, pa_subscription_event_type_t type, uint32_t index);
0054     void contextStateCallback(pa_context *context);
0055     void sinkCallback(const pa_sink_info *info);
0056     void sinkInputCallback(const pa_sink_input_info *info);
0057     void sourceCallback(const pa_source_info *info);
0058     void sourceOutputCallback(const pa_source_output_info *info);
0059     void clientCallback(const pa_client_info *info);
0060     void cardCallback(const pa_card_info *info);
0061     void moduleCallback(const pa_module_info *info);
0062     void streamRestoreCallback(const pa_ext_stream_restore_info *info);
0063     void serverCallback(const pa_server_info *info);
0064     void streamRestoreWrite(const pa_ext_stream_restore_info *info);
0065     void setGenericVolume(quint32 index,
0066                           int channel,
0067                           qint64 newVolume,
0068                           pa_cvolume cVolume,
0069                           const std::function<pa_operation *(pa_context *, uint32_t, const pa_cvolume *, pa_context_success_cb_t, void *)> &);
0070     void setGenericMute(quint32 index, bool mute, const std::function<pa_operation *(pa_context *, uint32_t, int, pa_context_success_cb_t, void *)> &);
0071     void setGenericPort(quint32 index,
0072                         const QString &portName,
0073                         const std::function<pa_operation *(pa_context *, uint32_t, const char *, pa_context_success_cb_t, void *)> &);
0074     void setGenericDeviceForStream(quint32 streamIndex,
0075                                    quint32 deviceIndex,
0076                                    const std::function<pa_operation *(pa_context *, uint32_t, uint32_t, pa_context_success_cb_t, void *)> &);
0077     void setGenericVolumes(quint32 index,
0078                            QVector<qint64> channelVolumes,
0079                            pa_cvolume cVolume,
0080                            const std::function<pa_operation *(pa_context *, uint32_t, const pa_cvolume *, pa_context_success_cb_t, void *)> &);
0081 
0082     void reset();
0083     void connectToDaemon();
0084     void checkConnectTries();
0085 
0086     Context *q;
0087 };
0088 
0089 }
0090 #endif