mcdesoundd: the session's Start and End tones (t0043)

dtsession starts mcdesoundd at login (config/0075.mcdesoundd) and the daemon
dies with the session; the two theme events Start and End were never played.
Now the daemon plays Start as soon as it owns _MCDE_SOUND_SERVER, and End in
an X I/O error handler: at logout dtlogin resets the X server, the daemon's
connection dies there, it forks the player (which outlives it) and exits.
Both go through the theme (MCDE_SOUND_THEME), not a fixed file; the path does
not need X, so it works in the I/O error handler.

Measured (Xvfb :86, installed Base theme, PULSE_SINK on a private null sink in
the running PulseAudio -- no sound on the real sink):
- start: "mcdesoundd: theme .../themes/Base" and
  "mcdesoundd: Start -> .../themes/Base/start.wav (player)".
- kill the Xvfb (the server reset at logout):
  "mcdesoundd: End -> .../themes/Base/end.wav (player)", and the daemon is
  gone (only the session's own daemon remains).
make mcde-linux MCDE_DIRS="install programs/mcdesoundd" exit=0;
MCDE_DIRS=plist "mcde-plist-check: ok".

The AX_* events of the same task (AccessX and the Keyboard pane) are not in
this commit; t0043 stays open for them.
This commit is contained in:
lotherk committed 2026-11-16 14:36:09 +00:00
1 parent 11cd07b560
commit 37d566dac5
2 files changed
+48 -1

No files matched your search

+5 -1
View File
@@ -625,7 +625,11 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
own short tones), `Base` (the lower voice) and `IRIX` (the old IRIX 6.5
sounds from `~/tmp/irix_extract/assets/desktop-sounds/sounds-events`, 20
events). `MCDE_SOUND_THEME=...` chooses one without a session (tests;
`mcdesoundd -selftest` checks the events and files). Output has the volume,
`mcdesoundd -selftest` checks the events and files). The session's own two
tones: the daemon plays `Start` once it owns the selection (dtsession
starts it at login) and `End` in the X I/O error handler -- at logout
dtlogin resets the server and the player it forks outlives the daemon
(t0043). Output has the volume,
Mute and "Show the volume in the bar" (`~/.dt/bar`, `showvolume=`, read by
dtbar at start -- unmanaged, the speaker is gone). Input is a note: McdeSys
has no capture API and no sound-device list yet.
+43
View File
@@ -14,6 +14,11 @@
* mcdesoundd -event NAME send one event to a running server
* mcdesoundd -selftest read the theme, check events and files
*
* The session's own two tones (t0043): the daemon plays "Start" when it has
* the selection (dtsession starts it at login), and "End" from the X I/O
* error handler -- at logout dtlogin resets the X server, every client's
* connection dies, and the player it forks lives on after this process.
*
* C99 and POSIX, Xlib and Xt, as every MCDE program.
*/
@@ -31,6 +36,7 @@
#include <Xm/Xm.h>
#include <Xm/DrawingA.h>
#include <Mcde/McdeSys.h>
#include <Mcde/Sound.h>
static Display *dpy;
@@ -38,6 +44,40 @@ static Window service;
static char lastEvent[64];
static struct timeval lastTime;
/* an event of the theme, played without asking the server (Start at login,
* End when the session's display goes): no X in this path, so it works in
* the I/O error handler too */
static void
PlayThemeEvent(const char *event)
{
const char *file = McdeSoundFile(event);
char path[768];
if (file == NULL) {
fprintf(stderr, "mcdesoundd: %s has no sound in the theme\n",
event);
return;
}
snprintf(path, sizeof path, "%s/%s", McdeSoundThemeDir(), file);
if (access(path, R_OK) != 0) {
fprintf(stderr, "mcdesoundd: %s -> %s (missing)\n", event, path);
return;
}
fprintf(stderr, "mcdesoundd: %s -> %s (%s)\n", event, path,
mcde_sys_sound_play(path) == MCDE_SYS_OK ? "player" : "failed");
}
/* dtlogin resets the X server at logout: the connection dies here, and the
* session's End tone is the last thing this daemon does */
static int
EndOnXError(Display *d)
{
(void) d;
PlayThemeEvent("End");
_exit(0);
return 0; /* not reached */
}
static long
MsSinceLast(void)
{
@@ -194,6 +234,7 @@ main(int argc, char **argv)
top = XtVaAppInitialize(&app, "Mcdesoundd", NULL, 0, &argc, argv, NULL,
NULL);
dpy = XtDisplay(top);
XSetIOErrorHandler(EndOnXError);
if (McdeSoundInit() != 0) {
fprintf(stderr, "mcdesoundd: no theme found\n");
return 1;
@@ -221,6 +262,8 @@ main(int argc, char **argv)
return 1;
}
fprintf(stderr, "mcdesoundd: theme %s\n", McdeSoundThemeDir());
/* dtsession starts this daemon at login; the session's Start tone */
PlayThemeEvent("Start");
XtAppMainLoop(app);
return 0;
}