Implement source activation/deactivation

Now sources will be properly activated and deactivated when they are in
use or not in use.

Had to figure out a way to handle child sources, and children of
children, just ended up implementing simple functions that parents use
to signal adding/removal to help with hierarchial activation and
deactivation of child sources.

To prevent the source activate/deactivate callbacks from being called
more than once, added an activation reference counter.  The first
increment will call the activate callback, and the last decrement will
call the deactivate callback.

Added "source-activate" and "source-deactivate" signals to the main obs
signal handler, and "activate" and "deactivate" to individual source
signal handlers.

Also, fixed the main window so it properly selects a source when the
current active scene has been changed.
This commit is contained in:
jp9000
2014-02-20 22:04:14 -07:00
parent 14c95ac421
commit d4f1eacc1f
8 changed files with 141 additions and 24 deletions

View File

@@ -37,6 +37,7 @@ Q_DECLARE_METATYPE(OBSSceneItem);
OBSBasic::OBSBasic(QWidget *parent)
: OBSMainWindow (parent),
outputTest (NULL),
sceneChanging (false),
ui (new Ui::OBSBasic)
{
ui->setupUi(this);
@@ -194,12 +195,14 @@ void OBSBasic::UpdateSceneSelection(OBSSource source)
obs_scene_t scene = obs_scene_fromsource(source);
const char *name = obs_source_getname(source);
QListWidgetItem *sel = ui->scenes->currentItem();
QList<QListWidgetItem*> items =
ui->scenes->findItems(QT_UTF8(name), Qt::MatchExactly);
if (items.contains(sel)) {
ui->scenes->setCurrentItem(sel);
if (items.count()) {
sceneChanging = true;
ui->scenes->setCurrentItem(items.first());
sceneChanging = false;
UpdateSources(scene);
}
}
@@ -384,20 +387,26 @@ void OBSBasic::on_action_Save_triggered()
/* TODO */
}
void OBSBasic::on_scenes_itemChanged(QListWidgetItem *item)
void OBSBasic::on_scenes_currentItemChanged(QListWidgetItem *current,
QListWidgetItem *prev)
{
obs_source_t source = NULL;
if (item) {
if (sceneChanging)
return;
if (current) {
obs_scene_t scene;
scene = item->data(Qt::UserRole).value<OBSScene>();
scene = current->data(Qt::UserRole).value<OBSScene>();
source = obs_scene_getsource(scene);
UpdateSources(scene);
}
/* TODO: allow transitions */
obs_set_output_source(0, source);
UNUSED_PARAMETER(prev);
}
void OBSBasic::on_scenes_customContextMenuRequested(const QPoint &pos)
@@ -462,10 +471,12 @@ void OBSBasic::on_actionSceneDown_triggered()
/* TODO */
}
void OBSBasic::on_sources_itemChanged(QListWidgetItem *item)
void OBSBasic::on_sources_currentItemChanged(QListWidgetItem *current,
QListWidgetItem *prev)
{
/* TODO */
UNUSED_PARAMETER(item);
UNUSED_PARAMETER(current);
UNUSED_PARAMETER(prev);
}
void OBSBasic::on_sources_customContextMenuRequested(const QPoint &pos)

View File

@@ -32,6 +32,7 @@ class OBSBasic : public OBSMainWindow {
private:
std::unordered_map<obs_source_t, int> sourceSceneRefs;
obs_output_t outputTest;
bool sceneChanging;
OBSScene GetCurrentScene();
OBSSceneItem GetCurrentSceneItem();
@@ -75,14 +76,16 @@ private slots:
void on_action_New_triggered();
void on_action_Open_triggered();
void on_action_Save_triggered();
void on_scenes_itemChanged(QListWidgetItem *item);
void on_scenes_currentItemChanged(QListWidgetItem *current,
QListWidgetItem *prev);
void on_scenes_customContextMenuRequested(const QPoint &pos);
void on_actionAddScene_triggered();
void on_actionRemoveScene_triggered();
void on_actionSceneProperties_triggered();
void on_actionSceneUp_triggered();
void on_actionSceneDown_triggered();
void on_sources_itemChanged(QListWidgetItem *item);
void on_sources_currentItemChanged(QListWidgetItem *current,
QListWidgetItem *prev);
void on_sources_customContextMenuRequested(const QPoint &pos);
void on_actionAddSource_triggered();
void on_actionRemoveSource_triggered();