mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
Modified handling channel names with source to make it thread safe
This commit is contained in:
parent
18c9cef1ea
commit
8bd0437497
@ -3598,6 +3598,7 @@ Stefan Herdler <herdler@gmx.de>
|
|||||||
for reporting the index file of a recording not being regenerated in case it is
|
for reporting the index file of a recording not being regenerated in case it is
|
||||||
present, but empty
|
present, but empty
|
||||||
for reporting a missing check for self-assignment in the move assignment operator
|
for reporting a missing check for self-assignment in the move assignment operator
|
||||||
|
for modifying handling channel names with source to make it thread safe
|
||||||
|
|
||||||
Tobias Faust <tobias.faust@gmx.de>
|
Tobias Faust <tobias.faust@gmx.de>
|
||||||
for the original "jumpingseconds" patch
|
for the original "jumpingseconds" patch
|
||||||
|
4
HISTORY
4
HISTORY
@ -9887,8 +9887,10 @@ Video Disk Recorder Revision History
|
|||||||
- Fixed possible duplicate component entries in the info of an ongoing recording
|
- Fixed possible duplicate component entries in the info of an ongoing recording
|
||||||
(reported by Christoph Haubrich).
|
(reported by Christoph Haubrich).
|
||||||
|
|
||||||
2024-03-01:
|
2024-03-02:
|
||||||
|
|
||||||
- Fixed the move assignment operator to check for self-assignment (suggested by
|
- Fixed the move assignment operator to check for self-assignment (suggested by
|
||||||
Stefan Herdler).
|
Stefan Herdler).
|
||||||
- Added missing initialization of cChannel::nameSourceMode (thanks to Winfried Köhler).
|
- Added missing initialization of cChannel::nameSourceMode (thanks to Winfried Köhler).
|
||||||
|
- Modified handling channel names with source to make it thread safe (thanks to
|
||||||
|
Stefan Herdler).
|
||||||
|
56
channels.c
56
channels.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: channels.c 5.2 2024/03/01 14:31:49 kls Exp $
|
* $Id: channels.c 5.3 2024/03/02 16:21:16 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
@ -60,7 +60,6 @@ cChannel::cChannel(void)
|
|||||||
provider = strdup("");
|
provider = strdup("");
|
||||||
portalName = strdup("");
|
portalName = strdup("");
|
||||||
memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__);
|
memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__);
|
||||||
nameSourceMode = 0;
|
|
||||||
parameters = "";
|
parameters = "";
|
||||||
modification = CHANNELMOD_NONE;
|
modification = CHANNELMOD_NONE;
|
||||||
seen = 0;
|
seen = 0;
|
||||||
@ -98,23 +97,32 @@ cChannel& cChannel::operator= (const cChannel &Channel)
|
|||||||
provider = strcpyrealloc(provider, Channel.provider);
|
provider = strcpyrealloc(provider, Channel.provider);
|
||||||
portalName = strcpyrealloc(portalName, Channel.portalName);
|
portalName = strcpyrealloc(portalName, Channel.portalName);
|
||||||
memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__);
|
memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__);
|
||||||
nameSource = NULL; // these will be recalculated automatically
|
UpdateNameSource();
|
||||||
nameSourceMode = 0;
|
|
||||||
shortNameSource = NULL;
|
|
||||||
parameters = Channel.parameters;
|
parameters = Channel.parameters;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cChannel::UpdateNameSource(void)
|
||||||
|
{
|
||||||
|
if (Setup.ShowChannelNamesWithSource == 0) {
|
||||||
|
nameSource = NULL;
|
||||||
|
shortNameSource = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Setup.ShowChannelNamesWithSource == 1)
|
||||||
|
nameSource = cString::sprintf("%s (%c)", name, cSource::ToChar(source));
|
||||||
|
else
|
||||||
|
nameSource = cString::sprintf("%s (%s)", name, *cSource::ToString(source));
|
||||||
|
|
||||||
|
shortNameSource = cString::sprintf("%s (%c)", shortName, cSource::ToChar(source));
|
||||||
|
}
|
||||||
|
|
||||||
const char *cChannel::Name(void) const
|
const char *cChannel::Name(void) const
|
||||||
{
|
{
|
||||||
if (Setup.ShowChannelNamesWithSource && !groupSep) {
|
if (Setup.ShowChannelNamesWithSource && !groupSep) {
|
||||||
if (isempty(nameSource) || nameSourceMode != Setup.ShowChannelNamesWithSource) {
|
if (!isempty(nameSource))
|
||||||
if (Setup.ShowChannelNamesWithSource == 1)
|
return nameSource;
|
||||||
nameSource = cString::sprintf("%s (%c)", name, cSource::ToChar(source));
|
|
||||||
else
|
|
||||||
nameSource = cString::sprintf("%s (%s)", name, *cSource::ToString(source));
|
|
||||||
}
|
|
||||||
return nameSource;
|
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -124,9 +132,8 @@ const char *cChannel::ShortName(bool OrName) const
|
|||||||
if (OrName && isempty(shortName))
|
if (OrName && isempty(shortName))
|
||||||
return Name();
|
return Name();
|
||||||
if (Setup.ShowChannelNamesWithSource && !groupSep) {
|
if (Setup.ShowChannelNamesWithSource && !groupSep) {
|
||||||
if (isempty(shortNameSource))
|
if (!isempty(shortNameSource))
|
||||||
shortNameSource = cString::sprintf("%s (%c)", shortName, cSource::ToChar(source));
|
return shortNameSource;
|
||||||
return shortNameSource;
|
|
||||||
}
|
}
|
||||||
return shortName;
|
return shortName;
|
||||||
}
|
}
|
||||||
@ -204,9 +211,7 @@ bool cChannel::SetTransponderData(int Source, int Frequency, int Srate, const ch
|
|||||||
srate = Srate;
|
srate = Srate;
|
||||||
parameters = Parameters;
|
parameters = Parameters;
|
||||||
schedule = NULL;
|
schedule = NULL;
|
||||||
nameSource = NULL;
|
UpdateNameSource();
|
||||||
nameSourceMode = 0;
|
|
||||||
shortNameSource = NULL;
|
|
||||||
if (Number() && !Quiet) {
|
if (Number() && !Quiet) {
|
||||||
dsyslog("changing transponder data of channel %d (%s) from %s to %s", Number(), name, *OldTransponderData, *TransponderDataToString());
|
dsyslog("changing transponder data of channel %d (%s) from %s to %s", Number(), name, *OldTransponderData, *TransponderDataToString());
|
||||||
modification |= CHANNELMOD_TRANSP;
|
modification |= CHANNELMOD_TRANSP;
|
||||||
@ -271,15 +276,12 @@ bool cChannel::SetName(const char *Name, const char *ShortName, const char *Prov
|
|||||||
dsyslog("changing name of channel %d from '%s,%s;%s' to '%s,%s;%s'", Number(), name, shortName, provider, Name, ShortName, Provider);
|
dsyslog("changing name of channel %d from '%s,%s;%s' to '%s,%s;%s'", Number(), name, shortName, provider, Name, ShortName, Provider);
|
||||||
modification |= CHANNELMOD_NAME;
|
modification |= CHANNELMOD_NAME;
|
||||||
}
|
}
|
||||||
if (nn) {
|
if (nn)
|
||||||
name = strcpyrealloc(name, Name);
|
name = strcpyrealloc(name, Name);
|
||||||
nameSource = NULL;
|
if (ns)
|
||||||
nameSourceMode = 0;
|
|
||||||
}
|
|
||||||
if (ns) {
|
|
||||||
shortName = strcpyrealloc(shortName, ShortName);
|
shortName = strcpyrealloc(shortName, ShortName);
|
||||||
shortNameSource = NULL;
|
if (nn || ns)
|
||||||
}
|
UpdateNameSource();
|
||||||
if (np)
|
if (np)
|
||||||
provider = strcpyrealloc(provider, Provider);
|
provider = strcpyrealloc(provider, Provider);
|
||||||
return true;
|
return true;
|
||||||
@ -805,9 +807,7 @@ bool cChannel::Parse(const char *s)
|
|||||||
free(tpidbuf);
|
free(tpidbuf);
|
||||||
free(caidbuf);
|
free(caidbuf);
|
||||||
free(namebuf);
|
free(namebuf);
|
||||||
nameSource = NULL;
|
UpdateNameSource();
|
||||||
nameSourceMode = 0;
|
|
||||||
shortNameSource = NULL;
|
|
||||||
if (!GetChannelID().Valid()) {
|
if (!GetChannelID().Valid()) {
|
||||||
esyslog("ERROR: channel data results in invalid ID!");
|
esyslog("ERROR: channel data results in invalid ID!");
|
||||||
return false;
|
return false;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: channels.h 5.2 2021/05/21 09:38:34 kls Exp $
|
* $Id: channels.h 5.3 2024/03/02 16:21:16 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __CHANNELS_H
|
#ifndef __CHANNELS_H
|
||||||
@ -87,6 +87,7 @@ class cChannels;
|
|||||||
class cChannel : public cListObject {
|
class cChannel : public cListObject {
|
||||||
friend class cSchedules;
|
friend class cSchedules;
|
||||||
friend class cMenuEditChannel;
|
friend class cMenuEditChannel;
|
||||||
|
friend class cMenuSetupMisc;
|
||||||
friend class cDvbSourceParam;
|
friend class cDvbSourceParam;
|
||||||
private:
|
private:
|
||||||
static cString ToText(const cChannel *Channel);
|
static cString ToText(const cChannel *Channel);
|
||||||
@ -123,9 +124,8 @@ private:
|
|||||||
int number; // Sequence number assigned on load
|
int number; // Sequence number assigned on load
|
||||||
bool groupSep;
|
bool groupSep;
|
||||||
int __EndData__;
|
int __EndData__;
|
||||||
mutable cString nameSource;
|
cString nameSource;
|
||||||
mutable int nameSourceMode;
|
cString shortNameSource;
|
||||||
mutable cString shortNameSource;
|
|
||||||
cString parameters;
|
cString parameters;
|
||||||
mutable int modification;
|
mutable int modification;
|
||||||
time_t seen; // When this channel was last seen in the SDT of its transponder
|
time_t seen; // When this channel was last seen in the SDT of its transponder
|
||||||
@ -133,6 +133,7 @@ private:
|
|||||||
cLinkChannels *linkChannels;
|
cLinkChannels *linkChannels;
|
||||||
cChannel *refChannel;
|
cChannel *refChannel;
|
||||||
cString TransponderDataToString(void) const;
|
cString TransponderDataToString(void) const;
|
||||||
|
void UpdateNameSource(void);
|
||||||
public:
|
public:
|
||||||
cChannel(void);
|
cChannel(void);
|
||||||
cChannel(const cChannel &Channel);
|
cChannel(const cChannel &Channel);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user