Ignore:
Timestamp:
Aug 31, 2016, 5:31:04 PM (9 years ago)
Author:
Silvan Scherrer
Message:

smplayer: update trunk to version 16.8.0

Location:
smplayer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • smplayer/trunk

  • smplayer/trunk/src/core.cpp

    r176 r181  
    4343#include "discname.h"
    4444#include "filters.h"
    45 #include "tvlist.h"
    46 
    47 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
     45#include "extensions.h"
     46
    4847#ifdef Q_OS_WIN
    4948#include <windows.h> // To change app priority
     
    5352#include "screensaver.h"
    5453#endif
    55 #endif
    56 
    57 #ifndef NO_USE_INI_FILES
     54
    5855#include "filesettings.h"
    5956#include "filesettingshash.h"
     57
     58
     59
    6060#include "tvsettings.h"
    6161#endif
     
    9090#endif
    9191
    92 #ifndef NO_USE_INI_FILES
    9392        // Create file_settings
    9493        file_settings = 0;
     
    9695
    9796        // TV settings
     97
    9898        tv_settings = new TVSettings(Paths::iniPath());
    9999#endif
     
    278278        mplayerwindow->setMonitorAspect( pref->monitor_aspect_double() );
    279279
    280 #if  defined(Q_OS_WIN) || defined(Q_OS_OS2)
    281280#ifdef SCREENSAVER_OFF
    282281        // Windows or OS2 screensaver
     
    286285        connect( proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(enableScreensaver()) );
    287286#endif
    288 #endif
    289287
    290288#ifdef YOUTUBE_SUPPORT
     
    311309
    312310Core::~Core() {
    313 #ifndef NO_USE_INI_FILES
    314311        saveMediaInfo();
    315 #endif
    316312
    317313        if (proc->isRunning()) stopMplayer();
     
    319315        delete proc;
    320316
    321 #ifndef NO_USE_INI_FILES
    322317        delete file_settings;
     318
    323319        delete tv_settings;
    324320#endif
    325321
    326 #if  defined(Q_OS_WIN) || defined(Q_OS_OS2)
    327322#ifdef SCREENSAVER_OFF
    328323        delete win_screensaver;
    329324#endif
    330 #endif
    331325
    332326#ifdef YOUTUBE_SUPPORT
     
    335329}
    336330
    337 #ifndef NO_USE_INI_FILES
    338331void Core::changeFileSettingsMethod(QString method) {
    339332        qDebug("Core::changeFileSettingsMethod: %s", method.toUtf8().constData());
     
    345338                file_settings = new FileSettings(Paths::iniPath());
    346339}
    347 #endif
    348340
    349341void Core::setState(State s) {
     
    384376}
    385377
    386 #ifndef NO_USE_INI_FILES
    387378void Core::saveMediaInfo() {
    388379        qDebug("Core::saveMediaInfo");
    389380
    390         if (pref->dont_remember_media_settings) {
    391                 qDebug("Core::saveMediaInfo: not saving settings, disabled by user");
     381        if (remember_media_settings) {
     382                qDebug("Core::saveMediaInfo: ");
    392383                return;
    393384        }
    394385
    395         if ( (mdat.type == TYPE_FILE) && (!mdat.filename.isEmpty()) ) {
    396                 file_settings->saveSettingsFor(mdat.filename, mset, proc->player());
    397         }
     386        if (mdat.type == TYPE_STREAM && !pref->remember_stream_settings) {
     387                qDebug("Core::saveMediaInfo: saving settings for streams is disabled");
     388                return;
     389        }
     390
     391        if ( (mdat.type == TYPE_FILE || mdat.type == TYPE_STREAM) && (!mdat.filename.isEmpty()) ) {
     392                file_settings->saveSettingsFor(mdat.filename, mdat.type, mset, proc->player());
     393        }
     394#ifdef TV_SUPPORT
    398395        else
    399396        if ( (mdat.type == TYPE_TV) && (!mdat.filename.isEmpty()) ) {
    400                 tv_settings->saveSettingsFor(mdat.filename, mset, proc->player());
    401         }
    402 }
    403 #endif // NO_USE_INI_FILES
     397                tv_settings->saveSettingsFor(mdat.filename, mdat.type, mset, proc->player());
     398        }
     399#endif
     400}
     401
     402void Core::restoreSettingsForMedia(const QString & name, int type) {
     403        qDebug() << "Core::restoreSettingsForMedia:" << name << "type:" << type;
     404
     405        if (!pref->remember_media_settings) {
     406                qDebug("Core::restoreSettingsForMedia: remember settings for files is disabled");
     407                return;
     408        }
     409
     410        if (type == TYPE_STREAM && !pref->remember_stream_settings) {
     411                qDebug("Core::restoreSettingsForMedia: remember settings for streams is disabled");
     412                return;
     413        }
     414
     415        file_settings->loadSettingsFor(name, type, mset, proc->player());
     416        qDebug("Core::restoreSettingsForMedia: media settings read");
     417
     418        // Resize the window and set the aspect as soon as possible
     419        int saved_width = mset.win_width;
     420        int saved_height = mset.win_height;
     421        // 400x300 is the default size for win_width and win_height
     422        // so we set them to 0 to avoid to resize the window on
     423        // audio files
     424        if ((saved_width == 400) && (saved_height == 300)) {
     425                saved_width = 0;
     426                saved_height = 0;
     427        }
     428        if ((saved_width > 0) && (saved_height > 0)) {
     429                emit needResize(mset.win_width, mset.win_height);
     430                changeAspectRatio(mset.aspect_ratio_id);
     431        }
     432
     433        if (!pref->remember_time_pos) {
     434                mset.current_sec = 0;
     435                qDebug("Core::restoreSettingsForMedia: time pos reset to 0");
     436        }
     437}
    404438
    405439void Core::initializeMenus() {
     
    525559                }
    526560        }
     561
    527562        else
    528563        if ((file.toLower().startsWith("dvb:")) || (file.toLower().startsWith("tv:"))) {
     
    530565                openTV(file);
    531566        }
     567
    532568        else {
    533569                qDebug("Core::open: * not identified, playing as stream");
     
    568604#endif
    569605
    570 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
    571606#ifdef SCREENSAVER_OFF
    572607void Core::enableScreensaver() {
     
    583618        }
    584619}
    585 #endif
    586620#endif
    587621
     
    704738
    705739        // Save data of previous file:
    706 #ifndef NO_USE_INI_FILES
    707740        saveMediaInfo();
    708 #endif
    709741
    710742        mdat.reset();
     
    732764
    733765        // Save data of previous file:
    734 #ifndef NO_USE_INI_FILES
    735766        saveMediaInfo();
    736 #endif
    737767
    738768        mdat.reset();
     
    779809
    780810        // Save data of previous file:
    781 #ifndef NO_USE_INI_FILES
    782811        saveMediaInfo();
    783 #endif
    784812
    785813        mdat.reset();
     
    827855
    828856        // Save data of previous file:
    829 #ifndef NO_USE_INI_FILES
    830857        saveMediaInfo();
    831 #endif
    832858
    833859        mdat.reset();
     
    846872#endif
    847873
     874
    848875void Core::openTV(QString channel_id) {
    849876        qDebug("Core::openTV: '%s'", channel_id.toUtf8().constData());
     
    855882
    856883        // Save data of previous file:
    857 #ifndef NO_USE_INI_FILES
    858884        saveMediaInfo();
    859 #endif
    860885
    861886        // Use last channel if the name is just "dvb://" or "tv://"
     
    882907        mset.current_deinterlacer = pref->initial_tv_deinterlace;
    883908
    884 #ifndef NO_USE_INI_FILES
    885         if (!pref->dont_remember_media_settings) {
     909        if (pref->remember_media_settings) {
    886910                // Check if we already have info about this file
    887                 if (tv_settings->existSettingsFor(channel_id)) {
     911                if (tv_settings->existSettingsFor(channel_id)) {
    888912                        qDebug("Core::openTV: we have settings for this file!!!");
    889913
    890914                        // In this case we read info from config
    891                         tv_settings->loadSettingsFor(channel_id, mset, proc->player());
     915                        tv_settings->loadSettingsFor(channel_id, mset, proc->player());
    892916                        qDebug("Core::openTV: media settings read");
    893917                }
    894918        }
    895 #endif
    896919
    897920        /* initializeMenus(); */
     
    899922        initPlaying();
    900923}
     924
    901925
    902926void Core::openStream(QString name) {
     
    929953
    930954        // Save data of previous file:
    931 #ifndef NO_USE_INI_FILES
    932955        saveMediaInfo();
    933 #endif
    934956
    935957        mdat.reset();
     
    939961        mset.reset();
    940962
     963
     964
     965
     966
     967
     968
     969
     970
     971
     972
     973
    941974        /* initializeMenus(); */
    942975
     
    954987
    955988        // Save data of previous file:
    956 #ifndef NO_USE_INI_FILES
    957989        saveMediaInfo();
    958 #endif
    959990
    960991        mdat.reset();
     
    965996        mset.reset();
    966997
    967 #ifndef NO_USE_INI_FILES
    968998        // Check if we already have info about this file
    969         if (file_settings->existSettingsFor(file)) {
    970                 qDebug("Core::playNewFile: We have settings for this file!!!");
    971 
    972                 // In this case we read info from config
    973                 if (!pref->dont_remember_media_settings) {
    974                         file_settings->loadSettingsFor(file, mset, proc->player());
    975                         qDebug("Core::playNewFile: Media settings read");
    976 
    977                         // Resize the window and set the aspect as soon as possible
    978                         int saved_width = mset.win_width;
    979                         int saved_height = mset.win_height;
    980                         // 400x300 is the default size for win_width and win_height
    981                         // so we set them to 0 to avoid to resize the window on
    982                         // audio files
    983                         if ((saved_width == 400) && (saved_height == 300)) {
    984                                 saved_width = 0;
    985                                 saved_height = 0;
    986                         }
    987                         if ((saved_width > 0) && (saved_height > 0)) {
    988                                 emit needResize(mset.win_width, mset.win_height);
    989                                 changeAspectRatio(mset.aspect_ratio_id);
    990                         }
    991 
    992                         if (pref->dont_remember_time_pos) {
    993                                 mset.current_sec = 0;
    994                                 qDebug("Core::playNewFile: Time pos reset to 0");
    995                         }
    996                 } else {
    997                         qDebug("Core::playNewFile: Media settings have not read because of preferences setting");
    998                 }
     999        if (file_settings->existSettingsFor(file, mdat.type)) {
     1000                qDebug("Core::playNewFile: we have settings for this file");
     1001                restoreSettingsForMedia(file, mdat.type);
    9991002        } else {
    10001003                // Recover volume
    10011004                mset.volume = old_volume;
    10021005        }
    1003 #else
    1004         // Recover volume
    1005         mset.volume = old_volume;
    1006 #endif // NO_USE_INI_FILES
    10071006
    10081007        /* initializeMenus(); */
     
    10681067
    10691068        // Video
     1069
    10701070        if ( (mset.current_video_id == MediaSettings::NoneSelected) &&
    10711071         (mdat.videos.numItems() > 0) )
     
    10731073                changeVideo( mdat.videos.itemAt(0).ID(), false ); // Don't allow to restart
    10741074        }
     1075
    10751076
    10761077#if !DELAYED_AUDIO_SETUP_ON_STARTUP && !NOTIFY_AUDIO_CHANGES
     
    12781279        emit mediaInfoChanged();
    12791280        emit newDuration(mdat.duration);
     1281
     1282
    12801283
    12811284        updateWidgets(); // New
     
    15461549        qDebug("Core::startMplayer: url_is_playlist: %d", url_is_playlist);
    15471550
     1551
     1552
     1553
     1554
     1555
     1556
     1557
     1558
    15481559
    15491560        // Check if a m4a file exists with the same name of file, in that cause if will be used as audio
     
    16951706        proc->setOption("sub-fuzziness", pref->subfuzziness);
    16961707
    1697         if (pref->vo != "player_default") {
    1698                 if (!pref->vo.isEmpty()) {
    1699                         proc->setOption("vo", pref->vo );
    1700                 } else {
    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                 }
    1711         }
     1708        if (!pref->vo.isEmpty()) {
     1709                QString vo = pref->vo;
     1710                if (!vo.endsWith(",")) vo += ",";
     1711                proc->setOption("vo", vo);
     1712        }
     1713        #ifdef Q_OS_WIN
     1714        else {
     1715                if (proc->isMPlayer() && QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) {
     1716                        proc->setOption("vo", "direct3d,");
     1717                }
     1718        }
     1719        #endif
    17121720
    17131721#if USE_ADAPTER
     
    17171725#endif
    17181726
    1719         if (pref->ao != "player_default") {
    1720                 if (!pref->ao.isEmpty()) {
    1721                         proc->setOption("ao", pref->ao );
    1722                 }
     1727        if () {
     1728               
     1729                ;
     1730               
    17231731        }
    17241732
     
    20782086                case TYPE_VCD           : cache = pref->cache_for_vcds; break;
    20792087                case TYPE_AUDIO_CD      : cache = pref->cache_for_audiocds; break;
     2088
    20802089                case TYPE_TV            : cache = pref->cache_for_tv; break;
     2090
    20812091#ifdef BLURAY_SUPPORT
    20822092                case TYPE_BLURAY        : cache = pref->cache_for_dvds; break; // FIXME: use cache for bluray?
     
    20852095        }
    20862096
    2087         proc->setOption("cache", QString::number(cache));
     2097        if (pref->cache_auto) {
     2098                proc->setOption("cache_auto");
     2099        } else {
     2100                proc->setOption("cache", QString::number(cache));
     2101        }
    20882102
    20892103        if (mset.speed != 1.0) {
     
    20942108                // Play A - B
    20952109                if ((mset.A_marker > -1) && (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));
     2110                        if (proc->isMPV()) {
     2111                                if (mset.loop) {
     2112                                        proc->setOption("ab-loop-a", QString::number(mset.A_marker));
     2113                                        proc->setOption("ab-loop-b", QString::number(mset.B_marker));
     2114                                }
     2115                        } else {
     2116                                proc->setOption("ss", QString::number(mset.A_marker));
     2117                                proc->setOption("endpos", QString::number(mset.B_marker - mset.A_marker));
     2118                        }
    20982119                }
    20992120                else
     
    23352356                }
    23362357
    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");
     2358                if (proc->isMPlayer()) {
     2359                        bool use_scaletempo = (pref->use_scaletempo == Preferences::Enabled);
     2360                        if (pref->use_scaletempo == Preferences::Detect) {
     2361                                use_scaletempo = (MplayerVersion::isMplayerAtLeast(24924));
     2362                        }
     2363                        if (use_scaletempo) {
     2364                                proc->addAF("scaletempo");
     2365                        }
     2366                } else {
     2367                        // MPV
     2368                        proc->setOption("scaletempo", pref->use_scaletempo != Preferences::Disabled);
    23432369                }
    23442370
     
    23642390
    23652391        if (pref->use_soft_vol) {
    2366                 proc->setOption("softvol");
    2367                 proc->setOption("softvol-max", QString::number(pref->softvol_max));
     2392                proc->setOption("softvol", QString::number(pref->softvol_max));
     2393        } else {
     2394                proc->setOption("softvol", "off");
    23682395        }
    23692396
    23702397#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
     2398        if (mdat.type == TYPE_STREAM) {
     2399                if (pref->streaming_type == Preferences::StreamingAuto) {
     2400                        bool is_youtube = false;
     2401                        #ifdef YOUTUBE_SUPPORT
     2402                        if (PREF_YT_ENABLED) is_youtube = (file == yt->latestPreferredUrl());
     2403                        #endif
     2404                        qDebug() << "Core::startMplayer: is_youtube:" << is_youtube;
     2405                        bool enable_sites = !is_youtube;
     2406
     2407                        if (!is_youtube) {
     2408                                // Check if the URL contains a media extension
     2409                                QString extension = Extensions::extensionFromUrl(file);
     2410                                qDebug() << "Core::startMplayer: URL extension:" << extension;
     2411                                Extensions e;
     2412                                if (e.allPlayable().contains(extension)) {
     2413                                        qDebug() << "Core::startMplayer: extension found in URL";
     2414                                        enable_sites = false;
     2415                                }
     2416                        }
     2417                        qDebug() << "Core::startMplayer: enable_sites:" << enable_sites;
     2418                        proc->setOption("enable_streaming_sites_support", enable_sites);
     2419                } else {
     2420                        proc->setOption("enable_streaming_sites_support", pref->streaming_type == Preferences::StreamingYTDL);
     2421                }
     2422        }
     2423#endif
     2424
     2425#if defined(TV_SUPPORT) && !defined(Q_OS_WIN)
    23842426        if (proc->isMPV() && file.startsWith("dvb:")) {
    23852427                QString channels_file = TVList::findChannelsFile();
     
    26572699        displayMessage( tr("\"A\" marker set to %1").arg(Helper::formatTime(sec)) );
    26582700
    2659         if (mset.B_marker > mset.A_marker) {
    2660                 if (proc->isRunning()) restartPlay();
     2701        if (proc->isMPV()) {
     2702                if (mset.loop) proc->setAMarker(sec);
     2703        } else {
     2704                // MPlayer
     2705                if (mset.B_marker > mset.A_marker) {
     2706                        if (proc->isRunning()) restartPlay();
     2707                }
    26612708        }
    26622709
     
    26742721        displayMessage( tr("\"B\" marker set to %1").arg(Helper::formatTime(sec)) );
    26752722
    2676         if ((mset.A_marker > -1) && (mset.A_marker < mset.B_marker)) {
    2677                 if (proc->isRunning()) restartPlay();
     2723        if (proc->isMPV()) {
     2724                if (mset.loop) proc->setBMarker(sec);
     2725        } else {
     2726                // MPlayer
     2727                if ((mset.A_marker > -1) && (mset.A_marker < mset.B_marker)) {
     2728                        if (proc->isRunning()) restartPlay();
     2729                }
    26782730        }
    26792731
     
    26882740                mset.B_marker = -1;
    26892741                displayMessage( tr("A-B markers cleared") );
    2690                 if (proc->isRunning()) restartPlay();
     2742                if (proc->isMPV()) {
     2743                        proc->clearABMarkers();
     2744                } else {
     2745                        // MPlayer
     2746                        if (proc->isRunning()) restartPlay();
     2747                }
    26912748        }
    26922749
     
    27072764                        int v = -1; // no loop
    27082765                        if (mset.loop) v = 0; // infinite loop
     2766
     2767
     2768
     2769
     2770
     2771
     2772
     2773
    27092774                        proc->setLoop(v);
    27102775                } else {
     
    34953560
    34963561void Core::changeCurrentSec(double sec) {
    3497     mset.current_sec = sec;
     3562        //qDebug() << "Core::changeCurrentSec:" << sec << "starting_time:" << mset.starting_time;
     3563
     3564        mset.current_sec = sec;
    34983565
    34993566        if (mset.starting_time != -1) {
     
    43454412
    43464413void Core::gotVO(QString vo) {
    4347         qDebug("Core::gotVO: '%s'", vo.toUtf8().data() );
    4348 
    4349         if ( pref->vo.isEmpty()) {
     4414        qDebug() << "Core::gotVO:" << vo;
     4415
     4416        /*
     4417        if (pref->vo.isEmpty()) {
    43504418                qDebug("Core::gotVO: saving vo");
    43514419                pref->vo = vo;
    43524420        }
     4421
    43534422}
    43544423
    43554424void Core::gotAO(QString ao) {
    4356         qDebug("Core::gotAO: '%s'", ao.toUtf8().data() );
    4357 
    4358         if ( pref->ao.isEmpty()) {
     4425        qDebug() << "Core::gotAO:" << ao;
     4426
     4427        /*
     4428        if (pref->ao.isEmpty()) {
    43594429                qDebug("Core::gotAO: saving ao");
    43604430                pref->ao = ao;
    43614431        }
     4432
    43624433}
    43634434
Note: See TracChangeset for help on using the changeset viewer.