public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/vdr] rawhide: Update to 2.8.3 (API version 14)
@ 2026-10-03 10:35 Martin Gansser
  0 siblings, 0 replies; only message in thread
From: Martin Gansser @ 2026-10-03 10:35 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/vdr
            Branch : rawhide
            Commit : 53b1fd13375d46a26400041236c9d229b8db54f9
            Author : Martin Gansser <mgansser@netcom-mail.de>
            Date   : 2026-10-03T12:34:42+02:00
            Stats  : +1996/-31 in 30 file(s)
            URL    : https://src.fedoraproject.org/rpms/vdr/c/53b1fd13375d46a26400041236c9d229b8db54f9?branch=rawhide

            Log:
            Update to 2.8.3 (API version 14)

Drop the patches merged into 2.8.3: cache-threadid, hoist-receiver-lock,
  fix-unused-variable, 03-osd-isopen-locking, 11-dvbdevice-stop-thread,
  12-launch-transfer-after-switch, 14-svdrp-stop-order,
  15-transfer-serialize-playts, 16-settrackdescriptions-lock-scope,
  17-device-track-table-lock, 20-lcars-flush-control-mutex-scope,
  23-device-subtitleconverter-lock, 30-detachallreceivers-lock-scope
Drop 26-capid-handlingpid-atomic: 28-device-pid-notify-lock-scope already
  calls cCamSlot::SetPid() outside of mutexPids, and without its mutex
  HandlingPid() could make a concurrent SetPid() skip a channel PID
Rework the rest for upstream as 01-17, with short descriptions and
  comments that give the reason: merge the pairs that guard one link
  (player/device, receiver PIDs/device, transfer, which also makes
  cTransfer::activated atomic), split the tuner patch into its atomics and
  a channel lock that no longer spans the signal ioctls, and fix the
  misplaced GetTrackId() documentation
Add 18-tsbuffer-get-timeout: faster channel switches
Add 19-22 for the end of a replay: a pause in the tail no longer ends it,
  B-frame tails are no longer cut, a recording that is still being written
  no longer ends at a stall or trickles out after its end, and PLUGINS.html
  describes DrainDevice()
Package the pes2ts script
Install skincurses with VDRDIR set: the plugin's make install resolved
  vdr.pc through the installed vdr-devel and used its API version

