Catch exceptions in VideoThread

pull/593/head
Evil Eye 4 years ago
parent 2042a66cf3
commit de37ca8e2c

@ -121,6 +121,7 @@
Bug #5975: NIF controllers from sheath meshes are used Bug #5975: NIF controllers from sheath meshes are used
Bug #5991: Activate should always be allowed for inventory items Bug #5991: Activate should always be allowed for inventory items
Bug #5995: NiUVController doesn't calculate the UV offset properly Bug #5995: NiUVController doesn't calculate the UV offset properly
Bug #6007: Crash when ending cutscene is playing
Bug #6016: Greeting interrupts Fargoth's sneak-walk Bug #6016: Greeting interrupts Fargoth's sneak-walk
Feature #390: 3rd person look "over the shoulder" Feature #390: 3rd person look "over the shoulder"
Feature #832: OpenMW-CS: Handle deleted references Feature #832: OpenMW-CS: Handle deleted references

@ -409,43 +409,50 @@ public:
pFrame = av_frame_alloc(); pFrame = av_frame_alloc();
while(self->videoq.get(packet, self) >= 0) try
{ {
if(packet->data == flush_pkt.data) while(self->videoq.get(packet, self) >= 0)
{ {
avcodec_flush_buffers(self->video_ctx); if(packet->data == flush_pkt.data)
{
avcodec_flush_buffers(self->video_ctx);
self->pictq_mutex.lock(); self->pictq_mutex.lock();
self->pictq_size = 0; self->pictq_size = 0;
self->pictq_rindex = 0; self->pictq_rindex = 0;
self->pictq_windex = 0; self->pictq_windex = 0;
self->pictq_mutex.unlock(); self->pictq_mutex.unlock();
self->frame_last_pts = packet->pts * av_q2d((*self->video_st)->time_base); self->frame_last_pts = packet->pts * av_q2d((*self->video_st)->time_base);
continue; continue;
} }
// Decode video frame // Decode video frame
int ret = avcodec_send_packet(self->video_ctx, packet); int ret = avcodec_send_packet(self->video_ctx, packet);
// EAGAIN is not expected // EAGAIN is not expected
if (ret < 0) if (ret < 0)
throw std::runtime_error("Error decoding video frame"); throw std::runtime_error("Error decoding video frame");
while (!ret) while (!ret)
{
ret = avcodec_receive_frame(self->video_ctx, pFrame);
if (!ret)
{ {
double pts = pFrame->best_effort_timestamp; ret = avcodec_receive_frame(self->video_ctx, pFrame);
pts *= av_q2d((*self->video_st)->time_base); if (!ret)
{
double pts = pFrame->best_effort_timestamp;
pts *= av_q2d((*self->video_st)->time_base);
pts = self->synchronize_video(pFrame, pts); pts = self->synchronize_video(pFrame, pts);
if(self->queue_picture(pFrame, pts) < 0) if(self->queue_picture(pFrame, pts) < 0)
break; break;
}
} }
} }
} }
catch(std::exception& e)
{
std::cerr << "An error occurred playing the video: " << e.what () << std::endl;
}
av_packet_unref(packet); av_packet_unref(packet);

Loading…
Cancel
Save