1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-25 18:15:00 +00:00

Migrate videoplayer to OSG logging system

This commit is contained in:
Andrei Kortunov 2024-10-18 10:20:22 +04:00
parent bac0018a09
commit 1933403400
2 changed files with 10 additions and 9 deletions

View File

@ -2,6 +2,7 @@
#include <iostream>
#include <osg/Notify>
#include <osg/Texture2D>
#include "audiofactory.hpp"
@ -45,7 +46,7 @@ void VideoPlayer::playVideo(std::unique_ptr<std::istream>&& inputstream, const s
}
}
catch(std::exception& e) {
std::cerr<< "Failed to play video: "<<e.what() <<std::endl;
OSG_FATAL << "Failed to play video: " << e.what() << std::endl;
close();
}
}

View File

@ -205,7 +205,7 @@ int VideoPicture::set_dimensions(int w, int h) {
std::unique_ptr<AVFrame, VideoPicture::AVFrameDeleter> frame{
av_frame_alloc()};
if (frame == nullptr) {
std::cerr << "av_frame_alloc failed" << std::endl;
OSG_FATAL << "av_frame_alloc failed" << std::endl;
return -1;
}
@ -215,7 +215,7 @@ int VideoPicture::set_dimensions(int w, int h) {
frame->height = h;
if (av_image_alloc(frame->data, frame->linesize, frame->width, frame->height,
kPixFmt, 1) < 0) {
std::cerr << "av_image_alloc failed" << std::endl;
OSG_FATAL << "av_image_alloc failed" << std::endl;
return -1;
}
@ -442,7 +442,7 @@ public:
}
catch(std::exception& e)
{
std::cerr << "An error occurred playing the video: " << e.what () << std::endl;
OSG_FATAL << "An error occurred playing the video: " << e.what() << std::endl;
}
})
{
@ -567,9 +567,9 @@ public:
{
// In the FFMpeg 4.0 a "filename" field was replaced by "url"
#if LIBAVCODEC_VERSION_INT < 3805796
std::cerr << "Error seeking " << self->format_ctx->filename << std::endl;
OSG_FATAL << "Error seeking " << self->format_ctx->filename << std::endl;
#else
std::cerr << "Error seeking " << self->format_ctx->url << std::endl;
OSG_FATAL << "Error seeking " << self->format_ctx->url << std::endl;
#endif
}
else
@ -635,7 +635,7 @@ public:
}
}
catch(std::exception& e) {
std::cerr << "An error occurred playing the video: " << e.what () << std::endl;
OSG_FATAL << "An error occurred playing the video: " << e.what() << std::endl;
}
self->mQuit = true;
@ -689,7 +689,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
if (!mAudioFactory)
{
std::cerr << "No audio factory registered, can not play audio stream" << std::endl;
OSG_FATAL << "No audio factory registered, can not play audio stream" << std::endl;
avcodec_free_context(&this->audio_ctx);
this->audio_st = nullptr;
return -1;
@ -698,7 +698,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
mAudioDecoder = mAudioFactory->createDecoder(this);
if (!mAudioDecoder)
{
std::cerr << "Failed to create audio decoder, can not play audio stream" << std::endl;
OSG_FATAL << "Failed to create audio decoder, can not play audio stream" << std::endl;
avcodec_free_context(&this->audio_ctx);
this->audio_st = nullptr;
return -1;