diff options
author | Mateusz Łukasik <mati75@linuxmint.pl> | 2018-01-10 18:21:21 +0100 |
---|---|---|
committer | Mateusz Łukasik <mati75@linuxmint.pl> | 2018-01-10 18:21:21 +0100 |
commit | 458e01ecbd3fe8ad87920bfffd113c1c87dfc637 (patch) | |
tree | 4ed5605a631bbc136817d2f1f4167c09e30532aa /src/mpvprocess.cpp | |
parent | d766ddb2d0f17beb0589a0375ee2d0509de2641d (diff) |
New upstream version 18.1.0~ds0
Diffstat (limited to 'src/mpvprocess.cpp')
-rw-r--r-- | src/mpvprocess.cpp | 103 |
1 files changed, 65 insertions, 38 deletions
diff --git a/src/mpvprocess.cpp b/src/mpvprocess.cpp index e37887a..8233ab1 100644 --- a/src/mpvprocess.cpp +++ b/src/mpvprocess.cpp @@ -1,5 +1,5 @@ /* smplayer, GUI front-end for mplayer. - Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net> + Copyright (C) 2006-2018 Ricardo Villalba <rvm@users.sourceforge.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,21 +44,21 @@ MPVProcess::MPVProcess(QObject * parent) #if NOTIFY_SUB_CHANGES , subtitle_info_received(false) , subtitle_info_changed(false) + , selected_subtitle(-1) #endif #if NOTIFY_AUDIO_CHANGES , audio_info_changed(false) + , selected_audio(-1) #endif #if NOTIFY_VIDEO_CHANGES , video_info_changed(false) + , selected_video(-1) #endif #if NOTIFY_CHAPTER_CHANGES , chapter_info_changed(false) #endif , dvd_current_title(-1) , br_current_title(-1) -#ifdef OSD_WITH_TIMER - , osd_timer(0) -#endif { player_id = PlayerID::MPV; @@ -73,6 +73,7 @@ MPVProcess::MPVProcess(QObject * parent) /* int svn = MplayerVersion::mplayerVersion("mpv unknown version (C)"); */ + initializeOptionVars(); initializeRX(); } @@ -91,16 +92,19 @@ bool MPVProcess::start() { subs.clear(); subtitle_info_received = false; subtitle_info_changed = false; + selected_subtitle = -1; #endif #if NOTIFY_AUDIO_CHANGES audios.clear(); audio_info_changed = false; + selected_audio = -1; #endif #if NOTIFY_VIDEO_CHANGES videos.clear(); video_info_changed = false; + selected_video = -1; #endif #if NOTIFY_CHAPTER_CHANGES @@ -294,7 +298,7 @@ void MPVProcess::parseLine(QByteArray ba) { qDebug("MPVProcess::parseLine: subtitle_info_changed"); subtitle_info_changed = false; subtitle_info_received = false; - emit subtitleInfoChanged(subs); + emit subtitleInfoChanged(subs, selected_subtitle); } if (subtitle_info_received) { qDebug("MPVProcess::parseLine: subtitle_info_received"); @@ -309,7 +313,7 @@ void MPVProcess::parseLine(QByteArray ba) { if (audio_info_changed) { qDebug("MPVProcess::parseLine: audio_info_changed"); audio_info_changed = false; - emit audioInfoChanged(audios); + emit audioInfoChanged(audios, selected_audio); } } #endif @@ -319,7 +323,7 @@ void MPVProcess::parseLine(QByteArray ba) { if (video_info_changed) { qDebug("MPVProcess::parseLine: video_info_changed"); video_info_changed = false; - emit videoInfoChanged(videos); + emit videoInfoChanged(videos, selected_video); } } #endif @@ -432,12 +436,12 @@ void MPVProcess::parseLine(QByteArray ba) { qDebug() << "MPVProcess::parseLine: audio id:" << ID << "lang:" << lang << "name:" << title; #if NOTIFY_AUDIO_CHANGES - updateAudioTrack(ID, title, lang); + updateAudioTrack(ID, title, lang, false); #else - if (md.audios.find(ID) == -1) { - md.audios.addID(ID); - md.audios.addName(ID, title); - md.audios.addLang(ID, lang); + if (md.taudios.find(ID) == -1) { + md.taudios.addID(ID); + md.taudios.addName(ID, title); + md.taudios.addLang(ID, lang); } #endif } @@ -459,12 +463,12 @@ void MPVProcess::parseLine(QByteArray ba) { qDebug() << "MPVProcess::parseLine: sub id:" << ID << "lang:" << lang << "name:" << title; #if NOTIFY_SUB_CHANGES - updateSubtitleTrack(ID, title, lang); + updateSubtitleTrack(ID, title, lang, false); #else - if (md.subs.find(SubData::Sub, ID) == -1) { - md.subs.add(SubData::Sub, ID); - md.subs.changeName(SubData::Sub, ID, title); - md.subs.changeLang(SubData::Sub, ID, lang); + if (md.tsubs.find(SubData::Sub, ID) == -1) { + md.tsubs.add(SubData::Sub, ID); + md.tsubs.changeName(SubData::Sub, ID, title); + md.tsubs.changeLang(SubData::Sub, ID, lang); } #endif } @@ -490,7 +494,7 @@ void MPVProcess::parseLine(QByteArray ba) { QString title = rx_video.cap(4); qDebug("MPVProcess::parseLine: video id: %d, name: '%s'", ID, title.toUtf8().constData()); //md.videos.addID(ID); - md.videos.addName(ID, title); + md.tvideos.addName(ID, title); } else #endif @@ -537,34 +541,19 @@ void MPVProcess::parseLine(QByteArray ba) { */ if (type == "video") { #if NOTIFY_VIDEO_CHANGES - int idx = videos.find(ID); - if (idx == -1) { - video_info_changed = true; - videos.addName(ID, name); - videos.addLang(ID, lang); - } else { - // Track already existed - if (videos.itemAt(idx).name() != name) { - video_info_changed = true; - videos.addName(ID, name); - } - if (videos.itemAt(idx).lang() != lang) { - video_info_changed = true; - videos.addLang(ID, lang); - } - } + updateVideoTrack(ID, name, lang, (selected == "yes")); #endif } else if (type == "audio") { #if NOTIFY_AUDIO_CHANGES - updateAudioTrack(ID, name, lang); + updateAudioTrack(ID, name, lang, (selected == "yes")); #endif } else if (type == "sub") { #if NOTIFY_SUB_CHANGES - updateSubtitleTrack(ID, name, lang); + updateSubtitleTrack(ID, name, lang, (selected == "yes")); #endif } } @@ -776,8 +765,36 @@ void MPVProcess::requestBitrateInfo() { } */ +#if NOTIFY_VIDEO_CHANGES +void MPVProcess::updateVideoTrack(int ID, const QString & name, const QString & lang, bool selected) { + qDebug("MPVProcess::updateVideoTrack: ID: %d", ID); + + int idx = videos.find(ID); + if (idx == -1) { + video_info_changed = true; + videos.addName(ID, name); + videos.addLang(ID, lang); + } else { + // Track already existed + if (videos.itemAt(idx).name() != name) { + video_info_changed = true; + videos.addName(ID, name); + } + if (videos.itemAt(idx).lang() != lang) { + video_info_changed = true; + videos.addLang(ID, lang); + } + } + + if (selected && selected_video != ID) { + selected_video = ID; + video_info_changed = true; + } +} +#endif + #if NOTIFY_AUDIO_CHANGES -void MPVProcess::updateAudioTrack(int ID, const QString & name, const QString & lang) { +void MPVProcess::updateAudioTrack(int ID, const QString & name, const QString & lang, bool selected) { qDebug("MPVProcess::updateAudioTrack: ID: %d", ID); int idx = audios.find(ID); @@ -796,11 +813,16 @@ void MPVProcess::updateAudioTrack(int ID, const QString & name, const QString & audios.addLang(ID, lang); } } + + if (selected && selected_audio != ID) { + selected_audio = ID; + audio_info_changed = true; + } } #endif #if NOTIFY_SUB_CHANGES -void MPVProcess::updateSubtitleTrack(int ID, const QString & name, const QString & lang) { +void MPVProcess::updateSubtitleTrack(int ID, const QString & name, const QString & lang, bool selected) { qDebug("MPVProcess::updateSubtitleTrack: ID: %d", ID); int idx = subs.find(SubData::Sub, ID); @@ -821,6 +843,11 @@ void MPVProcess::updateSubtitleTrack(int ID, const QString & name, const QString subs.changeLang(SubData::Sub, ID, lang); } } + + if (selected && selected_subtitle != ID) { + selected_subtitle = ID; + subtitle_info_changed = true; + } } #endif |