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
bed922f4
Vérifiée
Valider
bed922f4
rédigé
5 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Factorise code of the sdl2 module
parent
d9758bca
Aucune branche associée trouvée
Aucune étiquette associée trouvée
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
+15
-94
15 ajouts, 94 suppressions
src/module/module_sdl2.c
avec
15 ajouts
et
94 suppressions
src/module/module_sdl2.c
+
15
−
94
Voir le fichier @
bed922f4
...
@@ -36,14 +36,14 @@ die(const char *msg)
...
@@ -36,14 +36,14 @@ die(const char *msg)
exit
(
1
);
exit
(
1
);
}
}
static
void
*
static
inline
void
*
get_proc_address_mpv
(
void
*
fn_ctx
,
const
char
*
name
)
get_proc_address_mpv
(
void
*
fn_ctx
,
const
char
*
name
)
{
{
(
void
)
fn_ctx
;
(
void
)
fn_ctx
;
return
SDL_GL_GetProcAddress
(
name
);
return
SDL_GL_GetProcAddress
(
name
);
}
}
static
void
static
inline
void
on_mpv_events
(
void
*
ctx
)
on_mpv_events
(
void
*
ctx
)
{
{
(
void
)
ctx
;
(
void
)
ctx
;
...
@@ -51,7 +51,7 @@ on_mpv_events(void *ctx)
...
@@ -51,7 +51,7 @@ on_mpv_events(void *ctx)
SDL_PushEvent
(
&
event
);
SDL_PushEvent
(
&
event
);
}
}
static
void
static
inline
void
on_mpv_render_update
(
void
*
ctx
)
on_mpv_render_update
(
void
*
ctx
)
{
{
(
void
)
ctx
;
(
void
)
ctx
;
...
@@ -370,9 +370,7 @@ module_sdl2_close(struct lkt_win *const win)
...
@@ -370,9 +370,7 @@ module_sdl2_close(struct lkt_win *const win)
{
{
if
(
win
==
NULL
||
win
->
window
==
NULL
)
if
(
win
==
NULL
||
win
->
window
==
NULL
)
return
;
return
;
lmpv_free
(
&
((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv
);
struct
module_sdl2_window
*
const
sdl2
=
win
->
window
;
lmpv_free
(
&
sdl2
->
mpv
);
}
}
void
void
...
@@ -386,24 +384,9 @@ module_sdl2_toggle_pause(struct lkt_win *const win, bool *new_paused)
...
@@ -386,24 +384,9 @@ module_sdl2_toggle_pause(struct lkt_win *const win, bool *new_paused)
{
{
if
(
win
==
NULL
||
win
->
window
==
NULL
)
if
(
win
==
NULL
||
win
->
window
==
NULL
)
return
false
;
return
false
;
int
pause
,
ret
=
!
lmpv_toggle_pause
(((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv
,
&
pause
);
mpv_handle
*
ctx
=
((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv
;
*
new_paused
=
pause
;
return
ret
;
if
(
!
ctx
)
{
fprintf
(
stderr
,
" ! module_sdl2_toggle_pause: failed due to missing mpv ctx
\n
"
);
return
false
;
}
const
char
*
cmd
[]
=
{
"cycle"
,
"pause"
,
"up"
,
NULL
};
int
status
;
if
((
status
=
mpv_command
(
ctx
,
cmd
))
<
0
)
{
fprintf
(
stderr
,
"module_sdl2_toggle_pause: Failed issue command: %s
\n
"
,
mpv_error_string
(
status
));
return
false
;
}
return
module_sdl2_is_paused
(
win
,
new_paused
);
}
}
bool
bool
...
@@ -411,34 +394,11 @@ module_sdl2_load_file(struct lkt_win *const win, const char *filepath)
...
@@ -411,34 +394,11 @@ module_sdl2_load_file(struct lkt_win *const win, const char *filepath)
{
{
if
(
win
==
NULL
||
win
->
window
==
NULL
)
if
(
win
==
NULL
||
win
->
window
==
NULL
)
return
false
;
return
false
;
struct
module_sdl2_window
*
sdl2
=
win
->
window
;
struct
module_sdl2_window
*
sdl2
=
win
->
window
;
mpv_handle
*
ctx
=
sdl2
->
mpv
;
bool
ret
=
!
lmpv_load_file
(
sdl2
->
mpv
,
filepath
);
if
(
!
ctx
)
{
fprintf
(
stderr
,
" ! module_sdl2_load_file: failed due to missing mpv ctx
\n
"
);
return
false
;
}
if
(
access
(
filepath
,
R_OK
))
{
fprintf
(
stderr
,
" ! module_sdl2_load_file: Faild to read file: %s
\n
"
,
filepath
);
return
false
;
}
const
char
*
cmd
[]
=
{
"loadfile"
,
filepath
,
"replace"
,
NULL
};
int
status
;
if
((
status
=
mpv_command
(
ctx
,
cmd
))
<
0
)
{
fprintf
(
stderr
,
" ! module_sdl2_load_file: Failed to add '%s': %s
\n
"
,
filepath
,
mpv_error_string
(
status
));
return
false
;
}
sdl2
->
mpv_duration
=
0
;
sdl2
->
mpv_duration
=
0
;
sdl2
->
mpv_time_pos
=
0
;
sdl2
->
mpv_time_pos
=
0
;
return
ret
;
fprintf
(
stderr
,
" . module_x11_load_file: added file %s
\n
"
,
filepath
);
return
true
;
}
}
bool
bool
...
@@ -446,27 +406,7 @@ module_sdl2_set_volume(struct lkt_win *const win, int vol)
...
@@ -446,27 +406,7 @@ module_sdl2_set_volume(struct lkt_win *const win, int vol)
{
{
if
(
win
==
NULL
||
win
->
window
==
NULL
)
if
(
win
==
NULL
||
win
->
window
==
NULL
)
return
false
;
return
false
;
return
!
lmpv_set_volume
(((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv
,
vol
);
mpv_handle
*
ctx
=
((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv
;
if
(
!
ctx
)
{
fprintf
(
stderr
,
" ! module_sdl2_set_volume: failed due to missing mpv ctx
\n
"
);
return
false
;
}
int
status
;
char
str
[
5
];
memset
(
str
,
0
,
5
);
snprintf
(
str
,
4
,
"%d"
,
vol
);
const
char
*
cmd
[]
=
{
"set"
,
"ao-volume"
,
str
,
NULL
};
if
((
status
=
mpv_command
(
ctx
,
cmd
))
<
0
)
{
fprintf
(
stderr
,
" ! module_x11_set_volume: Failed to execute command: %s
\n
"
,
mpv_error_string
(
status
));
return
false
;
}
return
true
;
}
}
bool
bool
...
@@ -474,22 +414,9 @@ module_sdl2_is_paused(struct lkt_win *const win, bool *ret)
...
@@ -474,22 +414,9 @@ module_sdl2_is_paused(struct lkt_win *const win, bool *ret)
{
{
if
(
win
==
NULL
||
win
->
window
==
NULL
)
if
(
win
==
NULL
||
win
->
window
==
NULL
)
return
false
;
return
false
;
int
ret_
,
sta
=
!
lmpv_is_paused
(((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv
,
&
ret_
);
mpv_handle
*
ctx
=
((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv
;
*
ret
=
ret_
;
int
status
;
return
sta
;
if
(
!
ctx
)
{
fprintf
(
stderr
,
" ! module_sdl2_is_paused: failed due to missing mpv ctx
\n
"
);
return
false
;
}
if
((
status
=
mpv_get_property
(
ctx
,
"pause"
,
MPV_FORMAT_FLAG
,
&
ret
))
<
0
)
{
fprintf
(
stderr
,
"module_sdl2_is_paused: Failed to get pause property: %s
\n
"
,
mpv_error_string
(
status
));
return
false
;
}
return
true
;
}
}
bool
bool
...
@@ -497,10 +424,7 @@ module_sdl2_get_duration(struct lkt_win *const win, int *dur_sec)
...
@@ -497,10 +424,7 @@ module_sdl2_get_duration(struct lkt_win *const win, int *dur_sec)
{
{
if
(
win
==
NULL
||
win
->
window
==
NULL
)
if
(
win
==
NULL
||
win
->
window
==
NULL
)
return
false
;
return
false
;
*
dur_sec
=
((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv_duration
;
struct
module_sdl2_window
*
sdl2
=
win
->
window
;
*
dur_sec
=
sdl2
->
mpv_duration
;
return
true
;
return
true
;
}
}
...
@@ -509,10 +433,7 @@ module_sdl2_get_elapsed(struct lkt_win *const win, int *elapsed_sec)
...
@@ -509,10 +433,7 @@ module_sdl2_get_elapsed(struct lkt_win *const win, int *elapsed_sec)
{
{
if
(
win
==
NULL
||
win
->
window
==
NULL
)
if
(
win
==
NULL
||
win
->
window
==
NULL
)
return
false
;
return
false
;
*
elapsed_sec
=
((
struct
module_sdl2_window
*
)
win
->
window
)
->
mpv_time_pos
;
struct
module_sdl2_window
*
sdl2
=
win
->
window
;
*
elapsed_sec
=
sdl2
->
mpv_time_pos
;
return
true
;
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