Ignore:
Timestamp:
May 3, 2016, 5:25:45 PM (10 years ago)
Author:
Silvan Scherrer
Message:

smplayer: update trunk to version 16.4

Location:
smplayer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • smplayer/trunk

  • smplayer/trunk/src/core.cpp

    r170 r176  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2014 Ricardo Villalba <[email protected]>
     2    Copyright (C) 2006-201 Ricardo Villalba <[email protected]>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    2323#include <QTextStream>
    2424#include <QUrl>
     25
    2526
    2627#ifdef Q_OS_OS2
     
    4243#include "discname.h"
    4344#include "filters.h"
     45
    4446
    4547#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
     
    6163#ifdef YOUTUBE_SUPPORT
    6264#include "retrieveyoutubeurl.h"
    63   #ifdef YT_USE_SCRIPT
     65  #ifdef YT_USE_
    6466  #include "ytsig.h"
    6567  #endif
     68
     69
    6670#endif
    6771
     
    9599#endif
    96100
    97     proc = new MplayerProcess(this);
     101);
    98102
    99103        // Do this the first
     
    138142        */
    139143
     144
     145
     146
     147
     148
     149
    140150        connect( proc, SIGNAL(receivedCacheEmptyMessage(QString)),
    141151                         this, SIGNAL(buffering()));
     
    185195        connect( proc, SIGNAL(receivedStartingTime(double)),
    186196             this, SLOT(gotStartingTime(double)) );
     197
     198
     199
    187200
    188201        connect( proc, SIGNAL(receivedStreamTitle(QString)),
     
    209222             this, SLOT(initAudioTrack(const Tracks &)), Qt::QueuedConnection );
    210223#endif
     224
     225
     226
     227
     228
     229
     230
     231
     232
    211233#if DVDNAV_SUPPORT
    212234        connect( proc, SIGNAL(receivedDVDTitle(int)),
     
    271293        yt->setUseHttpsVi(pref->yt_use_https_vi);
    272294
    273         connect(yt, SIGNAL(gotPreferredUrl(const QString &)), this, SLOT(openYT(const QString &)));
     295        #ifdef YT_USE_SIG
     296        QSettings * sigset = new QSettings(Paths::configPath() + "/sig.ini", QSettings::IniFormat, this);
     297        yt->setSettings(sigset);
     298        #endif
     299
     300        connect(yt, SIGNAL(gotPreferredUrl(const QString &, int)), this, SLOT(openYT(const QString &)));
    274301        connect(yt, SIGNAL(connecting(QString)), this, SLOT(connectingToYT(QString)));
    275302        connect(yt, SIGNAL(errorOcurred(int,QString)), this, SLOT(YTFailed(int,QString)));
    276         /* connect(yt, SIGNAL(signatureNotFound()), this, SLOT(YTNoSignature())); */
     303       
    277304        connect(yt, SIGNAL(signatureNotFound(const QString&)), this, SIGNAL(signatureNotFound(const QString&)));
    278305        connect(yt, SIGNAL(gotEmptyList()), this, SLOT(YTNoVideoUrl()));
     
    288315#endif
    289316
    290     if (proc->isRunning()) stopMplayer();
    291     proc->terminate();
    292     delete proc;
     317if (proc->isRunning()) stopMplayer();
     318proc->terminate();
     319delete proc;
    293320
    294321#ifndef NO_USE_INI_FILES
     
    321348
    322349void Core::setState(State s) {
     350
    323351        if (s != _state) {
    324352                _state = s;
     
    366394
    367395        if ( (mdat.type == TYPE_FILE) && (!mdat.filename.isEmpty()) ) {
    368                 file_settings->saveSettingsFor(mdat.filename, mset);
     396                file_settings->saveSettingsFor(mdat.filename, mset);
    369397        }
    370398        else
    371399        if ( (mdat.type == TYPE_TV) && (!mdat.filename.isEmpty()) ) {
    372                 tv_settings->saveSettingsFor(mdat.filename, mset);
     400                tv_settings->saveSettingsFor(mdat.filename, mset);
    373401        }
    374402}
     
    389417
    390418
    391 void Core::tellmp(const QString & command) {
    392         qDebug("Core::tellmp: '%s'", command.toUtf8().data());
    393 
    394     //qDebug("Command: '%s'", command.toUtf8().data());
    395     if (proc->isRunning()) {
    396                 proc->writeToStdin( command );
    397     } else {
    398                 qWarning(" tellmp: no process running: %s", command.toUtf8().data());
    399     }
     419void Core::changeFullscreenMode(bool b) {
     420        proc->setFullscreen(b);
    400421}
    401422
     
    404425
    405426        if (proc->isRunning()) {
    406                 QString str = QString("osd_show_text \"%1\" %2 %3\n").arg(text.toUtf8().constData()).arg(duration).arg(level);
    407                 if (!prefix.isEmpty()) str = prefix + " " + str;
    408                 qDebug("Core::displayTextOnOSD: command: '%s'", str.toUtf8().constData());
    409                 proc->write(str.toLatin1());
     427                proc->setPausingPrefix(prefix);
     428                proc->showOSDText(text, duration, level);
    410429        }
    411430}
     
    427446                openDVD( DiscName::joinDVD(0, file, pref->use_dvdnav) );
    428447#else
    429                 openDVD( DiscName::joinDVD(1, file, false) );
     448                openDVD( DiscName::joinDVD(, file, false) );
    430449#endif
    431450        }
     
    446465                        qDebug("Core::open: * directory contains a dvd");
    447466#if DVDNAV_SUPPORT
    448                         openDVD( DiscName::joinDVD(1, file, pref->use_dvdnav) );
     467                        openDVD( DiscName::joinDVD(, file, pref->use_dvdnav) );
    449468#else
    450                         openDVD( DiscName::joinDVD(1, file, false) );
     469                        openDVD( DiscName::joinDVD(, file, false) );
    451470#endif
    452471                } else {
     
    544563}
    545564
    546 /*
    547 void Core::YTNoSignature() {
    548         emit showMessage( tr("Video protected. It can't be played."), 5000 );
    549 }
    550 */
    551 
    552565void Core::YTNoVideoUrl() {
    553566        emit showMessage( tr("Unable to locate the URL of the video") );
     
    580593
    581594                QFileInfo fi(sub);
    582                 if ((pref->fast_load_sub) && (fi.suffix().toLower() != "idx") && (mset.external_subtitles_fps == MediaSettings::SFPS_None)) {
     595                bool is_idx = (fi.suffix().toLower() == "idx");
     596                if (proc->isMPV()) is_idx = false; // Hack to ignore the idx extension with mpv
     597
     598                if ((pref->fast_load_sub) && (!is_idx) && (mset.external_subtitles_fps == MediaSettings::SFPS_None)) {
    583599                        QString sub_file = sub;
    584600                        #ifdef Q_OS_WIN
     
    590606                        }
    591607                        #endif
    592                         tellmp( "sub_load \""+ sub_file +"\"" );
     608                        );
    593609                } else {
    594610                        restartPlay();
     
    670686
    671687        mset.current_title_id = title;
    672         mset.current_chapter_id = 1;
    673688        mset.current_angle_id = 1;
    674689
     
    700715
    701716        mset.current_title_id = title;
    702         mset.current_chapter_id = -1;
    703717        mset.current_angle_id = -1;
    704718
     
    729743
    730744        mset.current_title_id = title;
    731         mset.current_chapter_id = -1;
    732745        mset.current_angle_id = -1;
    733746
     
    777790
    778791        mset.current_title_id = title;
    779         mset.current_chapter_id = firstChapter();
    780792        mset.current_angle_id = 1;
    781793
     
    826838
    827839        mset.current_title_id = title;
    828         mset.current_chapter_id = firstChapter();
    829840        mset.current_angle_id = 1;
    830841
     
    878889
    879890                        // In this case we read info from config
    880                         tv_settings->loadSettingsFor(channel_id, mset);
     891                        tv_settings->loadSettingsFor(channel_id, mset);
    881892                        qDebug("Core::openTV: media settings read");
    882893                }
     
    893904
    894905#ifdef YOUTUBE_SUPPORT
    895         // Check if the stream is a youtube url
    896         QString yt_full_url = yt->fullUrl(name);
    897         if (!yt_full_url.isEmpty()) {
    898                 qDebug("Core::openStream: youtube url detected: %s", yt_full_url.toLatin1().constData());
    899                 name = yt_full_url;
    900                 yt->setPreferredQuality( (RetrieveYoutubeUrl::Quality) pref->yt_quality );
    901                 qDebug("Core::openStream: user_agent: '%s'", pref->yt_user_agent.toUtf8().constData());
    902                 /*if (!pref->yt_user_agent.isEmpty()) yt->setUserAgent(pref->yt_user_agent); */
    903                 yt->setUserAgent(pref->yt_user_agent);
    904                 #ifdef YT_USE_SCRIPT
    905                 YTSig::setScriptFile( Paths::configPath() + "/yt.js" );
    906                 #endif
    907                 yt->fetchPage(name);
    908                 return;
     906        if (PREF_YT_ENABLED) {
     907                // Check if the stream is a youtube url
     908                QString yt_full_url = yt->fullUrl(name);
     909                if (!yt_full_url.isEmpty()) {
     910                        qDebug("Core::openStream: youtube url detected: %s", yt_full_url.toLatin1().constData());
     911                        name = yt_full_url;
     912                        yt->setPreferredQuality( (RetrieveYoutubeUrl::Quality) pref->yt_quality );
     913                        qDebug("Core::openStream: user_agent: '%s'", pref->yt_user_agent.toUtf8().constData());
     914                        /*if (!pref->yt_user_agent.isEmpty()) yt->setUserAgent(pref->yt_user_agent); */
     915                        yt->setUserAgent(pref->yt_user_agent);
     916                        #ifdef YT_USE_YTSIG
     917                        YTSig::setScriptFile( Paths::configPath() + "/yt.js" );
     918                        #endif
     919                        yt->fetchPage(name);
     920                        return;
     921                }
    909922        }
    910923#endif
     
    959972                // In this case we read info from config
    960973                if (!pref->dont_remember_media_settings) {
    961                         file_settings->loadSettingsFor(file, mset);
     974                        file_settings->loadSettingsFor(file, mset);
    962975                        qDebug("Core::playNewFile: Media settings read");
    963976
     
    10251038
    10261039#ifdef YOUTUBE_SUPPORT
    1027         // Avoid to pass to mplayer the youtube page url
    1028         if (mdat.type == TYPE_STREAM) {
    1029                 if (mdat.filename == yt->origUrl()) {
    1030                         mdat.filename = yt->latestPreferredUrl();
     1040        if (PREF_YT_ENABLED) {
     1041                // Avoid to pass to mplayer the youtube page url
     1042                if (mdat.type == TYPE_STREAM) {
     1043                        if (mdat.filename == yt->origUrl()) {
     1044                                mdat.filename = yt->latestPreferredUrl();
     1045                        }
    10311046                }
    10321047        }
     
    10481063
    10491064        initializeMenus(); // Old
     1065
     1066
     1067
    10501068
    10511069        // Video
     
    10971115#endif
    10981116
    1099         if (mdat.n_chapters > 0) {
    1100                 // Just to show the first chapter checked in the menu
    1101                 mset.current_chapter_id = firstChapter();
    1102         }
    1103 
    11041117        mdat.initialized = true;
    11051118
     
    11391152        }
    11401153
     1154
     1155
     1156
     1157
    11411158#ifdef YOUTUBE_SUPPORT
    1142         // Change the real url with the youtube page url and set the title
    1143         if (mdat.type == TYPE_STREAM) {
    1144                 if (mdat.filename == yt->latestPreferredUrl()) {
    1145                         mdat.filename = yt->origUrl();
    1146                         mdat.stream_title = yt->urlTitle();
     1159        if (PREF_YT_ENABLED) {
     1160                // Change the real url with the youtube page url and set the title
     1161                if (mdat.type == TYPE_STREAM) {
     1162                        if (mdat.filename == yt->latestPreferredUrl()) {
     1163                                mdat.filename = yt->origUrl();
     1164                                mdat.stream_title = yt->urlTitle();
     1165                        }
    11471166                }
    11481167        }
     
    12011220                // Recover current subtitle
    12021221                changeSubtitle( mset.current_sub_id );
     1222
    12031223        }
    12041224#endif
     
    12111231                qDebug("Core::finishRestart: don't set volume since -volume is used");
    12121232        } else {
     1233
     1234
    12131235                if (pref->global_volume) {
    12141236                        bool was_muted = pref->mute;
     
    12171239                } else {
    12181240                        bool was_muted = mset.mute;
    1219                          setVolume( mset.volume, true );
     1241                        setVolume( mset.volume, true );
    12201242                        if (was_muted) mute(true);
    12211243                }
    1222         }
    1223 
     1244                */
     1245                int vol = (pref->global_volume ? pref->volume : mset.volume);
     1246                volumeChanged(vol);
     1247
     1248                if (proc->isMPlayer() && pref->mute) {
     1249                        // Set mute here because mplayer doesn't have an option to set mute from the command line
     1250                        mute(true);
     1251                }
     1252        }
     1253
     1254#if 0
     1255// Old. Gamma already set with option -gamma
    12241256        if (pref->change_video_equalizer_on_startup && (mset.gamma != 0)) {
    12251257                int gamma = mset.gamma;
     
    12271259                setGamma( gamma );
    12281260        }
     1261
    12291262        // Hack to be sure that the equalizers are up to date
    12301263        emit videoEqualizerNeedsUpdate();
     
    12441277        emit mediaLoaded();
    12451278        emit mediaInfoChanged();
     1279
    12461280
    12471281        updateWidgets(); // New
     
    12921326
    12931327        if ((proc->isRunning()) && (state()==Paused)) {
    1294                 tellmp("pause"); // Unpauses
     1328               
    12951329        }
    12961330        else
     
    13191353        if (proc->isRunning()) {
    13201354                if (state() == Paused) {
    1321                         tellmp("frame_step");
    1322                 }
    1323                 else {
    1324                         tellmp("pause");
     1355                        proc->frameStep();
     1356                } else {
     1357                        proc->setPause(true);
    13251358                }
    13261359        }
     
    13281361
    13291362void Core::pause() {
    1330         qDebug("Core::pause");
    13311363        qDebug("Core::pause: current state: %s", stateToString().toUtf8().data());
    13321364
    13331365        if (proc->isRunning()) {
    13341366                // Pauses and unpauses
    1335                 tellmp("pause");
     1367                );
    13361368        }
    13371369}
     
    13491381
    13501382        if (proc->isRunning()) {
    1351                 tellmp("frame_step");
     1383                proc->frameStep();
     1384        }
     1385}
     1386
     1387void Core::frameBackStep() {
     1388        qDebug("Core::frameBackStep");
     1389
     1390        if (proc->isRunning()) {
     1391                proc->frameBackStep();
    13521392        }
    13531393}
     
    13591399         (QFileInfo(pref->screenshot_directory).isDir()) )
    13601400        {
    1361                 tellmp( pausing_prefix() + " screenshot 0");
     1401                proc->setPausingPrefix(pausing_prefix());
     1402                proc->takeScreenshot(PlayerProcess::Single, pref->subtitles_on_screenshots);
    13621403                qDebug("Core::screenshot: taken screenshot");
    13631404        } else {
     
    13731414         (QFileInfo(pref->screenshot_directory).isDir()) )
    13741415        {
    1375                 tellmp( "screenshot 1");
     1416                );
    13761417        } else {
    13771418                qDebug("Core::screenshots: error: directory for screenshots not valid");
     
    13791420        }
    13801421}
     1422
     1423
     1424
     1425
     1426
     1427
     1428
    13811429
    13821430void Core::processFinished()
     
    13961444        qDebug("Core::processFinished: exit_code: %d", exit_code);
    13971445        if (exit_code != 0) {
     1446
     1447
    13981448                emit mplayerFinishedWithError(exit_code);
    13991449        }
     
    14331483void Core::goToPos(double perc) {
    14341484        qDebug("Core::goToPos: per: %f", perc);
    1435         tellmp( seek_cmd(perc, 1) );
     1485        );
    14361486}
    14371487#else
    14381488void Core::goToPos(int perc) {
    14391489        qDebug("Core::goToPos: per: %d", perc);
    1440         tellmp( seek_cmd(perc, 1) );
     1490        );
    14411491}
    14421492#endif
     
    14661516        yt->close();
    14671517#endif
    1468 
    1469         bool is_mkv = (QFileInfo(file).suffix().toLower() == "mkv");
    14701518
    14711519        // DVD
     
    14781526                dvd_title = disc_data.title;
    14791527                file = disc_data.protocol + "://";
    1480                 if (dvd_title > 0) file += QString::number(dvd_title);
     1528                if (dvd_title > ) file += QString::number(dvd_title);
    14811529        }
    14821530
     
    15251573        proc->clearArguments();
    15261574
    1527         // Set working directory to screenshot directory
    1528         if (screenshot_enabled) {
    1529                 qDebug("Core::startMplayer: setting working directory to '%s'", pref->screenshot_directory.toUtf8().data());
    1530                 proc->setWorkingDirectory( pref->screenshot_directory );
    1531         }
     1575        // Set the screenshot directory
     1576        /* deleted (done later) */
    15321577
    15331578        // Use absolute path, otherwise after changing to the screenshot directory
     
    15361581        QString mplayer_bin = pref->mplayer_bin;
    15371582        QFileInfo fi(mplayer_bin);
    1538     if (fi.exists() && fi.isExecutable() && !fi.isDir()) {
    1539         mplayer_bin = fi.absoluteFilePath();
    1540         }
    1541 
     1583        if (fi.exists() && fi.isExecutable() && !fi.isDir()) {
     1584                mplayer_bin = fi.absoluteFilePath();
     1585        }
     1586
     1587#ifdef MPLAYER2_SUPPORT
    15421588        if (fi.baseName().toLower() == "mplayer2") {
    15431589                if (!pref->mplayer_is_mplayer2) {
     
    15461592                }
    15471593        }
    1548 
    1549         proc->addArgument( mplayer_bin );
    1550 
    1551         proc->addArgument("-noquiet");
     1594#endif
     1595
     1596        proc->setExecutable(mplayer_bin);
     1597        proc->);
    15521598
    15531599#ifdef LOG_MPLAYER
    15541600        if (pref->verbose_log) {
    1555                 proc->addArgument("-v");
     1601                proc->");
    15561602        }
    15571603#endif
    15581604
    15591605        if (pref->fullscreen && pref->use_mplayer_window) {
    1560                 proc->addArgument("-fs");
     1606                proc->);
    15611607        } else {
    15621608                // No mplayer fullscreen mode
    1563 #if !USE_MPLAYER_PANSCAN
    1564                 proc->addArgument("-nofs");
     1609                proc->setOption("fs", false);
     1610        }
     1611
     1612#if !ALLOW_DEMUXER_CODEC_CHANGE
     1613        if (pref->use_lavf_demuxer) {
     1614                proc->setOption("demuxer", "lavf");
     1615        }
    15651616#else
    1566                 // The command 'panscan' requires -fs
    1567                 proc->addArgument("-fs");
    1568 #endif
    1569         }
    1570 
    1571         proc->addArgument("-nomouseinput");
    1572 
    15731617        // Demuxer and audio and video codecs:
    15741618        if (!mset.forced_demuxer.isEmpty()) {
    1575                 proc->addArgument("-demuxer");
    1576                 proc->addArgument(mset.forced_demuxer);
     1619                proc->setOption("demuxer", mset.forced_demuxer);
    15771620        }
    15781621        if (!mset.forced_audio_codec.isEmpty()) {
    1579                 proc->addArgument("-ac");
    1580                 proc->addArgument(mset.forced_audio_codec);
     1622                proc->setOption("ac", mset.forced_audio_codec);
    15811623        }
    15821624        if (!mset.forced_video_codec.isEmpty()) {
    1583                 proc->addArgument("-vc");
    1584                 proc->addArgument(mset.forced_video_codec);
    1585         }
    1586 #ifndef Q_OS_WIN
    1587         else {
     1625                proc->setOption("vc", mset.forced_video_codec);
     1626        }
     1627        else
     1628#endif
     1629        {
     1630                #ifndef Q_OS_WIN
    15881631                /* if (pref->vo.startsWith("x11")) { */ // My card doesn't support vdpau, I use x11 to test
    15891632                if (pref->vo.startsWith("vdpau")) {
     
    15951638                        if (pref->vdpau.ffodivxvdpau) c += "ffodivxvdpau,";
    15961639                        if (!c.isEmpty()) {
    1597                                 proc->addArgument("-vc");
    1598                                 proc->addArgument(c);
     1640                                proc->setOption("vc", c);
    15991641                        }
    16001642                }
    1601 #endif 
    16021643                else {
     1644
    16031645                        if (pref->coreavc) {
    1604                                 proc->addArgument("-vc");
    1605                                 proc->addArgument("coreserve,");
     1646                                proc->setOption("vc", "coreserve,");
    16061647                        }
    1607                 }
    1608 #ifndef Q_OS_WIN
    1609         }
    1610 #endif
     1648               
     1649                }
     1650       
     1651        }
    16111652
    16121653        if (pref->use_hwac3) {
    1613                 proc->addArgument("-afm");
    1614                 proc->addArgument("hwac3");
    1615         }
    1616 
    1617 
    1618         QString lavdopts;
    1619 
    1620         if ( (pref->h264_skip_loop_filter == Preferences::LoopDisabled) ||
    1621          ((pref->h264_skip_loop_filter == Preferences::LoopDisabledOnHD) &&
    1622           (mset.is264andHD)) )
    1623         {
    1624                 if (!lavdopts.isEmpty()) lavdopts += ":";
    1625                 lavdopts += "skiploopfilter=all";
    1626         }
    1627 
    1628         if (pref->threads > 1) {
    1629                 if (!lavdopts.isEmpty()) lavdopts += ":";
    1630                 lavdopts += "threads=" + QString::number(pref->threads);
    1631         }
    1632 
    1633         if (!lavdopts.isEmpty()) {
    1634                 proc->addArgument("-lavdopts");
    1635                 proc->addArgument(lavdopts);
    1636         }
    1637 
    1638         proc->addArgument("-sub-fuzziness");
    1639         proc->addArgument( QString::number(pref->subfuzziness) );
    1640 
    1641         proc->addArgument("-identify");
    1642 
    1643         if (MplayerVersion::isMplayerAtLeast(27667)) {
    1644                 // From r27667 the number of chapters can be obtained from ID_CHAPTERS
    1645                 mset.current_chapter_id = 0; // Reset chapters
    1646         } else {
    1647                 // We need this to get info about mkv chapters
    1648                 if (is_mkv) {
    1649                         proc->addArgument("-msglevel");
    1650                         proc->addArgument("demux=6");
    1651 
    1652                         // **** Reset chapter ***
    1653                         // Select first chapter, otherwise we cannot
    1654                         // resume playback at the same point
    1655                         // (time would be relative to chapter)
    1656                         mset.current_chapter_id = 0;
    1657                 }
    1658         }
    1659 
    1660         proc->addArgument("-slave");
    1661 
    1662         if (!pref->vo.isEmpty()) {
    1663                 proc->addArgument( "-vo");
    1664                 proc->addArgument( pref->vo );
    1665         } else {
    1666                 proc->addArgument("-vo");
    1667 #ifdef Q_OS_WIN
    1668                 if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) {
    1669                         proc->addArgument("direct3d,");
     1654                proc->setOption("afm", "hwac3");
     1655        }
     1656
     1657
     1658        if (proc->isMPlayer()) {
     1659                // MPlayer
     1660                QString lavdopts;
     1661
     1662                if ( (pref->h264_skip_loop_filter == Preferences::LoopDisabled) ||
     1663                 ((pref->h264_skip_loop_filter == Preferences::LoopDisabledOnHD) &&
     1664                  (mset.is264andHD)) )
     1665                {
     1666                        if (!lavdopts.isEmpty()) lavdopts += ":";
     1667                        lavdopts += "skiploopfilter=all";
     1668                }
     1669
     1670                if (pref->threads > 1) {
     1671                        if (!lavdopts.isEmpty()) lavdopts += ":";
     1672                        lavdopts += "threads=" + QString::number(pref->threads);
     1673                }
     1674
     1675                if (!lavdopts.isEmpty()) {
     1676                        proc->setOption("lavdopts", lavdopts);
     1677                }
     1678        }
     1679        else {
     1680                // MPV
     1681                if ( (pref->h264_skip_loop_filter == Preferences::LoopDisabled) ||
     1682                 ((pref->h264_skip_loop_filter == Preferences::LoopDisabledOnHD) &&
     1683                  (mset.is264andHD)) )
     1684                {
     1685                        proc->setOption("skiploopfilter");
     1686                }
     1687
     1688                if (pref->threads > 1) {
     1689                        proc->setOption("threads", QString::number(pref->threads));
     1690                }
     1691        }
     1692
     1693        if (!pref->hwdec.isEmpty()) proc->setOption("hwdec", pref->hwdec);
     1694
     1695        proc->setOption("sub-fuzziness", pref->subfuzziness);
     1696
     1697        if (pref->vo != "player_default") {
     1698                if (!pref->vo.isEmpty()) {
     1699                        proc->setOption("vo", pref->vo );
    16701700                } else {
    1671                         proc->addArgument("directx,");
    1672                 }
    1673 #else
    1674                 proc->addArgument("xv,");
    1675 #endif
     1701                        #ifdef Q_OS_WIN
     1702                        if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) {
     1703                                proc->setOption("vo", "direct3d,");
     1704                        } else {
     1705                                proc->setOption("vo", "directx,");
     1706                        }
     1707                        #else
     1708                        proc->setOption("vo", "xv,");
     1709                        #endif
     1710                }
    16761711        }
    16771712
    16781713#if USE_ADAPTER
    16791714        if (pref->adapter > -1) {
    1680                 proc->addArgument("-adapter");
    1681                 proc->addArgument(QString::number(pref->adapter));
    1682         }
    1683 #endif
    1684 
    1685         if (!pref->ao.isEmpty()) {
    1686                 proc->addArgument( "-ao");
    1687                 proc->addArgument( pref->ao );
     1715                proc->);
     1716       
     1717#endif
     1718
     1719        if (pref->ao != "player_default") {
     1720        if (!pref->ao.isEmpty()) {
     1721                );
     1722               
    16881723        }
    16891724
    16901725#if !defined(Q_OS_WIN) && !defined(Q_OS_OS2)
    16911726        if (pref->vo.startsWith("x11")) {
    1692                 proc->addArgument( "-zoom");
    1693         }
    1694 #endif
    1695         proc->addArgument("-nokeepaspect");
     1727                proc->setOption("zoom");
     1728        }
     1729#endif
    16961730
    16971731        // Performance options
     
    17161750                default:                                                p = "normal";
    17171751        }
    1718         proc->addArgument("-priority");
    1719         proc->addArgument( p );
     1752        proc->setOption("priority", p);
    17201753        /*
    17211754        SetPriorityClass(GetCurrentProcess(), app_p);
     
    17241757        #endif
    17251758
     1759
     1760
     1761
     1762
    17261763        if (pref->frame_drop) {
    1727                 proc->addArgument("-framedrop");
    1728         }
    1729 
     1764                proc->");
     1765        }
     1766        else
    17301767        if (pref->hard_frame_drop) {
    1731                 proc->addArgument("-hardframedrop");
     1768                proc->");
    17321769        }
    17331770
    17341771        if (pref->autosync) {
    1735                 proc->addArgument("-autosync");
    1736                 proc->addArgument( QString::number( pref->autosync_factor ) );
     1772                proc->setOption("autosync", QString::number(pref->autosync_factor));
    17371773        }
    17381774
    17391775        if (pref->use_mc) {
    1740                 proc->addArgument("-mc");
    1741                 proc->addArgument( QString::number( pref->mc_value ) );
    1742         }
    1743 
    1744         if (pref->use_direct_rendering) {
    1745                 proc->addArgument("-dr");
    1746         } else {
    1747                 proc->addArgument("-nodr");
    1748         }
    1749 
    1750         if (pref->use_double_buffer) {
    1751                 proc->addArgument("-double");
    1752         } else {
    1753                 proc->addArgument("-nodouble");
    1754         }
    1755 
    1756 #if !defined(Q_OS_WIN) && !defined(Q_OS_OS2)
     1776                proc->setOption("mc", QString::number(pref->mc_value));
     1777        }
     1778
     1779        proc->setOption("dr", pref->use_direct_rendering);
     1780        proc->setOption("double", pref->use_double_buffer);
     1781
     1782#ifdef Q_WS_X11
     1783        proc->setOption("stop-xscreensaver", pref->disable_screensaver);
     1784#endif
     1785
    17571786        if (!pref->use_mplayer_window) {
    1758                 proc->addArgument( "-input" );
    1759                 if (MplayerVersion::isMplayerAtLeast(29058)) {
    1760                         proc->addArgument( "nodefault-bindings:conf=/dev/null" );
    1761                 } else {
    1762                         proc->addArgument( "conf=" + Paths::dataPath() +"/input.conf" );
    1763                 }
    1764         }
    1765 #endif
    1766 
    1767 #ifdef Q_WS_X11
    1768         if (pref->disable_screensaver) {
    1769                 proc->addArgument("-stop-xscreensaver");
    1770         } else {
    1771                 proc->addArgument("-nostop-xscreensaver");
    1772         }
    1773 #endif
    1774 
    1775         if (!pref->use_mplayer_window) {
    1776                 proc->addArgument("-wid");
     1787                proc->disableInput();
     1788                proc->setOption("keepaspect", false);
     1789
    17771790#if defined(Q_OS_OS2)
    17781791                #define WINIDFROMHWND(hwnd) ( ( hwnd ) - 0x80000000UL )
    1779                 proc->addArgument( QString::number( WINIDFROMHWND( (int) mplayerwindow->videoLayer()->winId() ) ));
     1792                proc-> QString::number( WINIDFROMHWND( (int) mplayerwindow->videoLayer()->winId() ) ));
    17801793#else
    1781                 proc->addArgument( QString::number( (qint64) mplayerwindow->videoLayer()->winId() ) );
     1794                proc-> QString::number( (qint64) mplayerwindow->videoLayer()->winId() ) );
    17821795#endif
    17831796
     
    17851798                #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
    17861799                if ((pref->vo.startsWith("directx")) || (pref->vo.startsWith("kva")) || (pref->vo.isEmpty())) {
    1787                         proc->addArgument("-colorkey");
    1788                         //proc->addArgument( "0x"+QString::number(pref->color_key, 16) );
    1789                         proc->addArgument( ColorUtils::colorToRGB(pref->color_key) );
     1800                        proc->setOption("colorkey", ColorUtils::colorToRGB(pref->color_key));
    17901801                } else {
    17911802                #endif
     1803
    17921804                        qDebug("Core::startMplayer: * not using -colorkey for %s", pref->vo.toUtf8().data());
    17931805                        qDebug("Core::startMplayer: * report if you can't see the video");
     1806
    17941807                #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
    17951808                }
     
    17981811
    17991812                // Square pixels
    1800                 proc->addArgument("-monitorpixelaspect");
    1801                 proc->addArgument("1");
     1813                proc->setOption("monitorpixelaspect", "1");
    18021814        } else {
    18031815                // no -wid
     1816
    18041817                if (!pref->monitor_aspect.isEmpty()) {
    1805                         proc->addArgument("-monitoraspect");
    1806                         proc->addArgument( pref->monitor_aspect );
    1807                 }
    1808         }
     1818                        proc->setOption("monitoraspect", pref->monitor_aspect);
     1819                }
     1820        }
     1821
     1822        // OSD
     1823        proc->setOption("osd-scale", proc->isMPlayer() ? pref->subfont_osd_scale : pref->osd_scale);
    18091824
    18101825        // Subtitles fonts
    18111826        if ((pref->use_ass_subtitles) && (pref->freetype_support)) {
    18121827                // ASS:
    1813                 proc->addArgument("-ass");
    1814                 proc->addArgument("-embeddedfonts");
    1815 
    1816                 proc->addArgument("-ass-line-spacing");
    1817                 proc->addArgument(QString::number(pref->ass_line_spacing));
    1818 
    1819                 proc->addArgument( "-ass-font-scale");
    1820                 proc->addArgument( QString::number(mset.sub_scale_ass) );
     1828                proc->setOption("ass");
     1829                proc->setOption("embeddedfonts");
     1830
     1831                proc->setOption("ass-line-spacing", QString::number(pref->ass_line_spacing));
     1832
     1833                proc->setOption("ass-font-scale", QString::number(mset.sub_scale_ass));
    18211834
    18221835#if !defined(Q_OS_OS2)
    1823                 if (!pref->mplayer_is_mplayer2) {
    1824                         proc->addArgument( "-noflip-hebrew" ); // It seems to be necessary to display arabic subtitles correctly when using -ass
    1825                 }
    1826 #endif
    1827 
    1828                 if (!pref->force_ass_styles) {
    1829                         // Load the styles.ass file
    1830                         if (!QFile::exists(Paths::subtitleStyleFile())) {
    1831                                 // If file doesn't exist, create it
    1832                                 pref->ass_styles.exportStyles(Paths::subtitleStyleFile());
     1836                #ifdef MPLAYER2_SUPPORT
     1837                if (!pref->mplayer_is_mplayer2)
     1838                #endif
     1839                {
     1840                        proc->setOption("flip-hebrew",false); // It seems to be necessary to display arabic subtitles correctly when using -ass
     1841                }
     1842#endif
     1843
     1844                if (pref->enable_ass_styles) {
     1845                        QString ass_force_style;
     1846                        if (!pref->user_forced_ass_style.isEmpty()) {
     1847                                ass_force_style = pref->user_forced_ass_style;
     1848                        } else {
     1849                                ass_force_style = pref->ass_styles.toString();
    18331850                        }
    1834                         if (QFile::exists(Paths::subtitleStyleFile())) {
    1835                                 proc->addArgument("-ass-styles");
    1836                                 proc->addArgument( Paths::subtitleStyleFile() );
     1851
     1852                        if (proc->isMPV()) {
     1853                                // MPV
     1854                                proc->setSubStyles(pref->ass_styles);
     1855                                if (pref->force_ass_styles) {
     1856                                        proc->setOption("ass-force-style", ass_force_style);
     1857                                }
    18371858                        } else {
    1838                                 qWarning("Core::startMplayer: '%s' doesn't exist", Paths::subtitleStyleFile().toUtf8().constData());
     1859                                // MPlayer
     1860                                if (!pref->force_ass_styles) {
     1861                                        proc->setSubStyles(pref->ass_styles, Paths::subtitleStyleFile());
     1862                                } else {
     1863                                        proc->setOption("ass-force-style", ass_force_style);
     1864                                }
    18391865                        }
    1840                 } else {
    1841                         // Force styles for ass subtitles too
    1842                         proc->addArgument("-ass-force-style");
    1843                         if (!pref->user_forced_ass_style.isEmpty()) {
    1844                                 proc->addArgument(pref->user_forced_ass_style);
    1845                         } else {
    1846                                 proc->addArgument(pref->ass_styles.toString());
    1847                         }
    1848                 }
     1866                }
     1867
    18491868                // Use the same font for OSD
    1850 #if !defined(Q_OS_OS2)
    1851                 if ((pref->use_fontconfig) && (!pref->ass_styles.fontname.isEmpty())) {
    1852                         #ifdef USE_FONTCONFIG_OPTIONS
    1853                         if (!pref->mplayer_is_mplayer2) { // -fontconfig removed from mplayer2
    1854                                 proc->addArgument("-fontconfig");
    1855                         }
    1856                         #endif
    1857                         proc->addArgument("-font");
    1858                         proc->addArgument( pref->ass_styles.fontname );
    1859                 }
    1860 #endif
     1869                // deleted
     1870
    18611871                // Set the size of OSD
    1862                 if (pref->freetype_support) {
    1863                         proc->addArgument("-subfont-autoscale");
    1864                         proc->addArgument("0");
    1865                         if (!pref->mplayer_is_mplayer2) { // Prevent huge OSD in mplayer2
    1866                                 proc->addArgument("-subfont-osd-scale");
    1867                                 proc->addArgument(QString::number(pref->ass_styles.fontsize));
    1868                         }
    1869                         proc->addArgument("-subfont-text-scale"); // Old versions (like 1.0rc2) need this
    1870                         proc->addArgument(QString::number(pref->ass_styles.fontsize));
    1871                 }
     1872                // deleted
    18721873        } else {
    18731874                // NO ASS:
    1874                 if (pref->freetype_support) proc->addArgument("-noass");
    1875 #if !defined(Q_OS_OS2)
    1876                 if ( (pref->use_fontconfig) && (!pref->font_name.isEmpty()) ) {
    1877                         #ifdef USE_FONTCONFIG_OPTIONS
    1878                         if (!pref->mplayer_is_mplayer2) { // -fontconfig removed from mplayer2
    1879                                 proc->addArgument("-fontconfig");
    1880                         }
    1881                         #endif
    1882                         proc->addArgument("-font");
    1883                         proc->addArgument( pref->font_name );
    1884                 }
    1885 #endif
    1886                 if ( (!pref->use_fontconfig) && (!pref->font_file.isEmpty()) ) {
    1887                         #ifdef USE_FONTCONFIG_OPTIONS
    1888                         if (!pref->mplayer_is_mplayer2) { // -nofontconfig removed from mplayer2
    1889                                 proc->addArgument("-nofontconfig");
    1890                         }
    1891                         #endif
    1892                         proc->addArgument("-font");
    1893                         proc->addArgument( pref->font_file );
    1894                 }
    1895 
    1896                 if (pref->freetype_support) {
    1897                         proc->addArgument( "-subfont-autoscale");
    1898                         proc->addArgument( QString::number( pref->font_autoscale ) );
    1899 
    1900                         proc->addArgument( "-subfont-text-scale");
    1901                         proc->addArgument( QString::number(mset.sub_scale) );
    1902                 }
     1875                if (pref->freetype_support) proc->setOption("noass");
     1876                proc->setOption("subfont-text-scale", QString::number(mset.sub_scale));
    19031877        }
    19041878
     
    19181892
    19191893                if (!encoding.isEmpty()) {
    1920                         proc->addArgument("-subcp");
    1921                         proc->addArgument( encoding );
     1894                        proc->setOption("subcp", encoding);
    19221895                }
    19231896        }
    19241897
    19251898        if (mset.closed_caption_channel > 0) {
    1926                 proc->addArgument("-subcc");
    1927                 if (MplayerVersion::isMplayerAtLeast(32607)) {
    1928                         proc->addArgument( QString::number( mset.closed_caption_channel ) );
    1929                 }
     1899                proc->setOption("subcc", QString::number(mset.closed_caption_channel));
    19301900        }
    19311901
    19321902        if (pref->use_forced_subs_only) {
    1933                 proc->addArgument("-forcedsubsonly");
     1903                proc->forcedsubsonly");
    19341904        }
    19351905
     
    19391909         (mset.current_audio_id == MediaSettings::NoneSelected)*/ )
    19401910        {
    1941                 proc->addArgument("-tsprog");
    1942                 proc->addArgument( QString::number( mset.current_program_id ) );
     1911                proc->setOption("tsprog", QString::number(mset.current_program_id));
    19431912        }
    19441913        // Don't set video and audio track if using -tsprog
     
    19461915#endif
    19471916
     1917
    19481918        if (mset.current_video_id != MediaSettings::NoneSelected) {
    1949                 proc->addArgument("-vid");
    1950                 proc->addArgument( QString::number( mset.current_video_id ) );
     1919                proc->setOption("vid", QString::number(mset.current_video_id));
    19511920        }
    19521921
     
    19551924                        // Workaround for MPlayer bug #1321 (http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1321)
    19561925                        if (mdat.audios.numItems() != 1) {
    1957                                 proc->addArgument("-aid");
    1958                                 proc->addArgument( QString::number( mset.current_audio_id ) );
     1926                                proc->setOption("aid", QString::number(mset.current_audio_id));
    19591927                        }
    19601928                }
    19611929        }
     1930
    19621931
    19631932#if PROGRAM_SWITCH
     
    19711940        }
    19721941        if (!mset.external_subtitles.isEmpty()) {
    1973                 if (QFileInfo(mset.external_subtitles).suffix().toLower()=="idx") {
     1942                bool is_idx = (QFileInfo(mset.external_subtitles).suffix().toLower()=="idx");
     1943                if (proc->isMPV()) is_idx = false; // Hack to ignore the idx extension with mpv
     1944
     1945                if (is_idx) {
    19741946                        // sub/idx subtitles
    19751947                        QFileInfo fi;
     
    19841956                        QString s = fi.path() +"/"+ fi.completeBaseName();
    19851957                        qDebug("Core::startMplayer: subtitle file without extension: '%s'", s.toUtf8().data());
    1986                         proc->addArgument("-vobsub");
    1987                         proc->addArgument( s );
     1958                        proc->setOption("vobsub", s);
    19881959                } else {
    1989                         proc->addArgument("-sub");
    19901960                        #ifdef Q_OS_WIN
    19911961                        if (pref->use_short_pathnames)
    1992                                 proc->addArgument(Helper::shortPathName(mset.external_subtitles));
     1962                                proc->Helper::shortPathName(mset.external_subtitles));
    19931963                        else
    19941964                        #endif
    1995                         proc->addArgument( mset.external_subtitles );
     1965                        {
     1966                                proc->setOption("sub", mset.external_subtitles);
     1967                        }
    19961968                }
    19971969                if (mset.external_subtitles_fps != MediaSettings::SFPS_None) {
     
    20061978                                default: fps = "25";
    20071979                        }
    2008                         proc->addArgument("-subfps");
    2009                         proc->addArgument( fps );
     1980                        proc->setOption("subfps", fps);
    20101981                }
    20111982        }
    20121983
    20131984        if (!mset.external_audio.isEmpty()) {
    2014                 proc->addArgument("-audiofile");
    20151985                #ifdef Q_OS_WIN
    20161986                if (pref->use_short_pathnames)
    2017                         proc->addArgument(Helper::shortPathName(mset.external_audio));
     1987                        proc->Helper::shortPathName(mset.external_audio));
    20181988                else
    20191989                #endif
    2020                 proc->addArgument( mset.external_audio );
    2021         }
    2022 
    2023         proc->addArgument("-subpos");
    2024         proc->addArgument( QString::number(mset.sub_pos) );
    2025 
    2026         if (mset.audio_delay!=0) {
    2027                 proc->addArgument("-delay");
    2028                 proc->addArgument( QString::number( (double) mset.audio_delay/1000 ) );
    2029         }
    2030 
    2031         if (mset.sub_delay!=0) {
    2032                 proc->addArgument("-subdelay");
    2033                 proc->addArgument( QString::number( (double) mset.sub_delay/1000 ) );
     1990                {
     1991                        proc->setOption("audiofile", mset.external_audio);
     1992                }
     1993        }
     1994
     1995        proc->setOption("subpos", QString::number(mset.sub_pos));
     1996
     1997        if (mset.audio_delay != 0) {
     1998                proc->setOption("delay", QString::number((double) mset.audio_delay/1000));
     1999        }
     2000
     2001        if (mset.sub_delay != 0) {
     2002                proc->setOption("subdelay", QString::number((double) mset.sub_delay/1000));
    20342003        }
    20352004
     
    20372006        if (pref->change_video_equalizer_on_startup) {
    20382007                if (mset.contrast != 0) {
    2039                         proc->addArgument("-contrast");
    2040                         proc->addArgument( QString::number( mset.contrast ) );
     2008                        proc->setOption("contrast", QString::number(mset.contrast));
    20412009                }
    20422010       
    20432011                if (mset.brightness != 0) {
    2044                         proc->addArgument("-brightness");
    2045                         proc->addArgument( QString::number( mset.brightness ) );
     2012                        proc->setOption("brightness", QString::number(mset.brightness));
    20462013                }
    20472014
    20482015                if (mset.hue != 0) {
    2049                         proc->addArgument("-hue");
    2050                         proc->addArgument( QString::number( mset.hue ) );
     2016                        proc->setOption("hue", QString::number(mset.hue));
    20512017                }
    20522018
    20532019                if (mset.saturation != 0) {
    2054                         proc->addArgument("-saturation");
    2055                         proc->addArgument( QString::number( mset.saturation ) );
    2056                 }
    2057         }
    2058 
    2059         // Set volume, requires mplayer svn r27872
    2060         bool use_volume_option = (MplayerVersion::isMplayerAtLeast(27872));
     2020                        proc->setOption("saturation", QString::number(mset.saturation));
     2021                }
     2022
     2023                if (mset.gamma != 0) {
     2024                        proc->setOption("gamma", QString::number(mset.gamma));
     2025                }
     2026        }
     2027
    20612028
    20622029        if (pref->mplayer_additional_options.contains("-volume")) {
    20632030                qDebug("Core::startMplayer: don't set volume since -volume is used");
    20642031        } else {
    2065                 if (pref->global_volume) {
    2066                         if (use_volume_option) {
    2067                                 proc->addArgument("-volume");
    2068                                 proc->addArgument( QString::number( pref->volume ) );
    2069                         }
    2070                 } else {
    2071                         if (use_volume_option) {
    2072                                 proc->addArgument("-volume");
    2073                                 // Note: mset.volume may not be right, it can be the volume of the previous video if
    2074                                 // playing a new one, but I think it's better to use anyway the current volume on
    2075                                 // startup than set it to 0 or something.
    2076                                 // The right volume will be set later, when the video starts to play.
    2077                                 proc->addArgument( QString::number( mset.volume ) );
    2078                         }
    2079                 }
     2032                int vol = (pref->global_volume ? pref->volume : mset.volume);
     2033                if (proc->isMPV()) {
     2034                        vol = adjustVolume(vol, pref->use_soft_vol ? pref->softvol_max : 100);
     2035                }
     2036                proc->setOption("volume", QString::number(vol));
     2037        }
     2038
     2039        if (pref->mute) {
     2040                proc->setOption("mute");
    20802041        }
    20812042
     
    20832044        if (mdat.type==TYPE_DVD) {
    20842045                if (!dvd_folder.isEmpty()) {
    2085                         proc->addArgument("-dvd-device");
    2086                         proc->addArgument( dvd_folder );
     2046                        #ifdef Q_OS_WIN
     2047                        if (pref->use_short_pathnames) {
     2048                                proc->setOption("dvd-device", Helper::shortPathName(dvd_folder));
     2049                        }
     2050                        else
     2051                        #endif
     2052                        proc->setOption("dvd-device", dvd_folder);
    20872053                } else {
    20882054                        qWarning("Core::startMplayer: dvd device is empty!");
     
    20922058        if ((mdat.type==TYPE_VCD) || (mdat.type==TYPE_AUDIO_CD)) {
    20932059                if (!pref->cdrom_device.isEmpty()) {
    2094                         proc->addArgument("-cdrom-device");
    2095                         proc->addArgument( pref->cdrom_device );
    2096                 }
    2097         }
    2098 
    2099         if (mset.current_chapter_id > 0) {
    2100                 proc->addArgument("-chapter");
    2101                 int chapter = mset.current_chapter_id;
    2102                 // Fix for older versions of mplayer:
    2103                 if ((mdat.type == TYPE_DVD) && (firstChapter() == 0)) chapter++;
    2104                 proc->addArgument( QString::number( chapter ) );
     2060                        proc->setOption("cdrom-device", pref->cdrom_device);
     2061                }
    21052062        }
    21062063
    21072064        if (mset.current_angle_id > 0) {
    2108                 proc->addArgument("-dvdangle");
    2109                 proc->addArgument( QString::number( mset.current_angle_id ) );
     2065                proc->setOption("dvdangle", QString::number( mset.current_angle_id));
    21102066        }
    21112067
     
    21292085        }
    21302086
    2131         if (cache > 31) { // Minimum value for cache = 32
    2132                 proc->addArgument("-cache");
    2133                 proc->addArgument( QString::number( cache ) );
    2134         } else {
    2135                 proc->addArgument("-nocache");
    2136         }
     2087        proc->setOption("cache", QString::number(cache));
    21372088
    21382089        if (mset.speed != 1.0) {
    2139                 proc->addArgument("-speed");
    2140                 proc->addArgument( QString::number( mset.speed ) );
     2090                proc->setOption("speed", QString::number(mset.speed));
    21412091        }
    21422092
     
    21442094                // Play A - B
    21452095                if ((mset.A_marker > -1) && (mset.B_marker > mset.A_marker)) {
    2146                         proc->addArgument("-ss");
    2147                         proc->addArgument( QString::number( mset.A_marker ) );
    2148                         proc->addArgument("-endpos");
    2149                         proc->addArgument( QString::number( mset.B_marker - mset.A_marker ) );
     2096                        proc->setOption("ss", QString::number(mset.A_marker));
     2097                        proc->setOption("endpos", QString::number(mset.B_marker - mset.A_marker));
    21502098                }
    21512099                else
    21522100                // If seek < 5 it's better to allow the video to start from the beginning
    21532101                if ((seek >= 5) && (!mset.loop)) {
    2154                         proc->addArgument("-ss");
    2155                         proc->addArgument( QString::number( seek ) );
     2102                        proc->setOption("ss", QString::number(seek));
    21562103                }
    21572104        }
     
    21592106        // Enable the OSD later, to avoid a lot of messages to be
    21602107        // printed on startup
    2161         proc->addArgument("-osdlevel");
    2162         proc->addArgument( "0" );
     2108        proc->setOption("osdlevel", "0");
    21632109
    21642110        if (pref->use_idx) {
    2165                 proc->addArgument("-idx");
     2111                proc->idx");
    21662112        }
    21672113
    21682114        if (mdat.type == TYPE_STREAM) {
    21692115                if (pref->prefer_ipv4) {
    2170                         proc->addArgument("-prefer-ipv4");
     2116                        proc->prefer-ipv4");
    21712117                } else {
    2172                         proc->addArgument("-prefer-ipv6");
     2118                        proc->prefer-ipv6");
    21732119                }
    21742120        }
    21752121
    21762122        if (pref->use_correct_pts != Preferences::Detect) {
    2177                 if (pref->use_correct_pts == Preferences::Enabled) {
    2178                         proc->addArgument("-correct-pts");
    2179                 } else {
    2180                         if (pref->mplayer_detected_version > 0) {
    2181                                 if (MplayerVersion::isMplayerAtLeast(26842)) {
    2182                                         proc->addArgument("-nocorrect-pts");
    2183                                 } else {
    2184                                         proc->addArgument("-no-correct-pts");
    2185                                 }
    2186                         } else {
    2187                                 qDebug("Core::startMplayer: unknown version of mplayer, not passing -no(-)correct-pts");
    2188                         }
    2189                 }
     2123                proc->setOption("correct-pts", (pref->use_correct_pts == Preferences::Enabled));
    21902124        }
    21912125
     
    21932127
    21942128#ifndef Q_OS_WIN
    2195         if ((pref->vdpau.disable_video_filters) && (pref->vo.startsWith("vdpau"))) {
    2196                 qDebug("Core::startMplayer: using vdpau, video filters are ignored");
    2197                 goto end_video_filters;
     2129        if (proc->isMPlayer()) {
     2130                if ((pref->vdpau.disable_video_filters) && (pref->vo.startsWith("vdpau"))) {
     2131                        qDebug("Core::startMplayer: using vdpau, video filters are ignored");
     2132                        goto end_video_filters;
     2133                }
     2134        } else {
     2135                // MPV
     2136                if (!pref->hwdec.isEmpty() && pref->hwdec != "no") {
     2137                        qDebug("Core::startMplayer: hardware decoding is enabled. The video filters will be ignored");
     2138                        goto end_video_filters;
     2139                }
    21982140        }
    21992141#endif
     
    22022144        // Phase
    22032145        if (mset.phase_filter) {
    2204                 proc->addArgument("-vf-add");
    2205                 proc->addArgument( "phase=A" );
     2146                proc->addVF("phase", "A");
    22062147        }
    22072148
    22082149        // Deinterlace
    22092150        if (mset.current_deinterlacer != MediaSettings::NoDeinterlace) {
    2210                 proc->addArgument("-vf-add");
    22112151                switch (mset.current_deinterlacer) {
    2212                         case MediaSettings::L5:                 proc->addArgument("pp=l5"); break;
    2213                         case MediaSettings::Yadif:              proc->addArgument("yadif"); break;
    2214                         case MediaSettings::LB:                 proc->addArgument("pp=lb"); break;
    2215                         case MediaSettings::Yadif_1:    proc->addArgument("yadif=1"); break;
    2216                         case MediaSettings::Kerndeint:  proc->addArgument("kerndeint=5"); break;
    2217                 }
     2152                        case MediaSettings::L5:                 proc->addVF("l5"); break;
     2153                        case MediaSettings::Yadif:              proc->addVF("yadif"); break;
     2154                        case MediaSettings::LB:                 proc->addVF("lb"); break;
     2155                        case MediaSettings::Yadif_1:    proc->addVF("yadif", "1"); break;
     2156                        case MediaSettings::Kerndeint:  proc->addVF("kerndeint", "5"); break;
     2157                }
     2158        }
     2159
     2160        // 3D stereo
     2161        if (mset.stereo3d_in != "none" && !mset.stereo3d_out.isEmpty()) {
     2162                proc->addStereo3DFilter(mset.stereo3d_in, mset.stereo3d_out);
    22182163        }
    22192164
    22202165        // Denoise
    22212166        if (mset.current_denoiser != MediaSettings::NoDenoise) {
    2222                 proc->addArgument("-vf-add");
    22232167                if (mset.current_denoiser==MediaSettings::DenoiseSoft) {
    2224                         proc->addArgument( pref->filters->item("denoise_soft").filter() );
     2168                        proc->add);
    22252169                } else {
    2226                         proc->addArgument( pref->filters->item("denoise_normal").filter() );
     2170                        proc->add);
    22272171                }
    22282172        }
     
    22302174        // Unsharp
    22312175        if (mset.current_unsharp != 0) {
    2232                 proc->addArgument("-vf-add");
    22332176                if (mset.current_unsharp == 1) {
    2234                         proc->addArgument( pref->filters->item("blur").filter() );
     2177                        proc->add);
    22352178                } else {
    2236                         proc->addArgument( pref->filters->item("sharpen").filter() );
     2179                        proc->add);
    22372180                }
    22382181        }
     
    22402183        // Deblock
    22412184        if (mset.deblock_filter) {
    2242                 proc->addArgument("-vf-add");
    2243                 proc->addArgument( pref->filters->item("deblock").filter() );
     2185                proc->addVF("deblock", pref->filters->item("deblock").options());
    22442186        }
    22452187
    22462188        // Dering
    22472189        if (mset.dering_filter) {
    2248                 proc->addArgument("-vf-add");
    2249                 proc->addArgument( "pp=dr" );
     2190                proc->addVF("dering");
    22502191        }
    22512192
    22522193        // Gradfun
    22532194        if (mset.gradfun_filter) {
    2254                 proc->addArgument("-vf-add");
    2255                 proc->addArgument( pref->filters->item("gradfun").filter() );
     2195                proc->addVF("gradfun", pref->filters->item("gradfun").options());
    22562196        }
    22572197
     
    22592199        if (mset.upscaling_filter) {
    22602200                int width = DesktopInfo::desktop_size(mplayerwindow).width();
    2261                 proc->addArgument("-sws");
    2262                 proc->addArgument("9");
    2263                 proc->addArgument("-vf-add");
    2264                 proc->addArgument("scale="+QString::number(width)+":-2");
     2201                proc->setOption("sws", "9");
     2202                proc->addVF("scale", QString::number(width) + ":-2");
    22652203        }
    22662204
    22672205        // Addnoise
    22682206        if (mset.noise_filter) {
    2269                 proc->addArgument("-vf-add");
    2270                 proc->addArgument( pref->filters->item("noise").filter() );
     2207                proc->addVF("noise", pref->filters->item("noise").options());
    22712208        }
    22722209
    22732210        // Postprocessing
    22742211        if (mset.postprocessing_filter) {
    2275                 proc->addArgument("-vf-add");
    2276                 proc->addArgument("pp");
    2277                 proc->addArgument("-autoq");
    2278                 proc->addArgument( QString::number(pref->autoq) );
     2212                proc->addVF("postprocessing");
     2213                proc->setOption("autoq", QString::number(pref->autoq));
    22792214        }
    22802215
     
    22822217        // Letterbox (expand)
    22832218        if ((mset.add_letterbox) || (pref->fullscreen && pref->add_blackborders_on_fullscreen)) {
    2284                 proc->addArgument("-vf-add");
    2285                 proc->addArgument( QString("expand=:::::%1,harddup").arg( DesktopInfo::desktop_aspectRatio(mplayerwindow)) );
    2286                 // Note: on some videos (h264 for instance) the subtitles doesn't disappear,
    2287                 // appearing the new ones on top of the old ones. It seems adding another
    2288                 // filter after expand fixes the problem. I chose harddup 'cos I think
    2289                 // it will be harmless in mplayer.
    2290                 // Anyway, if you know a proper way to fix the problem, please tell me.
     2219                proc->addVF("expand", QString("aspect=%1").arg( DesktopInfo::desktop_aspectRatio(mplayerwindow)));
    22912220        }
    22922221
    22932222        // Software equalizer
    22942223        if ( (pref->use_soft_video_eq) ) {
    2295                 proc->addArgument("-vf-add");
    2296                 QString eq_filter = "eq2,hue";
     2224                proc->add");
     2225                ;
    22972226                if ( (pref->vo == "gl") || (pref->vo == "gl2") || (pref->vo == "gl_tiled")
    22982227#ifdef Q_OS_WIN
    22992228             || (pref->vo == "directx:noaccel")
    23002229#endif
    2301                     ) eq_filter += ",scale";
    2302                 proc->addArgument(eq_filter);
     2230                    )
     2231                {
     2232                        proc->addVF("scale");
     2233                }
    23032234        }
    23042235
     
    23062237        // File
    23072238        if ( !mset.mplayer_additional_video_filters.isEmpty() ) {
    2308                 proc->addArgument("-vf-add");
    2309                 proc->addArgument( mset.mplayer_additional_video_filters );
     2239                proc->setOption("vf-add", mset.mplayer_additional_video_filters);
    23102240        }
    23112241        // Global
    23122242        if ( !pref->mplayer_additional_video_filters.isEmpty() ) {
    2313                 proc->addArgument("-vf-add");
    2314                 proc->addArgument( pref->mplayer_additional_video_filters );
     2243                proc->setOption("vf-add", pref->mplayer_additional_video_filters);
    23152244        }
    23162245
     
    23192248        {
    23202249                if (pref->use_ass_subtitles) {
    2321                         proc->addArgument("-vf-add");
    2322                         proc->addArgument("ass");
     2250                        proc->addVF("subs_on_screenshots", "ass");
    23232251                } else {
    2324                         proc->addArgument("-vf-add");
    2325                         proc->addArgument("expand=osd=1");
    2326                         //proc->addArgument("-noslices");
     2252                        proc->addVF("subs_on_screenshots");
    23272253                        force_noslices = true;
    23282254                }
     
    23312257        // Rotate
    23322258        if (mset.rotate != MediaSettings::NoRotate) {
    2333                 proc->addArgument( "-vf-add" );
    2334                 proc->addArgument( QString("rotate=%1").arg(mset.rotate) );
     2259                proc->addVF("rotate", QString::number(mset.rotate));
    23352260        }
    23362261
    23372262        // Flip
    23382263        if (mset.flip) {
    2339                 proc->addArgument( "-vf-add" );
    2340                 // expand + flip doesn't work well, a workaround is to add another
    2341                 // filter between them, so that's why harddup is here
    2342                 proc->addArgument("harddup,flip");
     2264                proc->addVF("flip");
    23432265        }
    23442266
    23452267        // Mirror
    23462268        if (mset.mirror) {
    2347                 proc->addArgument( "-vf-add" );
    2348                 proc->addArgument("mirror");
     2269                proc->addVF("mirror");
    23492270        }
    23502271
    23512272        // Screenshots
    2352         if (screenshot_enabled) {
    2353                 proc->addArgument("-vf-add");
    2354                 proc->addArgument("screenshot");
    2355         }
     2273        #ifdef MPLAYER_SUPPORT
     2274        if (screenshot_enabled && proc->isMPlayer()) {
     2275                QString dir = pref->screenshot_directory;
     2276                #ifdef Q_OS_WIN
     2277                if (pref->use_short_pathnames) dir = Helper::shortPathName(pref->screenshot_directory);
     2278                #endif
     2279                proc->enableScreenshots(dir);
     2280        }
     2281        #endif
    23562282
    23572283#ifndef Q_OS_WIN
     
    23592285#endif
    23602286
     2287
     2288
     2289
     2290
     2291
     2292
     2293
     2294
     2295
     2296
    23612297        // slices
    23622298        if ((pref->use_slices) && (!force_noslices)) {
    2363                 proc->addArgument("-slices");
     2299                proc->);
    23642300        } else {
    2365                 proc->addArgument("-noslices");
     2301                proc->);
    23662302        }
    23672303
     
    23692305        // Audio channels
    23702306        if (mset.audio_use_channels != 0) {
    2371                 proc->addArgument("-channels");
    2372                 proc->addArgument( QString::number( mset.audio_use_channels ) );
    2373         }
    2374 
    2375         // Audio filters
    2376         QString af="";
    2377         if (mset.karaoke_filter) {
    2378                 af="karaoke";
    2379         }
    2380 
    2381         // Stereo mode
    2382         if (mset.stereo_mode != 0) {
    2383                 switch (mset.stereo_mode) {
    2384                         case MediaSettings::Left: af += "channels=2:2:0:1:0:0"; break;
    2385                         case MediaSettings::Right: af += "channels=2:2:1:0:1:1"; break;
    2386                         case MediaSettings::Mono: af += "pan=1:0.5:0.5"; break;
    2387                         case MediaSettings::Reverse: af += "channels=2:2:0:1:1:0"; break;
    2388                 }
    2389         }
    2390 
    2391         if (mset.extrastereo_filter) {
    2392                 if (!af.isEmpty()) af += ",";
    2393                 af += "extrastereo";
    2394         }
    2395 
    2396         if (mset.volnorm_filter) {
    2397                 if (!af.isEmpty()) af += ",";
    2398                 af += pref->filters->item("volnorm").filter();
    2399         }
    2400 
    2401         bool use_scaletempo = (pref->use_scaletempo == Preferences::Enabled);
    2402         if (pref->use_scaletempo == Preferences::Detect) {
    2403                 use_scaletempo = (MplayerVersion::isMplayerAtLeast(24924));
    2404         }
    2405         if (use_scaletempo) {
    2406                 if (!af.isEmpty()) af += ",";
    2407                 af += "scaletempo";
    2408         }
    2409 
    2410         // Audio equalizer
    2411         if (pref->use_audio_equalizer) {
    2412                 if (!af.isEmpty()) af += ",";
    2413                 AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : mset.audio_equalizer;
    2414                 af += "equalizer=" + Helper::equalizerListToString(l);
    2415         }
    2416 
    2417 
    2418         // Additional audio filters, supplied by user
    2419         // File
    2420         if ( !pref->mplayer_additional_audio_filters.isEmpty() ) {
    2421                 if (!af.isEmpty()) af += ",";
    2422                 af += pref->mplayer_additional_audio_filters;
    2423         }
    2424         // Global
    2425         if ( !mset.mplayer_additional_audio_filters.isEmpty() ) {
    2426                 if (!af.isEmpty()) af += ",";
    2427                 af += mset.mplayer_additional_audio_filters;
    2428         }
    2429 
    2430         if (!af.isEmpty()) {
     2307                proc->setOption("channels", QString::number(mset.audio_use_channels));
     2308        }
     2309
     2310        if (!pref->use_hwac3) {
     2311
     2312                // Audio filters
     2313                #ifdef MPLAYER_SUPPORT
     2314                if (mset.karaoke_filter) {
     2315                        proc->addAF("karaoke");
     2316                }
     2317                #endif
     2318
     2319                // Stereo mode
     2320                if (mset.stereo_mode != 0) {
     2321                        switch (mset.stereo_mode) {
     2322                                case MediaSettings::Left: proc->addAF("channels", "2:2:0:1:0:0"); break;
     2323                                case MediaSettings::Right: proc->addAF("channels", "2:2:1:0:1:1"); break;
     2324                                case MediaSettings::Mono: proc->addAF("pan", "1:0.5:0.5"); break;
     2325                                case MediaSettings::Reverse: proc->addAF("channels", "2:2:0:1:1:0"); break;
     2326                        }
     2327                }
     2328
     2329                if (mset.extrastereo_filter) {
     2330                        proc->addAF("extrastereo");
     2331                }
     2332
     2333                if (mset.volnorm_filter) {
     2334                        proc->addAF("volnorm", pref->filters->item("volnorm").options());
     2335                }
     2336
     2337                bool use_scaletempo = (pref->use_scaletempo == Preferences::Enabled);
     2338                if (pref->use_scaletempo == Preferences::Detect) {
     2339                        use_scaletempo = (MplayerVersion::isMplayerAtLeast(24924));
     2340                }
     2341                if (use_scaletempo) {
     2342                        proc->addAF("scaletempo");
     2343                }
     2344
     2345                // Audio equalizer
     2346                if (pref->use_audio_equalizer) {
     2347                        AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : mset.audio_equalizer;
     2348                        proc->addAF("equalizer", Helper::equalizerListToString(l));
     2349                }
     2350
     2351                // Additional audio filters, supplied by user
     2352                // File
     2353                if ( !pref->mplayer_additional_audio_filters.isEmpty() ) {
     2354                        proc->setOption("af-add", pref->mplayer_additional_audio_filters);
     2355                }
     2356                // Global
     2357                if ( !mset.mplayer_additional_audio_filters.isEmpty() ) {
     2358                        proc->setOption("af-add", mset.mplayer_additional_audio_filters);
     2359                }
     2360        } else {
    24312361                // Don't use audio filters if using the S/PDIF output
    2432                 if (pref->use_hwac3) {
    24332362                        qDebug("Core::startMplayer: audio filters are disabled when using the S/PDIF output!");
    2434                 } else {
    2435                         proc->addArgument("-af");
    2436                         proc->addArgument( af );
    2437                 }
    24382363        }
    24392364
    24402365        if (pref->use_soft_vol) {
    2441                 proc->addArgument("-softvol");
    2442                 proc->addArgument("-softvol-max");
    2443                 proc->addArgument( QString::number(pref->softvol_max) );
    2444         }
     2366                proc->setOption("softvol");
     2367                proc->setOption("softvol-max", QString::number(pref->softvol_max));
     2368        }
     2369
     2370#ifdef MPV_SUPPORT
     2371        if (pref->streaming_type == Preferences::StreamingAuto) {
     2372                bool is_youtube = false;
     2373                #ifdef YOUTUBE_SUPPORT
     2374                if (PREF_YT_ENABLED) is_youtube = (file == yt->latestPreferredUrl());
     2375                #endif
     2376                qDebug() << "Core::startMplayer: is_youtube:" << is_youtube;
     2377                proc->setOption("enable_streaming_sites_support", !is_youtube);
     2378        } else {
     2379                proc->setOption("enable_streaming_sites_support", pref->streaming_type == Preferences::StreamingYTDL);
     2380        }
     2381#endif
     2382
     2383#ifndef Q_OS_WIN
     2384        if (proc->isMPV() && file.startsWith("dvb:")) {
     2385                QString channels_file = TVList::findChannelsFile();
     2386                qDebug("Core::startMplayer: channels_file: %s", channels_file.toUtf8().constData());
     2387                if (!channels_file.isEmpty()) proc->setChannelsFile(channels_file);
     2388        }
     2389#endif
     2390
     2391#ifdef CAPTURE_STREAM
     2392        // Set the capture directory
     2393        proc->setCaptureDirectory(pref->capture_directory);
     2394#endif
    24452395
    24462396        // Load edl file
     
    24602410                qDebug("Core::startMplayer: edl file: '%s'", edl_f.toUtf8().data());
    24612411                if (!edl_f.isEmpty()) {
    2462                         proc->addArgument("-edl");
    2463                         proc->addArgument(edl_f);
     2412                        proc->setOption("edl", edl_f);
    24642413                }
    24652414        }
     
    24692418        if (!mset.mplayer_additional_options.isEmpty()) {
    24702419                QStringList args = MyProcess::splitArguments(mset.mplayer_additional_options);
    2471         QStringList::Iterator it = args.begin();
    2472         while( it != args.end() ) {
    2473                         proc->addArgument( (*it) );
    2474                         ++it;
    2475                 }
    2476         }
     2420                for (int n = 0; n < args.count(); n++) {
     2421                        QString arg = args[n].simplified();
     2422                        if (!arg.isEmpty()) {
     2423                                proc->addUserOption(arg);
     2424                        }
     2425                }
     2426        }
     2427
    24772428        // Global
    24782429        if (!pref->mplayer_additional_options.isEmpty()) {
    24792430                QString additional_options = pref->mplayer_additional_options;
     2431
    24802432                // mplayer2 doesn't support -fontconfig and -nofontconfig
    24812433                if (pref->mplayer_is_mplayer2) {
     
    24832435                        additional_options.replace("-nofontconfig", "");
    24842436                }
     2437
    24852438                QStringList args = MyProcess::splitArguments(additional_options);
    24862439                for (int n = 0; n < args.count(); n++) {
     
    24882441                        if (!arg.isEmpty()) {
    24892442                                qDebug("arg %d: %s", n, arg.toUtf8().constData());
    2490                                 proc->addArgument(arg);
     2443                                proc->add(arg);
    24912444                        }
    24922445                }
    2493         }
    2494 
    2495         // File to play
    2496         if (url_is_playlist) {
    2497                 proc->addArgument("-playlist");
    2498         }
     2446
     2447        }
     2448
     2449        // Last checks for the file
     2450
     2451        // Open https URLs with ffmpeg
     2452        #if 0
     2453        // It doesn't seem necessary anymore
     2454        if (proc->isMPlayer() && file.startsWith("https")) {
     2455                file = "ffmpeg://" + file;
     2456        }
     2457        #endif
     2458
     2459#if DVDNAV_SUPPORT
     2460        if (proc->isMPV() && file.startsWith("dvdnav:")) {
     2461                // Hack to open the DVD menu with MPV
     2462                file = "dvd://menu";
     2463        }
     2464#endif
    24992465
    25002466#ifdef Q_OS_WIN
    2501         if (pref->use_short_pathnames)
    2502                 proc->addArgument(Helper::shortPathName(file));
    2503         else
    2504 #endif
    2505         proc->addArgument( file );
     2467        if (pref->use_short_pathnames) {
     2468                file = Helper::shortPathName(file);
     2469        }
     2470#endif
     2471
     2472#ifdef MPLAYER_SUPPORT
     2473        if (proc->isMPlayer()) {
     2474                proc->setMedia(file, pref->use_playlist_option ? url_is_playlist : false);
     2475        } else
     2476#endif
     2477        {
     2478                proc->setMedia(file, false); // Don't use playlist with mpv
     2479        }
    25062480
    25072481        // It seems the loop option must be after the filename
    25082482        if (mset.loop) {
    2509                 proc->addArgument("-loop");
    2510                 proc->addArgument("0");
     2483                proc->setOption("loop", "0");
    25112484        }
    25122485
     
    25202493        emit logLineAvailable(line_for_log);
    25212494
    2522 #ifdef Q_OS_WIN
    25232495        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
     2496
     2497
     2498
     2499
     2500
     2501
    25242502        if (!pref->use_windowsfontdir) {
    25252503                env.insert("FONTCONFIG_FILE", Paths::configPath() + "/fonts.conf");
    25262504        }
     2505
    25272506        proc->setProcessEnvironment(env);
    2528 #endif
     2507
    25292508        if ( !proc->start() ) {
    25302509            // error handling
     
    25382517
    25392518        if (!proc->isRunning()) {
    2540                 qWarning("Core::stopMplayer: mplayer in not running!");
     2519                qWarning("Core::stopMplayer: mplayer i not running!");
    25412520                return;
    25422521        }
     
    25472526        connect(proc, SIGNAL(processExited()), &eventLoop, SLOT(quit()));
    25482527
    2549         tellmp("quit");
     2528        );
    25502529
    25512530        QTimer::singleShot(5000, &eventLoop, SLOT(quit()));
     
    25572536        }
    25582537#else
    2559     tellmp("quit");
    2560    
     2538);
     2539
    25612540        qDebug("Core::stopMplayer: Waiting mplayer to finish...");
    25622541        if (!proc->waitForFinished(pref->time_to_kill_mplayer)) {
     
    25732552        qDebug("Core::goToSec: %f", sec);
    25742553
    2575     if (sec < 0) sec = 0;
    2576     if (sec > mdat.duration ) sec = mdat.duration - 20;
    2577     tellmp( seek_cmd(sec, 2) );
     2554if (sec < 0) sec = 0;
     2555if (sec > mdat.duration ) sec = mdat.duration - 20;
     2556);
    25782557}
    25792558
     
    25822561        qDebug("Core::seek: %d", secs);
    25832562        if ( (proc->isRunning()) && (secs!=0) ) {
    2584                 tellmp( seek_cmd(secs, 0) );
    2585         }
    2586 }
    2587 
    2588 QString Core::seek_cmd(double secs, int mode) {
    2589         QString s = QString("seek %1 %2").arg(secs).arg(mode);
    2590         if (MplayerVersion::isMplayer2()) {
    2591                 //hr-seek
    2592                 if (pref->precise_seeking) s += " 1"; else s += " -1";
    2593         }
    2594         return s;
     2563                seek_cmd(secs, 0);
     2564        }
     2565}
     2566
     2567void Core::seek_cmd(double secs, int mode) {
     2568        proc->seek(secs, mode, pref->precise_seeking);
    25952569}
    25962570
     
    26382612        seek(-secs);
    26392613}
     2614
     2615
     2616
     2617
     2618
     2619
     2620
     2621
     2622
     2623
     2624
     2625
    26402626
    26412627void Core::wheelUp() {
     
    27212707                        int v = -1; // no loop
    27222708                        if (mset.loop) v = 0; // infinite loop
    2723                         tellmp( QString("loop %1 1").arg(v) );
     2709                        );
    27242710                } else {
    27252711                        // Restart mplayer
     
    27302716
    27312717
    2732 void Core::toggleFlip() {
    2733         qDebug("Core::toggleFlip");
    2734         toggleFlip( !mset.flip );
    2735 }
    2736 
    2737 void Core::toggleFlip(bool b) {
    2738         qDebug("Core::toggleFlip: %d", b);
    2739 
    2740         if (mset.flip != b) {
    2741                 mset.flip = b;
    2742                 if (proc->isRunning()) restartPlay();
    2743         }
    2744 }
    2745 
    2746 void Core::toggleMirror() {
    2747         qDebug("Core::toggleMirror");
    2748         toggleMirror( !mset.mirror );
    2749 }
    2750 
    2751 void Core::toggleMirror(bool b) {
    2752         qDebug("Core::toggleMirror: %d", b);
    2753 
    2754         if (mset.mirror != b) {
    2755                 mset.mirror = b;
    2756                 if (proc->isRunning()) restartPlay();
    2757         }
    2758 }
    2759 
    27602718// Audio filters
     2719
    27612720void Core::toggleKaraoke() {
    27622721        toggleKaraoke( !mset.karaoke_filter );
     
    27692728                if (MplayerVersion::isMplayerAtLeast(31030)) {
    27702729                        // Change filter without restarting
    2771                         if (b) tellmp("af_add karaoke"); else tellmp("af_del karaoke");
     2730                        );
    27722731                } else {
    27732732                        restartPlay();
     
    27752734        }
    27762735}
     2736
    27772737
    27782738void Core::toggleExtrastereo() {
     
    27862746                if (MplayerVersion::isMplayerAtLeast(31030)) {
    27872747                        // Change filter without restarting
    2788                         if (b) tellmp("af_add extrastereo"); else tellmp("af_del extrastereo");
     2748                        );
    27892749                } else {
    27902750                        restartPlay();
     
    28042764                        // Change filter without restarting
    28052765                        QString f = pref->filters->item("volnorm").filter();
    2806                         if (b) tellmp("af_add " + f); else tellmp("af_del volnorm");
     2766                        );
    28072767                } else {
    28082768                        restartPlay();
     
    28292789
    28302790// Video filters
     2791
     2792
     2793
     2794
     2795
     2796
     2797
     2798
     2799
     2800
     2801
     2802
     2803
     2804
     2805
     2806
     2807
     2808
     2809
     2810
     2811
     2812
     2813
     2814
     2815
     2816
     2817
     2818
     2819
     2820
     2821
     2822
     2823
     2824
    28312825void Core::toggleAutophase() {
    28322826        toggleAutophase( !mset.phase_filter );
     
    28372831        if ( b != mset.phase_filter) {
    28382832                mset.phase_filter = b;
    2839                 restartPlay();
     2833                );
    28402834        }
    28412835}
     
    28492843        if ( b != mset.deblock_filter ) {
    28502844                mset.deblock_filter = b;
    2851                 restartPlay();
     2845                );
    28522846        }
    28532847}
     
    28612855        if ( b != mset.dering_filter) {
    28622856                mset.dering_filter = b;
    2863                 restartPlay();
     2857                );
    28642858        }
    28652859}
     
    28732867        if ( b != mset.gradfun_filter) {
    28742868                mset.gradfun_filter = b;
    2875                 restartPlay();
     2869                );
    28762870        }
    28772871}
     
    28832877void Core::toggleNoise(bool b) {
    28842878        qDebug("Core::toggleNoise: %d", b);
    2885         if ( b!= mset.noise_filter ) {
     2879        if ( b!= mset.noise_filter ) {
    28862880                mset.noise_filter = b;
    2887                 restartPlay();
     2881                );
    28882882        }
    28892883}
     
    28972891        if ( b != mset.postprocessing_filter ) {
    28982892                mset.postprocessing_filter = b;
    2899                 restartPlay();
     2893                );
    29002894        }
    29012895}
     
    29042898        qDebug( "Core::changeDenoise: %d", id );
    29052899        if (id != mset.current_denoiser) {
    2906                 mset.current_denoiser = id;
    2907                 restartPlay();
     2900                if (proc->isMPlayer()) {
     2901                        mset.current_denoiser = id;
     2902                        restartPlay();
     2903                } else {
     2904                        // MPV
     2905                        QString dsoft = pref->filters->item("denoise_soft").options();
     2906                        QString dnormal = pref->filters->item("denoise_normal").options();
     2907                        // Remove previous filter
     2908                        switch (mset.current_denoiser) {
     2909                                case MediaSettings::DenoiseSoft: proc->changeVF("hqdn3d", false, dsoft); break;
     2910                                case MediaSettings::DenoiseNormal: proc->changeVF("hqdn3d", false, dnormal); break;
     2911                        }
     2912                        // New filter
     2913                        mset.current_denoiser = id;
     2914                        switch (mset.current_denoiser) {
     2915                                case MediaSettings::DenoiseSoft: proc->changeVF("hqdn3d", true, dsoft); break;
     2916                                case MediaSettings::DenoiseNormal: proc->changeVF("hqdn3d", true, dnormal); break;
     2917                        }
     2918                }
    29082919        }
    29092920}
     
    29122923        qDebug( "Core::changeUnsharp: %d", id );
    29132924        if (id != mset.current_unsharp) {
    2914                 mset.current_unsharp = id;
    2915                 restartPlay();
     2925                if (proc->isMPlayer()) {
     2926                        mset.current_unsharp = id;
     2927                        restartPlay();
     2928                } else {
     2929                        // MPV
     2930                        // Remove previous filter
     2931                        switch (mset.current_unsharp) {
     2932                                // Current is blur
     2933                                case 1: proc->changeVF("blur", false); break;
     2934                                // Current if sharpen
     2935                                case 2: proc->changeVF("sharpen", false); break;
     2936                        }
     2937                        // New filter
     2938                        mset.current_unsharp = id;
     2939                        switch (mset.current_unsharp) {
     2940                                case 1: proc->changeVF("blur", true); break;
     2941                                case 2: proc->changeVF("sharpen", true); break;
     2942                        }
     2943                }
    29162944        }
    29172945}
     
    29212949        if (mset.upscaling_filter != b) {
    29222950                mset.upscaling_filter = b;
    2923                 restartPlay();
     2951                int width = DesktopInfo::desktop_size(mplayerwindow).width();
     2952                CHANGE_VF("scale", b, QString::number(width) + ":-2");
     2953        }
     2954}
     2955
     2956void Core::changeStereo3d(const QString & in, const QString & out) {
     2957        qDebug("Core::changeStereo3d: in: %s out: %s", in.toUtf8().constData(), out.toUtf8().constData());
     2958
     2959        if ((mset.stereo3d_in != in) || (mset.stereo3d_out != out)) {
     2960                if (proc->isMPlayer()) {
     2961                        mset.stereo3d_in = in;
     2962                        mset.stereo3d_out = out;
     2963                        restartPlay();
     2964                } else {
     2965                        // Remove previous filter
     2966                        if (mset.stereo3d_in != "none" && !mset.stereo3d_out.isEmpty()) {
     2967                                proc->changeStereo3DFilter(false, mset.stereo3d_in, mset.stereo3d_out);
     2968                        }
     2969
     2970                        // New filter
     2971                        mset.stereo3d_in = in;
     2972                        mset.stereo3d_out = out;
     2973                        if (mset.stereo3d_in != "none" && !mset.stereo3d_out.isEmpty()) {
     2974                                proc->changeStereo3DFilter(true, mset.stereo3d_in, mset.stereo3d_out);
     2975                        }
     2976                }
    29242977        }
    29252978}
     
    29322985
    29332986        if (value != mset.brightness) {
    2934                 tellmp(pausing_prefix() + " brightness " + QString::number(value) + " 1");
     2987                proc->setPausingPrefix(pausing_prefix());
     2988                proc->setBrightness(value);
    29352989                mset.brightness = value;
    29362990                displayMessage( tr("Brightness: %1").arg(value) );
     
    29473001
    29483002        if (value != mset.contrast) {
    2949                 tellmp(pausing_prefix() + " contrast " + QString::number(value) + " 1");
     3003                proc->setPausingPrefix(pausing_prefix());
     3004                proc->setContrast(value);
    29503005                mset.contrast = value;
    29513006                displayMessage( tr("Contrast: %1").arg(value) );
     
    29613016
    29623017        if (value != mset.gamma) {
    2963                 tellmp(pausing_prefix() + " gamma " + QString::number(value) + " 1");
     3018                proc->setPausingPrefix(pausing_prefix());
     3019                proc->setGamma(value);
    29643020                mset.gamma= value;
    29653021                displayMessage( tr("Gamma: %1").arg(value) );
     
    29753031
    29763032        if (value != mset.hue) {
    2977                 tellmp(pausing_prefix() + " hue " + QString::number(value) + " 1");
     3033                proc->setPausingPrefix(pausing_prefix());
     3034                proc->setHue(value);
    29783035                mset.hue = value;
    29793036                displayMessage( tr("Hue: %1").arg(value) );
     
    29893046
    29903047        if (value != mset.saturation) {
    2991                 tellmp(pausing_prefix() + " saturation " + QString::number(value) + " 1");
     3048                proc->setPausingPrefix(pausing_prefix());
     3049                proc->setSaturation(value);
    29923050                mset.saturation = value;
    29933051                displayMessage( tr("Saturation: %1").arg(value) );
     
    30433101
    30443102        mset.speed = value;
    3045         tellmp( "speed_set " + QString::number( value ) );
     3103        );
    30463104
    30473105        displayMessage( tr("Speed: %1").arg(value) );
     
    30923150}
    30933151
     3152
     3153
     3154
     3155
     3156
     3157
     3158
    30943159void Core::setVolume(int volume, bool force) {
    30953160        qDebug("Core::setVolume: %d", volume);
     
    31033168        if (current_volume < 0) current_volume = 0;
    31043169
    3105         if (state() == Paused) {
    3106                 // Change volume later, after quiting pause
    3107                 change_volume_after_unpause = true;
     3170        if (proc->isMPV()) {
     3171                // MPV
     3172                int vol = adjustVolume(current_volume, pref->use_soft_vol ? pref->softvol_max : 100);
     3173                proc->setVolume(vol);
    31083174        } else {
    3109                 tellmp("volume " + QString::number(current_volume) + " 1");
     3175                // MPlayer
     3176                if (state() == Paused) {
     3177                        // Change volume later, after quiting pause
     3178                        change_volume_after_unpause = true;
     3179                } else {
     3180                        proc->setVolume(current_volume);
     3181                }
    31103182        }
    31113183
     
    31343206        qDebug("Core::mute");
    31353207
    3136         int v = (b ? 1 : 0);
    3137         tellmp( pausing_prefix() + " mute " + QString::number(v) );
     3208        );
     3209        );
    31383210
    31393211        if (pref->global_volume) {
     
    31463218}
    31473219
     3220
     3221
     3222
     3223
     3224
     3225
     3226
     3227
     3228
     3229
     3230
     3231
    31483232void Core::incVolume() {
    31493233        qDebug("Core::incVolume");
    3150         int new_vol = (pref->global_volume ? pref->volume + pref->min_step : mset.volume + pref->min_step);
    3151         setVolume(new_vol);
     3234        incVolume(pref->min_step);
    31523235}
    31533236
    31543237void Core::decVolume() {
    31553238        qDebug("Core::incVolume");
    3156         int new_vol = (pref->global_volume ? pref->volume - pref->min_step : mset.volume - pref->min_step);
    3157         setVolume(new_vol);
     3239        decVolume(pref->min_step);
    31583240}
    31593241
     
    31613243        qDebug("Core::setSubDelay: %d", delay);
    31623244        mset.sub_delay = delay;
    3163         tellmp( pausing_prefix() + " sub_delay " + QString::number( (double) mset.sub_delay/1000 ) +" 1");
     3245        proc->setPausingPrefix(pausing_prefix());
     3246        proc->setSubDelay((double) mset.sub_delay/1000);
    31643247        displayMessage( tr("Subtitle delay: %1 ms").arg(delay) );
    31653248}
     
    31783261        qDebug("Core::setAudioDelay: %d", delay);
    31793262        mset.audio_delay = delay;
    3180         tellmp( pausing_prefix() + " audio_delay " + QString::number( (double) mset.audio_delay/1000 ) +" 1");
     3263        proc->setPausingPrefix(pausing_prefix());
     3264        proc->setAudioDelay((double) mset.audio_delay/1000);
    31813265        displayMessage( tr("Audio delay: %1 ms").arg(delay) );
    31823266}
     
    31973281        mset.sub_pos++;
    31983282        if (mset.sub_pos > 100) mset.sub_pos = 100;
    3199         tellmp("sub_pos " + QString::number( mset.sub_pos ) + " 1");
     3283        );
    32003284}
    32013285
     
    32053289        mset.sub_pos--;
    32063290        if (mset.sub_pos < 0) mset.sub_pos = 0;
    3207         tellmp("sub_pos " + QString::number( mset.sub_pos ) + " 1");
     3291        );
    32083292}
    32093293
     
    32343318                                restartPlay();
    32353319                        } else {
    3236                                 tellmp("sub_scale " + QString::number( mset.sub_scale_ass ) + " 1");
     3320                                );
    32373321                        }
    32383322                        displayMessage( tr("Font scale: %1").arg(mset.sub_scale_ass) );
     
    32453329                                restartPlay();
    32463330                        } else {
    3247                                 tellmp("sub_scale " + QString::number( mset.sub_scale ) + " 1");
    3248                                
     3331                                proc->setSubScale(mset.sub_scale);
    32493332                        }
    32503333                        displayMessage( tr("Font scale: %1").arg(mset.sub_scale) );
     
    32753358}
    32763359
     3360
     3361
     3362
     3363
     3364
     3365
     3366
     3367
     3368
     3369
     3370
     3371
     3372
     3373
     3374
     3375
     3376
     3377
     3378
     3379
     3380
     3381
     3382
     3383
     3384
     3385
     3386
     3387
     3388
     3389
     3390
     3391
     3392
     3393
    32773394void Core::incSubStep() {
    32783395        qDebug("Core::incSubStep");
    3279         tellmp("sub_step +1");
     3396        );
    32803397}
    32813398
    32823399void Core::decSubStep() {
    32833400        qDebug("Core::decSubStep");
    3284         tellmp("sub_step -1");
     3401        );
    32853402}
    32863403
     
    32883405        qDebug("Core::changeSubVisilibity: %d", visible);
    32893406        pref->sub_visibility = visible;
    3290         tellmp(QString("sub_visibility %1").arg(pref->sub_visibility ? 1 : 0));
     3407        );
    32913408
    32923409        if (pref->sub_visibility)
     
    33133430
    33143431        if (!restart) {
    3315                 const char *command = "af_cmdline equalizer ";
    3316                 if (!MplayerVersion::isMplayerAtLeast(32505))
    3317                         command = "af_eq_set_bands ";
    3318                 tellmp( command + Helper::equalizerListToString(values) );
     3432                proc->setAudioEqualizer(Helper::equalizerListToString(values));
    33193433        } else {
    33203434                restartPlay();
    33213435        }
    33223436
    3323         emit audioEqualizerNeedsUpdate();
     3437        // Infinite recursion
     3438        //emit audioEqualizerNeedsUpdate();
    33243439}
    33253440
     
    33843499        if (mset.starting_time != -1) {
    33853500                mset.current_sec -= mset.starting_time;
     3501
     3502
     3503
     3504
     3505
    33863506        }
    33873507       
     
    34293549}
    34303550
     3551
     3552
     3553
     3554
     3555
     3556
     3557
    34313558
    34323559void Core::changePause() {
     
    34403567        qDebug("Core::changeDeinterlace: %d", ID);
    34413568
    3442         if (ID!=mset.current_deinterlacer) {
    3443                 mset.current_deinterlacer = ID;
    3444                 restartPlay();
     3569        if (ID != mset.current_deinterlacer) {
     3570                if (proc->isMPlayer()) {
     3571                        mset.current_deinterlacer = ID;
     3572                        restartPlay();
     3573                } else {
     3574                        // MPV
     3575                        // Remove previous filter
     3576                        switch (mset.current_deinterlacer) {
     3577                                case MediaSettings::L5:                 proc->changeVF("l5", false); break;
     3578                                case MediaSettings::Yadif:              proc->changeVF("yadif", false); break;
     3579                                case MediaSettings::LB:                 proc->changeVF("lb", false); break;
     3580                                case MediaSettings::Yadif_1:    proc->changeVF("yadif", false, "1"); break;
     3581                                case MediaSettings::Kerndeint:  proc->changeVF("kerndeint", false, "5"); break;
     3582                        }
     3583                        mset.current_deinterlacer = ID;
     3584                        // New filter
     3585                        switch (mset.current_deinterlacer) {
     3586                                case MediaSettings::L5:                 proc->changeVF("l5", true); break;
     3587                                case MediaSettings::Yadif:              proc->changeVF("yadif", true); break;
     3588                                case MediaSettings::LB:                 proc->changeVF("lb", true); break;
     3589                                case MediaSettings::Yadif_1:    proc->changeVF("yadif", true, "1"); break;
     3590                                case MediaSettings::Kerndeint:  proc->changeVF("kerndeint", true, "5"); break;
     3591                        }
     3592                }
    34453593        }
    34463594}
     
    34633611        qDebug("Core::changeSubtitle: ID: %d", ID);
    34643612
    3465         bool use_new_commands = (pref->use_new_sub_commands == Preferences::Enabled);
    3466         if (pref->use_new_sub_commands == Preferences::Detect) {
    3467                 use_new_commands = (MplayerVersion::isMplayerAtLeast(25158));
    3468         }
    3469 
    3470         if (!use_new_commands) {
    3471                 // Old command sub_select
    3472                 tellmp( "sub_select " + QString::number(ID) );
     3613        int real_id = -1;
     3614        if (ID == -1) {
     3615                proc->disableSubtitles();
    34733616        } else {
    3474                 // New commands
    3475                 int real_id = -1;
    3476                 if (ID == -1) {
    3477                         tellmp( "sub_source -1" );
     3617                bool valid_item = ( (ID >= 0) && (ID < mdat.subs.numItems()) );
     3618                if (!valid_item) qWarning("Core::changeSubtitle: ID: %d is not valid!", ID);
     3619                if ( (mdat.subs.numItems() > 0) && (valid_item) ) {
     3620                        real_id = mdat.subs.itemAt(ID).ID();
     3621                        proc->setSubtitle(mdat.subs.itemAt(ID).type(), real_id);
    34783622                } else {
    3479                         bool valid_item = ( (ID >= 0) && (ID < mdat.subs.numItems()) );
    3480                         if (!valid_item) qWarning("Core::changeSubtitle: ID: %d is not valid!", ID);
    3481                         if ( (mdat.subs.numItems() > 0) && (valid_item) ) {
    3482                                 real_id = mdat.subs.itemAt(ID).ID();
    3483                                 switch (mdat.subs.itemAt(ID).type()) {
    3484                                         case SubData::Vob:
    3485                                                 tellmp( "sub_vob " + QString::number(real_id) );
    3486                                                 break;
    3487                                         case SubData::Sub:
    3488                                                 tellmp( "sub_demux " + QString::number(real_id) );
    3489                                                 break;
    3490                                         case SubData::File:
    3491                                                 tellmp( "sub_file " + QString::number(real_id) );
    3492                                                 break;
    3493                                         default: {
    3494                                                 qWarning("Core::changeSubtitle: unknown type!");
    3495                                         }
    3496                                 }
    3497                         } else {
    3498                                 qWarning("Core::changeSubtitle: subtitle list is empty!");
    3499                         }
     3623                        qWarning("Core::changeSubtitle: subtitle list is empty!");
    35003624                }
    35013625        }
     
    35213645}
    35223646
     3647
     3648
     3649
     3650
     3651
     3652
     3653
     3654
     3655
     3656
     3657
     3658
     3659
     3660
     3661
     3662
     3663
     3664
     3665
     3666
     3667
     3668
     3669
     3670
     3671
     3672
     3673
    35233674void Core::changeAudio(int ID, bool allow_restart) {
    35243675        qDebug("Core::changeAudio: ID: %d, allow_restart: %d", ID, allow_restart);
     
    35293680
    35303681                bool need_restart = false;
     3682
    35313683                if (allow_restart) {
    35323684                        need_restart = (pref->fast_audio_change == Preferences::Disabled);
     
    35353687                        }
    35363688                }
     3689
    35373690
    35383691                if (need_restart) {
    3539                         restartPlay(); 
     3692                        restartPlay();
    35403693                } else {
    3541                         tellmp("switch_audio " + QString::number(ID) );
     3694                        );
    35423695                        // Workaround for a mplayer problem in windows,
    35433696                        // volume is too loud after changing audio.
     
    35463699                        // the volume is reduced if using -softvol-max.
    35473700
    3548                         if (pref->mplayer_additional_options.contains("-volume")) {
    3549                                 qDebug("Core::changeAudio: don't set volume since -volume is used");
    3550                         } else {
    3551                                 if (pref->global_volume) {
    3552                                         setVolume( pref->volume, true);
    3553                                         if (pref->mute) mute(true);
     3701                        if (proc->isMPlayer()) {
     3702                                if (pref->mplayer_additional_options.contains("-volume")) {
     3703                                        qDebug("Core::changeAudio: don't set volume since -volume is used");
    35543704                                } else {
    3555                                         setVolume( mset.volume, true );
    3556                                         if (mset.mute) mute(true); // if muted, mute again
     3705                                        if (pref->global_volume) {
     3706                                                setVolume( pref->volume, true);
     3707                                                if (pref->mute) mute(true);
     3708                                        } else {
     3709                                                setVolume( mset.volume, true );
     3710                                                if (mset.mute) mute(true); // if muted, mute again
     3711                                        }
    35573712                                }
    35583713                        }
     
    35963751                        if (mdat.demuxer == "nsv") {
    35973752                                // Workaround a problem with the nsv demuxer
    3598                                 qWarning("Core::changeVideo: not calling set_property switch_video with nsv to prevent mplayer go crazy");
     3753                                qWarning("Core::changeVideo: not cvideo with nsv to prevent mplayer go crazy");
    35993754                        } else {
    3600                                 tellmp("set_property switch_video " + QString::number(ID) );
     3755                                );
    36013756                        }
    36023757                }
     
    36263781        if (ID != mset.current_program_id) {
    36273782                mset.current_program_id = ID;
    3628                 tellmp("set_property switch_program " + QString::number(ID) );
    3629 
    3630                 tellmp("get_property switch_audio");
    3631                 tellmp("get_property switch_video");
     3783                proc->setTSProgram(ID);
    36323784
    36333785                /*
     
    36613813                #if DVDNAV_SUPPORT
    36623814                if (mdat.filename.startsWith("dvdnav:")) {
    3663                         tellmp("switch_title " + QString::number(ID));
     3815                        );
    36643816                } else {
    36653817                #endif
     
    36893841void Core::changeChapter(int ID) {
    36903842        qDebug("Core::changeChapter: ID: %d", ID);
    3691 
    3692         if (mdat.type != TYPE_DVD) {
    3693                 /*
    3694                 if (mdat.chapters.find(ID) > -1) {
    3695                         double start = mdat.chapters.item(ID).start();
    3696                         qDebug("Core::changeChapter: start: %f", start);
    3697                         goToSec(start);
    3698                         mset.current_chapter_id = ID;
    3699                 } else {
    3700                 */
    3701                         tellmp("seek_chapter " + QString::number(ID) +" 1");
    3702                         mset.current_chapter_id = ID;
    3703                         //updateWidgets();
    3704                 /*
    3705                 }
    3706                 */
    3707         } else {
    3708 #if SMART_DVD_CHAPTERS
    3709                 if (pref->cache_for_dvds == 0) {
    3710 #else
    3711                 if (pref->fast_chapter_change) {
    3712 #endif
    3713                         tellmp("seek_chapter " + QString::number(ID) +" 1");
    3714                         mset.current_chapter_id = ID;
    3715                         updateWidgets();
    3716                 } else {
    3717                         stopMplayer();
    3718                         mset.current_chapter_id = ID;
    3719                         //goToPos(0);
    3720                         mset.current_sec = 0;
    3721                         restartPlay();
    3722                 }
    3723         }
     3843        proc->setChapter(ID);
    37243844}
    37253845
     
    37323852}
    37333853
     3854
     3855
     3856
     3857
     3858
     3859
     3860
     3861
     3862
     3863
     3864
     3865
     3866
     3867
     3868
     3869
    37343870void Core::prevChapter() {
    37353871        qDebug("Core::prevChapter");
    3736 
    3737         int last_chapter = 0;
    3738         int first_chapter = firstChapter();
    3739 
    3740         int ID = mdat.chapters.itemBeforeTime(mset.current_sec).ID();
    3741 
    3742         if (ID == -1) {
    3743                 last_chapter = mdat.n_chapters + firstChapter() - 1;
    3744 
    3745                 ID = mset.current_chapter_id - 1;
    3746                 if (ID < first_chapter) {
    3747                         ID = last_chapter;
    3748                 }
    3749         }
    3750 
    3751         changeChapter(ID);
     3872        proc->previousChapter();
    37523873}
    37533874
    37543875void Core::nextChapter() {
    37553876        qDebug("Core::nextChapter");
    3756 
    3757         int last_chapter = mdat.n_chapters + firstChapter() - 1;
    3758 
    3759         int ID = mdat.chapters.itemAfterTime(mset.current_sec).ID();
    3760 
    3761         if (ID == -1) {
    3762                 ID = mset.current_chapter_id + 1;
    3763                 if (ID > last_chapter) {
    3764                         ID = firstChapter();
    3765                 }
    3766         }
    3767 
    3768         changeChapter(ID);
     3877        proc->nextChapter();
    37693878}
    37703879
     
    37863895
    37873896        if (!pref->use_mplayer_window) {
    3788                 mplayerwindow->setAspect( asp );
     3897                mplayerwindow->setAspect();
    37893898        } else {
    37903899                // Using mplayer own window
    37913900                if (!mdat.novideo) {
    3792                         tellmp("switch_ratio " + QString::number(asp));
     3901                        if (ID == MediaSettings::AspectAuto) {
     3902                                asp = mdat.video_aspect;
     3903                        }
     3904                        proc->setAspect(asp);
    37933905                }
    37943906        }
     
    38633975        if (mset.add_letterbox != b) {
    38643976                mset.add_letterbox = b;
    3865                 restartPlay();
    3866         }
     3977                CHANGE_VF("letterbox", b, DesktopInfo::desktop_aspectRatio(mplayerwindow));
     3978        }
     3979}
     3980
     3981void Core::changeLetterboxOnFullscreen(bool b) {
     3982        qDebug("Core::changeLetterboxOnFullscreen: %d", b);
     3983        CHANGE_VF("letterbox", b, DesktopInfo::desktop_aspectRatio(mplayerwindow));
    38673984}
    38683985
     
    38713988
    38723989        pref->osd = v;
    3873         tellmp( pausing_prefix() + " osd " + QString::number( pref->osd ) );
     3990
     3991        proc->setPausingPrefix(pausing_prefix());
     3992        proc->setOSD(pref->osd);
     3993
    38743994        updateWidgets();
    38753995}
     
    38874007
    38884008        if (mset.rotate != r) {
    3889                 mset.rotate = r;
    3890                 restartPlay();
     4009                if (proc->isMPlayer()) {
     4010                        mset.rotate = r;
     4011                        restartPlay();
     4012                } else {
     4013                        // MPV
     4014                        // Remove previous filter
     4015                        switch (mset.rotate) {
     4016                                case MediaSettings::Clockwise_flip: proc->changeVF("rotate", false, MediaSettings::Clockwise_flip); break;
     4017                                case MediaSettings::Clockwise: proc->changeVF("rotate", false, MediaSettings::Clockwise); break;
     4018                                case MediaSettings::Counterclockwise: proc->changeVF("rotate", false, MediaSettings::Counterclockwise); break;
     4019                                case MediaSettings::Counterclockwise_flip: proc->changeVF("rotate", false, MediaSettings::Counterclockwise_flip); break;
     4020                        }
     4021                        mset.rotate = r;
     4022                        // New filter
     4023                        switch (mset.rotate) {
     4024                                case MediaSettings::Clockwise_flip: proc->changeVF("rotate", true, MediaSettings::Clockwise_flip); break;
     4025                                case MediaSettings::Clockwise: proc->changeVF("rotate", true, MediaSettings::Clockwise); break;
     4026                                case MediaSettings::Counterclockwise: proc->changeVF("rotate", true, MediaSettings::Counterclockwise); break;
     4027                                case MediaSettings::Counterclockwise_flip: proc->changeVF("rotate", true, MediaSettings::Counterclockwise_flip); break;
     4028                        }
     4029                }
    38914030        }
    38924031}
     
    40134152}
    40144153
    4015 #if USE_MPLAYER_PANSCAN
    4016 void Core::changePanscan(double p) {
    4017          qDebug("Core::changePanscan: %f", p);
    4018 
    4019         if (p < 0.1) p = 0;
    4020         if (p > 1) p = 1;
    4021 
    4022         mset.panscan_factor = p;
    4023         tellmp(QString("panscan %1 1").arg(mset.panscan_factor));
    4024         displayMessage( QString("Panscan: %1").arg(mset.panscan_factor) );
    4025 }
    4026 
    4027 void Core::incPanscan() {
    4028         changePanscan(mset.panscan_factor + .1);
    4029 }
    4030 
    4031 void Core::decPanscan() {
    4032         changePanscan(mset.panscan_factor - .1);
    4033 }
    4034 #endif
    4035 
    40364154void Core::showFilenameOnOSD() {
    4037         tellmp("osd_show_property_text \"${filename}\" 5000 0");
     4155        proc->showFilenameOnOSD();
     4156}
     4157
     4158void Core::showTimeOnOSD() {
     4159        proc->showTimeOnOSD();
    40384160}
    40394161
    40404162void Core::toggleDeinterlace() {
    40414163        qDebug("Core::toggleDeinterlace");
    4042 
    4043         tellmp("step_property deinterlace");
    4044 }
    4045 
    4046 void Core::changeUseAss(bool b) {
    4047         qDebug("Core::changeUseAss: %d", b);
    4048 
    4049         if (pref->use_ass_subtitles != b) {
    4050                 pref->use_ass_subtitles = b;
     4164        proc->toggleDeinterlace();
     4165}
     4166
     4167void Core::changeUseCustomSubStyle(bool b) {
     4168        qDebug("Core::changeUseCustomSubStyle: %d", b);
     4169
     4170        if (pref->enable_ass_styles != b) {
     4171                pref->enable_ass_styles = b;
    40514172                if (proc->isRunning()) restartPlay();
    40524173        }
     
    40594180                pref->use_forced_subs_only = b;
    40604181                //if (proc->isRunning()) restartPlay();
    4061                 int v = 0;
    4062                 if (b) v = 1;
    4063                 tellmp( QString("forced_subs_only %1").arg(v) );
     4182                proc->setSubForcedOnly(b);
    40644183        }
    40654184}
     
    40934212void Core::dvdnavUp() {
    40944213        qDebug("Core::dvdnavUp");
    4095         tellmp("dvdnav up");
     4214        up");
    40964215}
    40974216
    40984217void Core::dvdnavDown() {
    40994218        qDebug("Core::dvdnavDown");
    4100         tellmp("dvdnav down");
     4219        down");
    41014220}
    41024221
    41034222void Core::dvdnavLeft() {
    41044223        qDebug("Core::dvdnavLeft");
    4105         tellmp("dvdnav left");
     4224        left");
    41064225}
    41074226
    41084227void Core::dvdnavRight() {
    41094228        qDebug("Core::dvdnavRight");
    4110         tellmp("dvdnav right");
     4229        right");
    41114230}
    41124231
    41134232void Core::dvdnavMenu() {
    41144233        qDebug("Core::dvdnavMenu");
    4115         tellmp("dvdnav menu");
     4234        menu");
    41164235}
    41174236
    41184237void Core::dvdnavSelect() {
    41194238        qDebug("Core::dvdnavSelect");
    4120         tellmp("dvdnav select");
     4239        select");
    41214240}
    41224241
    41234242void Core::dvdnavPrev() {
    41244243        qDebug("Core::dvdnavPrev");
    4125         tellmp("dvdnav prev");
     4244        prev");
    41264245}
    41274246
     
    41304249
    41314250        if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:"))) {
    4132                 //QPoint p = mplayerwindow->videoLayer()->mapFromGlobal(QCursor::pos());
    4133                 //tellmp(QString("set_mouse_pos %1 %2").arg(p.x()).arg(p.y()));
    4134                 tellmp("dvdnav mouse");
     4251                proc->discButtonPressed("mouse");
    41354252        }
    41364253}
     
    41474264
    41484265void Core::displayScreenshotName(QString filename) {
    4149         qDebug("Core::displayScreenshotName");
    4150         //QString text = tr("Screenshot saved as %1").arg(filename);
    4151         QString text = QString("Screenshot saved as %1").arg(filename);
    4152 
     4266        qDebug("Core::displayScreenshotName: %s", filename.toUtf8().constData());
     4267
     4268        QFileInfo fi(filename);
     4269
     4270        QString text = tr("Screenshot saved as %1").arg(fi.fileName());
     4271        //QString text = QString("Screenshot saved as %1").arg(fi.fileName());
     4272
     4273#ifdef MPLAYER2_SUPPORT
    41534274        if (MplayerVersion::isMplayer2()) {
    41544275                displayTextOnOSD(text, 3000, 1, "");
    41554276        }
    41564277        else
     4278
    41574279        if (MplayerVersion::isMplayerAtLeast(27665)) {
    41584280                displayTextOnOSD(text, 3000, 1, "pausing_keep_force");
     
    41744296
    41754297void Core::displayBuffering() {
    4176         emit showMessage(tr("Buffering..."));
     4298        setState(Buffering);
     4299//      emit showMessage(tr("Buffering..."));
     4300}
     4301
     4302void Core::displayPlaying() {
     4303        qDebug("Core::displayPlaying");
     4304        setState(Buffering);
     4305        emit showMessage(tr("Starting..."), 60000);
    41774306}
    41784307
     
    42644393#endif
    42654394
    4266         if ((state == Playing) && (change_volume_after_unpause)) {
     4395        if ((state == Playing) && (change_volume_after_unpause)) {
    42674396                // Delayed volume change
    42684397                qDebug("Core::watchState: delayed volume change");
    42694398                int volume = (pref->global_volume ? pref->volume : mset.volume);
    4270                 tellmp("volume " + QString::number(volume) + " 1");
     4399                );
    42714400                change_volume_after_unpause = false;
    42724401        }
     
    43244453#endif
    43254454
     4455
     4456
     4457
     4458
     4459
     4460
     4461
     4462
     4463
    43264464#if NOTIFY_AUDIO_CHANGES
    43274465void Core::initAudioTrack(const Tracks & audios) {
     
    44064544                restore_subs = false;
    44074545                just_loaded_external_subs = false;
    4408                
     4546
    44094547                QFileInfo fi(mset.external_subtitles);
    4410                 if (fi.suffix().toLower() != "idx") {
     4548                bool is_idx = (fi.suffix().toLower() == "idx");
     4549                if (proc->isMPV()) is_idx = false; // Hack to ignore the idx extension with mpv
     4550
     4551                if (!is_idx) {
    44114552                        // The loaded subtitle file is the last one, so
    44124553                        // try to select that one.
     
    44664607        }
    44674608end:
     4609
     4610
     4611
     4612
    44684613        updateWidgets();
    44694614}
     
    44724617        qDebug("Core::setSubtitleTrackAgain");
    44734618        changeSubtitle( mset.current_sub_id );
     4619
     4620
     4621
     4622
     4623
     4624
     4625
     4626
     4627
    44744628}
    44754629#endif
     
    44894643
    44904644void Core::askForInfo() {
    4491         if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:"))) {
    4492                 tellmp( pausing_prefix() + " get_property length");
     4645        if (proc->isMPlayer()) {
     4646                if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:"))) {
     4647                        proc->setPausingPrefix(pausing_prefix());
     4648                        proc->askForLength();
     4649                }
    44934650        }
    44944651}
    44954652
    44964653void Core::dvdnavUpdateMousePos(QPoint pos) {
    4497         //qDebug("Core::dvdnavUpdateMousePos");
     4654#if 0
     4655        bool under_mouse = mplayerwindow->videoLayer()->underMouse();
     4656
     4657        qDebug("Core::dvdnavUpdateMousePos: %d %d", pos.x(), pos.y());
     4658        qDebug("Core::dvdnavUpdateMousePos: state: %d", state());
     4659        qDebug("Core::dvdnavUpdateMousePos: filename: %s", mdat.filename.toUtf8().constData());
     4660        qDebug("Core::dvdnavUpdateMousePos: dvdnav_title_is_menu: %d", dvdnav_title_is_menu);
     4661        qDebug("Core::dvdnavUpdateMousePos: under mouse: %d", under_mouse);
     4662#endif
    44984663        if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:")) && (dvdnav_title_is_menu)) {
    4499                 if (mplayerwindow->videoLayer()->underMouse()) {
    4500                         tellmp(QString("set_mouse_pos %1 %2").arg(pos.x()).arg(pos.y()));
    4501                 }
     4664                ) {
     4665                        ));
     4666                }
    45024667        }
    45034668}
     
    45114676        qDebug("Core::dvdTitleIsMovie");
    45124677        dvdnav_title_is_menu = false;
    4513 
    45144678}
    45154679#endif
     
    45184682        qDebug("Core::pausing_prefix");
    45194683
     4684
    45204685        if (MplayerVersion::isMplayer2()) {
    45214686                return QString::null;
    45224687        }
    45234688        else
     4689
    45244690        if ( (pref->use_pausing_keep_force) &&
    45254691         (MplayerVersion::isMplayerAtLeast(27665)) )
     
    45314697}
    45324698
     4699
     4700
     4701
     4702
     4703
     4704
     4705
     4706
     4707
     4708
     4709
     4710
     4711
     4712
     4713
     4714
     4715
     4716
     4717
     4718
     4719
     4720
     4721
     4722
     4723
     4724
     4725
     4726
     4727
     4728
     4729
     4730
     4731
     4732
     4733
     4734
     4735
     4736
     4737
     4738
     4739
    45334740#include "moc_core.cpp"
Note: See TracChangeset for help on using the changeset viewer.