[igt-dev] [PATCH i-g-t v3 6/6] lib/igt_kmod: properly handle pipewire-pulse
Mauro Carvalho Chehab
mauro.chehab at linux.intel.com
Mon May 16 16:51:16 UTC 2022
On Mon, 16 May 2022 15:35:14 +0200
Mauro Carvalho Chehab <mauro.chehab at linux.intel.com> wrote:
> On Mon, 16 May 2022 14:49:21 +0200
> Andi Shyti <andi.shyti at linux.intel.com> wrote:
>
> > Hi Mauro,
> >
> > > +static void pipewire_reserve_wait(int pipewire_pulse_pid)
> > > +{
> > > + char xdg_dir[PATH_MAX];
> > > + const char *homedir;
> > > + struct passwd *pw;
> > > + proc_t *proc_info;
> > > + PROCTAB *proc;
> > > +
> > > + igt_fork(child, 1) {
> > > + igt_info("Preventing pipewire-pulse to use the audio drivers\n");
> > > +
> > > + proc = openproc(PROC_FILLCOM | PROC_FILLSTAT | PROC_FILLARG);
> > > + igt_assert(proc != NULL);
> > > +
> > > + while ((proc_info = readproc(proc, NULL))) {
> > > + if (pipewire_pulse_pid == proc_info->tid)
> > > + break;
> > > + freeproc(proc_info);
> > > + }
> > > + closeproc(proc);
> > > +
> > > + /* Sanity check: if it can't find the process, it means it has gone */
> > > + if (pipewire_pulse_pid != proc_info->tid)
> > > + exit(0);
> > > +
> > > + pw = getpwuid(proc_info->euid);
> > > + homedir = pw->pw_dir;
> > > + snprintf(xdg_dir, sizeof(xdg_dir), "/run/user/%d", proc_info->euid);
> > > + setgid(proc_info->egid);
> > > + setuid(proc_info->euid);
> > > + clearenv();
> > > + setenv("HOME", homedir, 1);
> > > + setenv("XDG_RUNTIME_DIR",xdg_dir, 1);
> > > + freeproc(proc_info);
> > > +
> > > + exit(system("pw-reserve -n Audio0 -r"));
> >
> > no exit...
> >
> > > + }
> >
> > ... and waitchild().
> >
> > Like in patch 1 :)
>
> OK!
Actually, no!
See, this is what happens if it calls waitchild():
IGT-Version: 1.26-g30915d22 (x86_64) (Linux: 5.18.0-rc7-drm-ad75b5b819c9+ x86_64)
Starting subtest: unbind-rebind
process 12096 (alsactl) is using audio device. Should be terminated.
process 12801 (pipewire-pulse) is using audio device. Should be requested to stop using them.
Preventing pipewire-pulse to use the audio drivers
Device Audio0 can not be acquired: Success
reserve acquired
<wait forever, as pw-reserve will run forever>
By using exit(system()) there, everything works like a charm:
IGT-Version: 1.26-gac8dabf6 (x86_64) (Linux: 5.18.0-rc7-drm-ad75b5b819c9+ x86_64)
Starting subtest: unbind-rebind
process 12801 (pipewire-pulse) is using audio device. Should be requested to stop using them.
Preventing pipewire-pulse to use the audio drivers
Device Audio0 can not be acquired: Success
reserve acquired
Unloaded audio driver snd_hda_intel
Realoading snd_hda_intel
Subtest unbind-rebind: SUCCESS (2.755s)
See, what we want is to run pw-reserve in backgroud, then remove
snd_hda_intel and finally kill it with SIGTERM.
Regards,
Mauro
More information about the igt-dev
mailing list