Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
lektor
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
6f61189f
Vérifiée
Valider
6f61189f
rédigé
5 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Passing the window to the SDL thread, but nothing is displaying
parent
15b7d97b
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
1 requête de fusion
!57
Resolve "SDL2 module"
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/module/module_sdl2.c
+20
-10
20 ajouts, 10 suppressions
src/module/module_sdl2.c
avec
20 ajouts
et
10 suppressions
src/module/module_sdl2.c
+
20
−
10
Voir le fichier @
6f61189f
...
@@ -36,6 +36,7 @@ struct module_sdl2_window {
...
@@ -36,6 +36,7 @@ struct module_sdl2_window {
pthread_mutex_t
mtx
;
pthread_mutex_t
mtx
;
struct
lkt_thread
self
;
struct
lkt_thread
self
;
volatile
int
launched
;
volatile
int
launched
;
volatile
int
mpv_wakeup
;
};
};
/* Thread related functions */
/* Thread related functions */
...
@@ -51,8 +52,8 @@ sdl_thread__(struct lkt_thread_arg *arg)
...
@@ -51,8 +52,8 @@ sdl_thread__(struct lkt_thread_arg *arg)
int
w
,
h
;
int
w
,
h
;
free
(
arg
);
free
(
arg
);
(
void
)
self
;
(
void
)
self
;
if
(
sdl2
==
NULL
)
RETURN_UNLESS
(
sdl2
,
"Big nope here, the sdl window pointer is NULL"
,
NULL
)
;
return
false
;
fprintf
(
stderr
,
" * Started SDL thread
\n
"
)
;
/* SDL events won't change the database, only the mpv one's will.
/* SDL events won't change the database, only the mpv one's will.
Do this to be able to put the SDL stuff inside a thread and don't change
Do this to be able to put the SDL stuff inside a thread and don't change
...
@@ -96,6 +97,8 @@ loop:
...
@@ -96,6 +97,8 @@ loop:
flags
=
mpv_render_context_update
(
sdl2
->
mpv_gl
);
flags
=
mpv_render_context_update
(
sdl2
->
mpv_gl
);
if
(
flags
&
MPV_RENDER_UPDATE_FRAME
)
if
(
flags
&
MPV_RENDER_UPDATE_FRAME
)
redraw
=
1
;
redraw
=
1
;
if
(
event
.
type
==
wakeup_on_mpv_events
)
sdl2
->
mpv_wakeup
=
1
;
}
}
/* Handle mpv events are not done here. */
/* Handle mpv events are not done here. */
}
}
...
@@ -217,8 +220,8 @@ module_sdl2_new(struct lkt_win *const win)
...
@@ -217,8 +220,8 @@ module_sdl2_new(struct lkt_win *const win)
if
(
sdl2
==
NULL
)
{
if
(
sdl2
==
NULL
)
{
sdl2
=
calloc
(
1
,
sizeof
(
struct
module_sdl2_window
));
sdl2
=
calloc
(
1
,
sizeof
(
struct
module_sdl2_window
));
memset
(
sdl2
,
0
,
sizeof
(
struct
module_sdl2_window
));
RETURN_UNLESS
(
sdl2
,
"Out of memory"
,
false
);
RETURN_UNLESS
(
sdl2
,
"Out of memory"
,
false
);
memset
(
sdl2
,
0
,
sizeof
(
struct
module_sdl2_window
));
/* Yeah, this is how it is done. */
/* Yeah, this is how it is done. */
pthread_mutex_t
mtx
=
PTHREAD_MUTEX_INITIALIZER
;
pthread_mutex_t
mtx
=
PTHREAD_MUTEX_INITIALIZER
;
...
@@ -259,19 +262,21 @@ module_sdl2_new(struct lkt_win *const win)
...
@@ -259,19 +262,21 @@ module_sdl2_new(struct lkt_win *const win)
/* Init mpv_gl here */
/* Init mpv_gl here */
RETURN_IF
(
init_mpv_gl__
(
sdl2
->
mpv
,
&
sdl2
->
mpv_gl
,
params
),
"Failed to init mpv_gl"
,
false
);
RETURN_IF
(
init_mpv_gl__
(
sdl2
->
mpv
,
&
sdl2
->
mpv_gl
,
params
),
"Failed to init mpv_gl"
,
false
);
/* Finish */
SDL_SetWindowTitle
(
sdl2
->
window
,
"Lektord"
);
SDL_DisableScreenSaver
();
win
->
window
=
sdl2
;
/* Start the SDL thread */
/* Start the SDL thread */
if
(
!
sdl2
->
launched
)
{
if
(
!
sdl2
->
launched
)
{
struct
lkt_thread_arg
*
arg
=
calloc
(
1
,
sizeof
(
struct
lkt_thread_arg
));
struct
lkt_thread_arg
*
arg
=
calloc
(
1
,
sizeof
(
struct
lkt_thread_arg
));
RETURN_UNLESS
(
arg
,
"Out of memory"
,
false
);
RETURN_UNLESS
(
arg
,
"Out of memory"
,
false
);
arg
->
args
=
win
;
arg
->
args
=
win
;
sdl2
->
launched
=
1
;
RETURN_IF
(
lkt_th_new
(
&
sdl2
->
self
,
LKT_DEFAULT_LIST_SIZE
,
sdl_thread__
,
arg
),
RETURN_IF
(
lkt_th_new
(
&
sdl2
->
self
,
LKT_DEFAULT_LIST_SIZE
,
sdl_thread__
,
arg
),
"Failed to launch the SDL thread"
,
false
);
"Failed to launch the SDL thread"
,
false
);
}
}
/* Finish */
SDL_SetWindowTitle
(
sdl2
->
window
,
"Lektord"
);
SDL_DisableScreenSaver
();
win
->
window
=
sdl2
;
return
true
;
return
true
;
}
}
...
@@ -338,7 +343,12 @@ module_sdl2_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_
...
@@ -338,7 +343,12 @@ module_sdl2_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_
{
{
struct
module_sdl2_window
*
sdl2
=
win
->
window
;
struct
module_sdl2_window
*
sdl2
=
win
->
window
;
RETURN_UNLESS
(
sdl2
,
"Can't handle events from a NULL window"
,
false
);
RETURN_UNLESS
(
sdl2
,
"Can't handle events from a NULL window"
,
false
);
return
!
lmpv_handle
(
win
,
sdl2
->
mpv
,
db
,
mpd_idle_events
,
if
(
sdl2
->
mpv_wakeup
)
{
(
int
*
)
&
sdl2
->
mpv_time_pos
,
sdl2
->
mpv_wakeup
=
0
;
(
int
*
)
&
sdl2
->
mpv_duration
);
return
!
lmpv_handle
(
win
,
sdl2
->
mpv
,
db
,
mpd_idle_events
,
(
int
*
)
&
sdl2
->
mpv_time_pos
,
(
int
*
)
&
sdl2
->
mpv_duration
);
}
else
return
true
;
}
}
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter