Skip to content

Commit 001d390

Browse files
committed
Merge branch 'video_logging' into 'master'
Migrate videoplayer to OSG logging system See merge request OpenMW/openmw!4408
2 parents bac0018 + 1933403 commit 001d390

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

extern/osg-ffmpeg-videoplayer/videoplayer.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <iostream>
44

5+
#include <osg/Notify>
56
#include <osg/Texture2D>
67

78
#include "audiofactory.hpp"
@@ -45,7 +46,7 @@ void VideoPlayer::playVideo(std::unique_ptr<std::istream>&& inputstream, const s
4546
}
4647
}
4748
catch(std::exception& e) {
48-
std::cerr<< "Failed to play video: "<<e.what() <<std::endl;
49+
OSG_FATAL << "Failed to play video: " << e.what() << std::endl;
4950
close();
5051
}
5152
}

extern/osg-ffmpeg-videoplayer/videostate.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ int VideoPicture::set_dimensions(int w, int h) {
205205
std::unique_ptr<AVFrame, VideoPicture::AVFrameDeleter> frame{
206206
av_frame_alloc()};
207207
if (frame == nullptr) {
208-
std::cerr << "av_frame_alloc failed" << std::endl;
208+
OSG_FATAL << "av_frame_alloc failed" << std::endl;
209209
return -1;
210210
}
211211

@@ -215,7 +215,7 @@ int VideoPicture::set_dimensions(int w, int h) {
215215
frame->height = h;
216216
if (av_image_alloc(frame->data, frame->linesize, frame->width, frame->height,
217217
kPixFmt, 1) < 0) {
218-
std::cerr << "av_image_alloc failed" << std::endl;
218+
OSG_FATAL << "av_image_alloc failed" << std::endl;
219219
return -1;
220220
}
221221

@@ -442,7 +442,7 @@ class VideoThread
442442
}
443443
catch(std::exception& e)
444444
{
445-
std::cerr << "An error occurred playing the video: " << e.what () << std::endl;
445+
OSG_FATAL << "An error occurred playing the video: " << e.what() << std::endl;
446446
}
447447
})
448448
{
@@ -567,9 +567,9 @@ class ParseThread
567567
{
568568
// In the FFMpeg 4.0 a "filename" field was replaced by "url"
569569
#if LIBAVCODEC_VERSION_INT < 3805796
570-
std::cerr << "Error seeking " << self->format_ctx->filename << std::endl;
570+
OSG_FATAL << "Error seeking " << self->format_ctx->filename << std::endl;
571571
#else
572-
std::cerr << "Error seeking " << self->format_ctx->url << std::endl;
572+
OSG_FATAL << "Error seeking " << self->format_ctx->url << std::endl;
573573
#endif
574574
}
575575
else
@@ -635,7 +635,7 @@ class ParseThread
635635
}
636636
}
637637
catch(std::exception& e) {
638-
std::cerr << "An error occurred playing the video: " << e.what () << std::endl;
638+
OSG_FATAL << "An error occurred playing the video: " << e.what() << std::endl;
639639
}
640640

641641
self->mQuit = true;
@@ -689,7 +689,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
689689

690690
if (!mAudioFactory)
691691
{
692-
std::cerr << "No audio factory registered, can not play audio stream" << std::endl;
692+
OSG_FATAL << "No audio factory registered, can not play audio stream" << std::endl;
693693
avcodec_free_context(&this->audio_ctx);
694694
this->audio_st = nullptr;
695695
return -1;
@@ -698,7 +698,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
698698
mAudioDecoder = mAudioFactory->createDecoder(this);
699699
if (!mAudioDecoder)
700700
{
701-
std::cerr << "Failed to create audio decoder, can not play audio stream" << std::endl;
701+
OSG_FATAL << "Failed to create audio decoder, can not play audio stream" << std::endl;
702702
avcodec_free_context(&this->audio_ctx);
703703
this->audio_st = nullptr;
704704
return -1;

0 commit comments

Comments
 (0)