Skip to content

Commit

Permalink
examples/player: uninstall old libavfilter if parameters changed
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Dec 10, 2015
1 parent 8665d57 commit 94b894b
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions examples/player/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,36 +1413,28 @@ void MainWindow::onCaptureConfigChanged()

void MainWindow::onAVFilterVideoConfigChanged()
{
if (Config::instance().avfilterVideoEnable()) {
if (!mpVideoFilter) {
mpVideoFilter = new LibAVFilterVideo(this);
}
mpVideoFilter->setEnabled(true);
mpPlayer->installFilter(mpVideoFilter);
mpVideoFilter->setOptions(Config::instance().avfilterVideoOptions());
} else {
if (mpVideoFilter) {
mpVideoFilter->setEnabled(false);
}
mpPlayer->uninstallFilter(mpVideoFilter);
if (mpVideoFilter) {
mpVideoFilter->uninstall();
delete mpVideoFilter;
mpVideoFilter = 0;
}
mpVideoFilter = new LibAVFilterVideo(this);
mpVideoFilter->setEnabled(Config::instance().avfilterVideoEnable());
mpPlayer->installFilter(mpVideoFilter);
mpVideoFilter->setOptions(Config::instance().avfilterVideoOptions());
}

void MainWindow::onAVFilterAudioConfigChanged()
{
if (Config::instance().avfilterAudioEnable()) {
if (!mpAudioFilter) {
mpAudioFilter = new LibAVFilterAudio(this);
}
mpAudioFilter->setEnabled(true);
mpPlayer->installFilter(mpAudioFilter);
mpAudioFilter->setOptions(Config::instance().avfilterAudioOptions());
} else {
if (mpAudioFilter) {
mpAudioFilter->setEnabled(false);
}
mpPlayer->uninstallFilter(mpAudioFilter);
if (mpAudioFilter) {
mpAudioFilter->uninstall();
delete mpAudioFilter;
mpAudioFilter = 0;
}
mpAudioFilter = new LibAVFilterAudio(this);
mpAudioFilter->setEnabled(Config::instance().avfilterAudioEnable());
mpAudioFilter->installTo(mpPlayer);
mpAudioFilter->setOptions(Config::instance().avfilterAudioOptions());
}

void MainWindow::donate()
Expand Down

0 comments on commit 94b894b

Please sign in to comment.