mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-28 16:01:22 +02:00
libeplayer3: tracks update is now lock-free
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user