Changeset 181 for smplayer/trunk/src/core.cpp
- Timestamp:
- Aug 31, 2016, 5:31:04 PM (9 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/core.cpp (modified) (44 diffs)
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 179
- Property svn:mergeinfo changed
-
smplayer/trunk/src/core.cpp
r176 r181 43 43 #include "discname.h" 44 44 #include "filters.h" 45 #include "tvlist.h" 46 47 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) 45 #include "extensions.h" 46 48 47 #ifdef Q_OS_WIN 49 48 #include <windows.h> // To change app priority … … 53 52 #include "screensaver.h" 54 53 #endif 55 #endif 56 57 #ifndef NO_USE_INI_FILES 54 58 55 #include "filesettings.h" 59 56 #include "filesettingshash.h" 57 58 59 60 60 #include "tvsettings.h" 61 61 #endif … … 90 90 #endif 91 91 92 #ifndef NO_USE_INI_FILES93 92 // Create file_settings 94 93 file_settings = 0; … … 96 95 97 96 // TV settings 97 98 98 tv_settings = new TVSettings(Paths::iniPath()); 99 99 #endif … … 278 278 mplayerwindow->setMonitorAspect( pref->monitor_aspect_double() ); 279 279 280 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)281 280 #ifdef SCREENSAVER_OFF 282 281 // Windows or OS2 screensaver … … 286 285 connect( proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(enableScreensaver()) ); 287 286 #endif 288 #endif289 287 290 288 #ifdef YOUTUBE_SUPPORT … … 311 309 312 310 Core::~Core() { 313 #ifndef NO_USE_INI_FILES314 311 saveMediaInfo(); 315 #endif316 312 317 313 if (proc->isRunning()) stopMplayer(); … … 319 315 delete proc; 320 316 321 #ifndef NO_USE_INI_FILES322 317 delete file_settings; 318 323 319 delete tv_settings; 324 320 #endif 325 321 326 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)327 322 #ifdef SCREENSAVER_OFF 328 323 delete win_screensaver; 329 324 #endif 330 #endif331 325 332 326 #ifdef YOUTUBE_SUPPORT … … 335 329 } 336 330 337 #ifndef NO_USE_INI_FILES338 331 void Core::changeFileSettingsMethod(QString method) { 339 332 qDebug("Core::changeFileSettingsMethod: %s", method.toUtf8().constData()); … … 345 338 file_settings = new FileSettings(Paths::iniPath()); 346 339 } 347 #endif348 340 349 341 void Core::setState(State s) { … … 384 376 } 385 377 386 #ifndef NO_USE_INI_FILES387 378 void Core::saveMediaInfo() { 388 379 qDebug("Core::saveMediaInfo"); 389 380 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: "); 392 383 return; 393 384 } 394 385 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 398 395 else 399 396 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 402 void 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 } 404 438 405 439 void Core::initializeMenus() { … … 525 559 } 526 560 } 561 527 562 else 528 563 if ((file.toLower().startsWith("dvb:")) || (file.toLower().startsWith("tv:"))) { … … 530 565 openTV(file); 531 566 } 567 532 568 else { 533 569 qDebug("Core::open: * not identified, playing as stream"); … … 568 604 #endif 569 605 570 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)571 606 #ifdef SCREENSAVER_OFF 572 607 void Core::enableScreensaver() { … … 583 618 } 584 619 } 585 #endif586 620 #endif 587 621 … … 704 738 705 739 // Save data of previous file: 706 #ifndef NO_USE_INI_FILES707 740 saveMediaInfo(); 708 #endif709 741 710 742 mdat.reset(); … … 732 764 733 765 // Save data of previous file: 734 #ifndef NO_USE_INI_FILES735 766 saveMediaInfo(); 736 #endif737 767 738 768 mdat.reset(); … … 779 809 780 810 // Save data of previous file: 781 #ifndef NO_USE_INI_FILES782 811 saveMediaInfo(); 783 #endif784 812 785 813 mdat.reset(); … … 827 855 828 856 // Save data of previous file: 829 #ifndef NO_USE_INI_FILES830 857 saveMediaInfo(); 831 #endif832 858 833 859 mdat.reset(); … … 846 872 #endif 847 873 874 848 875 void Core::openTV(QString channel_id) { 849 876 qDebug("Core::openTV: '%s'", channel_id.toUtf8().constData()); … … 855 882 856 883 // Save data of previous file: 857 #ifndef NO_USE_INI_FILES858 884 saveMediaInfo(); 859 #endif860 885 861 886 // Use last channel if the name is just "dvb://" or "tv://" … … 882 907 mset.current_deinterlacer = pref->initial_tv_deinterlace; 883 908 884 #ifndef NO_USE_INI_FILES 885 if (!pref->dont_remember_media_settings) { 909 if (pref->remember_media_settings) { 886 910 // Check if we already have info about this file 887 if (tv_settings->existSettingsFor(channel_id )) {911 if (tv_settings->existSettingsFor(channel_id)) { 888 912 qDebug("Core::openTV: we have settings for this file!!!"); 889 913 890 914 // In this case we read info from config 891 tv_settings->loadSettingsFor(channel_id, m set, proc->player());915 tv_settings->loadSettingsFor(channel_id, mset, proc->player()); 892 916 qDebug("Core::openTV: media settings read"); 893 917 } 894 918 } 895 #endif896 919 897 920 /* initializeMenus(); */ … … 899 922 initPlaying(); 900 923 } 924 901 925 902 926 void Core::openStream(QString name) { … … 929 953 930 954 // Save data of previous file: 931 #ifndef NO_USE_INI_FILES932 955 saveMediaInfo(); 933 #endif934 956 935 957 mdat.reset(); … … 939 961 mset.reset(); 940 962 963 964 965 966 967 968 969 970 971 972 973 941 974 /* initializeMenus(); */ 942 975 … … 954 987 955 988 // Save data of previous file: 956 #ifndef NO_USE_INI_FILES957 989 saveMediaInfo(); 958 #endif959 990 960 991 mdat.reset(); … … 965 996 mset.reset(); 966 997 967 #ifndef NO_USE_INI_FILES968 998 // 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); 999 1002 } else { 1000 1003 // Recover volume 1001 1004 mset.volume = old_volume; 1002 1005 } 1003 #else1004 // Recover volume1005 mset.volume = old_volume;1006 #endif // NO_USE_INI_FILES1007 1006 1008 1007 /* initializeMenus(); */ … … 1068 1067 1069 1068 // Video 1069 1070 1070 if ( (mset.current_video_id == MediaSettings::NoneSelected) && 1071 1071 (mdat.videos.numItems() > 0) ) … … 1073 1073 changeVideo( mdat.videos.itemAt(0).ID(), false ); // Don't allow to restart 1074 1074 } 1075 1075 1076 1076 1077 #if !DELAYED_AUDIO_SETUP_ON_STARTUP && !NOTIFY_AUDIO_CHANGES … … 1278 1279 emit mediaInfoChanged(); 1279 1280 emit newDuration(mdat.duration); 1281 1282 1280 1283 1281 1284 updateWidgets(); // New … … 1546 1549 qDebug("Core::startMplayer: url_is_playlist: %d", url_is_playlist); 1547 1550 1551 1552 1553 1554 1555 1556 1557 1558 1548 1559 1549 1560 // Check if a m4a file exists with the same name of file, in that cause if will be used as audio … … 1695 1706 proc->setOption("sub-fuzziness", pref->subfuzziness); 1696 1707 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 1712 1720 1713 1721 #if USE_ADAPTER … … 1717 1725 #endif 1718 1726 1719 if ( pref->ao != "player_default") {1720 if (!pref->ao.isEmpty()) {1721 proc->setOption("ao", pref->ao );1722 }1727 if () { 1728 1729 ; 1730 1723 1731 } 1724 1732 … … 2078 2086 case TYPE_VCD : cache = pref->cache_for_vcds; break; 2079 2087 case TYPE_AUDIO_CD : cache = pref->cache_for_audiocds; break; 2088 2080 2089 case TYPE_TV : cache = pref->cache_for_tv; break; 2090 2081 2091 #ifdef BLURAY_SUPPORT 2082 2092 case TYPE_BLURAY : cache = pref->cache_for_dvds; break; // FIXME: use cache for bluray? … … 2085 2095 } 2086 2096 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 } 2088 2102 2089 2103 if (mset.speed != 1.0) { … … 2094 2108 // Play A - B 2095 2109 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 } 2098 2119 } 2099 2120 else … … 2335 2356 } 2336 2357 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); 2343 2369 } 2344 2370 … … 2364 2390 2365 2391 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"); 2368 2395 } 2369 2396 2370 2397 #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) 2384 2426 if (proc->isMPV() && file.startsWith("dvb:")) { 2385 2427 QString channels_file = TVList::findChannelsFile(); … … 2657 2699 displayMessage( tr("\"A\" marker set to %1").arg(Helper::formatTime(sec)) ); 2658 2700 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 } 2661 2708 } 2662 2709 … … 2674 2721 displayMessage( tr("\"B\" marker set to %1").arg(Helper::formatTime(sec)) ); 2675 2722 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 } 2678 2730 } 2679 2731 … … 2688 2740 mset.B_marker = -1; 2689 2741 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 } 2691 2748 } 2692 2749 … … 2707 2764 int v = -1; // no loop 2708 2765 if (mset.loop) v = 0; // infinite loop 2766 2767 2768 2769 2770 2771 2772 2773 2709 2774 proc->setLoop(v); 2710 2775 } else { … … 3495 3560 3496 3561 void 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; 3498 3565 3499 3566 if (mset.starting_time != -1) { … … 4345 4412 4346 4413 void 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()) { 4350 4418 qDebug("Core::gotVO: saving vo"); 4351 4419 pref->vo = vo; 4352 4420 } 4421 4353 4422 } 4354 4423 4355 4424 void 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()) { 4359 4429 qDebug("Core::gotAO: saving ao"); 4360 4430 pref->ao = ao; 4361 4431 } 4432 4362 4433 } 4363 4434
Note:
See TracChangeset
for help on using the changeset viewer.
