mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
Do not wait in the FFMPEG thread.
Signed-off-by: max_10 <max_10@gmx.de>
This commit is contained in:
@@ -182,7 +182,7 @@ static void releaseMutex(const char *filename __attribute__((unused)), const con
|
||||
|
||||
typedef int32_t (* Write_FN)(Context_t *context, void *);
|
||||
|
||||
static int32_t Write(Write_FN WriteFun, Context_t *context, void *privateData)
|
||||
static int32_t Write(Write_FN WriteFun, Context_t *context, void *privateData, int64_t pts __attribute__((unused)))
|
||||
{
|
||||
/* Because Write is blocking we will release mutex which protect
|
||||
* avformat structures, during write time
|
||||
@@ -485,6 +485,10 @@ static int64_t calcPts(uint32_t avContextIdx, AVStream *stream, int64_t pts)
|
||||
{
|
||||
pts = INVALID_PTS_VALUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pts &= 0x01FFFFFFFF; // PES header can handle only 33 bit PTS
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
|
||||
@@ -571,6 +575,14 @@ static void FFMPEGThread(Context_t *context)
|
||||
int8_t isWaitingForFinish = 0;
|
||||
while (context && context->playback && context->playback->isPlaying)
|
||||
{
|
||||
/* When user press PAUSE we call pause on AUDIO and VIDEO decoders,
|
||||
* we will not wait here because we can still fill
|
||||
* DVB drivers buffers at PAUSE time
|
||||
*
|
||||
* In the future we can add buffering queue before injection in to
|
||||
* AUDIO, VIDEO decoders, so we can not wait here
|
||||
*/
|
||||
#ifdef __sh__
|
||||
//IF MOVIE IS PAUSED, WAIT
|
||||
if (context->playback->isPaused)
|
||||
{
|
||||
@@ -579,6 +591,7 @@ static void FFMPEGThread(Context_t *context)
|
||||
usleep(10000);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (context->playback->isSeeking)
|
||||
{
|
||||
ffmpeg_printf(10, "seeking\n");
|
||||
@@ -835,7 +848,7 @@ static void FFMPEGThread(Context_t *context)
|
||||
{
|
||||
avOut.infoFlags = 1; // TS container
|
||||
}
|
||||
if (Write(context->output->video->Write, context, &avOut) < 0)
|
||||
if (Write(context->output->video->Write, context, &avOut, pts) < 0)
|
||||
{
|
||||
ffmpeg_err("writing data to video device failed\n");
|
||||
}
|
||||
@@ -903,7 +916,7 @@ static void FFMPEGThread(Context_t *context)
|
||||
avOut.width = 0;
|
||||
avOut.height = 0;
|
||||
avOut.type = "audio";
|
||||
if (Write(context->output->audio->Write, context, &avOut) < 0)
|
||||
if (Write(context->output->audio->Write, context, &avOut, pts) < 0)
|
||||
{
|
||||
ffmpeg_err("(raw pcm) writing data to audio device failed\n");
|
||||
}
|
||||
@@ -1079,7 +1092,7 @@ static void FFMPEGThread(Context_t *context)
|
||||
avOut.width = 0;
|
||||
avOut.height = 0;
|
||||
avOut.type = "audio";
|
||||
if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut) < 0)
|
||||
if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut, pts) < 0)
|
||||
{
|
||||
ffmpeg_err("writing data to audio device failed\n");
|
||||
}
|
||||
@@ -1100,7 +1113,7 @@ static void FFMPEGThread(Context_t *context)
|
||||
avOut.width = 0;
|
||||
avOut.height = 0;
|
||||
avOut.type = "audio";
|
||||
if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut) < 0)
|
||||
if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut, pts) < 0)
|
||||
{
|
||||
ffmpeg_err("(aac) writing data to audio device failed\n");
|
||||
}
|
||||
@@ -1117,7 +1130,7 @@ static void FFMPEGThread(Context_t *context)
|
||||
avOut.width = 0;
|
||||
avOut.height = 0;
|
||||
avOut.type = "audio";
|
||||
if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut) < 0)
|
||||
if (!context->playback->BackWard && Write(context->output->audio->Write, context, &avOut, pts) < 0)
|
||||
{
|
||||
ffmpeg_err("writing data to audio device failed\n");
|
||||
}
|
||||
@@ -1146,7 +1159,7 @@ static void FFMPEGThread(Context_t *context)
|
||||
subOut.data = (uint8_t *)packet.data;
|
||||
subOut.pts = pts;
|
||||
subOut.durationMS = duration;
|
||||
if (Write(context->output->subtitle->Write, context, &subOut) < 0)
|
||||
if (Write(context->output->subtitle->Write, context, &subOut, pts) < 0)
|
||||
{
|
||||
ffmpeg_err("writing data to teletext fifo failed\n");
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ static int flv2mpeg4_context_write_packet_cb(void *usr_data, int keyframe, int p
|
||||
avOut.width = ctx->track->width;
|
||||
avOut.height = ctx->track->height;
|
||||
avOut.type = "video";
|
||||
if (Write(ctx->out_ctx->output->video->Write, ctx->out_ctx, &avOut) < 0)
|
||||
if (Write(ctx->out_ctx->output->video->Write, ctx->out_ctx, &avOut, avOut.pts) < 0)
|
||||
{
|
||||
ffmpeg_err("writing data to video device failed\n");
|
||||
}
|
||||
|
@@ -107,7 +107,7 @@ static void mpeg4p2_write(Context_t *ctx, Track_t *track, int avContextIdx, int6
|
||||
avOut.width = track->width;
|
||||
avOut.height = track->height;
|
||||
avOut.type = "video";
|
||||
if (Write(ctx->output->video->Write, ctx, &avOut) < 0)
|
||||
if (Write(ctx->output->video->Write, ctx, &avOut, avOut.pts) < 0)
|
||||
{
|
||||
ffmpeg_err("writing data to video device failed\n");
|
||||
}
|
||||
|
@@ -635,7 +635,7 @@ int main(int argc, char *argv[])
|
||||
memset(argvBuff, '\0', sizeof(argvBuff));
|
||||
int commandRetVal = -1;
|
||||
/* inform client that we can handle additional commands */
|
||||
fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 39);
|
||||
fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 40);
|
||||
if (0 != ParseParams(argc, argv, file, audioFile, &audioTrackIdx, &subtitleTrackIdx))
|
||||
{
|
||||
printf("Usage: exteplayer3 filePath [-u user-agent] [-c cookies] [-h headers] [-p prio] [-a] [-d] [-w] [-l] [-s] [-i] [-t audioTrackId] [-9 subtitleTrackId] [-x separateAudioUri] plabackUri\n");
|
||||
@@ -922,7 +922,21 @@ int main(int argc, char *argv[])
|
||||
commandRetVal = g_player->playback->Command(g_player, PLAYBACK_PTS, &pts);
|
||||
if (0 == commandRetVal)
|
||||
{
|
||||
fprintf(stderr, "{\"J\":{\"ms\":%lld}}\n", pts / 90);
|
||||
int64_t lastPts = 0;
|
||||
commandRetVal = 1;
|
||||
if (g_player->container && g_player->container->selectedContainer)
|
||||
{
|
||||
commandRetVal = g_player->container->selectedContainer->Command((Context_t*)g_player->container, CONTAINER_LAST_PTS, &lastPts);
|
||||
}
|
||||
|
||||
if (0 == commandRetVal && lastPts != INVALID_PTS_VALUE)
|
||||
{
|
||||
fprintf(stderr, "{\"J\":{\"ms\":%lld,\"lms\":%lld}}\n", pts / 90, lastPts / 90);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "{\"J\":{\"ms\":%lld}}\n", pts / 90);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user