Skip to content

Commit

Permalink
fix random crash when exit with active output.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorayuki committed May 17, 2020
1 parent f89efca commit c46cd6d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(obs-multi-rtmp VERSION 0.2.3.0)
project(obs-multi-rtmp VERSION 0.2.3.1)

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

Expand Down
14 changes: 5 additions & 9 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
# [See Readme](./docs)
# [See Readme](https://sorayuki.github.io/obs-multi-rtmp)


# 声明

近日发现百度贴吧有个叫 maggot 的用户在售卖此插件。
近日发现百度贴吧有个叫 maggot 的用户在售卖此插件。咸鱼上也有,没得救了。

本插件免费使用,作者不收取费用。

对此侵权行为已经投诉贴吧
举报之后百度贴吧找我要软件著作权证明,累不爱


# Announce

This plugin is provided without fee.

Recently an Baidu Tieba account 'maggot' is selling this plugin.

I have reported it.
Recently an Baidu Tieba account 'maggot' is selling this plugin. Don't buy it.


# お知らせ

このプラグインは無料ソフトです。

最近百度Tiebaで有料でこのソフトを提供する人があります。

もう通報しました。
最近百度Tiebaで有料でこのソフトを提供する人があります。注意してください。
23 changes: 19 additions & 4 deletions src/obs-multi-rtmp.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "obs-multi-rtmp.h"
#include "obs-multi-rtmp.h"
#include "obs-module.h"
#include "obs-frontend-api.h"
#include "util/config-file.h"
Expand Down Expand Up @@ -123,13 +123,14 @@ class IOBSOutputEventHanlder



static QThread* s_uiThread = nullptr;

template<class T>
bool RunInUIThread(T&& func)
{
auto mainwnd = (QMainWindow*)obs_frontend_get_main_window();
if (mainwnd == nullptr)
if (s_uiThread == nullptr)
return false;
QMetaObject::invokeMethod(mainwnd, [func = std::move(func)]() {
QMetaObject::invokeMethod(s_uiThread, [func = std::move(func)]() {
func();
});
return true;
Expand Down Expand Up @@ -679,6 +680,9 @@ class PushWidget : public QWidget, public IOBSOutputEventHanlder
timer_ = new QTimer(this);
timer_->setInterval(std::chrono::milliseconds(1000));
QObject::connect(timer_, &QTimer::timeout, [this]() {
if (output_)
return;

auto new_frames = obs_output_get_total_frames(output_);
auto now = clock::now();

Expand Down Expand Up @@ -949,6 +953,11 @@ class MultiOutputWidget : public QDockWidget
});
layout_->addWidget(addButton_);

if (std::string(u8"多路推流") == obs_module_text("Title"))
layout_->addWidget(new QLabel(u8"本插件免费提供,请不要为此付费。\n作者:雷鸣", container_));
else
layout_->addWidget(new QLabel(u8"This plugin provided free of charge. \nAuthor: SoraYuki", container_));

// load config
LoadConfig();

Expand Down Expand Up @@ -1067,6 +1076,12 @@ bool obs_module_load()
return false;

auto mainwin = (QMainWindow*)obs_frontend_get_main_window();
if (mainwin == nullptr)
return false;
QMetaObject::invokeMethod(mainwin, []() {
s_uiThread = QThread::currentThread();
});

auto dock = new MultiOutputWidget(mainwin);
auto action = (QAction*)obs_frontend_add_dock(dock);
QObject::connect(action, &QAction::toggled, dock, &MultiOutputWidget::visibleToggled);
Expand Down

0 comments on commit c46cd6d

Please sign in to comment.