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é GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
f94bad46
Vérifiée
Valider
f94bad46
rédigé
Il y a 5 ans
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
A working state, must clean some things up
parent
63913fe4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!57
Resolve "SDL2 module"
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/module/module_sdl2.c
+81
-86
81 ajouts, 86 suppressions
src/module/module_sdl2.c
avec
81 ajouts
et
86 suppressions
src/module/module_sdl2.c
+
81
−
86
Voir le fichier @
f94bad46
...
...
@@ -41,6 +41,60 @@ struct module_sdl2_window {
volatile
int
is_sdl_init
;
};
/* Private functions. */
static
inline
void
*
get_proc_address_mpv
(
void
*
fn_ctx
,
const
char
*
name
)
{
(
void
)
fn_ctx
;
return
SDL_GL_GetProcAddress
(
name
);
}
static
inline
void
on_mpv_events
(
void
*
ctx
)
{
(
void
)
ctx
;
SDL_Event
event
=
{
.
type
=
wakeup_on_mpv_events
};
SDL_PushEvent
(
&
event
);
}
static
inline
void
on_mpv_render_update
(
void
*
ctx
)
{
(
void
)
ctx
;
SDL_Event
event
=
{
.
type
=
wakeup_on_mpv_render_update
};
SDL_PushEvent
(
&
event
);
}
static
inline
bool
init_mpv__
(
mpv_handle
**
ctx
)
{
*
ctx
=
lmpv_prepare
();
int
status
;
RETURN_IF
((
status
=
mpv_initialize
(
*
ctx
))
<
0
,
mpv_error_string
(
status
),
1
);
RETURN_UNLESS
(
lmpv_observe_properties
(
*
ctx
),
"Observe properties failed"
,
1
);
return
0
;
}
static
inline
bool
init_mpv_gl__
(
mpv_handle
*
mpv
,
mpv_render_context
**
mpv_gl
,
mpv_render_param
*
params
)
{
int
status
;
RETURN_IF
((
status
=
mpv_render_context_create
(
mpv_gl
,
mpv
,
params
))
<
0
,
mpv_error_string
(
status
),
1
);
wakeup_on_mpv_render_update
=
SDL_RegisterEvents
(
1
);
wakeup_on_mpv_events
=
SDL_RegisterEvents
(
1
);
if
(
wakeup_on_mpv_render_update
==
(
Uint32
)
-
1
||
wakeup_on_mpv_events
==
(
Uint32
)
-
1
)
{
fprintf
(
stderr
,
" . init_mpv_gl__: Failed to register events
\n
"
);
return
1
;
}
mpv_set_wakeup_callback
(
mpv
,
on_mpv_events
,
NULL
);
mpv_render_context_set_update_callback
(
*
mpv_gl
,
on_mpv_render_update
,
NULL
);
return
0
;
}
/* Thread related functions */
static
void
*
...
...
@@ -66,6 +120,33 @@ sdl_thread__(struct lkt_thread_arg *arg)
RETURN_UNLESS
(
sdl2
->
glcontext
,
"Failed to create the SDL context"
,
NULL
);
sdl2
->
is_sdl_init
=
1
;
/* Init mpv here */
RETURN_IF
(
init_mpv__
((
mpv_handle
**
)
&
sdl2
->
mpv
),
"Failed to init mpv"
,
false
);
mpv_render_param
params
[]
=
{
{
MPV_RENDER_PARAM_API_TYPE
,
MPV_RENDER_API_TYPE_OPENGL
},
{
MPV_RENDER_PARAM_OPENGL_INIT_PARAMS
,
&
(
mpv_opengl_init_params
)
{
.
get_proc_address
=
get_proc_address_mpv
,
}
},
{
// Can't use mpv_command with that thing, should change to mpv_command_async
MPV_RENDER_PARAM_ADVANCED_CONTROL
,
&
(
int
)
{
1
}
},
{
0
}
};
/* Init mpv_gl here */
RETURN_IF
(
init_mpv_gl__
((
mpv_handle
*
)
sdl2
->
mpv
,
(
mpv_render_context
**
)
&
sdl2
->
mpv_gl
,
params
),
"Failed to init mpv_gl"
,
false
);
while
(
!
sdl2
->
launched
)
sched_yield
();
...
...
@@ -139,31 +220,6 @@ loop:
goto
loop
;
/* A loop without indentation. */
}
/* Private functions. */
static
inline
void
*
get_proc_address_mpv
(
void
*
fn_ctx
,
const
char
*
name
)
{
(
void
)
fn_ctx
;
return
SDL_GL_GetProcAddress
(
name
);
}
static
inline
void
on_mpv_events
(
void
*
ctx
)
{
(
void
)
ctx
;
SDL_Event
event
=
{
.
type
=
wakeup_on_mpv_events
};
SDL_PushEvent
(
&
event
);
}
static
inline
void
on_mpv_render_update
(
void
*
ctx
)
{
(
void
)
ctx
;
SDL_Event
event
=
{
.
type
=
wakeup_on_mpv_render_update
};
SDL_PushEvent
(
&
event
);
}
/* Exported functions */
extern
int
...
...
@@ -186,40 +242,6 @@ module_set_function(void *arg__, void *handle__)
return
0
;
}
/* Private init functions */
static
inline
bool
init_mpv__
(
mpv_handle
**
ctx
)
{
*
ctx
=
lmpv_prepare
();
int
status
;
RETURN_IF
((
status
=
mpv_initialize
(
*
ctx
))
<
0
,
mpv_error_string
(
status
),
1
);
RETURN_UNLESS
(
lmpv_observe_properties
(
*
ctx
),
"Observe properties failed"
,
1
);
return
0
;
}
static
inline
bool
init_mpv_gl__
(
mpv_handle
*
mpv
,
mpv_render_context
**
mpv_gl
,
mpv_render_param
*
params
)
{
int
status
;
RETURN_IF
((
status
=
mpv_render_context_create
(
mpv_gl
,
mpv
,
params
))
<
0
,
mpv_error_string
(
status
),
1
);
wakeup_on_mpv_render_update
=
SDL_RegisterEvents
(
1
);
wakeup_on_mpv_events
=
SDL_RegisterEvents
(
1
);
if
(
wakeup_on_mpv_render_update
==
(
Uint32
)
-
1
||
wakeup_on_mpv_events
==
(
Uint32
)
-
1
)
{
fprintf
(
stderr
,
" . init_mpv_gl__: Failed to register events
\n
"
);
return
1
;
}
mpv_set_wakeup_callback
(
mpv
,
on_mpv_events
,
NULL
);
mpv_render_context_set_update_callback
(
*
mpv_gl
,
on_mpv_render_update
,
NULL
);
return
0
;
}
/* Exported functions */
bool
module_sdl2_new
(
struct
lkt_win
*
const
win
)
{
...
...
@@ -246,33 +268,6 @@ module_sdl2_new(struct lkt_win *const win)
while
(
!
((
struct
module_sdl2_window
*
)
win
->
window
)
->
is_sdl_init
)
sched_yield
();
/* Init mpv here */
RETURN_IF
(
init_mpv__
((
mpv_handle
**
)
&
((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv
),
"Failed to init mpv"
,
false
);
mpv_render_param
params
[]
=
{
{
MPV_RENDER_PARAM_API_TYPE
,
MPV_RENDER_API_TYPE_OPENGL
},
{
MPV_RENDER_PARAM_OPENGL_INIT_PARAMS
,
&
(
mpv_opengl_init_params
)
{
.
get_proc_address
=
get_proc_address_mpv
,
}
},
{
// Can't use mpv_command with that thing, should change to mpv_command_async
MPV_RENDER_PARAM_ADVANCED_CONTROL
,
&
(
int
)
{
1
}
},
{
0
}
};
/* Init mpv_gl here */
RETURN_IF
(
init_mpv_gl__
((
mpv_handle
*
)
((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv
,
(
mpv_render_context
**
)
&
((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv_gl
,
params
),
"Failed to init mpv_gl"
,
false
);
/* Finish */
SDL_SetWindowTitle
((
SDL_Window
*
)
((
struct
module_sdl2_window
*
)
win
->
window
)
->
window
,
"Lektord"
);
SDL_DisableScreenSaver
();
...
...
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