m_videoSink->setRhi(nullptr); // https://bugreports.qt.io/browse/QTBUG-97789的意思
时间: 2023-07-18 15:48:51 浏览: 138
`m_videoSink->setRhi(nullptr)` 的作用是将 Qt Multimedia 模块中的 Render Hardware Interface (RHI) 对象设置为 `nullptr`,以解决 QTBUG-97789 这个已知问题。这个问题的描述是:在 Android 平台上,当应用程序启动时,Qt Multimedia 模块会自动创建一个 RHI 对象,该对象与 Android 平台上的 Surface 对象关联,用于将视频帧渲染到屏幕上。但是,在某些情况下,当应用程序在后台运行或被销毁后重新启动时,这个 RHI 对象没有被正确地释放,导致应用程序崩溃。为了解决这个问题,可以在应用程序启动时将 RHI 对象设置为 `nullptr`,以确保每次重新创建一个新的 RHI 对象。
相关问题
Setting pipeline to PAUSED ... Pipeline is PREROLLING ... WARNING: from element /GstPipeline:pipeline0/GstAutoAudioSink:autoaudiosink0: Could not open audio device for playback. Additional debug info: gstalsasink.c(865): gst_alsasink_open (): /GstAlsaSink:autoaudiosink0-actual-sink-alsa: Playback open error on device 'default': Invalid argument WARNING: from element /GstPipeline:pipeline0/GstQTDemux:demux: Delayed linking failed. Additional debug info: ./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstQTDemux:demux: failed delayed linking pad video_0 of GstQTDemux named demux to some pad of GstQueue named queue0 WARNING: from element /GstPipeline:pipeline0/GstQTDemux:demux: Delayed linking failed. Additional debug info: ./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstQTDemux:demux: failed delayed linking pad audio_0 of GstQTDemux named demux to some pad of GstQueue named queue1 ERROR: from element /GstPipeline:pipeline0/GstQTDemux:demux: Internal data stream error. Additional debug info: qtdemux.c(6073): gst_qtdemux_loop (): /GstPipeline:pipeline0/GstQTDemux:demux: streaming stopped, reason not-linked (-1) ERROR: pipeline doesn't want to preroll. Setting pipeline to NULL ... Freeing pipeline ...
根据您的提示信息,播放器无法打开音频设备进行播放。要解决此问题,您可以尝试更改播放器使用的音频设备。
```
gst-launch-1.0 filesrc location=/path/to/your/video.mp4 ! qtdemux name=demux \
demux.video_0 ! queue ! mpegvideoparse ! decodebin ! videoconvert ! autovideosink \
demux.audio_0 ! queue ! mpegaudioparse ! decodebin ! audioconvert ! alsasink device=hw:0,0
```
在此命令中,我们使用 `alsasink` 元素将音频数据发送到 Linux 系统上的 ALSA 音频驱动程序。`device=hw:0,0` 参数指定使用硬件设备 `hw:0,0` 进行播放。如果您的系统上有多个音频设备,请根据实际情况更改设备名称。
#ifndef MYSPDLOG_H #define MYSPDLOG_H #include <fstream> #include <iostream> #define SPDLOG_HEADER_ONLY #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG #include "spdlog/spdlog.h" #include "spdlog/logger.h" #include "spdlog/sinks/basic_file_sink.h" #include "spdlog/sinks/rotating_file_sink.h" #include "spdlog/sinks/stdout_color_sinks.h" #include "spdlog/sinks/daily_file_sink.h" class MySpdlog { public: static MySpdlog*getInstace() { static MySpdlog MySpdlogStatic; return &MySpdlogStatic; } int init() { std::string formatStr="%Y-%m-%dT%H:%M:%S.%e[%l][%s:%#][%!]%v"; // auto myLogger1 = std::make_shared<spdlog::sinks::rotating_file_sink_mt>("spdlog", "logs/myspdlog.log", 1024 * 1024 * 10, 10); // auto myLogger1 = std::make_shared<spdlog::sinks::daily_file_sink>("spdlog", "logs/log.txt", 0, 0); myLogger1 = spdlog::daily_logger_mt("spdlog", "logs/log.txt", 0, 0); // myLogger1 = spdlog::rotating_logger_mt("spdlog", "logs/myspdlog.log", 1024 * 1024 * 10, 10); spdlog::set_default_logger(myLogger1); myLogger1->set_level(spdlog::level::debug); myLogger1->set_pattern(formatStr); myLogger2 = spdlog::stdout_color_mt("baseLogger2"); spdlog::set_default_logger(myLogger2); myLogger2->set_level(spdlog::level::debug); myLogger2->set_pattern(formatStr); return 0; } void uninit() { } static std::shared_ptr<spdlog::logger> myLogger1; static std::shared_ptr<spdlog::logger> myLogger2; private: MySpdlog() {} ~MySpdlog() {} }; #define SPLOG_INIT() MySpdlog::getInstace()->init() #define SPLOG_UNINIT() MySpdlog::getInstace()->uninit() #define SPLOG_DEBUG(...) do {SPDLOG_LOGGER_DEBUG(MySpdlog::getInstace()->myLogger1, __VA_ARGS__);\ SPDLOG_LOGGER_DEBUG(MySpdlog::getInstace()->myLogger2, __VA_ARGS__);}while(0) #define SPLOG_INFO(...) do {SPDLOG_LOGGER_INFO(MySpdlog::getInstace()->myLogger1, __VA_ARGS__);\ SPDLOG_LOGGER_INFO(MySpdlog::getInstace()->myLogger2, __VA_ARGS__); }while(0) #define SPLOG_ERROR(...) do {SPDLOG_LOGGER_ERROR(MySpdlog::getInstace()->myLogger1, __VA_ARGS__);\ SPDLOG_LOGGER_ERROR(MySpdlog::getInstace()->myLogger2, __VA_ARGS__);}while(0) #define SPDLOG_CLRAR(a) do{std::fstream fout((a),std::ios::out|std::ios::trunc);fout.close();}while(0); #endif // MYSPDLOG_H这样写完打印的log不是实时打印的
可以尝试使用flush_on()函数,将日志输出立即刷新到文件中,达到实时打印的效果。例如,在MySpdlog::init()函数中加入如下代码:
myLogger1->flush_on(spdlog::level::debug);
myLogger2->flush_on(spdlog::level::debug);
这样,在SPLOG_DEBUG()宏中打印日志时,日志将会立即刷新到文件中。另外,也可以使用set_pattern()函数来设置日志输出的格式。
阅读全文