---
diff --git a/.gitignore b/.gitignore
index 23fc6ff..b2a8052 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 -/*.gz
 -/*.bz2
+/vdr-2.8.3.tar.bz2

diff --git a/sources b/sources
index 31680d6..43f2abd 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-SHA512 (vdr-2.8.2.tar.bz2) = cecc90bb6a25f14a53f82238bd1680e0e3919bc197be81e405e0f698b3425fb3f7a21d600e789fdd1db2710baf624bef431b7b6babcb721ef41773136275ca9e
+SHA512 (vdr-2.8.3.tar.bz2) = 7cb5c9d65b81fc82a72758bf24484f471269e9337d72b2e7438471e2108b11f871e99e9d9194cef1edebc272c9e26d6c15d287162d36ccefa60588442cf5abbe

diff --git a/vdr-01-thread-atomics.patch b/vdr-01-thread-atomics.patch
new file mode 100644
index 0000000..b60fbca
--- /dev/null
+++ b/vdr-01-thread-atomics.patch
@@ -0,0 +1,147 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] thread, ringbuffer: make the fields read without a lock atomic
+
+cMutex::Lock() and cRwLock::Lock() read the holder's thread id before
+they own the lock. cThread's active/running/childThreadId are written by
+the thread itself and read by Start()/Active()/Cancel() in other threads.
+cIoThrottle::Engaged() reads 'count' without the mutex, and the writing
+thread logs cRingBuffer::getThreadTid, which the reading thread sets.
+std::atomic makes these accesses defined; ThreadSanitizer no longer
+reports them.
+
+---
+--- a/ringbuffer.c
++++ b/ringbuffer.c
+@@ -50,7 +50,7 @@ void cRingBuffer::UpdatePercentage(int Fill)
+   int percent = Fill * 100 / (Size() - 1) / PERCENTAGEDELTA * PERCENTAGEDELTA; // clamp down to nearest quantum
+   if (percent != lastPercent) {
+      if (percent >= PERCENTAGETHRESHOLD && percent > lastPercent || percent < PERCENTAGETHRESHOLD && lastPercent >= PERCENTAGETHRESHOLD) {
+-        dsyslog("buffer usage: %d%% (tid=%d)", percent, getThreadTid);
++        dsyslog("buffer usage: %d%% (tid=%d)", percent, getThreadTid.load());
+         lastPercent = percent;
+         }
+      }
+--- a/ringbuffer.h
++++ b/ringbuffer.h
+@@ -25,7 +25,7 @@ private:
+   int overflowBytes;
+   cIoThrottle *ioThrottle;
+ protected:
+-  tThreadId getThreadTid;
++  std::atomic<tThreadId> getThreadTid; // set by the reading thread, logged by the writing one
+   int maxFill;//XXX
+   int lastPercent;
+   bool statistics;//XXX
+--- a/thread.c
++++ b/thread.c
+@@ -306,10 +306,10 @@ void *cThread::StartThread(cThread *Thread)
+ {
+   Thread->childThreadId = ThreadId();
+   if (Thread->description) {
+-     dsyslog("%s thread started (pid=%d, tid=%d, prio=%s)", Thread->description, getpid(), Thread->childThreadId, Thread->lowPriority ? "low" : "high");
++     dsyslog("%s thread started (pid=%d, tid=%d, prio=%s)", Thread->description, getpid(), Thread->childThreadId.load(), Thread->lowPriority ? "low" : "high");
+ #ifdef PR_SET_NAME
+      if (prctl(PR_SET_NAME, Thread->description, 0, 0, 0) < 0)
+-        esyslog("%s thread naming failed (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId);
++        esyslog("%s thread naming failed (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId.load());
+ #endif
+      }
+   if (Thread->lowPriority) {
+@@ -318,7 +318,7 @@ void *cThread::StartThread(cThread *Thread)
+      }
+   Thread->Action();
+   if (Thread->description)
+-     dsyslog("%s thread ended (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId);
++     dsyslog("%s thread ended (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId.load());
+   Thread->running = false;
+   Thread->active = false;
+   return NULL;
+@@ -388,7 +388,7 @@ void cThread::Cancel(int WaitSeconds)
+                  return;
+               cCondWait::SleepMs(10);
+               }
+-        esyslog("ERROR: %s thread %d won't end (waited %d seconds) - canceling it...", description ? description : "", childThreadId, WaitSeconds);
++        esyslog("ERROR: %s thread %d won't end (waited %d seconds) - canceling it...", description ? description : "", childThreadId.load(), WaitSeconds);
+         }
+      pthread_cancel(childTid);
+      childTid = 0;
+@@ -926,7 +926,7 @@ bool cStateKey::StateChanged(void)
+ // --- cIoThrottle -----------------------------------------------------------
+ 
+ cMutex cIoThrottle::mutex;
+-int cIoThrottle::count = 0;
++std::atomic<int> cIoThrottle::count(0);
+ 
+ cIoThrottle::cIoThrottle(void)
+ {
+@@ -944,7 +944,7 @@ void cIoThrottle::Activate(void)
+   if (!active) {
+      count++;
+      active = true;
+-     dsyslog("i/o throttle activated, count = %d (tid=%d)", count, cThread::ThreadId());
++     dsyslog("i/o throttle activated, count = %d (tid=%d)", count.load(), cThread::ThreadId());
+      }
+   mutex.Unlock();
+ }
+@@ -955,7 +955,7 @@ void cIoThrottle::Release(void)
+   if (active) {
+      count--;
+      active = false;
+-     dsyslog("i/o throttle released, count = %d (tid=%d)", count, cThread::ThreadId());
++     dsyslog("i/o throttle released, count = %d (tid=%d)", count.load(), cThread::ThreadId());
+      }
+   mutex.Unlock();
+ }
+--- a/thread.h
++++ b/thread.h
+@@ -10,6 +10,7 @@
+ #ifndef __THREAD_H
+ #define __THREAD_H
+ 
++#include <atomic>
+ #include <pthread.h>
+ #include <stdio.h>
+ #include <sys/types.h>
+@@ -56,7 +57,7 @@ class cRwLock {
+ private:
+   pthread_rwlock_t rwlock;
+   int locked;
+-  tThreadId writeLockThreadId;
++  std::atomic<tThreadId> writeLockThreadId; // Lock() reads it without holding the lock
+ public:
+   cRwLock(bool PreferWriter = false);
+   ~cRwLock();
+@@ -68,7 +69,7 @@ class cMutex {
+   friend class cCondVar;
+ private:
+   pthread_mutex_t mutex;
+-  tThreadId lockThreadId; // current holder, 0 == unlocked; lets Lock() short-circuit recursive entry
++  std::atomic<tThreadId> lockThreadId; // current holder, 0 == unlocked; lets Lock() short-circuit recursive entry (read without holding the mutex)
+   int locked;
+ public:
+   cMutex(void);
+@@ -85,10 +86,12 @@ public:
+ class cThread {
+   friend class cThreadLock;
+ private:
+-  bool active;
+-  bool running;
++  // Shared by the thread and those that start, poll or cancel it; whoever
++  // sees 'active' false must also see everything Action() did:
++  std::atomic<bool> active;
++  std::atomic<bool> running;
+   pthread_t childTid;
+-  tThreadId childThreadId;
++  std::atomic<tThreadId> childThreadId; // set by the thread itself, logged by Cancel()
+   cMutex mutex;
+   char *description;
+   bool lowPriority;
+@@ -278,7 +281,7 @@ public:
+ class cIoThrottle {
+ private:
+   static cMutex mutex;
+-  static int count;
++  static std::atomic<int> count; // Engaged() reads it without the mutex
+   bool active;
+ public:
+   cIoThrottle(void);

diff --git a/vdr-02-device-track-atomics.patch b/vdr-02-device-track-atomics.patch
new file mode 100644
index 0000000..7ac2750
--- /dev/null
+++ b/vdr-02-device-track-atomics.patch
@@ -0,0 +1,53 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] device: make the current channel and track numbers atomic
+
+PlayTs() routes packets by currentAudioTrack/currentSubtitleTrack, and
+the skins read them through the getters, without a lock while other
+threads change them (user selection, PMT updates, channel switches).
+currentChannel is set by whichever thread switches the channel (e.g.
+SVDRP CHAN) and read everywhere through CurrentChannel().
+
+---
+--- a/device.c
++++ b/device.c
+@@ -72,7 +72,7 @@ bool cDeviceHook::DeviceProvidesEIT(const cDevice *Device) const
+ int cDevice::numDevices = 0;
+ int cDevice::useDevice = 0;
+ int cDevice::nextCardIndex = 0;
+-int cDevice::currentChannel = 1;
++std::atomic<int> cDevice::currentChannel(1);
+ cDevice *cDevice::device[MAXDEVICES] = { NULL };
+ cDevice *cDevice::primaryDevice = NULL;
+ cList<cDeviceHook> cDevice::deviceHooks;
+--- a/device.h
++++ b/device.h
+@@ -266,7 +266,7 @@ private:
+   time_t occupiedTimeout;
+   int occupiedPriority;
+ protected:
+-  static int currentChannel;
++  static std::atomic<int> currentChannel; // set by whichever thread switches the channel, read by any
+ public:
+   virtual bool ProvidesSource(int Source) const;
+          ///< Returns true if this device can provide the given source.
+@@ -368,7 +368,7 @@ protected:
+   virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
+          ///< Sets the device to the given channel (actual physical setup).
+ public:
+-  static int CurrentChannel(void) { return primaryDevice ? currentChannel : 0; }
++  static int CurrentChannel(void) { return primaryDevice ? currentChannel.load() : 0; }
+          ///< Returns the number of the current channel on the primary device.
+   static void SetCurrentChannel(int ChannelNumber) { currentChannel = ChannelNumber; }
+          ///< Sets the number of the current channel on the primary device, without
+@@ -552,8 +552,9 @@ public:
+ 
+ private:
+   tTrackId availableTracks[ttMaxTrackTypes];
+-  eTrackType currentAudioTrack;
+-  eTrackType currentSubtitleTrack;
++  // read without a lock by PlayTs() and the getters, while other threads change them:
++  std::atomic<eTrackType> currentAudioTrack;
++  std::atomic<eTrackType> currentSubtitleTrack;
+   cMutex mutexCurrentAudioTrack;
+   cMutex mutexCurrentSubtitleTrack;
+   int currentAudioTrackMissingCount;

diff --git a/vdr-03-device-player-atomics.patch b/vdr-03-device-player-atomics.patch
new file mode 100644
index 0000000..f9c7300
--- /dev/null
+++ b/vdr-03-device-player-atomics.patch
@@ -0,0 +1,140 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] device, player: make the player/device pointers atomic
+
+cDevice::AttachPlayer() and Detach() set and clear cDevice::player and
+cPlayer::device from any thread, while the player's threads call the
+Device*() wrappers and other threads call Replaying() and the track
+setters. The readers loaded the pointer twice ('device ? device->X() :
+Y'), so a concurrent Detach() could clear it between check and call;
+each now acts on one snapshot.
+
+---
+--- a/device.c
++++ b/device.c
+@@ -1190,8 +1190,8 @@ bool cDevice::SetCurrentAudioTrack(eTrackType Type)
+      if (IS_DOLBY_TRACK(Type))
+         SetDigitalAudioDevice(true);
+      currentAudioTrack = Type;
+-     if (player)
+-        player->SetAudioTrack(currentAudioTrack, GetTrack(currentAudioTrack));
++     if (cPlayer *p = player)
++        p->SetAudioTrack(currentAudioTrack, GetTrack(currentAudioTrack));
+      else
+         SetAudioTrackDevice(currentAudioTrack);
+      if (IS_AUDIO_TRACK(Type))
+@@ -1232,8 +1232,8 @@ bool cDevice::SetCurrentSubtitleTrack(eTrackType Type, bool Manual)
+        liveSubtitle = NULL;
+      }
+      delete ls;
+-     if (player)
+-        player->SetSubtitleTrack(currentSubtitleTrack, GetTrack(currentSubtitleTrack));
++     if (cPlayer *p = player)
++        p->SetSubtitleTrack(currentSubtitleTrack, GetTrack(currentSubtitleTrack));
+      else
+         SetSubtitleTrackDevice(currentSubtitleTrack);
+      if (currentSubtitleTrack != ttNone && !Replaying() && !Transferring()) {
+@@ -1444,9 +1444,9 @@ bool cDevice::AttachPlayer(cPlayer *Player)
+      player = Player;
+      if (!Transferring())
+         ClrAvailableTracks(false, true);
+-     SetPlayMode(player->playMode);
+-     player->device = this;
+-     player->Activate(true);
++     SetPlayMode(Player->playMode);
++     Player->device = this;
++     Player->Activate(true);
+      return true;
+      }
+   return false;
+--- a/device.h
++++ b/device.h
+@@ -651,7 +651,7 @@ public:
+ // Player facilities
+ 
+ private:
+-  cPlayer *player;
++  std::atomic<cPlayer *> player; // cleared by Detach() in any thread, read without a lock
+   cPatPmtParser patPmtParser;
+   cTsToPes tsToPesVideo;
+   cTsToPes tsToPesAudio;
+--- a/player.c
++++ b/player.c
+@@ -25,16 +25,16 @@ cPlayer::~cPlayer()
+ 
+ int cPlayer::PlayPes(const uchar *Data, int Length, bool VideoOnly)
+ {
+-  if (device)
+-     return device->PlayPes(Data, Length, VideoOnly);
++  if (cDevice *d = device)
++     return d->PlayPes(Data, Length, VideoOnly);
+   esyslog("ERROR: attempt to use cPlayer::PlayPes() without attaching to a cDevice!");
+   return -1;
+ }
+ 
+ void cPlayer::Detach(void)
+ {
+-  if (device)
+-     device->Detach(this);
++  if (cDevice *d = device)
++     d->Detach(this);
+ }
+ 
+ // --- cControl --------------------------------------------------------------
+--- a/player.h
++++ b/player.h
+@@ -16,28 +16,28 @@
+ class cPlayer {
+   friend class cDevice;
+ private:
+-  cDevice *device;
++  std::atomic<cDevice *> device; // cleared by cDevice::Detach() while the player's threads use it
+   ePlayMode playMode;
+ protected:
+-  void DeviceClrAvailableTracks(bool DescriptionsOnly = false) { if (device) device->ClrAvailableTracks(DescriptionsOnly); }
+-  bool DeviceSetAvailableTrack(eTrackType Type, int Index, uint16_t Id, const char *Language = NULL, const char *Description = NULL) { return device ? device->SetAvailableTrack(Type, Index, Id, Language, Description) : false; }
+-  bool DeviceSetCurrentAudioTrack(eTrackType Type) { return device ? device->SetCurrentAudioTrack(Type) : false; }
+-  bool DeviceSetCurrentSubtitleTrack(eTrackType Type) { return device ? device->SetCurrentSubtitleTrack(Type) : false; }
+-  bool DevicePoll(cPoller &Poller, int TimeoutMs = 0) { return device ? device->Poll(Poller, TimeoutMs) : false; }
++  void DeviceClrAvailableTracks(bool DescriptionsOnly = false) { if (cDevice *d = device) d->ClrAvailableTracks(DescriptionsOnly); }
++  bool DeviceSetAvailableTrack(eTrackType Type, int Index, uint16_t Id, const char *Language = NULL, const char *Description = NULL) { cDevice *d = device; return d ? d->SetAvailableTrack(Type, Index, Id, Language, Description) : false; }
++  bool DeviceSetCurrentAudioTrack(eTrackType Type) { cDevice *d = device; return d ? d->SetCurrentAudioTrack(Type) : false; }
++  bool DeviceSetCurrentSubtitleTrack(eTrackType Type) { cDevice *d = device; return d ? d->SetCurrentSubtitleTrack(Type) : false; }
++  bool DevicePoll(cPoller &Poller, int TimeoutMs = 0) { cDevice *d = device; return d ? d->Poll(Poller, TimeoutMs) : false; }
+   [[deprecated("use DeviceDrain() instead")]]
+   bool DeviceFlush(int TimeoutMs = 0) { return DeviceDrain(); }
+-  bool DeviceDrain(void) { return device ? device->Drain() : false; }
+-  bool DeviceHasIBPTrickSpeed(void) { return device ? device->HasIBPTrickSpeed() : false; }
+-  bool DeviceIsPlayingVideo(void) { return device ? device->IsPlayingVideo() : false; }
+-  void DeviceTrickSpeed(int Speed, bool Forward) { if (device) device->TrickSpeed(Speed, Forward); }
+-  void DeviceClear(void) { if (device) device->Clear(); }
+-  void DevicePlay(void) { if (device) device->Play(); }
+-  void DeviceFreeze(void) { if (device) device->Freeze(); }
+-  void DeviceMute(void) { if (device) device->Mute(); }
+-  void DeviceSetVideoDisplayFormat(eVideoDisplayFormat VideoDisplayFormat) { if (device) device->SetVideoDisplayFormat(VideoDisplayFormat); }
+-  void DeviceStillPicture(const uchar *Data, int Length) { if (device) device->StillPicture(Data, Length); }
+-  void DeviceSetTempSubtitles(void) { if (device) device->SetTempSubtitles(); }
+-  uint64_t DeviceGetSTC(void) { return device ? device->GetSTC() : -1; }
++  bool DeviceDrain(void) { cDevice *d = device; return d ? d->Drain() : false; }
++  bool DeviceHasIBPTrickSpeed(void) { cDevice *d = device; return d ? d->HasIBPTrickSpeed() : false; }
++  bool DeviceIsPlayingVideo(void) { cDevice *d = device; return d ? d->IsPlayingVideo() : false; }
++  void DeviceTrickSpeed(int Speed, bool Forward) { if (cDevice *d = device) d->TrickSpeed(Speed, Forward); }
++  void DeviceClear(void) { if (cDevice *d = device) d->Clear(); }
++  void DevicePlay(void) { if (cDevice *d = device) d->Play(); }
++  void DeviceFreeze(void) { if (cDevice *d = device) d->Freeze(); }
++  void DeviceMute(void) { if (cDevice *d = device) d->Mute(); }
++  void DeviceSetVideoDisplayFormat(eVideoDisplayFormat VideoDisplayFormat) { if (cDevice *d = device) d->SetVideoDisplayFormat(VideoDisplayFormat); }
++  void DeviceStillPicture(const uchar *Data, int Length) { if (cDevice *d = device) d->StillPicture(Data, Length); }
++  void DeviceSetTempSubtitles(void) { if (cDevice *d = device) d->SetTempSubtitles(); }
++  uint64_t DeviceGetSTC(void) { cDevice *d = device; return d ? d->GetSTC() : -1; }
+   void Detach(void);
+   virtual void Activate(bool On) {}
+        // This function is called right after the cPlayer has been attached to
+@@ -47,7 +47,7 @@ protected:
+        // Sends the given PES Data to the device and returns the number of
+        // bytes that have actually been accepted by the device (or a
+        // negative value in case of an error).
+-  int PlayTs(const uchar *Data, int Length, bool VideoOnly = false) { return device ? device->PlayTs(Data, Length, VideoOnly) : -1; }
++  int PlayTs(const uchar *Data, int Length, bool VideoOnly = false) { cDevice *d = device; return d ? d->PlayTs(Data, Length, VideoOnly) : -1; }
+        // Sends the given TS packet to the device and returns a positive number
+        // if the packet has been accepted by the device, or a negative value in
+        // case of an error.

diff --git a/vdr-04-receiver-atomics.patch b/vdr-04-receiver-atomics.patch
new file mode 100644
index 0000000..a844c2c
--- /dev/null
+++ b/vdr-04-receiver-atomics.patch
@@ -0,0 +1,74 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] receiver: make the PID array and the device pointer atomic
+
+The device thread scans an attached receiver's PIDs in WantsPid() while
+cCaPidReceiver (EMM PIDs) and cCamSlot::BuildCaPmts() (ECM PIDs) change
+them in other threads; taking the device's receiver mutex there would
+invert the lock order against the CAM slot mutex. A transiently
+inconsistent PID set only misroutes single TS packets at the moment of
+the change. cDevice::Detach() clears 'device' while another thread may
+be in AddPid()/DelPid(), which now act on one snapshot.
+
+---
+--- a/receiver.c
++++ b/receiver.c
+@@ -45,8 +45,8 @@ bool cReceiver::AddPid(int Pid)
+      if (numPids < MAXRECEIVEPIDS) {
+         if (!WantsPid(Pid)) {
+            pids[numPids++] = Pid;
+-           if (device)
+-              device->AddPid(Pid);
++           if (cDevice *d = device)
++              d->AddPid(Pid);
+            }
+         }
+      else {
+@@ -93,10 +93,10 @@ void cReceiver::DelPid(int Pid)
+      for (int i = 0; i < numPids; i++) {
+          if (pids[i] == Pid) {
+             for ( ; i < numPids; i++) // we also copy the terminating 0!
+-                pids[i] = pids[i + 1];
++                pids[i] = pids[i + 1].load();
+             numPids--;
+-            if (device)
+-               device->DelPid(Pid);
++            if (cDevice *d = device)
++               d->DelPid(Pid);
+             return;
+             }
+          }
+@@ -124,6 +124,6 @@ bool cReceiver::WantsPid(int Pid)
+ 
+ void cReceiver::Detach(void)
+ {
+-  if (device)
+-     device->Detach(this);
++  if (cDevice *d = device)
++     d->Detach(this);
+ }
+--- a/receiver.h
++++ b/receiver.h
+@@ -10,6 +10,7 @@
+ #ifndef __RECEIVER_H
+ #define __RECEIVER_H
+ 
++#include <atomic>
+ #include "device.h"
+ 
+ #define MAXRECEIVEPIDS  64 // the maximum number of PIDs per receiver
+@@ -17,11 +18,12 @@
+ class cReceiver {
+   friend class cDevice;
+ private:
+-  cDevice *device;
++  std::atomic<cDevice *> device; // cleared by cDevice::Detach() in any thread
+   tChannelID channelID;
+   int priority;
+-  int pids[MAXRECEIVEPIDS];
+-  int numPids;
++  // changed while attached (EMM/ECM PIDs), scanned by the device thread without a lock:
++  std::atomic<int> pids[MAXRECEIVEPIDS];
++  std::atomic<int> numPids;
+   time_t lastScrambledPacket;
+   time_t startScrambleDetection;
+   int scramblingTimeout;

diff --git a/vdr-05-transfer-atomics.patch b/vdr-05-transfer-atomics.patch
new file mode 100644
index 0000000..0f3697e
--- /dev/null
+++ b/vdr-05-transfer-atomics.patch
@@ -0,0 +1,49 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] transfer: make 'activated' and receiverDevice atomic
+
+Activate() sets 'activated' in the thread that attaches the player, and
+Receive() reads it in the receiver thread; the atomic also makes the
+PAT/PMT that Activate() plays visible before Receive()'s first PlayTs().
+receiverDevice is set and cleared by whichever thread creates or
+destroys the transfer control (e.g. SVDRP CHAN), and read without a lock
+by cDevice::ActualDevice() and the skins.
+
+---
+--- a/transfer.c
++++ b/transfer.c
+@@ -71,7 +71,7 @@ void cTransfer::Receive(const uchar *Data, int Length)
+ 
+ // --- cTransferControl ------------------------------------------------------
+ 
+-cDevice *cTransferControl::receiverDevice = NULL;
++std::atomic<cDevice *> cTransferControl::receiverDevice(NULL);
+ 
+ cTransferControl::cTransferControl(cDevice *ReceiverDevice, const cChannel *Channel)
+ :cControl(NULL, true)
+--- a/transfer.h
++++ b/transfer.h
+@@ -10,13 +10,14 @@
+ #ifndef __TRANSFER_H
+ #define __TRANSFER_H
+ 
++#include <atomic>
+ #include "player.h"
+ #include "receiver.h"
+ #include "remux.h"
+ 
+ class cTransfer : public cReceiver, public cPlayer {
+ private:
+-  bool activated;
++  std::atomic<bool> activated; // set by Activate() after the PAT/PMT, checked by Receive() in the receiver thread
+   time_t lastErrorReport;
+   int numLostPackets;
+   cPatPmtGenerator patPmtGenerator;
+@@ -31,7 +32,7 @@ public:
+ class cTransferControl : public cControl {
+ private:
+   cTransfer *transfer;
+-  static cDevice *receiverDevice;
++  static std::atomic<cDevice *> receiverDevice; // set and cleared by the switching thread, read by any
+ public:
+   cTransferControl(cDevice *ReceiverDevice, const cChannel *Channel);
+   ~cTransferControl();

diff --git a/vdr-06-dvbplayer-atomics.patch b/vdr-06-dvbplayer-atomics.patch
new file mode 100644
index 0000000..a3a6aab
--- /dev/null
+++ b/vdr-06-dvbplayer-atomics.patch
@@ -0,0 +1,86 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] dvbplayer: make the state read without the thread lock atomic
+
+The control functions change playMode, playDir, trickSpeed and readIndex
+under LOCK_THREAD, but Action() reads some of them before taking it, and
+GetIndex(), GetFrameNumber() and GetReplayMode() read them from the main
+thread. cNonBlockingFileReader changes buffer, wanted and length under
+its thread lock, but WaitForDataMs() reads them under newDataMutex only
+and Reading() without any lock.
+
+---
+--- a/dvbplayer.c
++++ b/dvbplayer.c
+@@ -129,9 +129,10 @@ int cPtsIndex::FindFrameNumber(uint32_t Pts, bool Forward, bool Still)
+ class cNonBlockingFileReader : public cThread {
+ private:
+   cUnbufferedFile *f;
+-  uchar *buffer;
+-  int wanted;
+-  int length;
++  // changed under the thread lock, read without it by Reading() and WaitForDataMs():
++  std::atomic<uchar *> buffer;
++  std::atomic<int> wanted;
++  std::atomic<int> length;
+   cCondWait newSet;
+   cCondVar newDataCond;
+   cMutex newDataMutex;
+@@ -201,12 +202,13 @@ void cNonBlockingFileReader::Action(void)
+   while (Running()) {
+         Lock();
+         if (f && buffer && length < wanted) {
+-           int r = f->Read(buffer + length, wanted - length);
++           uchar *b = buffer;
++           int r = f->Read(b + length, wanted - length);
+            if (r > 0)
+               length += r;
+            else if (r == 0) { // r == 0 means EOF
+               if (length > 0)
+-                 wanted = length; // already read something, so return the rest
++                 wanted = length.load(); // already read something, so return the rest
+               else
+                  length = wanted = 0; // report EOF
+               }
+@@ -256,10 +258,11 @@ private:
+   bool pauseLive;
+   bool eof;
+   bool firstPacket;
+-  ePlayModes playMode;
+-  ePlayDirs playDir;
+-  int trickSpeed;
+-  int readIndex;
++  // changed under LOCK_THREAD, read without it in Action() and by the Get*() functions:
++  std::atomic<ePlayModes> playMode;
++  std::atomic<ePlayDirs> playDir;
++  std::atomic<int> trickSpeed;
++  std::atomic<int> readIndex;
+   bool readIndependent;
+   cFrame *readFrame;
+   cFrame *playFrame;
+@@ -458,7 +461,7 @@ void cDvbPlayer::Action(void)
+ 
+   readIndex = Resume();
+   if (readIndex > 0)
+-     isyslog("resuming replay at index %d (%s)", readIndex, *IndexToHMSF(readIndex, true, framesPerSecond));
++     isyslog("resuming replay at index %d (%s)", readIndex.load(), *IndexToHMSF(readIndex, true, framesPerSecond));
+   else if (Setup.SkipEdited && marks) {
+      cStateKey StateKey;
+      marks->Lock(StateKey);
+@@ -817,7 +820,7 @@ void cDvbPlayer::Forward(void)
+             TrickSpeed(Setup.MultiSpeedMode ? -1 : -MAX_SPEEDS);
+             }
+             break;
+-       default: esyslog("ERROR: unknown playMode %d (%s)", playMode, __FUNCTION__);
++       default: esyslog("ERROR: unknown playMode %d (%s)", playMode.load(), __FUNCTION__);
+        }
+      }
+ }
+@@ -869,7 +872,7 @@ void cDvbPlayer::Backward(void)
+             TrickSpeed(Setup.MultiSpeedMode ? -1 : -MAX_SPEEDS);
+             }
+             break;
+-       default: esyslog("ERROR: unknown playMode %d (%s)", playMode, __FUNCTION__);
++       default: esyslog("ERROR: unknown playMode %d (%s)", playMode.load(), __FUNCTION__);
+        }
+      }
+ }

diff --git a/vdr-07-dvbtuner-atomics.patch b/vdr-07-dvbtuner-atomics.patch
new file mode 100644
index 0000000..4c3e716
--- /dev/null
+++ b/vdr-07-dvbtuner-atomics.patch
@@ -0,0 +1,72 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] dvbdevice: make the tuner state read without the mutex atomic
+
+The tuner thread changes tunerStatus under its mutex, while Locked() and
+IsTunedTo() read it and the destructor sets it without the mutex.
+frontendType and positioner are set by the tuner thread and read by
+other threads through FrontendType() and Positioner(); GetPositioner()
+now publishes the positioner only after SetFrontend().
+
+---
+--- a/dvbdevice.c
++++ b/dvbdevice.c
+@@ -533,7 +533,7 @@ class cDvbTuner : public cThread {
+ private:
+   static cMutex bondMutex;
+   enum eTunerStatus { tsIdle, tsSet, tsPositioning, tsTuned, tsLocked };
+-  int frontendType;
++  std::atomic<int> frontendType; // FrontendType() reads it without the mutex
+   const cDvbDevice *device;
+   mutable int fd_frontend;
+   int adapter;
+@@ -552,10 +552,10 @@ private:
+   mutable const cDiseqc *lastDiseqc;
+   int diseqcOffset;
+   mutable int lastSource;
+-  cPositioner *positioner;
++  std::atomic<cPositioner *> positioner; // Positioner() reads it without the mutex
+   const cScr *scr;
+   mutable bool lnbPowerTurnedOn;
+-  eTunerStatus tunerStatus;
++  std::atomic<eTunerStatus> tunerStatus; // Locked() and the destructor use it without the mutex
+   mutable cMutex mutex;
+   cCondVar locked;
+   cCondVar newSet;
+@@ -1482,11 +1482,13 @@ static unsigned int FrequencyToHz(unsigned int f)
+ 
+ cPositioner *cDvbTuner::GetPositioner(void)
+ {
+-  if (!positioner) {
+-     positioner = cPositioner::GetPositioner();
+-     positioner->SetFrontend(fd_frontend);
++  cPositioner *p = positioner;
++  if (!p) {
++     p = cPositioner::GetPositioner();
++     p->SetFrontend(fd_frontend);
++     positioner = p;
+      }
+-  return positioner;
++  return p;
+ }
+ 
+ void cDvbTuner::ExecuteDiseqc(const cDiseqc *Diseqc, int *Frequency)
+@@ -1712,8 +1714,8 @@ void cDvbTuner::Action(void)
+                tunerStatus = SetFrontend() ? tsPositioning : tsIdle;
+                continue;
+           case tsPositioning:
+-               if (positioner) {
+-                  if (positioner->IsMoving())
++               if (cPositioner *p = positioner) {
++                  if (p->IsMoving())
+                      break; // we want the TimedWait() below!
+                   else if (diseqcOffset) {
+                      lastDiseqc = NULL;
+@@ -1776,7 +1778,7 @@ void cDvbTuner::Action(void)
+                   continue;
+                   }
+                break;
+-          default: esyslog("ERROR: unknown tuner status %d", tunerStatus);
++          default: esyslog("ERROR: unknown tuner status %d", tunerStatus.load());
+           }
+         newSet.TimedWait(mutex, WaitTime);
+         }

diff --git a/vdr-08-dvbtuner-channel-lock.patch b/vdr-08-dvbtuner-channel-lock.patch
new file mode 100644
index 0000000..5ad15c1
--- /dev/null
+++ b/vdr-08-dvbtuner-channel-lock.patch
@@ -0,0 +1,38 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] dvbdevice: read the tuner's channel only under its mutex
+
+SetChannel() reassigns 'channel' under the tuner mutex, which frees its
+old name and parameter strings, while IsTunedTo() (device selection in
+other threads) and GetSignalStrength()/GetSignalQuality() (skins) read
+it without the mutex. The signal functions take it only for the SSI/SQI
+calculation: their frontend ioctls can take hundreds of milliseconds on
+USB tuners, and holding the mutex across them would stall the tuner
+thread.
+
+---
+--- a/dvbdevice.c
++++ b/dvbdevice.c
+@@ -798,6 +798,7 @@ cDvbTuner *cDvbTuner::GetBondedMaster(void)
+ 
+ bool cDvbTuner::IsTunedTo(const cChannel *Channel) const
+ {
++  cMutexLock MutexLock(&mutex); // SetChannel() reassigns 'channel', freeing its strings
+   if (tunerStatus == tsIdle)
+      return false; // not tuned to
+   if (channel.Source() != Channel->Source() || channel.Transponder() != Channel->Transponder() || channel.Srate() != Channel->Srate())
+@@ -1257,6 +1258,7 @@ int cDvbTuner::GetSignalStrength(void) const
+       int FeFec = (Props[3].u.st.len > 0) ? (int)Props[3].u.data : -1;
+       int Signal = 0;
+       if (Props[0].u.st.len > 0) {
++         cMutexLock MutexLock(&mutex); // for 'channel' (see IsTunedTo()), but not across the slow ioctls above, which would stall the tuner thread
+          switch (Props[0].u.st.stat[0].scale) {
+            case FE_SCALE_DECIBEL:  Signal = StrengthToSSI(&channel, Props[0].u.st.stat[0].svalue, FeMod, FeCod, FeFec);
+                                    break;
+@@ -1335,6 +1337,7 @@ int cDvbTuner::GetSignalQuality(void) const
+          }
+       int Cnr = 0;
+       if (Props[0].u.st.len > 0) {
++         cMutexLock MutexLock(&mutex); // for 'channel', see GetSignalStrength()
+          switch (Props[0].u.st.stat[0].scale) {
+            case FE_SCALE_DECIBEL:  Cnr = SignalToSQI(&channel, Props[0].u.st.stat[0].svalue, Ber, FeMod, FeCod, FeFec);
+                                    break;

diff --git a/vdr-09-sections-sdt-atomics.patch b/vdr-09-sections-sdt-atomics.patch
new file mode 100644
index 0000000..2b96cdf
--- /dev/null
+++ b/vdr-09-sections-sdt-atomics.patch
@@ -0,0 +1,35 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] sections, sdt: make the section handler's status flags atomic
+
+cSectionHandler::SetStatus() changes on/waitForLock/flush under the
+thread lock, but Action() reads them for its poll() timeout and resets
+'flush' outside of it. cSdtFilter's transponderState is set by the
+section handler thread and read by the tuner thread through
+TransponderWrong().
+
+---
+--- a/sdt.h
++++ b/sdt.h
+@@ -24,7 +24,7 @@ private:
+   int lastNid;
+   int lastTid;
+   cPatFilter *patFilter;
+-  enum eTransponderState transponderState;
++  std::atomic<eTransponderState> transponderState; // set by the section handler thread, read by the tuner thread
+ protected:
+   virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length) override;
+ public:
+--- a/sections.h
++++ b/sections.h
+@@ -26,8 +26,9 @@ private:
+   cSectionHandlerPrivate *shp;
+   cDevice *device;
+   int statusCount;
+-  bool on, waitForLock;
+-  bool flush;
++  // SetStatus() changes these under the thread lock, Action() also uses them outside of it:
++  std::atomic<bool> on, waitForLock;
++  std::atomic<bool> flush;
+   bool startFilters;
+   cTimeMs flushTimer;
+   cList<cFilter> filters;

diff --git a/vdr-10-svdrp-ready-atomic.patch b/vdr-10-svdrp-ready-atomic.patch
new file mode 100644
index 0000000..166935b
--- /dev/null
+++ b/vdr-10-svdrp-ready-atomic.patch
@@ -0,0 +1,18 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] svdrp: make the server handler's 'ready' flag atomic
+
+Action() sets it once the listening socket is up, while WaitUntilReady()
+polls it from the main thread.
+
+---
+--- a/svdrp.c
++++ b/svdrp.c
+@@ -2785,7 +2785,7 @@ void SetSVDRPGrabImageDir(const char *GrabImageDir)
+ 
+ class cSVDRPServerHandler : public cThread {
+ private:
+-  bool ready;
++  std::atomic<bool> ready; // set by Action(), polled by WaitUntilReady() in the main thread
+   cSocket tcpSocket;
+   cVector<cSVDRPServer *> serverConnections;
+   void HandleServerConnection(void);

diff --git a/vdr-11-dvbsubtitle-atomics.patch b/vdr-11-dvbsubtitle-atomics.patch
new file mode 100644
index 0000000..3cded8e
--- /dev/null
+++ b/vdr-11-dvbsubtitle-atomics.patch
@@ -0,0 +1,43 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] dvbsubtitle: make 'frozen' and setupLevel atomic
+
+Action() reads 'frozen' outside the thread lock, while Freeze() (from
+cDevice::Play()/Freeze()) and Reset() set it in other threads.
+SetupChanged() increments the static setupLevel in the main thread,
+which Action() polls.
+
+---
+--- a/dvbsubtitle.c
++++ b/dvbsubtitle.c
+@@ -1353,7 +1353,7 @@ void cDvbSubtitleBitmaps::DbgDump(int WindowWidth, int WindowHeight)
+ 
+ #define SUBTITLE_RETENTION 120 // seconds
+ 
+-int cDvbSubtitleConverter::setupLevel = 0;
++std::atomic<int> cDvbSubtitleConverter::setupLevel(0);
+ 
+ cDvbSubtitleConverter::cDvbSubtitleConverter(void)
+ :cThread("subtitle converter")
+--- a/dvbsubtitle.h
++++ b/dvbsubtitle.h
+@@ -12,6 +12,7 @@
+ #ifndef __DVBSUBTITLE_H
+ #define __DVBSUBTITLE_H
+ 
++#include <atomic>
+ #include "osd.h"
+ #include "thread.h"
+ #include "tools.h"
+@@ -22,10 +23,10 @@ class cDvbSubtitleBitmaps;
+ 
+ class cDvbSubtitleConverter : public cThread {
+ private:
+-  static int setupLevel;
++  static std::atomic<int> setupLevel; // incremented by SetupChanged() in the main thread, read by Action()
+   cDvbSubtitleAssembler *dvbSubtitleAssembler;
+   cOsd *osd;
+-  bool frozen;
++  std::atomic<bool> frozen; // set by Freeze() and Reset() in other threads, read by Action() without the lock
+   int ddsVersionNumber;
+   int displayWidth;
+   int displayHeight;

diff --git a/vdr-12-device-camslot-atomic.patch b/vdr-12-device-camslot-atomic.patch
new file mode 100644
index 0000000..d461537
--- /dev/null
+++ b/vdr-12-device-camslot-atomic.patch
@@ -0,0 +1,109 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] device: make the camSlot pointer atomic
+
+cCamSlot::Assign() sets it through SetCamSlot(), possibly in another
+thread's channel switch, while the receiver and play threads read it
+without a lock. ReleaseCamSlot(), SetChannel(), AttachReceiver() and
+Detach() loaded it more than once ('CamSlot() &&
+CamSlot()->WantsTsData()'), so it could turn NULL between check and use;
+they now act on one snapshot. AddPid()/DelPid() are converted by the
+patch that moves their CAM notification out of mutexPids.
+
+---
+--- a/device.c
++++ b/device.c
+@@ -454,8 +454,10 @@ cDevice *cDevice::GetDeviceForTransponder(const cChannel *Channel, int Priority)
+ 
+ void cDevice::ReleaseCamSlot(void)
+ {
+-  if (camSlot && !camSlot->IsDecrypting() && !camSlot->IsActivating())
+-     camSlot->Assign(NULL);
++  if (cCamSlot *cs = camSlot) {
++     if (!cs->IsDecrypting() && !cs->IsActivating())
++        cs->Assign(NULL);
++     }
+ }
+ 
+ bool cDevice::HasCi(void)
+@@ -911,7 +913,8 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
+ 
+   bool NeedsTransferMode = LiveView && Device != PrimaryDevice();
+   // If the CAM slot wants the TS data, we need to switch to Transfer Mode:
+-  if (!NeedsTransferMode && LiveView && IsPrimaryDevice() && CamSlot() && CamSlot()->WantsTsData())
++  cCamSlot *PrimaryCamSlot = CamSlot();
++  if (!NeedsTransferMode && LiveView && IsPrimaryDevice() && PrimaryCamSlot && PrimaryCamSlot->WantsTsData())
+      NeedsTransferMode = true;
+ 
+   eSetChannelResult Result = scrOk;
+@@ -935,8 +938,8 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
+         }
+      // Tell the camSlot about the channel switch and add all PIDs of this
+      // channel to it, for possible later decryption:
+-     if (camSlot)
+-        camSlot->AddChannel(Channel);
++     if (cCamSlot *cs = camSlot)
++        cs->AddChannel(Channel);
+      SetPowerSaveMode(false);
+      if (SetChannelDevice(Channel, LiveView)) {
+         // Start section handling:
+@@ -945,8 +948,8 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
+            sectionHandler->SetStatus(true);
+            }
+         // Start decrypting any PIDs that might have been set in SetChannelDevice():
+-        if (camSlot)
+-           camSlot->StartDecrypting();
++        if (cCamSlot *cs = camSlot)
++           cs->StartDecrypting();
+         }
+      else
+         Result = scrFailed;
+@@ -1926,20 +1929,21 @@ bool cDevice::AttachReceiver(cReceiver *Receiver)
+          Receiver->Activate(true);
+          Receiver->device = this;
+          receiver[i] = Receiver;
+-         if (camSlot && Receiver->priority > MINPRIORITY) { // priority check to avoid an infinite loop with the CAM slot's caPidReceiver
+-            camSlot->StartDecrypting();
+-            if (camSlot->WantsTsData()) {
++         cCamSlot *cs = camSlot;
++         if (cs && Receiver->priority > MINPRIORITY) { // priority check to avoid an infinite loop with the CAM slot's caPidReceiver
++            cs->StartDecrypting();
++            if (cs->WantsTsData()) {
+                Receiver->lastEitInjection = 0;
+                Receiver->startEitInjection = time(NULL);
+                }
+             if (CamSlots.NumReadyMasterSlots() > 1) { // don't try different CAMs if there is only one
+                Receiver->startScrambleDetection = time(NULL);
+                Receiver->scramblingTimeout = TS_SCRAMBLING_TIMEOUT;
+-               bool KnownToDecrypt = ChannelCamRelations.CamDecrypt(Receiver->ChannelID(), camSlot->MasterSlotNumber());
++               bool KnownToDecrypt = ChannelCamRelations.CamDecrypt(Receiver->ChannelID(), cs->MasterSlotNumber());
+                if (KnownToDecrypt)
+                   Receiver->scramblingTimeout *= 9; // give it time to receive ECM/EMM (must be less than MAXBROKENTIMEOUT in recorder.c!)
+                if (Receiver->ChannelID().Valid())
+-                  dsyslog("CAM %d: %sknown to decrypt channel %s (scramblingTimeout = %ds)", camSlot->MasterSlotNumber(), KnownToDecrypt ? "" : "not ", *Receiver->ChannelID().ToString(), Receiver->scramblingTimeout);
++                  dsyslog("CAM %d: %sknown to decrypt channel %s (scramblingTimeout = %ds)", cs->MasterSlotNumber(), KnownToDecrypt ? "" : "not ", *Receiver->ChannelID().ToString(), Receiver->scramblingTimeout);
+                }
+             }
+          if (patFilter && Receiver->ChannelID().Valid())
+@@ -1971,9 +1975,9 @@ void cDevice::Detach(cReceiver *Receiver, bool ReleaseCam)
+   Receiver->Activate(false);
+   for (int n = 0; n < Receiver->numPids; n++)
+       DelPid(Receiver->pids[n]);
+-  if (camSlot) {
++  if (cCamSlot *cs = camSlot) {
+      if (Receiver->priority > MINPRIORITY) { // priority check to avoid an infinite loop with the CAM slot's caPidReceiver
+-        camSlot->StartDecrypting();
++        cs->StartDecrypting();
+         if (ReleaseCam)
+            ReleaseCamSlot();
+         }
+--- a/device.h
++++ b/device.h
+@@ -476,7 +476,7 @@ public:
+ // Common Interface facilities:
+ 
+ private:
+-  cCamSlot *camSlot;
++  std::atomic<cCamSlot *> camSlot; // set by cCamSlot::Assign() in any thread, read without a lock
+   void ReleaseCamSlot(void);
+          ///< Releases the CAM slot if it is currently not used.
+ public:

diff --git a/vdr-13-camslot-assign-lock-scope.patch b/vdr-13-camslot-assign-lock-scope.patch
new file mode 100644
index 0000000..bea722a
--- /dev/null
+++ b/vdr-13-camslot-assign-lock-scope.patch
@@ -0,0 +1,135 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] ci: don't hold the CAM slot mutex across device calls in Assign()
+
+Assign() held the slot mutex while calling cDevice::Detach(),
+SetCamSlot() and AttachReceiver(), which take the device's receiver
+mutex and thread lock, while AttachReceiver() -> AddPid() ->
+cCamSlot::SetPid() takes the receiver mutex first and the slot mutex
+last. Two threads switching channels on CAM devices could deadlock. A
+new assignMutex serializes Assign(), and the slot mutex only guards the
+assignedDevice updates; Device() reads that without a lock, so it is
+atomic.
+
+---
+--- a/ci.c
++++ b/ci.c
+@@ -2220,41 +2220,54 @@ cCamSlot *cCamSlot::MtdSpawn(void)
+ 
+ bool cCamSlot::Assign(cDevice *Device, bool Query)
+ {
+-  cMutexLock MutexLock(&mutex);
+-  if (Device == assignedDevice)
+-     return true;
+-  if (ciAdapter) {
+-     int OldDeviceNumber = 0;
+-     if (assignedDevice && !Query) {
+-        OldDeviceNumber = assignedDevice->DeviceNumber() + 1;
+-        if (caPidReceiver)
+-           assignedDevice->Detach(caPidReceiver);
+-        assignedDevice->SetCamSlot(NULL);
+-        assignedDevice = NULL;
+-        }
+-     if (ciAdapter->Assign(Device, true)) {
+-        if (!Query) {
+-           StopDecrypting();
+-           if (ciAdapter->Assign(Device)) {
+-              if (Device) {
+-                 Device->SetCamSlot(this);
+-                 assignedDevice = Device;
+-                 if (caPidReceiver) {
+-                    caPidReceiver->Reset();
+-                    Device->AttachReceiver(caPidReceiver);
+-                    }
+-                 dsyslog("CAM %d: assigned to device %d", MasterSlotNumber(), Device->DeviceNumber() + 1);
+-                 }
+-              else {
+-                 CancelActivation();
+-                 dsyslog("CAM %d: unassigned from device %d", MasterSlotNumber(), OldDeviceNumber);
++  // 'mutex' isn't held across the cDevice calls below: they take the device's
++  // receiver lock, under which AttachReceiver() -> AddPid() -> SetPid() takes
++  // 'mutex'. Readers may briefly see no assigned device, which is harmless:
++  cMutexLock AssignMutexLock(&assignMutex);
++  cDevice *OldDevice = NULL;
++  {
++    cMutexLock MutexLock(&mutex);
++    if (Device == assignedDevice)
++       return true;
++    if (!ciAdapter)
++       return false;
++    if (assignedDevice && !Query) {
++       OldDevice = assignedDevice;
++       assignedDevice = NULL;
++       }
++  }
++  int OldDeviceNumber = 0;
++  if (OldDevice) {
++     OldDeviceNumber = OldDevice->DeviceNumber() + 1;
++     if (caPidReceiver)
++        OldDevice->Detach(caPidReceiver);
++     OldDevice->SetCamSlot(NULL);
++     }
++  if (ciAdapter->Assign(Device, true)) {
++     if (!Query) {
++        StopDecrypting();
++        if (ciAdapter->Assign(Device)) {
++           if (Device) {
++              Device->SetCamSlot(this);
++              {
++                cMutexLock MutexLock(&mutex);
++                assignedDevice = Device;
++              }
++              if (caPidReceiver) {
++                 caPidReceiver->Reset();
++                 Device->AttachReceiver(caPidReceiver);
+                  }
++              dsyslog("CAM %d: assigned to device %d", MasterSlotNumber(), Device->DeviceNumber() + 1);
++              }
++           else {
++              CancelActivation();
++              dsyslog("CAM %d: unassigned from device %d", MasterSlotNumber(), OldDeviceNumber);
+               }
+-           else
+-              return false;
+            }
+-        return true;
++        else
++           return false;
+         }
++     return true;
+      }
+   return false;
+ }
+@@ -2264,8 +2277,8 @@ bool cCamSlot::Devices(cVector<int> &DeviceNumbers)
+   cMutexLock MutexLock(&mutex);
+   if (mtdHandler)
+      return mtdHandler->Devices(DeviceNumbers);
+-  if (assignedDevice)
+-     DeviceNumbers.Append(assignedDevice->DeviceNumber());
++  if (cDevice *d = assignedDevice)
++     DeviceNumbers.Append(d->DeviceNumber());
+   return DeviceNumbers.Size() > 0;
+ }
+ 
+--- a/ci.h
++++ b/ci.h
+@@ -10,6 +10,7 @@
+ #ifndef __CI_H
+ #define __CI_H
+ 
++#include <atomic>
+ #include <stdint.h>
+ #include <stdio.h>
+ #include "channels.h"
+@@ -236,10 +237,11 @@ class cCamSlot : public cListObject {
+   friend class cMtdCamSlot;
+ private:
+   cMutex mutex;
++  cMutex assignMutex; // serializes Assign(), which can't hold 'mutex' across its cDevice calls
+   cCondVar processed;
+   cCiAdapter *ciAdapter;
+   cCamSlot *masterSlot;
+-  cDevice *assignedDevice;
++  std::atomic<cDevice *> assignedDevice; // Device() reads it without the mutex
+   cCaPidReceiver *caPidReceiver;
+   cCaActivationReceiver *caActivationReceiver;
+   int slotIndex;

diff --git a/vdr-14-device-pid-notify-lock-scope.patch b/vdr-14-device-pid-notify-lock-scope.patch
new file mode 100644
index 0000000..321d8a6
--- /dev/null
+++ b/vdr-14-device-pid-notify-lock-scope.patch
@@ -0,0 +1,211 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] device: call cCamSlot::SetPid() and DetachAll() outside of mutexPids
+
+AddPid()/DelPid() called cCamSlot::SetPid(), which takes the mutexes of
+cCaPidReceiver and the CAM slot, and on errors DetachAll(), which takes
+mutexReceiver, while holding mutexPids. Those locks are held elsewhere
+while AddPid()/DelPid() take mutexPids: cCamSlot::BuildCaPmts() and
+cCaPidReceiver::AddEmmPid()/DelEmmPids() change their ECM and EMM PIDs
+through cReceiver -> cDevice::AddPid()/DelPid(), and AttachReceiver()
+holds mutexReceiver. The notification is now collected under the lock
+and delivered after releasing it.
+
+---
+--- a/device.c
++++ b/device.c
+@@ -568,98 +568,111 @@ bool cDevice::HasPid(int Pid) const
+ 
+ bool cDevice::AddPid(int Pid, ePidType PidType, int StreamType)
+ {
+-  cMutexLock MutexLock(&mutexPids);
+-  if (Pid || PidType == ptPcr) {
+-     int n = -1;
+-     int a = -1;
+-     if (PidType != ptPcr) { // PPID always has to be explicit
+-        for (int i = 0; i < MAXPIDHANDLES; i++) {
+-            if (i != ptPcr) {
+-               if (pidHandles[i].pid == Pid)
+-                  n = i;
+-               else if (a < 0 && i >= ptOther && !pidHandles[i].used)
+-                  a = i;
+-               }
+-            }
+-        }
+-     if (n >= 0) {
+-        // The Pid is already in use
+-        if (++pidHandles[n].used == 2 && n <= ptTeletext) {
+-           // It's a special PID that may have to be switched into "tap" mode
+-           PRINTPIDS("A");
+-           if (!SetPid(&pidHandles[n], n, true)) {
+-              esyslog("ERROR: can't set PID %d on device %d", Pid, DeviceNumber() + 1);
+-              if (PidType <= ptTeletext)
+-                 DetachAll(Pid);
+-              DelPid(Pid, PidType);
+-              return false;
++  // cCamSlot::SetPid() and DetachAll() are called after releasing mutexPids:
++  // the locks they take are held while calling AddPid() elsewhere (the CAM
++  // slot's and cCaPidReceiver's mutexes when adding ECM/EMM PIDs, mutexReceiver
++  // in AttachReceiver()):
++  cCamSlot *NotifySlot = NULL;
++  bool Failed = false;
++  {
++    cMutexLock MutexLock(&mutexPids);
++    if (Pid || PidType == ptPcr) {
++       int n = -1;
++       int a = -1;
++       if (PidType != ptPcr) { // PPID always has to be explicit
++          for (int i = 0; i < MAXPIDHANDLES; i++) {
++              if (i != ptPcr) {
++                 if (pidHandles[i].pid == Pid)
++                    n = i;
++                 else if (a < 0 && i >= ptOther && !pidHandles[i].used)
++                    a = i;
++                 }
+               }
+-           if (camSlot)
+-              camSlot->SetPid(Pid, true);
+-           }
+-        PRINTPIDS("a");
+-        return true;
+-        }
+-     else if (PidType < ptOther) {
+-        // The Pid is not yet in use and it is a special one
+-        n = PidType;
+-        }
+-     else if (a >= 0) {
+-        // The Pid is not yet in use and we have a free slot
+-        n = a;
+-        }
+-     else {
+-        esyslog("ERROR: no free slot for PID %d on device %d", Pid, DeviceNumber() + 1);
+-        return false;
+-        }
+-     if (n >= 0) {
+-        pidHandles[n].pid = Pid;
+-        pidHandles[n].streamType = StreamType;
+-        pidHandles[n].used = 1;
+-        PRINTPIDS("C");
+-        if (!SetPid(&pidHandles[n], n, true)) {
+-           esyslog("ERROR: can't set PID %d on device %d", Pid, DeviceNumber() + 1);
+-           if (PidType <= ptTeletext)
+-              DetachAll(Pid);
+-           DelPid(Pid, PidType);
+-           return false;
+-           }
+-        if (camSlot)
+-           camSlot->SetPid(Pid, true);
+-        }
++          }
++       if (n >= 0) {
++          // The Pid is already in use
++          if (++pidHandles[n].used == 2 && n <= ptTeletext) {
++             // It's a special PID that may have to be switched into "tap" mode
++             PRINTPIDS("A");
++             if (!SetPid(&pidHandles[n], n, true)) {
++                esyslog("ERROR: can't set PID %d on device %d", Pid, DeviceNumber() + 1);
++                Failed = true;
++                }
++             else
++                NotifySlot = camSlot;
++             }
++          PRINTPIDS("a");
++          }
++       else {
++          if (PidType < ptOther) {
++             // The Pid is not yet in use and it is a special one
++             n = PidType;
++             }
++          else if (a >= 0) {
++             // The Pid is not yet in use and we have a free slot
++             n = a;
++             }
++          else {
++             esyslog("ERROR: no free slot for PID %d on device %d", Pid, DeviceNumber() + 1);
++             return false;
++             }
++          pidHandles[n].pid = Pid;
++          pidHandles[n].streamType = StreamType;
++          pidHandles[n].used = 1;
++          PRINTPIDS("C");
++          if (!SetPid(&pidHandles[n], n, true)) {
++             esyslog("ERROR: can't set PID %d on device %d", Pid, DeviceNumber() + 1);
++             Failed = true;
++             }
++          else
++             NotifySlot = camSlot;
++          }
++       }
++  }
++  if (Failed) {
++     if (PidType <= ptTeletext)
++        DetachAll(Pid);
++     DelPid(Pid, PidType);
++     return false;
+      }
++  if (NotifySlot)
++     NotifySlot->SetPid(Pid, true);
+   return true;
+ }
+ 
+ void cDevice::DelPid(int Pid, ePidType PidType)
+ {
+-  cMutexLock MutexLock(&mutexPids);
+-  if (Pid || PidType == ptPcr) {
+-     int n = -1;
+-     if (PidType == ptPcr)
+-        n = PidType; // PPID always has to be explicit
+-     else {
+-        for (int i = 0; i < MAXPIDHANDLES; i++) {
+-            if (pidHandles[i].pid == Pid) {
+-               n = i;
+-               break;
+-               }
+-            }
+-        }
+-     if (n >= 0 && pidHandles[n].used) {
+-        PRINTPIDS("D");
+-        if (--pidHandles[n].used < 2) {
+-           SetPid(&pidHandles[n], n, false);
+-           if (pidHandles[n].used == 0) {
+-              pidHandles[n].handle = -1;
+-              pidHandles[n].pid = 0;
+-              if (camSlot)
+-                 camSlot->SetPid(Pid, false);
++  cCamSlot *NotifySlot = NULL; // notified after releasing mutexPids, see AddPid()
++  {
++    cMutexLock MutexLock(&mutexPids);
++    if (Pid || PidType == ptPcr) {
++       int n = -1;
++       if (PidType == ptPcr)
++          n = PidType; // PPID always has to be explicit
++       else {
++          for (int i = 0; i < MAXPIDHANDLES; i++) {
++              if (pidHandles[i].pid == Pid) {
++                 n = i;
++                 break;
++                 }
+               }
+-           }
+-        PRINTPIDS("E");
+-        }
+-     }
++          }
++       if (n >= 0 && pidHandles[n].used) {
++          PRINTPIDS("D");
++          if (--pidHandles[n].used < 2) {
++             SetPid(&pidHandles[n], n, false);
++             if (pidHandles[n].used == 0) {
++                pidHandles[n].handle = -1;
++                pidHandles[n].pid = 0;
++                NotifySlot = camSlot;
++                }
++             }
++          PRINTPIDS("E");
++          }
++       }
++  }
++  if (NotifySlot)
++     NotifySlot->SetPid(Pid, false);
+ }
+ 
+ bool cDevice::SetPid(cPidHandle *Handle, int Type, bool On)

diff --git a/vdr-15-control-mutex-null.patch b/vdr-15-control-mutex-null.patch
new file mode 100644
index 0000000..653304c
--- /dev/null
+++ b/vdr-15-control-mutex-null.patch
@@ -0,0 +1,31 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] player: don't keep the control mutex locked when Control() returns NULL
+
+cControl::Control() left the caller's cMutexLock locked even when it
+returned NULL. The main loop holds that lock across its whole key
+dispatch, where cDisplayChannel takes the Channels lock, while
+cControl::Shutdown() is called with the Channels lock held
+(cChannels::SwitchTo() -> cDevice::SwitchChannel()): a lock order
+inversion, with no control to protect. The mutex now stays locked only
+when a control is returned.
+
+---
+--- a/player.c
++++ b/player.c
+@@ -77,8 +77,14 @@ cControl *cControl::Control(cMutexLock &MutexLock, bool Hidden, bool *LockedOthe
+   int Timeout = cThread::IsMainThread() ? 0 : CONTROL_LOCK_TIMEOUT;
+   if (LockedOtherwise)
+      *LockedOtherwise = false;
+-  if (MutexLock.Lock(&mutex, Timeout, LockedOtherwise))
+-     return (control && (!control->hidden || Hidden)) ? control : NULL;
++  // Only a control needs the caller to keep the mutex locked. The main loop holds
++  // it across its key dispatch, which takes the Channels lock, while
++  // cControl::Shutdown() is called with the Channels lock held:
++  cMutexLock ControlMutexLock;
++  if (ControlMutexLock.Lock(&mutex, Timeout, LockedOtherwise)) {
++     if (control && (!control->hidden || Hidden) && MutexLock.Lock(&mutex)) // recursive, stays locked for the caller
++        return control;
++     }
+   return NULL;
+ }
+ 

diff --git a/vdr-16-osd-deregister-before-delete.patch b/vdr-16-osd-deregister-before-delete.patch
new file mode 100644
index 0000000..6a71e4c
--- /dev/null
+++ b/vdr-16-osd-deregister-before-delete.patch
@@ -0,0 +1,287 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] osd: deregister an OSD from the global list before deleting it
+
+OSDs are deleted in different threads (skins in the main thread,
+subtitle converters in their own). ~cOsd() removed the OSD from Osds
+only after the derived destructor had run, so another thread's ~cOsd()
+could still call Osds[0]->SetActive() on it: a virtual call into a
+half-destroyed object. cOsd::Deregister() unlinks the OSD and activates
+the next one under the OSD mutex, and cOsd::Delete() deregisters before
+deleting. The core deletes its OSDs that way; ~cOsd() still deregisters
+for plugins that don't.
+
+---
+--- a/dvbsubtitle.c
++++ b/dvbsubtitle.c
+@@ -1382,7 +1382,7 @@ cDvbSubtitleConverter::~cDvbSubtitleConverter()
+ {
+   Cancel(3);
+   delete dvbSubtitleAssembler;
+-  delete osd;
++  cOsd::Delete(osd);
+   delete bitmaps;
+   delete pages;
+ }
+@@ -1392,7 +1392,7 @@ void cDvbSubtitleConverter::SetVisible(bool Visible)
+   LOCK_THREAD;
+   visible = Visible;
+   if (!visible)
+-     DELETENULL(osd);
++     cOsd::Delete(osd);
+   endVisible = -1;
+ }
+ 
+@@ -1417,7 +1417,7 @@ void cDvbSubtitleConverter::Reset(void)
+   Lock();
+   pages->Clear();
+   current = NULL;
+-  DELETENULL(osd);
++  cOsd::Delete(osd);
+   frozen = false;
+   ddsVersionNumber = -1;
+   Unlock();
+@@ -1525,13 +1525,13 @@ void cDvbSubtitleConverter::Action(void)
+               int NewSetupLevel = setupLevel;
+               if (LastSetupLevel != NewSetupLevel) {
+                  dbgoutput("closing osd<br>\n");
+-                 DELETENULL(osd);
++                 cOsd::Delete(osd);
+                  }
+               LastSetupLevel = NewSetupLevel;
+               }
+            int64_t STC = cDevice::PrimaryDevice()->GetSTC();
+            if (osd && current && current->Timeout() * 1000 - PtsDeltaMs(STC, current->Pts()) <= 0)
+-              DELETENULL(osd);
++              cOsd::Delete(osd);
+            for (cDvbSubtitleBitmaps *sb = bitmaps->First(); sb; ) {
+                // Calculate the Delta between the STC (the current timestamp of the video)
+                // and the bitmap's PTS (the timestamp when the bitmap shall be presented).
+@@ -1550,10 +1550,10 @@ void cDvbSubtitleConverter::Action(void)
+                      if (endVisible >= 0 && PtsDeltaMs(STC, endVisible) > TEMPSUBTITLETAIL) {
+                         visible = false;
+                         endVisible = -1;
+-                        DELETENULL(osd);
++                        cOsd::Delete(osd);
+                         }
+                      else if (!current->HasBitmaps() || current->Timeout() * 1000 - PtsDeltaMs(STC, current->Pts()) <= 0)
+-                        DELETENULL(osd);
++                        cOsd::Delete(osd);
+                      else if (visible && AssertOsd()) {
+                         dbgoutput("showing bitmap #%d of %d<br>\n", current->Index() + 1, bitmaps->Count());
+                         current->Draw(osd);
+--- a/osd.c
++++ b/osd.c
+@@ -1939,6 +1939,12 @@ cOsd::~cOsd()
+      DestroyPixmap(savedPixmap);
+   for (int i = 0; i < pixmaps.Size(); i++)
+       delete pixmaps[i];
++  Deregister(); // in case the owner didn't use Delete()
++}
++
++void cOsd::Deregister(void)
++{
++  cMutexLock MutexLock(&mutex);
+   for (int i = 0; i < Osds.Size(); i++) {
+       if (Osds[i] == this) {
+          Osds.Remove(i);
+@@ -1949,6 +1955,15 @@ cOsd::~cOsd()
+       }
+ }
+ 
++void cOsd::Delete(cOsd *&Osd)
++{
++  if (Osd) {
++     Osd->Deregister();
++     delete Osd;
++     Osd = NULL;
++     }
++}
++
+ void cOsd::SetOsdPosition(int Left, int Top, int Width, int Height)
+ {
+   osdLeft = Left;
+--- a/osd.h
++++ b/osd.h
+@@ -828,6 +828,14 @@ protected:
+ public:
+   virtual ~cOsd();
+        ///< Shuts down the OSD.
++  void Deregister(void);
++       ///< Removes this OSD from the list of open OSDs and activates the next one.
++       ///< An OSD shall be deregistered before it is deleted (see Delete()): while
++       ///< its derived destructor runs, another thread deleting its own OSD could
++       ///< otherwise still call SetActive() on it. ~cOsd() deregisters as well, for
++       ///< code that doesn't.
++  static void Delete(cOsd *&Osd);
++       ///< Deregisters and deletes the given Osd (if any) and sets it to NULL.
+   static int OsdLeft(void) { return osdLeft ? osdLeft : Setup.OSDLeft; }
+   static int OsdTop(void) { return osdTop ? osdTop : Setup.OSDTop; }
+   static int OsdWidth(void) { return osdWidth ? osdWidth : Setup.OSDWidth; }
+--- a/skinclassic.c
++++ b/skinclassic.c
+@@ -111,7 +111,7 @@ cSkinClassicDisplayChannel::cSkinClassicDisplayChannel(bool WithInfo)
+ 
+ cSkinClassicDisplayChannel::~cSkinClassicDisplayChannel()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinClassicDisplayChannel::SetChannel(const cChannel *Channel, int Number)
+@@ -234,7 +234,7 @@ cSkinClassicDisplayMenu::cSkinClassicDisplayMenu(void)
+ 
+ cSkinClassicDisplayMenu::~cSkinClassicDisplayMenu()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinClassicDisplayMenu::DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
+@@ -510,7 +510,7 @@ cSkinClassicDisplayReplay::cSkinClassicDisplayReplay(bool ModeOnly)
+ 
+ cSkinClassicDisplayReplay::~cSkinClassicDisplayReplay()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinClassicDisplayReplay::SetTitle(const char *Title)
+@@ -607,7 +607,7 @@ cSkinClassicDisplayVolume::cSkinClassicDisplayVolume(void)
+ 
+ cSkinClassicDisplayVolume::~cSkinClassicDisplayVolume()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinClassicDisplayVolume::SetVolume(int Current, int Total, bool Mute)
+@@ -685,7 +685,7 @@ cSkinClassicDisplayTracks::cSkinClassicDisplayTracks(const char *Title, int NumT
+ 
+ cSkinClassicDisplayTracks::~cSkinClassicDisplayTracks()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinClassicDisplayTracks::SetItem(const char *Text, int Index, bool Current)
+@@ -745,7 +745,7 @@ cSkinClassicDisplayMessage::cSkinClassicDisplayMessage(void)
+ 
+ cSkinClassicDisplayMessage::~cSkinClassicDisplayMessage()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinClassicDisplayMessage::SetMessage(eMessageType Type, const char *Text)
+--- a/skinlcars.c
++++ b/skinlcars.c
+@@ -477,7 +477,7 @@ cSkinLCARSDisplayChannel::~cSkinLCARSDisplayChannel()
+ {
+   delete tallFont;
+   delete tinyFont;
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinLCARSDisplayChannel::DrawDate(void)
+@@ -956,7 +956,7 @@ cSkinLCARSDisplayMenu::~cSkinLCARSDisplayMenu()
+ {
+   delete tallFont;
+   delete tinyFont;
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinLCARSDisplayMenu::SetMenuCategory(eMenuCategory MenuCategory)
+@@ -1882,7 +1882,7 @@ cSkinLCARSDisplayReplay::cSkinLCARSDisplayReplay(bool ModeOnly)
+ 
+ cSkinLCARSDisplayReplay::~cSkinLCARSDisplayReplay()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinLCARSDisplayReplay::DrawDate(void)
+@@ -2026,7 +2026,7 @@ cSkinLCARSDisplayVolume::cSkinLCARSDisplayVolume(void)
+ 
+ cSkinLCARSDisplayVolume::~cSkinLCARSDisplayVolume()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinLCARSDisplayVolume::SetVolume(int Current, int Total, bool Mute)
+@@ -2152,7 +2152,7 @@ cSkinLCARSDisplayTracks::cSkinLCARSDisplayTracks(const char *Title, int NumTrack
+ 
+ cSkinLCARSDisplayTracks::~cSkinLCARSDisplayTracks()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinLCARSDisplayTracks::SetItem(const char *Text, int Index, bool Current)
+@@ -2243,7 +2243,7 @@ cSkinLCARSDisplayMessage::cSkinLCARSDisplayMessage(void)
+ 
+ cSkinLCARSDisplayMessage::~cSkinLCARSDisplayMessage()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinLCARSDisplayMessage::SetMessage(eMessageType Type, const char *Text)
+--- a/skinsttng.c
++++ b/skinsttng.c
+@@ -259,7 +259,7 @@ cSkinSTTNGDisplayChannel::cSkinSTTNGDisplayChannel(bool WithInfo)
+ 
+ cSkinSTTNGDisplayChannel::~cSkinSTTNGDisplayChannel()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinSTTNGDisplayChannel::SetChannel(const cChannel *Channel, int Number)
+@@ -501,7 +501,7 @@ cSkinSTTNGDisplayMenu::cSkinSTTNGDisplayMenu(void)
+ 
+ cSkinSTTNGDisplayMenu::~cSkinSTTNGDisplayMenu()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinSTTNGDisplayMenu::DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
+@@ -883,7 +883,7 @@ cSkinSTTNGDisplayReplay::cSkinSTTNGDisplayReplay(bool ModeOnly)
+ 
+ cSkinSTTNGDisplayReplay::~cSkinSTTNGDisplayReplay()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinSTTNGDisplayReplay::SetTitle(const char *Title)
+@@ -1006,7 +1006,7 @@ cSkinSTTNGDisplayVolume::cSkinSTTNGDisplayVolume(void)
+ 
+ cSkinSTTNGDisplayVolume::~cSkinSTTNGDisplayVolume()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinSTTNGDisplayVolume::SetVolume(int Current, int Total, bool Mute)
+@@ -1151,7 +1151,7 @@ cSkinSTTNGDisplayTracks::cSkinSTTNGDisplayTracks(const char *Title, int NumTrack
+ 
+ cSkinSTTNGDisplayTracks::~cSkinSTTNGDisplayTracks()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinSTTNGDisplayTracks::SetItem(const char *Text, int Index, bool Current)
+@@ -1258,7 +1258,7 @@ cSkinSTTNGDisplayMessage::cSkinSTTNGDisplayMessage(void)
+ 
+ cSkinSTTNGDisplayMessage::~cSkinSTTNGDisplayMessage()
+ {
+-  delete osd;
++  cOsd::Delete(osd);
+ }
+ 
+ void cSkinSTTNGDisplayMessage::SetMessage(eMessageType Type, const char *Text)

diff --git a/vdr-17-skins-locked-track-copy.patch b/vdr-17-skins-locked-track-copy.patch
new file mode 100644
index 0000000..069ddd6
--- /dev/null
+++ b/vdr-17-skins-locked-track-copy.patch
@@ -0,0 +1,95 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] device, skins: read the current track through a locked copy
+
+The skins' DrawTrack() read the audio track description through
+GetTrack(), a bare pointer into cDevice::availableTracks[], while a
+channel switch in another thread (e.g. SVDRP CHAN) clears and refills
+that table under mutexCurrentAudioTrack. cDevice::GetTrackId() copies
+the entry under that mutex.
+
+---
+--- a/device.c
++++ b/device.c
+@@ -1179,6 +1179,16 @@ const tTrackId *cDevice::GetTrack(eTrackType Type)
+   return (ttNone < Type && Type < ttMaxTrackTypes) ? &availableTracks[Type] : NULL;
+ }
+ 
++bool cDevice::GetTrackId(eTrackType Type, tTrackId &TrackId)
++{
++  cMutexLock MutexLock(&mutexCurrentAudioTrack);
++  if (const tTrackId *Track = GetTrack(Type)) {
++     TrackId = *Track;
++     return true;
++     }
++  return false;
++}
++
+ int cDevice::NumTracks(eTrackType FirstTrack, eTrackType LastTrack) const
+ {
+   int n = 0;
+--- a/device.h
++++ b/device.h
+@@ -582,6 +582,11 @@ public:
+   const tTrackId *GetTrack(eTrackType Type);
+        ///< Returns a pointer to the given track id, or NULL if Type is not
+        ///< less than ttMaxTrackTypes.
++  bool GetTrackId(eTrackType Type, tTrackId &TrackId);
++       ///< Copies the given track id into TrackId and returns true, or returns
++       ///< false if Type is not a valid track type. Unlike GetTrack() this may be
++       ///< used while another thread switches the channel, which rewrites the
++       ///< track table.
+   int NumTracks(eTrackType FirstTrack, eTrackType LastTrack) const;
+        ///< Returns the number of tracks in the given range that are currently
+        ///< available.
+--- a/skinlcars.c
++++ b/skinlcars.c
+@@ -492,10 +492,11 @@ void cSkinLCARSDisplayChannel::DrawDate(void)
+ void cSkinLCARSDisplayChannel::DrawTrack(void)
+ {
+   cDevice *Device = cDevice::PrimaryDevice();
+-  const tTrackId *Track = Device->GetTrack(Device->GetCurrentAudioTrack());
+-  if (Track ? strcmp(lastTrackId.description, Track->description) : *lastTrackId.description) {
+-     osd->DrawText(xc03, yc07, Track ? Track->description : "", Theme.Color(clrTrackName), Theme.Color(clrBackground), cFont::GetFont(fontOsd), xc07 - xc03);
+-     strn0cpy(lastTrackId.description, Track ? Track->description : "", sizeof(lastTrackId.description));
++  tTrackId TrackId;
++  bool Track = Device->GetTrackId(Device->GetCurrentAudioTrack(), TrackId);
++  if (Track ? strcmp(lastTrackId.description, TrackId.description) : *lastTrackId.description) {
++     osd->DrawText(xc03, yc07, Track ? TrackId.description : "", Theme.Color(clrTrackName), Theme.Color(clrBackground), cFont::GetFont(fontOsd), xc07 - xc03);
++     strn0cpy(lastTrackId.description, Track ? TrackId.description : "", sizeof(lastTrackId.description));
+      }
+ }
+ 
+@@ -1897,10 +1898,11 @@ void cSkinLCARSDisplayReplay::DrawDate(void)
+ void cSkinLCARSDisplayReplay::DrawTrack(void)
+ {
+   cDevice *Device = cDevice::PrimaryDevice();
+-  const tTrackId *Track = Device->GetTrack(Device->GetCurrentAudioTrack());
+-  if (Track ? strcmp(lastTrackId.description, Track->description) : *lastTrackId.description) {
+-     osd->DrawText(xp03, yp04, Track ? Track->description : "", Theme.Color(clrTrackName), Theme.Color(clrBackground), cFont::GetFont(fontOsd), xp07 - xp03);
+-     strn0cpy(lastTrackId.description, Track ? Track->description : "", sizeof(lastTrackId.description));
++  tTrackId TrackId;
++  bool Track = Device->GetTrackId(Device->GetCurrentAudioTrack(), TrackId);
++  if (Track ? strcmp(lastTrackId.description, TrackId.description) : *lastTrackId.description) {
++     osd->DrawText(xp03, yp04, Track ? TrackId.description : "", Theme.Color(clrTrackName), Theme.Color(clrBackground), cFont::GetFont(fontOsd), xp07 - xp03);
++     strn0cpy(lastTrackId.description, Track ? TrackId.description : "", sizeof(lastTrackId.description));
+      }
+ }
+ 
+--- a/skinsttng.c
++++ b/skinsttng.c
+@@ -338,10 +338,11 @@ void cSkinSTTNGDisplayChannel::Flush(void)
+            lastDate = date;
+            }
+         cDevice *Device = cDevice::PrimaryDevice();
+-        const tTrackId *Track = Device->GetTrack(Device->GetCurrentAudioTrack());
+-        if (Track ? strcmp(lastTrackId.description, Track->description) : *lastTrackId.description) {
+-           osd->DrawText(x3 + TextFrame, y6, Track ? Track->description : "", Theme.Color(clrChannelName), frameColor, font, x4 - x3 - w - 2 * TextFrame);
+-           strn0cpy(lastTrackId.description, Track ? Track->description : "", sizeof(lastTrackId.description));
++        tTrackId TrackId;
++        bool Track = Device->GetTrackId(Device->GetCurrentAudioTrack(), TrackId);
++        if (Track ? strcmp(lastTrackId.description, TrackId.description) : *lastTrackId.description) {
++           osd->DrawText(x3 + TextFrame, y6, Track ? TrackId.description : "", Theme.Color(clrChannelName), frameColor, font, x4 - x3 - w - 2 * TextFrame);
++           strn0cpy(lastTrackId.description, Track ? TrackId.description : "", sizeof(lastTrackId.description));
+            }
+         int DeviceNumber = cDevice::ActualDevice()->DeviceNumber() + 1;
+         if (DeviceNumber != lastDeviceNumber || time(NULL) != lastSignalDisplay) {

diff --git a/vdr-18-tsbuffer-get-timeout.patch b/vdr-18-tsbuffer-get-timeout.patch
new file mode 100644
index 0000000..da23b32
--- /dev/null
+++ b/vdr-18-tsbuffer-get-timeout.patch
@@ -0,0 +1,23 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] device: let the TS buffer consumer re-check every 10 ms
+
+cTSBuffer's ring signals its consumer only once it is 10% full, which
+live traffic rarely reaches, so cDevice::Action() waits for the 100 ms
+get timeout: the first packets of a new channel reach the receivers in
+100 ms steps, and a receiver that was told to stop notices it up to
+100 ms late. With 10 ms, the first video PES of a same-transponder zap
+arrived about 85 ms earlier (median); the extra wake-ups cost no
+measurable CPU time.
+
+---
+--- a/device.c
++++ b/device.c
+@@ -2048,7 +2048,7 @@ cTSBuffer::cTSBuffer(int File, int Size, int DeviceNumber)
+   deviceNumber = DeviceNumber;
+   delivered = 0;
+   ringBuffer = new cRingBufferLinear(Size, TS_SIZE, true, "TS");
+-  ringBuffer->SetTimeouts(100, 100);
++  ringBuffer->SetTimeouts(100, 10); // the ring signals Get() only above 10% fill, too late for live TV
+   ringBuffer->SetIoThrottle();
+   Start();
+ }

diff --git a/vdr-19-dvbplayer-pause-stuckateof.patch b/vdr-19-dvbplayer-pause-stuckateof.patch
new file mode 100644
index 0000000..3057b44
--- /dev/null
+++ b/vdr-19-dvbplayer-pause-stuckateof.patch
@@ -0,0 +1,21 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] dvbplayer: a pause at the end of a recording is no stuck STC
+
+While paused, Action() leaves the loop body with 'continue' before the
+end-of-recording handling, so its 'StuckAtEof = 0' for pmPause never
+runs. During the drain at the end StuckAtEof is set almost all the time
+(the loop runs every 3 ms, the STC moves once per frame), so after a
+pause there of more than MAXSTUCKATEOF seconds, Play ended the replay at
+once, and what the device still held was never shown.
+
+---
+--- a/dvbplayer.c
++++ b/dvbplayer.c
+@@ -626,6 +626,7 @@ void cDvbPlayer::Action(void)
+                 }
+              }
+           else {
++             StuckAtEof = 0; // the STC stands still while paused, which is no stall
+              Sleep = true;
+              continue;
+              }

diff --git a/vdr-20-dvbplayer-last-frame.patch b/vdr-20-dvbplayer-last-frame.patch
new file mode 100644
index 0000000..8c21719
--- /dev/null
+++ b/vdr-20-dvbplayer-last-frame.patch
@@ -0,0 +1,46 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] dvbplayer: don't end a replay when the STC reaches the last frame read
+
+A forward replay also stopped once the STC reached LastReadFrame, the
+last frame in decode order. With B-frames that isn't the last frame
+shown, so the device was still playing out the tail (80-100 ms with
+1080i H.264 or SD MPEG-2, a multiple of that in slow motion). Without
+the replay OSD this went unnoticed, since the main loop tore the replay
+down only up to a second later; with the OSD open it did so at once.
+Drain() now tells when the device has shown everything, and
+MAXSTUCKATEOF covers devices that don't implement it.
+
+---
+--- a/dvbplayer.c
++++ b/dvbplayer.c
+@@ -485,7 +485,6 @@ void cDvbPlayer::Action(void)
+   bool WaitingForData = false;
+   time_t StuckAtEof = 0;
+   uint32_t LastStc = 0;
+-  int LastReadFrame = -1;
+   int SwitchToPlayFrame = 0;
+   bool CutIn = false;
+   bool AtLastMark = false;
+@@ -590,7 +589,6 @@ void cDvbPlayer::Action(void)
+                    int r = nonBlockingFileReader->Result(&b);
+                    if (r > 0) {
+                       WaitingForData = false;
+-                      LastReadFrame = readIndex;
+                       int64_t Pts = isPesRecording ? (PesHasPts(b) ? PesGetPts(b) : -1) : TsGetPts(b, r);
+                       readFrame = new cFrame(b, -r, ftUnknown, readIndex, Pts, readIndependent); // hands over b to the ringBuffer
+                       if (AtLastMark) {
+@@ -714,11 +712,9 @@ void cDvbPlayer::Action(void)
+                 StuckAtEof = time(NULL);
+              LastStc = Stc;
+              int Index = ptsIndex.FindIndex(Stc, playMode == pmStill);
+-             if (playDir == pdForward && !SwitchToPlayFrame) {
+-                if (Index >= LastReadFrame)
+-                   break; // automatically stop at end of recording
+-                }
+-             else if (Index <= 0 || SwitchToPlayFrame && Index >= SwitchToPlayFrame)
++             // The end of a forward replay is decided above: the last frame read isn't the
++             // last one shown if there are B-frames.
++             if ((playDir != pdForward || SwitchToPlayFrame) && (Index <= 0 || SwitchToPlayFrame && Index >= SwitchToPlayFrame))
+                 SwitchToPlay = true;
+              if (SwitchToPlay) {
+                 if (!SwitchToPlayFrame) {

diff --git a/vdr-21-dvbplayer-growing-recording.patch b/vdr-21-dvbplayer-growing-recording.patch
new file mode 100644
index 0000000..7ad0781
--- /dev/null
+++ b/vdr-21-dvbplayer-growing-recording.patch
@@ -0,0 +1,77 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] dvbplayer, recording: keep replaying a recording that is still being written
+
+Replaying a recording in progress hits eof whenever the recorder writes
+nothing for longer than cIndexFile's catch-up time, and draining the
+device there ended the replay while the recording went on. In forward
+play such an eof is now a stall (no drain, no timeout), and StuckAtEof
+is reset whenever a frame is played, so a stall doesn't count at the
+real end. Once the recording has ended, CatchUp() closes the index file
+instead of waiting the full catch-up time on every read past the end
+(the rest trickled out at about one frame per second, or not at all),
+which also makes IsStillRecording() say so.
+
+---
+--- a/dvbplayer.c
++++ b/dvbplayer.c
+@@ -641,6 +641,7 @@ void cDvbPlayer::Action(void)
+ 
+           if (playFrame) {
+              eof = false;
++             StuckAtEof = 0; // a stall at the end of a growing recording must not count at its real end
+              if (!p) {
+                 p = playFrame->Data();
+                 pc = playFrame->Count();
+@@ -698,10 +699,12 @@ void cDvbPlayer::Action(void)
+ 
+           if (eof || SwitchToPlayFrame) {
+              bool SwitchToPlay = false;
++             // In a recording that is still being written, eof in forward play is only a stall:
++             bool FinalEof = eof && (!index || !index->IsStillRecording() || playDir != pdForward);
+              uint32_t Stc = DeviceGetSTC();
+              if (playMode == pmPause)
+                 StuckAtEof = 0;
+-             else if (eof && DeviceDrain() || StuckAtEof && time(NULL) - StuckAtEof > MAXSTUCKATEOF) {
++             else if (FinalEof && DeviceDrain() || (!eof || FinalEof) && StuckAtEof && time(NULL) - StuckAtEof > MAXSTUCKATEOF) {
+                 if (playDir == pdForward)
+                    break; // automatically stop at end of recording
+                 SwitchToPlay = true;
+--- a/recording.c
++++ b/recording.c
+@@ -3044,11 +3044,13 @@ void cIndexFile::ConvertToPes(tIndexTs *IndexTs, int Count)
+ bool cIndexFile::CatchUp(int Index)
+ {
+   // returns true unless something really goes wrong, so that 'index' becomes NULL
++  cMutexLock MutexLock(&mutex); // 'f' may be closed by another thread's CatchUp(), even while this one waits below
+   if (index && f >= 0) {
+-     cMutexLock MutexLock(&mutex);
+      // Note that CatchUp() is triggered even if Index is 'last' (and thus valid).
+      // This is done to make absolutely sure we don't miss any data at the very end.
+-     for (int i = 0; i <= MAXINDEXCATCHUP && (Index < 0 || Index >= last); i++) {
++     for (int i = 0; f >= 0 && i <= MAXINDEXCATCHUP && (Index < 0 || Index >= last); i++) {
++         // Checked before reading: the timer file is removed after the last index entry has been written.
++         bool Ended = !StillRecording(*cString(*fileName, strrchr(*fileName, '/')));
+          struct stat buf;
+          if (fstat(f, &buf) == 0) {
+             int newLast = int(buf.st_size / sizeof(tIndexTs) - 1);
+@@ -3090,6 +3092,12 @@ bool cIndexFile::CatchUp(int Index)
+             LOG_ERROR_STR(*fileName);
+          if (Index < last)
+             break;
++         if (Ended) {
++            // nothing more will come, so don't wait for it on every read past the end
++            close(f);
++            f = -1;
++            break;
++            }
+          cCondVar CondVar;
+          CondVar.TimedWait(mutex, INDEXCATCHUPWAIT);
+          }
+@@ -3237,6 +3245,7 @@ int cIndexFile::Get(uint16_t FileNumber, off_t FileOffset)
+ 
+ bool cIndexFile::IsStillRecording(void)
+ {
++  cMutexLock MutexLock(&mutex); // CatchUp() closes 'f' once the recording has ended
+   return f >= 0;
+ }
+ 

diff --git a/vdr-22-plugins-html-draindevice.patch b/vdr-22-plugins-html-draindevice.patch
new file mode 100644
index 0000000..79de705
--- /dev/null
+++ b/vdr-22-plugins-html-draindevice.patch
@@ -0,0 +1,37 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] PLUGINS.html: describe the end of stream handling with DrainDevice()
+
+The contract of Drain() and DrainDevice() is only documented in device.h.
+Output plugin authors look for the functions a device implements in
+PLUGINS.html, where the replay section lists them.
+
+---
+--- a/PLUGINS.html
++++ b/PLUGINS.html
+@@ -1962,6 +1962,26 @@ virtual void SetVideoFormat(bool VideoFormat16_9);
+ virtual void SetVolumeDevice(int Volume);
+ </pre></td></tr></table><p>
+ 
++<div class="modified">
++<b>End of stream</b>
++<p>
++When a player has delivered the last data of a stream, it calls <tt>Drain()</tt>
++repeatedly until it returns <tt>true</tt>. <tt>Drain()</tt> first plays out the PES
++data that <tt>PlayTs()</tt> still holds back, and then calls
++
++<p><table><tr><td class="code"><pre>
++virtual bool DrainDevice(void);
++</pre></td></tr></table><p>
++
++which a device implements to play out all data it still holds in its buffers and
++decoders, without repeating or discarding anything. It must not block, shall return
++<tt>true</tt> once the last frame has actually been played out, and <tt>GetSTC()</tt>
++must keep advancing until then. <tt>Clear()</tt> and <tt>SetPlayMode()</tt> cancel
++the draining. A device that buffers data in its own <tt>PlayTsVideo()</tt>,
++<tt>PlayTsAudio()</tt> or <tt>PlayTsSubtitle()</tt> plays out that data here, too.
++The default implementation calls the deprecated <tt>Flush()</tt>.
++</div>
++
+ <p>
+ <b>Section Filtering</b>
+ <p>

diff --git a/vdr-fedora.patch b/vdr-fedora.patch
index f9403c7..9c1f77c 100644
--- a/vdr-fedora.patch
+++ b/vdr-fedora.patch
@@ -1,12 +1,15 @@
-vdr.pc must export datadir/rundir/vardir/user/group: the packaged RPM
-macros and Make.config resolve them via pkg-config, and an unset user
-would make VDR skip dropping privileges. The installed vdr-newplugin
-runs outside a VDR source tree, so it must create its skeleton in the
-current directory.
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] Makefile, newplugin: export the packaging variables via vdr.pc
 
+The packaged RPM macros and Make.config read datadir, rundir, vardir,
+user and group from vdr.pc; with 'user' unset VDR would not drop its
+privileges. The installed vdr-newplugin runs outside a VDR source tree,
+so it creates the skeleton in the current directory.
+
+---
 --- a/Makefile
 +++ b/Makefile
-@@ -186,6 +186,12 @@
+@@ -186,6 +186,12 @@ vdr.pc:
  	@echo "cflags=$(CFLAGS) $(CDEFINES) $(CINCLUDES) $(HDRDIR)" >> $@
  	@echo "cxxflags=$(CXXFLAGS) $(CDEFINES) $(CINCLUDES) $(HDRDIR)" >> $@
  	@echo "" >> $@
@@ -21,7 +24,7 @@ current directory.
  	@echo "URL: https://www.tvdr.de/" >> $@
 --- a/newplugin
 +++ b/newplugin
-@@ -24,7 +24,7 @@
+@@ -24,7 +24,7 @@ $PLUGIN_VERSION = "0.0.1";
  $PLUGIN_DESCRIPTION = "Enter description for '$PLUGIN_NAME' plugin";
  $PLUGIN_MAINENTRY = $PLUGIN_CLASS;
  

diff --git a/vdr-fsf-address.patch b/vdr-fsf-address.patch
index c56cbc9..c0aaa6d 100644
--- a/vdr-fsf-address.patch
+++ b/vdr-fsf-address.patch
@@ -1,8 +1,12 @@
-The FSF no longer resides at 51 Franklin Street, and packaging tools
-have started to reject license files carrying a stale postal address.
-Refer to <https://fsf.org/> and <https://www.gnu.org/licenses/> instead,
-as the FSF itself does in the GPLv3 text. License terms are unchanged.
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] COPYING: replace the FSF's former postal address with the license URLs
 
+The FSF no longer resides at 51 Franklin Street, and packaging checks
+reject license files with the old address. Refer to <https://fsf.org/>
+and <https://www.gnu.org/licenses/>, as the GPLv3 text does. The license
+terms are unchanged.
+
+---
 --- a/COPYING
 +++ b/COPYING
 @@ -2,7 +2,7 @@
@@ -14,7 +18,7 @@ as the FSF itself does in the GPLv3 text. License terms are unchanged.
   Everyone is permitted to copy and distribute verbatim copies
   of this license document, but changing it is not allowed.
  
-@@ -304,8 +304,7 @@
+@@ -304,8 +304,7 @@ the "copyright" line and a pointer to where the full notice is found.
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License
@@ -35,7 +39,7 @@ as the FSF itself does in the GPLv3 text. License terms are unchanged.
   Everyone is permitted to copy and distribute verbatim copies
   of this license document, but changing it is not allowed.
  
-@@ -304,8 +304,7 @@
+@@ -304,8 +304,7 @@ the "copyright" line and a pointer to where the full notice is found.
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License

diff --git a/vdr-mainmenuhooks.patch b/vdr-mainmenuhooks.patch
index 8c40aca..4b8d676 100644
--- a/vdr-mainmenuhooks.patch
+++ b/vdr-mainmenuhooks.patch
@@ -1,13 +1,15 @@
-epgsearch's "Replace original schedule" option needs the service call
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] menu: MainMenuHooks, reduced to the osSchedule hook
+
+epgsearch's "Replace original schedule" calls the service
 "MainMenuHooksPatch-v1.0::osSchedule"; without it the option silently
-does nothing. Only this hook is wired up: the other three hooks of the
-original MainMenuHooks-1.0.5 patch have no consumer here, and the
-MAINMENUHOOKSVERSNUM defines are omitted so no plugin can feature-test
-itself into using hooks that are absent.
+does nothing. Only this hook is wired up, and the MAINMENUHOOKSVERSNUM
+defines are left out, so no plugin can detect hooks that aren't there.
 
+---
 --- a/menu.c
 +++ b/menu.c
-@@ -4718,7 +4718,18 @@
+@@ -4756,7 +4756,18 @@ cMenuMain::cMenuMain(eOSState State, bool OpenSubMenus)
    // Initial submenus:
  
    switch (State) {
@@ -27,7 +29,7 @@ itself into using hooks that are absent.
      case osChannels:   AddSubMenu(new cMenuChannels); break;
      case osTimers:     AddSubMenu(new cMenuTimers); break;
      case osRecordings: AddSubMenu(new cMenuRecordings(NULL, 0, OpenSubMenus)); break;
-@@ -4855,7 +4866,21 @@
+@@ -4893,7 +4904,21 @@ eOSState cMenuMain::ProcessKey(eKeys Key)
    HadSubMenu |= HasSubMenu();
  
    switch (state) {

diff --git a/vdr-posix-inet-functions.patch b/vdr-posix-inet-functions.patch
new file mode 100644
index 0000000..c475a6b
--- /dev/null
+++ b/vdr-posix-inet-functions.patch
@@ -0,0 +1,56 @@
+From: Dirk Nehring <dnehring@gmx.net>
+Subject: [PATCH] config, svdrp: use inet_pton()/inet_ntop() instead of the legacy inet_* calls
+
+inet_ntoa() returns a static buffer, but cIpAddress::Set() runs in
+concurrent SVDRP handler threads. inet_aton() and inet_addr() go as
+well: they are obsolete (distribution checks flag them), and VDR only
+passes dotted-decimal addresses, the one form inet_pton() accepts.
+Connect() fails on an invalid address instead of connecting to 0.0.0.0.
+
+---
+--- a/config.c
++++ b/config.c
+@@ -49,7 +49,7 @@ bool cSVDRPhost::Parse(const char *s)
+         mask = htonl(mask);
+         }
+      }
+-  int result = inet_aton(s, &addr);
++  int result = inet_pton(AF_INET, s, &addr);
+   if (p)
+      *(char *)p = '/'; // there it is again
+   return result != 0 && (mask != 0 || addr.s_addr == 0);
+--- a/svdrp.c
++++ b/svdrp.c
+@@ -91,7 +91,8 @@ void cIpAddress::Set(const char *Address, int Port)
+ void cIpAddress::Set(const sockaddr *SockAddr)
+ {
+   const sockaddr_in *Addr = (sockaddr_in *)SockAddr;
+-  Set(inet_ntoa(Addr->sin_addr), ntohs(Addr->sin_port));
++  char buf[INET_ADDRSTRLEN];
++  Set(inet_ntop(AF_INET, &Addr->sin_addr, buf, sizeof(buf)), ntohs(Addr->sin_port));
+ }
+ 
+ // --- cSocket ---------------------------------------------------------------
+@@ -202,7 +203,11 @@ bool cSocket::Connect(const char *Address)
+      memset(&Addr, 0, sizeof(Addr));
+      Addr.sin_family = AF_INET;
+      Addr.sin_port = htons(port);
+-     Addr.sin_addr.s_addr = inet_addr(Address);
++     if (inet_pton(AF_INET, Address, &Addr.sin_addr) != 1) {
++        esyslog("ERROR: invalid IP address '%s'", Address);
++        Close();
++        return false;
++        }
+      if (connect(sock, (sockaddr *)&Addr, sizeof(Addr)) < 0) {
+         LOG_ERROR;
+         Close();
+@@ -250,7 +255,8 @@ bool cSocket::SendDgram(const char *Dgram, int Port)
+   Addr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
+   Addr.sin_port = htons(Port);
+   // Send datagram:
+-  dbgsvdrp("> %s:%d %s\n", inet_ntoa(Addr.sin_addr), Port, Dgram);
++  char buf[INET_ADDRSTRLEN];
++  dbgsvdrp("> %s:%d %s\n", inet_ntop(AF_INET, &Addr.sin_addr, buf, sizeof(buf)), Port, Dgram);
+   int Length = strlen(Dgram);
+   int Sent = sendto(Socket, Dgram, Length, 0, (sockaddr *)&Addr, sizeof(Addr));
+   if (Sent < 0)

diff --git a/vdr-shutdown.sh b/vdr-shutdown.sh
old mode 100644
new mode 100755

diff --git a/vdr.spec b/vdr.spec
index 07746fa..2af9507 100644
--- a/vdr.spec
+++ b/vdr.spec
@@ -13,8 +13,8 @@
 %global __provides_exclude_from ^%{plugindir}/.*\\.so.*$
 
 Name:           vdr
-Version:        2.8.2
-Release:        3%{?dist}
+Version:        2.8.3
+Release:        1%{?dist}
 Summary:        Video Disk Recorder
 
 License:        GPL-2.0-or-later
@@ -44,13 +44,44 @@ Source14:       %{name}-check-setup.sh
 Source15:       %{name}-set-wakeup.sh
 
 # Fedora/FHS integration: export datadir/rundir/vardir/user/group from vdr.pc
-Patch:          %{name}-fedora.patch
+Patch0:         %{name}-fedora.patch
 # MainMenuHooks, reduced to the only hook any shipped plugin implements
-# (epgsearch's "Replace original schedule").
-Patch:          %{name}-mainmenuhooks.patch
-# Sent upstream: replace the FSF's stale postal address in COPYING with the
-# license URLs; rpmlint rejects the old address.
-Patch:          %{name}-fsf-address.patch
+# (epgsearch's "Replace original schedule")
+Patch1:         %{name}-mainmenuhooks.patch
+# Sent upstream: replace the FSF's former postal address in COPYING with the
+# license URLs; rpmlint rejects the old address
+Patch2:         %{name}-fsf-address.patch
+# Sent upstream: thread-safe inet_pton()/inet_ntop() instead of inet_ntoa() & Co.
+Patch3:         %{name}-posix-inet-functions.patch
+
+# For upstream, Patch1NN is %%{name}-NN-*.patch, in dependency order:
+# data races found with ThreadSanitizer (01-12)
+Patch101:       %{name}-01-thread-atomics.patch
+Patch102:       %{name}-02-device-track-atomics.patch
+Patch103:       %{name}-03-device-player-atomics.patch
+Patch104:       %{name}-04-receiver-atomics.patch
+Patch105:       %{name}-05-transfer-atomics.patch
+Patch106:       %{name}-06-dvbplayer-atomics.patch
+Patch107:       %{name}-07-dvbtuner-atomics.patch
+Patch108:       %{name}-08-dvbtuner-channel-lock.patch
+Patch109:       %{name}-09-sections-sdt-atomics.patch
+Patch110:       %{name}-10-svdrp-ready-atomic.patch
+Patch111:       %{name}-11-dvbsubtitle-atomics.patch
+Patch112:       %{name}-12-device-camslot-atomic.patch
+# lock order inversions and object lifetime (13-17)
+Patch113:       %{name}-13-camslot-assign-lock-scope.patch
+Patch114:       %{name}-14-device-pid-notify-lock-scope.patch
+Patch115:       %{name}-15-control-mutex-null.patch
+Patch116:       %{name}-16-osd-deregister-before-delete.patch
+Patch117:       %{name}-17-skins-locked-track-copy.patch
+# live data reached the receivers in 100 ms steps, slowing down channel switches
+Patch118:       %{name}-18-tsbuffer-get-timeout.patch
+# the end of a replay: a pause in the tail, B-frame tails cut by the STC check,
+# recordings that are still being written, and DrainDevice() in PLUGINS.html
+Patch119:       %{name}-19-dvbplayer-pause-stuckateof.patch
+Patch120:       %{name}-20-dvbplayer-last-frame.patch
+Patch121:       %{name}-21-dvbplayer-growing-recording.patch
+Patch122:       %{name}-22-plugins-html-draindevice.patch
 
 BuildRequires:  gcc-c++
 BuildRequires:  make
@@ -201,7 +232,7 @@ PKG_CONFIG_PATH="%{buildroot}%{_libdir}/pkgconfig:$PKG_CONFIG_PATH" \
 make install-bin install-dirs install-conf install-doc install-i18n \
     install-includes DESTDIR=%{buildroot}
 
-install -pm 755 epg2html %{buildroot}%{_bindir}
+install -pm 755 epg2html pes2ts %{buildroot}%{_bindir}
 
 install -dm 755 %{buildroot}%{configdir}/plugins
 install -dm 755 %{buildroot}%{_sysconfdir}/sysconfig/vdr-plugins.d
@@ -283,7 +314,8 @@ install -Dpm 644 %{SOURCE4} %{buildroot}%{_rpmmacrodir}/macros.vdr
 
 # plugins
 
-%make_install -C PLUGINS/src/skincurses
+# VDRDIR: resolve vdr.pc from this tree, not from an installed vdr-devel
+%make_install -C PLUGINS/src/skincurses VDRDIR=$PWD PLGCFG=$PWD/bundled-plugins.mk
 install -pm 644 %{SOURCE8} \
     %{buildroot}%{_sysconfdir}/sysconfig/vdr-plugins.d/skincurses.conf
 
@@ -328,6 +360,7 @@ visudo -cf %{buildroot}%{_sysconfdir}/sudoers.d/vdr
 %config(noreplace) %{_sysconfdir}/sysconfig/vdr
 %config %dir %{_sysconfdir}/sysconfig/vdr-plugins.d/
 %{_bindir}/epg2html
+%{_bindir}/pes2ts
 %{_bindir}/runvdr
 %{_bindir}/svdrpsend
 %{_bindir}/vdr
@@ -383,6 +416,45 @@ visudo -cf %{buildroot}%{_sysconfdir}/sudoers.d/vdr
 
 
 %changelog
+* Sun Sep 27 2026 Dirk Nehring  <dnehring@gmx.net> - 2.8.3-1
+- Update to 2.8.3 (API version 14)
+- Drop the patches merged into 2.8.3: cache-threadid, hoist-receiver-lock,
+  fix-unused-variable, 03-osd-isopen-locking, 11-dvbdevice-stop-thread,
+  12-launch-transfer-after-switch, 14-svdrp-stop-order,
+  15-transfer-serialize-playts, 16-settrackdescriptions-lock-scope,
+  17-device-track-table-lock, 20-lcars-flush-control-mutex-scope,
+  23-device-subtitleconverter-lock, 30-detachallreceivers-lock-scope
+- Drop 26-capid-handlingpid-atomic: 28-device-pid-notify-lock-scope already
+  calls cCamSlot::SetPid() outside of mutexPids, and without its mutex
+  HandlingPid() could make a concurrent SetPid() skip a channel PID
+- Rework the rest for upstream as 01-17, with short descriptions and
+  comments that give the reason: merge the pairs that guard one link
+  (player/device, receiver PIDs/device, transfer, which also makes
+  cTransfer::activated atomic), split the tuner patch into its atomics and
+  a channel lock that no longer spans the signal ioctls, and fix the
+  misplaced GetTrackId() documentation
+- Add 18-tsbuffer-get-timeout: faster channel switches
+- Add 19-22 for the end of a replay: a pause in the tail no longer ends it,
+  B-frame tails are no longer cut, a recording that is still being written
+  no longer ends at a stall or trickles out after its end, and PLUGINS.html
+  describes DrainDevice()
+- Package the pes2ts script
+- Install skincurses with VDRDIR set: the plugin's make install resolved
+  vdr.pc through the installed vdr-devel and used its API version
+
+* Sat Aug 22 2026 Dirk Nehring  <dnehring@gmx.net> - 2.8.2-4
+- Drop vdr-10-lcars-sttng-event-lock.patch and
+  vdr-19-setchannel-lock-order.patch, both rejected upstream. For 19, every
+  caller of cDevice::SetChannel() already holds the channels read lock before
+  it takes mutexChannel, so the lock the patch hoisted was a recursive re-lock
+  in the same thread and the lock order it was meant to fix was never inverted
+- Drop vdr-02-displaychannel-lock-order.patch. cDisplayChannel::DisplayInfo()
+  is private and both of its callers already hold LOCK_CHANNELS_READ, so the
+  channels lock the patch added was a recursive re-lock and changed no lock
+  order. The ThreadSanitizer report behind it was a false positive: the
+  inversion it flagged cannot deadlock, because a thread holding the channels
+  read lock blocks cSchedules::Read() from taking the write half
+
 * Thu Aug 13 2026 Dirk Nehring  <dnehring@gmx.net> - 2.8.2-3
 - Refactor the spec file
 - Themes live in /etc/vdr/themes: stock VDR's path, now that the old

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-03 10:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-03 10:35 [rpms/vdr] rawhide: Update to 2.8.3 (API version 14) Martin Gansser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox