libeplayer3: tracks update is now lock-free

This commit is contained in:
martii
2013-08-16 19:35:07 +02:00
committed by Stefan Seyfried
parent 7645863bfb
commit 545a3208d4
7 changed files with 107 additions and 43 deletions

View File

@@ -65,7 +65,7 @@ static const char FILENAME[] = __FILE__;
/* Varaibles */
/* ***************************** */
static Track_t * Tracks;
static Track_t * Tracks = NULL;
static int TrackCount = 0;
static int CurrentTrack = -1;
@@ -91,6 +91,14 @@ static int ManagerAdd(Context_t *context, Track_t track) {
return cERR_TELETEXT_MGR_ERROR;
}
int i;
for (i = 0; i < TRACKWRAP; i++) {
if (Tracks[i].Id == track.Id) {
Tracks[i].pending = 0;
return cERR_TELETEXT_MGR_NO_ERROR;
}
}
if (TrackCount < TRACKWRAP) {
copyTrack(&Tracks[TrackCount], &track);
TrackCount++;
@@ -124,6 +132,8 @@ static char ** ManagerList(Context_t *context __attribute__((unused))) {
}
for (i = 0, j = 0; i < TrackCount; i++, j+=2) {
if (Tracks[i].pending)
continue;
size_t len = strlen(Tracks[i].Name) + 20;
char tmp[len];
snprintf(tmp, len, "%d %s\n", Tracks[i].Id, Tracks[i].Name);
@@ -236,6 +246,12 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
ret = ManagerDel(context);
break;
}
case MANAGER_INIT_UPDATE: {
int i;
for (i = 0; i < TrackCount; i++)
Tracks[i].pending = 1;
break;
}
default:
teletext_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
ret = cERR_TELETEXT_MGR_ERROR;