mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 07:23:11 +02:00
libeplayer3: tracks update is now lock-free
This commit is contained in:
@@ -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_DVBSUBTITLE_MGR_ERROR;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < TRACKWRAP; i++) {
|
||||
if (Tracks[i].Id == track.Id) {
|
||||
Tracks[i].pending = 0;
|
||||
return cERR_DVBSUBTITLE_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:
|
||||
dvbsubtitle_mgr_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command);
|
||||
ret = cERR_DVBSUBTITLE_MGR_ERROR;
|
||||
|
Reference in New Issue
Block a user