Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 7b9c9120 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

MPV: Add the callbacks after init to try to avoid some strange segfaults witihn mpv's lua

parent 0230e2d0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!18Implement the VivyDocument specification
......@@ -33,13 +33,13 @@ MpvContainer::MpvContainer(QWidget *parent)
mpv_observe_property(mpv, 0, "duration", MPV_FORMAT_DOUBLE);
mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
connect(this, &MpvContainer::mpvEvent, this, &MpvContainer::onMpvEvent, Qt::QueuedConnection);
mpv_set_wakeup_callback(mpv, &MpvContainer::mpvEventWakeUpCB, this);
if (int rc = mpv_initialize(mpv); rc < 0) {
printMpvError(rc);
throw std::runtime_error("Failed to initialize the mpv context");
}
connect(this, &MpvContainer::mpvEvent, this, &MpvContainer::onMpvEvent, Qt::QueuedConnection);
mpv_set_wakeup_callback(mpv, &MpvContainer::mpvEventWakeUpCB, this);
}
void
......@@ -78,7 +78,6 @@ void
MpvContainer::handleMpvEvent(const mpv_event *const event) noexcept
{
// Declare here variables that can be used in the switch-case statements
qint64 w, h;
double time;
QString msgText;
union {
......@@ -94,14 +93,6 @@ MpvContainer::handleMpvEvent(const mpv_event *const event) noexcept
switch (event->event_id) {
case MPV_EVENT_SHUTDOWN: closeMpv(); break;
case MPV_EVENT_VIDEO_RECONFIG:
// TODO: Those are sync calls, prefer async calls
if (mpv_get_property(mpv, "dwidth", MPV_FORMAT_INT64, &w) >= 0 &&
mpv_get_property(mpv, "dheight", MPV_FORMAT_INT64, &h) >= 0 && (w > 0 && h > 0)) {
qDebug() << "Reconfigure video to" << w << "x" << h;
}
break;
case MPV_EVENT_LOG_MESSAGE:
msg = reinterpret_cast<mpv_event_log_message *>(event->data);
msgText = QString::fromUtf8(msg->text);
......@@ -143,7 +134,6 @@ MpvContainer::handleMpvEvent(const mpv_event *const event) noexcept
break;
case MPV_EVENT_START_FILE: qDebug() << "MPV: Begin of file"; break;
case MPV_EVENT_END_FILE: qDebug() << "MPV: Reached end of file!"; break;
case MPV_EVENT_COMMAND_REPLY:
......@@ -152,6 +142,7 @@ MpvContainer::handleMpvEvent(const mpv_event *const event) noexcept
break;
// Explicitly ignored
case MPV_EVENT_VIDEO_RECONFIG:
case MPV_EVENT_NONE:
case MPV_EVENT_GET_PROPERTY_REPLY:
case MPV_EVENT_SET_PROPERTY_REPLY:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter