File indexing completed on 2024-12-08 04:19:44

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     QTimer m_connectTimer;
0047     int m_connectTries;
0048 
0049     static QString s_applicationId;
0050 
0051     void subscribeCallback(pa_context *context, pa_subscription_event_type_t type, uint32_t index);
0052     void contextStateCallback(pa_context *context);
0053     void sinkCallback(const pa_sink_info *info);
0054     void sinkInputCallback(const pa_sink_input_info *info);
0055     void sourceCallback(const pa_source_info *info);
0056     void sourceOutputCallback(const pa_source_output_info *info);
0057     void clientCallback(const pa_client_info *info);
0058     void cardCallback(const pa_card_info *info);
0059     void moduleCallback(const pa_module_info *info);
0060     void streamRestoreCallback(const pa_ext_stream_restore_info *info);
0061     void serverCallback(const pa_server_info *info);
0062     void streamRestoreWrite(const pa_ext_stream_restore_info *info);
0063     void setGenericVolume(quint32 index,
0064                           int channel,
0065                           qint64 newVolume,
0066                           pa_cvolume cVolume,
0067                           const std::function<pa_operation *(pa_context *, uint32_t, const pa_cvolume *, pa_context_success_cb_t, void *)> &);
0068     void setGenericMute(quint32 index, bool mute, const std::function<pa_operation *(pa_context *, uint32_t, int, pa_context_success_cb_t, void *)> &);
0069     void setGenericPort(quint32 index,
0070                         const QString &portName,
0071                         const std::function<pa_operation *(pa_context *, uint32_t, const char *, pa_context_success_cb_t, void *)> &);
0072     void setGenericDeviceForStream(quint32 streamIndex,
0073                                    quint32 deviceIndex,
0074                                    const std::function<pa_operation *(pa_context *, uint32_t, uint32_t, pa_context_success_cb_t, void *)> &);
0075     void setGenericVolumes(quint32 index,
0076                            QVector<qint64> channelVolumes,
0077                            pa_cvolume cVolume,
0078                            const std::function<pa_operation *(pa_context *, uint32_t, const pa_cvolume *, pa_context_success_cb_t, void *)> &);
0079 
0080     void reset();
0081     void connectToDaemon();
0082     void checkConnectTries();
0083 
0084     Context *q;
0085 };
0086 
0087 }
0088 #endif