Ignore:
Timestamp:
May 15, 2014, 7:53:54 PM (12 years ago)
Author:
Silvan Scherrer
Message:

SMPlayer: update vendor to 0.8.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • smplayer/vendor/current/src/core.cpp

    r154 r163  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2013 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
     
    224224             this, SLOT(dvdTitleIsMovie()) );
    225225#endif
    226        
     226
     227        connect( proc, SIGNAL(receivedForbiddenText()), this, SIGNAL(receivedForbidden()) );
     228
    227229        connect( this, SIGNAL(stateChanged(Core::State)),
    228230                 this, SLOT(watchState(Core::State)) );
     
    245247
    246248#if DVDNAV_SUPPORT
    247         connect( mplayerwindow, SIGNAL(mouseMoved(QPoint)),
     249        connect( mplayerwindow
    248250             this, SLOT(dvdnavUpdateMousePos(QPoint)) );
    249251#endif
     
    258260        // Windows or OS2 screensaver
    259261        win_screensaver = new WinScreenSaver();
    260 #endif
    261 #endif
    262 
    263 #if DISCNAME_TEST
    264         DiscName::test();
     262        connect( this, SIGNAL(aboutToStartPlaying()), this, SLOT(disableScreensaver()) );
     263        connect( proc, SIGNAL(processExited()), this, SLOT(enableScreensaver()) );
     264        connect( proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(enableScreensaver()) );
     265#endif
    265266#endif
    266267
     
    403404                if (!prefix.isEmpty()) str = prefix + " " + str;
    404405                qDebug("Core::displayTextOnOSD: command: '%s'", str.toUtf8().constData());
    405                 proc->write(str.toAscii());
     406                proc->write(str.to());
    406407        }
    407408}
     
    468469        }
    469470        else
     471
     472
     473
     474
     475
     476
     477
    470478        if (file.toLower().startsWith("vcd:")) {
    471479                qDebug("Core::open: * identified as vcd");
     
    540548
    541549void Core::YTNoVideoUrl() {
    542         emit showMessage( tr("Unable to locate the url of the video") );
    543 }
     550        emit showMessage( tr("Unable to locate the URL of the video") );
     551}
     552#endif
     553
     554#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
     555#ifdef SCREENSAVER_OFF
     556void Core::enableScreensaver() {
     557        qDebug("Core::enableScreensaver");
     558        if (pref->turn_screensaver_off) {
     559                win_screensaver->enable();
     560        }
     561}
     562
     563void Core::disableScreensaver() {
     564        qDebug("Core::disableScreensaver");
     565        if (pref->turn_screensaver_off) {
     566                win_screensaver->disable();
     567        }
     568}
     569#endif
    544570#endif
    545571
     
    606632                        if ( (fi.exists()) && (fi.isDir()) ) {
    607633                                pref->dvd_directory = directory;
    608                                 pref->play_dvd_from_hd = TRUE;
     634                                pref->play_dvd_from_hd = ;
    609635                                openDVD();
    610636                        } else {
     
    615641                }
    616642        } else {
    617                 pref->play_dvd_from_hd = FALSE;
     643                pref->play_dvd_from_hd = ;
    618644                openDVD();
    619645        }
     
    756782}
    757783
     784
     785
     786
     787
     788
     789
     790
     791
     792
     793
     794
     795
     796
     797
     798
     799
     800
     801
     802
     803
     804
     805
     806
     807
     808
     809
     810
     811
     812
     813
     814
     815
     816
     817
     818
     819
     820
     821
     822
     823
     824
     825
     826
     827
     828
     829
     830
     831
     832
     833
    758834void Core::openTV(QString channel_id) {
    759835        qDebug("Core::openTV: '%s'", channel_id.toUtf8().constData());
     
    814890
    815891#ifdef YOUTUBE_SUPPORT
    816         if (name.contains("youtube.com/watch", Qt::CaseInsensitive) ||
    817         name.contains("youtu.be/", Qt::CaseInsensitive) ||
    818         name.contains("y2u.be/", Qt::CaseInsensitive) )
    819         {
    820                 qDebug("Core::openStream: youtube url detected");
    821                 if (name.startsWith("www.youtube.com")) name = "http://" + name;
    822                 if (name.startsWith("youtube.com")) name = "http://www." + name;
    823                 if (name.startsWith("youtu.be")) name = "http://" + name;
    824                 if (name.startsWith("y2u.be")) name = "http://" + name;
     892        // Check if the stream is a youtube url
     893        QString yt_full_url = yt->fullUrl(name);
     894        if (!yt_full_url.isEmpty()) {
     895                qDebug("Core::openStream: youtube url detected: %s", yt_full_url.toLatin1().constData());
     896                name = yt_full_url;
    825897                yt->setPreferredQuality( (RetrieveYoutubeUrl::Quality) pref->yt_quality );
    826898                qDebug("Core::openStream: user_agent: '%s'", pref->yt_user_agent.toUtf8().constData());
    827899                if (!pref->yt_user_agent.isEmpty()) yt->setUserAgent(pref->yt_user_agent);
    828900                #ifdef YT_USE_SCRIPT
    829                 YTSig::setScriptFile( Paths::configPath() + "/ytcode.script" );
     901                YTSig::setScriptFile( Paths::configPath() + "/yt" );
    830902                #endif
    831903                yt->fetchPage(name);
     
    10261098        }
    10271099
    1028         mdat.initialized = TRUE;
     1100        mdat.initialized = ;
    10291101
    10301102        // MPlayer doesn't display the length in ID_LENGTH for audio CDs...
     
    11321204        changeAspectRatio(mset.aspect_ratio_id);
    11331205
    1134         if (pref->global_volume) {
    1135                 bool was_muted = pref->mute;
    1136                 setVolume( pref->volume, true);
    1137                 if (was_muted) mute(true);
     1206        if (pref->mplayer_additional_options.contains("-volume")) {
     1207                qDebug("Core::finishRestart: don't set volume since -volume is used");
    11381208        } else {
    1139                 bool was_muted = mset.mute;
    1140                  setVolume( mset.volume, true );
    1141                 if (was_muted) mute(true);
     1209                if (pref->global_volume) {
     1210                        bool was_muted = pref->mute;
     1211                        setVolume( pref->volume, true);
     1212                        if (was_muted) mute(true);
     1213                } else {
     1214                        bool was_muted = mset.mute;
     1215                         setVolume( mset.volume, true );
     1216                        if (was_muted) mute(true);
     1217                }
    11421218        }
    11431219
     
    12081284
    12091285
    1210 void Core::play()
    1211 {
     1286void Core::play() {
    12121287        qDebug("Core::play");
    1213    
     1288
    12141289        if ((proc->isRunning()) && (state()==Paused)) {
    12151290                tellmp("pause"); // Unpauses
    1216     }
     1291        }
    12171292        else
    12181293        if ((proc->isRunning()) && (state()==Playing)) {
     
    12291304                        */
    12301305                        restartPlay();
    1231                 }
    1232     }
     1306                } else {
     1307                        emit noFileToPlay();
     1308                }
     1309        }
    12331310}
    12341311
     
    13021379{
    13031380    qDebug("Core::processFinished");
    1304 
    1305 #if  defined(Q_OS_WIN) || defined(Q_OS_OS2)
    1306 #ifdef SCREENSAVER_OFF
    1307         // Restores the Windows or OS2 screensaver
    1308         if (pref->turn_screensaver_off) {
    1309                 win_screensaver->enable();
    1310         }
    1311 #endif
    1312 #endif
    1313 
    13141381        qDebug("Core::processFinished: we_are_restarting: %d", we_are_restarting);
    13151382
     
    13941461        #endif
    13951462        yt->close();
    1396 #endif
    1397 
    1398 #if  defined(Q_OS_WIN) || defined(Q_OS_OS2)
    1399 #ifdef SCREENSAVER_OFF
    1400         // Disable the Windows or OS2 screensaver
    1401         if (pref->turn_screensaver_off) {
    1402                 win_screensaver->disable();
    1403         }
    1404 #endif
    14051463#endif
    14061464
     
    14291487                qDebug("Core::startMplayer: url path: '%s'", url.path().toUtf8().constData());
    14301488
    1431                 QRegExp rx("\\.ram$|\\.asx$|\\.m3u$|\\.pls$", Qt::CaseInsensitive);
    1432                 url_is_playlist = (rx.indexIn(url.path()) != -1);
     1489                if (url.scheme().toLower() != "ffmpeg") {
     1490                        QRegExp rx("\\.ram$|\\.asx$|\\.m3u$|\\.m3u8$|\\.pls$", Qt::CaseInsensitive);
     1491                        url_is_playlist = (rx.indexIn(url.path()) != -1);
     1492                }
    14331493        }
    14341494        qDebug("Core::startMplayer: url_is_playlist: %d", url_is_playlist);
     1495
     1496
     1497
     1498
     1499
     1500
     1501
     1502
     1503
     1504
     1505
     1506
     1507
     1508
     1509
     1510
     1511
     1512
     1513
     1514
    14351515
    14361516
     
    17361816                proc->addArgument( QString::number(mset.sub_scale_ass) );
    17371817
     1818
     1819
     1820
     1821
    17381822                if (!pref->force_ass_styles) {
    17391823                        // Load the styles.ass file
     
    17591843                // Use the same font for OSD
    17601844#if !defined(Q_OS_OS2)
    1761                 if (!pref->ass_styles.fontname.isEmpty()) {
     1845                if ()) {
    17621846                        #ifdef USE_FONTCONFIG_OPTIONS
    17631847                        if (!pref->mplayer_is_mplayer2) { // -fontconfig removed from mplayer2
     
    18611945        }
    18621946
    1863         if (mset.current_audio_id != MediaSettings::NoneSelected) {
    1864                 // Workaround for MPlayer bug #1321 (http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1321)
    1865                 if (mdat.audios.numItems() != 1) {
    1866                         proc->addArgument("-aid");
    1867                         proc->addArgument( QString::number( mset.current_audio_id ) );
     1947        if (mset.external_audio.isEmpty()) {
     1948                if (mset.current_audio_id != MediaSettings::NoneSelected) {
     1949                        // Workaround for MPlayer bug #1321 (http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1321)
     1950                        if (mdat.audios.numItems() != 1) {
     1951                                proc->addArgument("-aid");
     1952                                proc->addArgument( QString::number( mset.current_audio_id ) );
     1953                        }
    18681954                }
    18691955        }
     
    19682054        bool use_volume_option = (MplayerVersion::isMplayerAtLeast(27872));
    19692055
    1970         if (pref->global_volume) {
    1971                 if (use_volume_option) {
    1972                         proc->addArgument("-volume");
    1973                         proc->addArgument( QString::number( pref->volume ) );
    1974                 }
     2056        if (pref->mplayer_additional_options.contains("-volume")) {
     2057                qDebug("Core::startMplayer: don't set volume since -volume is used");
    19752058        } else {
    1976                 if (use_volume_option) {
    1977                         proc->addArgument("-volume");
    1978                         // Note: mset.volume may not be right, it can be the volume of the previous video if
    1979                         // playing a new one, but I think it's better to use anyway the current volume on
    1980                         // startup than set it to 0 or something.
    1981                         // The right volume will be set later, when the video starts to play.
    1982                         proc->addArgument( QString::number( mset.volume ) );
     2059                if (pref->global_volume) {
     2060                        if (use_volume_option) {
     2061                                proc->addArgument("-volume");
     2062                                proc->addArgument( QString::number( pref->volume ) );
     2063                        }
     2064                } else {
     2065                        if (use_volume_option) {
     2066                                proc->addArgument("-volume");
     2067                                // Note: mset.volume may not be right, it can be the volume of the previous video if
     2068                                // playing a new one, but I think it's better to use anyway the current volume on
     2069                                // startup than set it to 0 or something.
     2070                                // The right volume will be set later, when the video starts to play.
     2071                                proc->addArgument( QString::number( mset.volume ) );
     2072                        }
    19832073                }
    19842074        }
     
    20192109                case TYPE_FILE          : cache = pref->cache_for_files; break;
    20202110                case TYPE_DVD           : cache = pref->cache_for_dvds;
    2021 #if DVDNAV_SUPPORT
     2111#if DVDNAV_SUPPORT
    20222112                                                          if (file.startsWith("dvdnav:")) cache = 0;
    2023 #endif
     2113#endif
    20242114                                      break;
    20252115                case TYPE_STREAM        : cache = pref->cache_for_streams; break;
     
    20272117                case TYPE_AUDIO_CD      : cache = pref->cache_for_audiocds; break;
    20282118                case TYPE_TV            : cache = pref->cache_for_tv; break;
     2119
     2120
     2121
    20292122                default: cache = 0;
    20302123        }
     
    23122405        if (pref->use_audio_equalizer) {
    23132406                if (!af.isEmpty()) af += ",";
    2314                 af += "equalizer=" + Helper::equalizerListToString(mset.audio_equalizer);
     2407                AudioEqualizerList l = pref->global_audio_equalizer ? pref->audio_equalizer : mset.audio_equalizer;
     2408                af += "equalizer=" + Helper::equalizerListToString(l);
    23152409        }
    23162410
     
    23502444                QString basename = f.path() + "/" + f.completeBaseName();
    23512445
    2352                 qDebug("Core::startMplayer: file basename: '%s'", basename.toUtf8().data());
     2446                qDebug("Core::startMplayer: file basename: '%s'", basename.toUtf8().data());
    23532447
    23542448                if (QFile::exists(basename+".edl"))
     
    24192513        QString line_for_log = commandline + "\n";
    24202514        emit logLineAvailable(line_for_log);
    2421        
     2515
     2516#ifdef Q_OS_WIN
     2517        if (!pref->use_windowsfontdir) {
     2518                QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
     2519                env.insert("FONTCONFIG_FILE", Paths::configPath() + "/fonts.conf");
     2520                proc->setProcessEnvironment(env);
     2521        }
     2522#endif
    24222523        if ( !proc->start() ) {
    24232524            // error handling
     
    28902991
    28912992void Core::incBrightness() {
    2892         setBrightness(mset.brightness + 4);
     2993        setBrightness(mset.brightness + );
    28932994}
    28942995
    28952996void Core::decBrightness() {
    2896         setBrightness(mset.brightness - 4);
     2997        setBrightness(mset.brightness - );
    28972998}
    28982999
    28993000void Core::incContrast() {
    2900         setContrast(mset.contrast + 4);
     3001        setContrast(mset.contrast + );
    29013002}
    29023003
    29033004void Core::decContrast() {
    2904         setContrast(mset.contrast - 4);
     3005        setContrast(mset.contrast - );
    29053006}
    29063007
    29073008void Core::incGamma() {
    2908         setGamma(mset.gamma + 4);
     3009        setGamma(mset.gamma + );
    29093010}
    29103011
    29113012void Core::decGamma() {
    2912         setGamma(mset.gamma - 4);
     3013        setGamma(mset.gamma - );
    29133014}
    29143015
    29153016void Core::incHue() {
    2916         setHue(mset.hue + 4);
     3017        setHue(mset.hue + );
    29173018}
    29183019
    29193020void Core::decHue() {
    2920         setHue(mset.hue - 4);
     3021        setHue(mset.hue - );
    29213022}
    29223023
    29233024void Core::incSaturation() {
    2924         setSaturation(mset.saturation + 4);
     3025        setSaturation(mset.saturation + );
    29253026}
    29263027
    29273028void Core::decSaturation() {
    2928         setSaturation(mset.saturation - 4);
     3029        setSaturation(mset.saturation - );
    29293030}
    29303031
     
    30413142void Core::incVolume() {
    30423143        qDebug("Core::incVolume");
    3043         int new_vol = (pref->global_volume ? pref->volume + 4 : mset.volume + 4);
     3144        int new_vol = (pref->global_volume ? pref->volume + );
    30443145        setVolume(new_vol);
    30453146}
     
    30473148void Core::decVolume() {
    30483149        qDebug("Core::incVolume");
    3049         int new_vol = (pref->global_volume ? pref->volume - 4 : mset.volume - 4);
     3150        int new_vol = (pref->global_volume ? pref->volume - );
    30503151        setVolume(new_vol);
    30513152}
     
    31993300// Audio equalizer functions
    32003301void Core::setAudioEqualizer(AudioEqualizerList values, bool restart) {
    3201         mset.audio_equalizer = values;
     3302        if (pref->global_audio_equalizer) {
     3303                pref->audio_equalizer = values;
     3304        } else {
     3305                mset.audio_equalizer = values;
     3306        }
    32023307
    32033308        if (!restart) {
     
    32143319
    32153320void Core::updateAudioEqualizer() {
    3216         setAudioEqualizer(mset.audio_equalizer);
     3321        setAudioEqualizer(pref->global_audio_equalizer ? pref->audio_equalizer : mset.audio_equalizer);
     3322}
     3323
     3324void Core::setAudioEq(int eq, int value) {
     3325        if (pref->global_audio_equalizer) {
     3326                pref->audio_equalizer[eq] = value;
     3327        } else {
     3328                mset.audio_equalizer[eq] = value;
     3329        }
     3330        updateAudioEqualizer();
    32173331}
    32183332
    32193333void Core::setAudioEq0(int value) {
    3220         mset.audio_equalizer[0] = value;
    3221         updateAudioEqualizer();
     3334        setAudioEq(0, value);
    32223335}
    32233336
    32243337void Core::setAudioEq1(int value) {
    3225         mset.audio_equalizer[1] = value;
    3226         updateAudioEqualizer();
     3338        setAudioEq(1, value);
    32273339}
    32283340
    32293341void Core::setAudioEq2(int value) {
    3230         mset.audio_equalizer[2] = value;
    3231         updateAudioEqualizer();
     3342        setAudioEq(2, value);
    32323343}
    32333344
    32343345void Core::setAudioEq3(int value) {
    3235         mset.audio_equalizer[3] = value;
    3236         updateAudioEqualizer();
     3346        setAudioEq(3, value);
    32373347}
    32383348
    32393349void Core::setAudioEq4(int value) {
    3240         mset.audio_equalizer[4] = value;
    3241         updateAudioEqualizer();
     3350        setAudioEq(4, value);
    32423351}
    32433352
    32443353void Core::setAudioEq5(int value) {
    3245         mset.audio_equalizer[5] = value;
    3246         updateAudioEqualizer();
     3354        setAudioEq(5, value);
    32473355}
    32483356
    32493357void Core::setAudioEq6(int value) {
    3250         mset.audio_equalizer[6] = value;
    3251         updateAudioEqualizer();
     3358        setAudioEq(6, value);
    32523359}
    32533360
    32543361void Core::setAudioEq7(int value) {
    3255         mset.audio_equalizer[7] = value;
    3256         updateAudioEqualizer();
     3362        setAudioEq(7, value);
    32573363}
    32583364
    32593365void Core::setAudioEq8(int value) {
    3260         mset.audio_equalizer[8] = value;
    3261         updateAudioEqualizer();
     3366        setAudioEq(8, value);
    32623367}
    32633368
    32643369void Core::setAudioEq9(int value) {
    3265         mset.audio_equalizer[9] = value;
    3266         updateAudioEqualizer();
     3370        setAudioEq(9, value);
    32673371}
    32683372
     
    34363540                        // the volume is reduced if using -softvol-max.
    34373541
    3438                         if (pref->global_volume) {
    3439                                 setVolume( pref->volume, true);
    3440                                 if (pref->mute) mute(true);
     3542                        if (pref->mplayer_additional_options.contains("-volume")) {
     3543                                qDebug("Core::changeAudio: don't set volume since -volume is used");
    34413544                        } else {
    3442                                 setVolume( mset.volume, true );
    3443                                 if (mset.mute) mute(true); // if muted, mute again
     3545                                if (pref->global_volume) {
     3546                                        setVolume( pref->volume, true);
     3547                                        if (pref->mute) mute(true);
     3548                                } else {
     3549                                        setVolume( mset.volume, true );
     3550                                        if (mset.mute) mute(true); // if muted, mute again
     3551                                }
    34443552                        }
    34453553                        updateWidgets();
     
    35453653        else
    35463654        if (mdat.type == TYPE_DVD) {
    3547 #if DVDNAV_SUPPORT
     3655#if DVDNAV_SUPPORT
    35483656                if (mdat.filename.startsWith("dvdnav:")) {
    35493657                        tellmp("switch_title " + QString::number(ID));
    35503658                } else {
    3551 #endif
     3659#endif
    35523660                        DiscData disc_data = DiscName::split(mdat.filename);
    35533661                        disc_data.title = ID;
     
    35553663
    35563664                        openDVD( DiscName::join(disc_data) );
    3557 #if DVDNAV_SUPPORT
    3558                 }
    3559 #endif
    3560         }
     3665                #if DVDNAV_SUPPORT
     3666                }
     3667                #endif
     3668        }
     3669#ifdef BLURAY_SUPPORT
     3670        else
     3671        if (mdat.type == TYPE_BLURAY) {
     3672                //DiscName::test();
     3673
     3674                DiscData disc_data = DiscName::split(mdat.filename);
     3675                disc_data.title = ID;
     3676                QString bluray_url = DiscName::join(disc_data);
     3677                qDebug("Core::changeTitle: bluray_url: %s", bluray_url.toUtf8().constData());
     3678                openBluRay(bluray_url);
     3679        }
     3680#endif
    35613681}
    35623682
     
    36803800      << MediaSettings::Aspect54        // 1.25
    36813801      << MediaSettings::Aspect43        // 1.33
     3802
    36823803      << MediaSettings::Aspect1410      // 1.4
    36833804      << MediaSettings::Aspect32        // 1.5
     
    37093830                        a = 2;
    37103831                // See if we are done
    3711                 if(pref->wheel_function_cycle.testFlag(QFlag(a)))
     3832                if))
    37123833                        done = true;
    37133834        }
     
    40844205        emit needResize( mset.win_width, mset.win_height );
    40854206        */
    4086         //mplayerwindow->showLogo(TRUE);
     4207        //mplayerwindow->showLogo();
    40874208        emit noVideo();
    40884209}
     
    43434464void Core::durationChanged(double length) {
    43444465        qDebug("Core::durationChanged: %f", length);
    4345         mdat.duration = length;
     4466        if (mdat.duration != length) {
     4467                mdat.duration = length;
     4468                emit newDuration(length);
     4469        }
    43464470}
    43474471
     
    43534477
    43544478void Core::dvdnavUpdateMousePos(QPoint pos) {
     4479
    43554480        if ((state() == Playing) && (mdat.filename.startsWith("dvdnav:")) && (dvdnav_title_is_menu)) {
    43564481                if (mplayerwindow->videoLayer()->underMouse()) {
    4357                         QPoint p = mplayerwindow->videoLayer()->mapFromParent(pos);
    4358                         tellmp(QString("set_mouse_pos %1 %2").arg(p.x()).arg(p.y()));
     4482                        tellmp(QString("set_mouse_pos %1 %2").arg(pos.x()).arg(pos.y()));
    43594483                }
    43604484        }
Note: See TracChangeset for help on using the changeset viewer.