libeplayer3: tracks update is now lock-free

This commit is contained in:
martii
2013-08-16 19:35:07 +02:00
parent d1a2ceaa67
commit 370efa3852
7 changed files with 107 additions and 43 deletions

View File

@@ -64,7 +64,7 @@ static const char FILENAME[] = __FILE__;
/* Varaibles */
/* ***************************** */
static Track_t * Tracks;
static Track_t * Tracks = NULL;
static int TrackCount = 0;
static int CurrentTrack = -1; //no as default.
@@ -90,6 +90,14 @@ static int ManagerAdd(Context_t *context, Track_t track) {
return cERR_SUBTITLE_MGR_ERROR;
}
int i;
for (i = 0; i < TRACKWRAP; i++) {
if (Tracks[i].Id == track.Id) {
Tracks[i].pending = 0;
return cERR_SUBTITLE_MGR_NO_ERROR;
}
}
if (TrackCount < TRACKWRAP) {
copyTrack(&Tracks[TrackCount], &track);
TrackCount++;
@@ -123,6 +131,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);
@@ -238,6 +248,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:
subtitle_mgr_err("%s:%s: ConatinerCmd not supported!", FILENAME, __FUNCTION__);
ret = cERR_SUBTITLE_MGR_ERROR;