Use Qt instead of a full glib event loop just for pulseaudio
ClosedPublic

Authored by sandsmark on Apr 19 2020, 2:35 PM.

Details

Summary

Replaces the glib event loop with something simple that wraps pulseaudio stuff to qt stuff (timers etc.).

Makes it work better with QT_NO_GLIB set, and one less dependency, and integrates better with qt in general (prioritization of events etc.).

Test Plan

Been testing qtpamainloop.h here for a while, and it seems to work well: https://github.com/sandsmark/pavucontrol-qt/

Diff Detail

Repository
R345 KMix
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sandsmark requested review of this revision.Apr 19 2020, 2:35 PM
sandsmark created this revision.

Apologies for taking a long time to review this. Great work, good idea to try to reduce external dependencies as much as possible (especially any starting with 'g').

One observation: would it be possible to allocate the m_mainloop in the Mixer_PULSE constructor, so that there can be just a pointer to it in mixer_pulse.h? Then there would be no need to include qtpamainloop.h in mixer_pulse.h. See inline comments.

backends/mixer_pulse.cpp
1029

m_mainloop = new QtPaMainLoop;

1068

delete m_mainloop

backends/mixer_pulse.h
30

forward declare QtPaMainLoop, move include to cpp file

82

pointer

sandsmark updated this revision to Diff 82449.May 10 2020, 4:03 PM
sandsmark edited the summary of this revision. (Show Details)

Replaced it with a pointer, but as explained in the reply to the comment about deleting and recreating I don't think it makes sense to delete and recreate the fake "mainloop"/event loop since it only wraps the Qt event loop (and can't delete and recreate the Qt event loop obviously).

I thought a bit about it, and ended up not seeing why it should be done at least (everything should work fine as is). But I might be missing something.

sandsmark marked 2 inline comments as done.May 10 2020, 4:03 PM
sandsmark added inline comments.
backends/mixer_pulse.cpp
1068

I thought about doing it initially, but it isn't really necessary.

Since our "mainloop" isn't a real mainloop but just a wrapper around Qt's mainloop, deleting and creating it doesn't really do anything.

marten accepted this revision.May 11 2020, 8:30 AM

Appreciate that using a pointer doesn't change anything at runtime, it was just for the purpose of eliminating an include in the mixer_pulse.h header file.

This revision is now accepted and ready to land.May 11 2020, 8:30 AM

@sandsmark: do you have commit access?

This revision was automatically updated to reflect the committed changes.