armbox eplayer: fix playing files with subtitles

Signed-off-by: Thilo Graf <dbt@novatux.de>

Conflicts:
	libeplayer3-arm/manager/subtitle.c

additional format fixes, solved conflicts and clean up
This commit is contained in:
max_10
2017-12-30 13:41:06 +01:00
committed by Thilo Graf
parent 5930dca63f
commit 15b4162b58

View File

@@ -33,7 +33,6 @@
#define TRACKWRAP 20 #define TRACKWRAP 20
//#define SAM_WITH_DEBUG
#ifdef SAM_WITH_DEBUG #ifdef SAM_WITH_DEBUG
#define SUBTITLE_MGR_DEBUG #define SUBTITLE_MGR_DEBUG
#else #else
@@ -60,14 +59,12 @@ if (debug_level >= level) printf(x); } while (0)
#define cERR_SUBTITLE_MGR_NO_ERROR 0 #define cERR_SUBTITLE_MGR_NO_ERROR 0
#define cERR_SUBTITLE_MGR_ERROR -1 #define cERR_SUBTITLE_MGR_ERROR -1
static const char FILENAME[] = __FILE__;
/* ***************************** */ /* ***************************** */
/* Types */ /* Types */
/* ***************************** */ /* ***************************** */
/* ***************************** */ /* ***************************** */
/* Varaibles */ /* Variables */
/* ***************************** */ /* ***************************** */
static Track_t *Tracks = NULL; static Track_t *Tracks = NULL;
@@ -84,21 +81,21 @@ static int CurrentTrack = -1; //no as default.
static int ManagerAdd(Context_t *context __attribute__((unused)), Track_t track) static int ManagerAdd(Context_t *context __attribute__((unused)), Track_t track)
{ {
subtitle_mgr_printf(10, "%s::%s %s %s %d\n", __FILE__, __FUNCTION__, track.Name, track.Encoding, track.Id);
subtitle_mgr_printf(10, "%s::%s %s %s %d\n", FILENAME, __FUNCTION__,
track.Name, track.Encoding, track.Id);
if (Tracks == NULL) if (Tracks == NULL)
{ {
Tracks = malloc(sizeof(Track_t) * TRACKWRAP); Tracks = malloc(sizeof(Track_t) * TRACKWRAP);
int i; int i;
for (i = 0; i < TRACKWRAP; i++) for (i = 0; i < TRACKWRAP; i++)
{
Tracks[i].Id = -1; Tracks[i].Id = -1;
} }
}
if (Tracks == NULL) if (Tracks == NULL)
{ {
subtitle_mgr_err("%s:%s malloc failed\n", FILENAME, __FUNCTION__); subtitle_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__);
return cERR_SUBTITLE_MGR_ERROR; return cERR_SUBTITLE_MGR_ERROR;
} }
@@ -119,13 +116,16 @@ static int ManagerAdd(Context_t * context __attribute__((unused)), Track_t track
} }
else else
{ {
subtitle_mgr_err("%s:%s TrackCount out if range %d - %d\n", __FILE__, __FUNCTION__, TrackCount, TRACKWRAP);
subtitle_mgr_err("%s:%s TrackCount out if range %d - %d\n",
FILENAME, __FUNCTION__, TrackCount, TRACKWRAP);
return cERR_SUBTITLE_MGR_ERROR; return cERR_SUBTITLE_MGR_ERROR;
} }
subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); if (TrackCount > 0)
{
// context->playback->isSubtitle = 1;
}
subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
return cERR_SUBTITLE_MGR_NO_ERROR; return cERR_SUBTITLE_MGR_NO_ERROR;
} }
@@ -135,7 +135,7 @@ static char **ManagerList(Context_t * context __attribute__ ((unused)))
char **tracklist = NULL; char **tracklist = NULL;
int i = 0, j = 0; int i = 0, j = 0;
subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks != NULL) if (Tracks != NULL)
{ {
@@ -143,18 +143,20 @@ static char **ManagerList(Context_t * context __attribute__ ((unused)))
if (tracklist == NULL) if (tracklist == NULL)
{ {
subtitle_mgr_err("%s:%s malloc failed\n", FILENAME, subtitle_mgr_err("%s:%s malloc failed\n", __FILE__, __FUNCTION__);
__FUNCTION__);
return NULL; return NULL;
} }
for (i = 0, j = 0; i < TrackCount; i++, j += 2) for (i = 0, j = 0; i < TrackCount; i++, j += 2)
{ {
if (Tracks[i].pending) if (Tracks[i].pending)
{
continue; continue;
}
size_t len = strlen(Tracks[i].Name) + 20; size_t len = strlen(Tracks[i].Name) + 20;
char tmp[len]; char tmp[len];
snprintf(tmp, len, "%d %s\n", Tracks[i].Id, Tracks[i].Name); snprintf(tmp, len, "%d %s", Tracks[i].Id, Tracks[i].Name);
tracklist[j] = strdup(tmp); tracklist[j] = strdup(tmp);
tracklist[j + 1] = strdup(Tracks[i].Encoding); tracklist[j + 1] = strdup(Tracks[i].Encoding);
} }
@@ -162,18 +164,16 @@ static char **ManagerList(Context_t * context __attribute__ ((unused)))
tracklist[j] = NULL; tracklist[j] = NULL;
} }
subtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", FILENAME, subtitle_mgr_printf(10, "%s::%s return %p (%d - %d)\n", __FILE__, __FUNCTION__, tracklist, j, TrackCount);
__FUNCTION__, tracklist, j, TrackCount);
return tracklist; return tracklist;
} }
static int ManagerDel(Context_t *context __attribute__((unused))) static int ManagerDel(Context_t *context __attribute__((unused)))
{ {
int i = 0; int i = 0;
subtitle_mgr_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); subtitle_mgr_printf(10, "%s::%s\n", __FILE__, __FUNCTION__);
if (Tracks != NULL) if (Tracks != NULL)
{ {
@@ -187,16 +187,15 @@ static int ManagerDel(Context_t * context __attribute__((unused)))
} }
else else
{ {
subtitle_mgr_err("%s::%s nothing to delete!\n", FILENAME, subtitle_mgr_err("%s::%s nothing to delete!\n", __FILE__, __FUNCTION__);
__FUNCTION__);
return cERR_SUBTITLE_MGR_ERROR; return cERR_SUBTITLE_MGR_ERROR;
} }
TrackCount = 0; TrackCount = 0;
CurrentTrack = -1; CurrentTrack = -1;
// context->playback->isSubtitle = 0;
subtitle_mgr_printf(10, "%s::%s return no error\n", FILENAME, subtitle_mgr_printf(10, "%s::%s return no error\n", __FILE__, __FUNCTION__);
__FUNCTION__);
return cERR_SUBTITLE_MGR_NO_ERROR; return cERR_SUBTITLE_MGR_NO_ERROR;
} }
@@ -205,8 +204,7 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
{ {
int ret = cERR_SUBTITLE_MGR_NO_ERROR; int ret = cERR_SUBTITLE_MGR_NO_ERROR;
subtitle_mgr_printf(50, "%s::%s %d\n", FILENAME, __FUNCTION__, subtitle_mgr_printf(50, "%s::%s %d\n", __FILE__, __FUNCTION__, command);
command);
switch (command) switch (command)
{ {
@@ -225,25 +223,43 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
case MANAGER_GET: case MANAGER_GET:
{ {
if (TrackCount > 0 && CurrentTrack >= 0) if (TrackCount > 0 && CurrentTrack >= 0)
{
*((int *)argument) = (int)Tracks[CurrentTrack].Id; *((int *)argument) = (int)Tracks[CurrentTrack].Id;
}
else else
{
*((int *)argument) = (int) - 1; *((int *)argument) = (int) - 1;
}
break;
}
case MANAGER_GET_TRACK_DESC:
{
if ((TrackCount > 0) && (CurrentTrack >= 0))
{
TrackDescription_t *track = malloc(sizeof(TrackDescription_t));
*((TrackDescription_t **)argument) = track;
if (track)
{
memset(track, 0, sizeof(TrackDescription_t));
track->Id = Tracks[CurrentTrack].Id;
track->Name = strdup(Tracks[CurrentTrack].Name);
track->Encoding = strdup(Tracks[CurrentTrack].Encoding);
}
}
else
{
*((TrackDescription_t **)argument) = NULL;
}
break; break;
} }
case MANAGER_GET_TRACK: case MANAGER_GET_TRACK:
{ {
//subtitle_mgr_printf(20, "%s::%s MANAGER_GET_TRACK\n", FILENAME, __FUNCTION__);
if ((TrackCount > 0) && (CurrentTrack >= 0)) if ((TrackCount > 0) && (CurrentTrack >= 0))
{ {
subtitle_mgr_printf(120, "return %d, %p\n", CurrentTrack, *((Track_t **)argument) = (Track_t *) &Tracks[CurrentTrack];
&Tracks[CurrentTrack]);
*((Track_t **) argument) =
(Track_t *) & Tracks[CurrentTrack];
} }
else else
{ {
subtitle_mgr_printf(20, "return NULL\n");
*((Track_t **)argument) = NULL; *((Track_t **)argument) = NULL;
} }
break; break;
@@ -251,26 +267,31 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
case MANAGER_GETENCODING: case MANAGER_GETENCODING:
{ {
if (TrackCount > 0 && CurrentTrack >= 0) if (TrackCount > 0 && CurrentTrack >= 0)
*((char **) argument) = {
(char *) strdup(Tracks[CurrentTrack].Encoding); *((char **)argument) = (char *)strdup(Tracks[CurrentTrack].Encoding);
}
else else
{
*((char **)argument) = (char *)strdup(""); *((char **)argument) = (char *)strdup("");
}
break; break;
} }
case MANAGER_GETNAME: case MANAGER_GETNAME:
{ {
if (TrackCount > 0 && CurrentTrack >= 0) if (TrackCount > 0 && CurrentTrack >= 0)
*((char **) argument) = {
(char *) strdup(Tracks[CurrentTrack].Name); *((char **)argument) = (char *)strdup(Tracks[CurrentTrack].Name);
}
else else
{
*((char **)argument) = (char *)strdup(""); *((char **)argument) = (char *)strdup("");
}
break; break;
} }
case MANAGER_SET: case MANAGER_SET:
{ {
int i; int i;
subtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, subtitle_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", __FILE__, __FUNCTION__, *((int *)argument));
__FUNCTION__, *((int *) argument));
if (*((int *)argument) < 0) if (*((int *)argument) < 0)
{ {
@@ -279,15 +300,17 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
} }
for (i = 0; i < TrackCount; i++) for (i = 0; i < TrackCount; i++)
{
if (Tracks[i].Id == *((int *)argument)) if (Tracks[i].Id == *((int *)argument))
{ {
CurrentTrack = i; CurrentTrack = i;
break; break;
} }
}
if (i == TrackCount) if (i == TrackCount)
{ {
subtitle_mgr_err("%s::%s track id %d unknown\n", FILENAME, subtitle_mgr_err("%s::%s track id %d unknown\n", __FILE__, __FUNCTION__, *((int *)argument));
__FUNCTION__, *((int *) argument));
ret = cERR_SUBTITLE_MGR_ERROR; ret = cERR_SUBTITLE_MGR_ERROR;
} }
break; break;
@@ -301,24 +324,22 @@ static int Command(Context_t *context, ManagerCmd_t command, void *argument)
{ {
int i; int i;
for (i = 0; i < TrackCount; i++) for (i = 0; i < TrackCount; i++)
//if (!Tracks[i].is_static) {
Tracks[i].pending = 1; Tracks[i].pending = 1;
}
break; break;
} }
default: default:
subtitle_mgr_err("%s:%s: ConatinerCmd not supported!", FILENAME, subtitle_mgr_err("%s:%s: ContainerCmd not supported!", __FILE__, __FUNCTION__);
__FUNCTION__);
ret = cERR_SUBTITLE_MGR_ERROR; ret = cERR_SUBTITLE_MGR_ERROR;
break; break;
} }
subtitle_mgr_printf(50, "%s:%s: returning %d\n", FILENAME, subtitle_mgr_printf(50, "%s:%s: returning %d\n", __FILE__, __FUNCTION__, ret);
__FUNCTION__, ret);
return ret; return ret;
} }
struct Manager_s SubtitleManager = struct Manager_s SubtitleManager =
{ {
"Subtitle", "Subtitle",