18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 04:47:06 +01:00
Commit Graph

1 Commits

Author SHA1 Message Date
pol102 b7f2186a19 fix(audio): the sound comes back after the output device is lost or changed (#433)
* fix(audio): the sound comes back after the output device is lost or changed

Pulling out the headphones, or changing the output in the system, could leave the game silent until it was
restarted, also after the very same output came back. The renderer learned about the output only from the
events of the system (ALC_SOFT_system_events), and the check of the connection ran only without them. But:

- the system doesn't report every loss. A stream invalidated without the device being removed and without
  another default output (a jack pulled out of a shared output, a change of the format, exclusive mode taken
  by another program) only marks the device as disconnected. Nothing looked at that, so nothing reopened it;
- alcReopenDeviceSOFT returns ALC_TRUE also when the new output was opened but failed to start, which happens
  when the default output is reported before it is ready. The log said "reopened", the device stayed dead;
- a reopen that failed was never tried again, in spite of "(will retry)" in the log;
- with a device set in eu07.ini (sound.openal.renderer) nothing was followed at all: once that device lost its
  output it stayed silent, and a device absent at the start meant no sound for the whole session.

Now the connection of the device is checked once a second next to the events, a removed device has it checked
at once, a reopen counts only if the device is connected afterwards, and a failed one is tried again after
0.5, 1, 2, 4 and then every 4 s, and at once when the system reports any change. A device set in eu07.ini is
left alone while it works; when it is lost it is opened again, the default output stands in for it while it is
absent (also at the start), and the playback moves back when it returns. The failure is logged once per loss.

The decisions are in audio::output_follower (audio/outputfollow.h), free of OpenAL, with unit tests. The time
is the real one (steady_clock) rather than the simulation's, which stands still in pause and runs faster with
time acceleration.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QRgQ1GsKSGmguyc4rhvXWy

* Revert "fix(physicslog): no road-vehicle logs, formatting on the writer, a slow disk and the closing kept short (#408)"

This reverts commit d6c3593520.

* fix(audio): no gaps from devices that aren't the one set, the move back retried, rarer attempts after a minute

Answers the review of #433:

- A move back to the device set in eu07.ini that opened but didn't start
  left no output at all (the library lets go of the default output before it
  tries the other one). The default output is opened again at once.
- The device set in eu07.ini is tried only when the library lists it, so a
  device of any other kind coming (USB, Bluetooth, HDMI of a monitor) no
  longer breaks the sound for a moment.
- With no output at all the attempts thin out to every 30 s after the first
  minute. An event of the system still has one made at once, but not sooner
  than 250 ms after the last one, as a device coming reports a burst.

And two faults found on the way:

- A device name with Polish letters, written in code page 1250 by the
  starter, was never found again once the device had been absent: it was
  passed to the library as it was. It is matched as 1250 text too, with or
  without the "OpenAL Soft on " prefix of the library.
- A move back that failed (the device reported before it was ready) wasn't
  tried again until another device came. It is tried again after 1, 2 and 4 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(audio): the log says which OpenAL library the game got and whether the sound follows the output with it

At the start the game writes one line naming the OpenAL library it plays through, its version and the file it
was loaded from (OpenAL32.dll of the game folder or of the system). With OpenAL Soft 1.23 or newer the line
says the sound follows the default output of the system, or the device set in eu07.ini
(sound.openal.renderer). With an older one, such as the 1.18.1 the game folder still has, nothing changes: the
sound stays on the device opened at the start, and the line says why and what library follows the output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: jerrrrycho <jurek.pakula@gmail.com>
2026-11-27 23:51:50 +01:00