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
ae31efcd
Vérifiée
Valider
ae31efcd
rédigé
5 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Separing the mpv event handle
parent
013bb733
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!57
Resolve "SDL2 module"
Modifications
3
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
inc/lektor/module/mpv.h
+4
-0
4 ajouts, 0 suppression
inc/lektor/module/mpv.h
src/module/module_x11.c
+4
-75
4 ajouts, 75 suppressions
src/module/module_x11.c
src/module/mpv.c
+77
-0
77 ajouts, 0 suppression
src/module/mpv.c
avec
85 ajouts
et
75 suppressions
inc/lektor/module/mpv.h
+
4
−
0
Voir le fichier @
ae31efcd
#pragma once
#pragma once
#include
<sqlite3.h>
#include
<mpv/client.h>
#include
<mpv/client.h>
#include
<lektor/net.h>
void
lmpv_free
(
mpv_handle
**
ctx
);
void
lmpv_free
(
mpv_handle
**
ctx
);
mpv_handle
*
lmpv_new
(
unsigned
long
int
wid
);
mpv_handle
*
lmpv_new
(
unsigned
long
int
wid
);
...
@@ -11,3 +13,5 @@ int lmpv_is_paused(mpv_handle *ctx, int *ret);
...
@@ -11,3 +13,5 @@ int lmpv_is_paused(mpv_handle *ctx, int *ret);
int
lmpv_set_volume
(
mpv_handle
*
ctx
,
int
vol
);
int
lmpv_set_volume
(
mpv_handle
*
ctx
,
int
vol
);
int
lmpv_load_file
(
mpv_handle
*
ctx
,
const
char
*
file
);
int
lmpv_load_file
(
mpv_handle
*
ctx
,
const
char
*
file
);
int
lmpv_toggle_pause
(
mpv_handle
*
ctx
,
int
*
pause
);
int
lmpv_toggle_pause
(
mpv_handle
*
ctx
,
int
*
pause
);
int
lmpv_handle
(
struct
lkt_win
*
win
,
mpv_handle
*
ctx
,
sqlite3
*
db
,
enum
mpd_idle_flag
*
mpd_idle_flag
,
int
*
time_pos
,
int
*
time_duration
);
Ce diff est replié.
Cliquez pour l'agrandir.
src/module/module_x11.c
+
4
−
75
Voir le fichier @
ae31efcd
...
@@ -212,80 +212,6 @@ lx11_handle(struct module_x11_window *win)
...
@@ -212,80 +212,6 @@ lx11_handle(struct module_x11_window *win)
*
*
*/
*/
static
inline
bool
lmpv_handle
(
struct
lkt_win
*
win
,
sqlite3
*
db
,
enum
mpd_idle_flag
*
mpd_idle_events
)
{
int
ao_volume
;
struct
lkt_queue_state
state
;
bool
sta
=
false
;
struct
module_x11_window
*
win_x11
=
win
->
window
;
mpv_event
*
event
=
NULL
;
mpv_event_property
*
prop
;
if
(
!
win
||
!
win_x11
||
!
win_x11
->
mpv
)
goto
end
;
if
(
!
database_queue_state
(
db
,
&
state
))
goto
end
;
for
(;;)
{
event
=
mpv_wait_event
(
win_x11
->
mpv
,
0
);
switch
(
event
->
event_id
)
{
case
MPV_EVENT_PAUSE
:
case
MPV_EVENT_UNPAUSE
:
database_queue_toggle_pause
(
db
);
break
;
case
MPV_EVENT_SHUTDOWN
:
database_queue_stop
(
db
);
win
->
close
(
win
);
goto
end
;
case
MPV_EVENT_NONE
:
goto
end
;
case
MPV_EVENT_IDLE
:
if
(
state
.
current
>
0
&&
win_x11
->
mpv_time_pos
>
0
)
command_next
(
db
,
win
,
mpd_idle_events
);
break
;
case
MPV_EVENT_PROPERTY_CHANGE
:
prop
=
(
mpv_event_property
*
)
event
->
data
;
if
(
prop
->
format
==
MPV_FORMAT_NONE
)
break
;
// MPV volume (BUG: The flag is not MPV_FORMAT_NONE only at the end of the song...) //
if
(
!
strcmp
(
prop
->
name
,
"ao-volume"
)
&&
prop
->
format
==
MPV_FORMAT_INT64
)
{
ao_volume
=
*
(
int
*
)
prop
->
data
;
database_config_queue
(
db
,
"volume"
,
ao_volume
);
}
// File duration //
if
(
!
strcmp
(
prop
->
name
,
"duration"
)
&&
prop
->
format
==
MPV_FORMAT_INT64
)
{
win_x11
->
mpv_duration
=
*
(
int
*
)
prop
->
data
;
database_config_queue
(
db
,
"duration"
,
*
(
int
*
)
prop
->
data
);
}
if
(
!
strcmp
(
prop
->
name
,
"time-pos"
)
&&
prop
->
format
==
MPV_FORMAT_INT64
)
{
win_x11
->
mpv_time_pos
=
*
(
int
*
)
prop
->
data
;
database_config_queue
(
db
,
"elapsed"
,
*
(
int
*
)
prop
->
data
);
}
// Pause state //
if
(
!
strcmp
(
prop
->
name
,
"pause"
)
&&
prop
->
format
==
MPV_FORMAT_FLAG
)
database_queue_set_paused
(
db
,
*
(
bool
*
)
prop
->
data
);
break
;
default:
fprintf
(
stderr
,
" ! Unhandled mpv event: %s
\n
"
,
mpv_event_name
(
event
->
event_id
));
break
;
}
}
sta
=
true
;
end:
return
sta
;
}
/*
/*
*
*
...
@@ -424,5 +350,8 @@ module_x11_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_f
...
@@ -424,5 +350,8 @@ module_x11_handle_events(struct lkt_win *const win, sqlite3 *db, enum mpd_idle_f
{
{
if
(
win
==
NULL
||
win
->
window
==
NULL
)
if
(
win
==
NULL
||
win
->
window
==
NULL
)
return
false
;
return
false
;
return
lx11_handle
(
win
->
window
)
&&
lmpv_handle
(
win
,
db
,
mpd_idle_events
);
struct
module_x11_window
*
xwin
=
win
->
window
;
return
lx11_handle
(
xwin
)
&&
lmpv_handle
(
win
,
xwin
->
mpv
,
db
,
mpd_idle_events
,
(
int
*
)
&
xwin
->
mpv_time_pos
,
(
int
*
)
&
xwin
->
mpv_duration
);
}
}
Ce diff est replié.
Cliquez pour l'agrandir.
src/module/mpv.c
+
77
−
0
Voir le fichier @
ae31efcd
#include
<lektor/module/mpv.h>
#include
<lektor/module/mpv.h>
#include
<lektor/commands.h>
#include
<lektor/database.h>
#include
<stdio.h>
#include
<stdio.h>
#include
<string.h>
#include
<string.h>
#include
<unistd.h>
#include
<unistd.h>
#include
<sqlite3.h>
void
void
lmpv_free
(
mpv_handle
**
ctx
)
lmpv_free
(
mpv_handle
**
ctx
)
...
@@ -196,3 +199,77 @@ lmpv_toggle_pause(mpv_handle *ctx, int *pause)
...
@@ -196,3 +199,77 @@ lmpv_toggle_pause(mpv_handle *ctx, int *pause)
}
}
return
lmpv_is_paused
(
ctx
,
pause
);
return
lmpv_is_paused
(
ctx
,
pause
);
}
}
int
lmpv_handle
(
struct
lkt_win
*
win
,
mpv_handle
*
ctx
,
sqlite3
*
db
,
enum
mpd_idle_flag
*
mpd_idle_events
,
int
*
time_pos
,
int
*
time_duration
)
{
int
ao_volume
;
struct
lkt_queue_state
state
;
bool
sta
=
false
;
mpv_event
*
event
=
NULL
;
mpv_event_property
*
prop
;
if
(
!
ctx
||
!
win
)
goto
end
;
if
(
!
database_queue_state
(
db
,
&
state
))
goto
end
;
loop:
event
=
mpv_wait_event
(
ctx
,
0
);
switch
(
event
->
event_id
)
{
case
MPV_EVENT_PAUSE
:
case
MPV_EVENT_UNPAUSE
:
database_queue_toggle_pause
(
db
);
break
;
case
MPV_EVENT_SHUTDOWN
:
database_queue_stop
(
db
);
win
->
close
(
win
);
goto
end
;
case
MPV_EVENT_NONE
:
goto
end
;
case
MPV_EVENT_IDLE
:
if
(
state
.
current
>
0
&&
*
time_pos
>
0
)
command_next
(
db
,
win
,
mpd_idle_events
);
break
;
case
MPV_EVENT_PROPERTY_CHANGE
:
prop
=
(
mpv_event_property
*
)
event
->
data
;
if
(
prop
->
format
==
MPV_FORMAT_NONE
)
break
;
// MPV volume (BUG: The flag is not MPV_FORMAT_NONE only at the end of the song...) //
if
(
!
strcmp
(
prop
->
name
,
"ao-volume"
)
&&
prop
->
format
==
MPV_FORMAT_INT64
)
{
ao_volume
=
*
(
int
*
)
prop
->
data
;
database_config_queue
(
db
,
"volume"
,
ao_volume
);
}
// File duration //
if
(
!
strcmp
(
prop
->
name
,
"duration"
)
&&
prop
->
format
==
MPV_FORMAT_INT64
)
{
*
time_duration
=
*
(
int
*
)
prop
->
data
;
database_config_queue
(
db
,
"duration"
,
*
(
int
*
)
prop
->
data
);
}
if
(
!
strcmp
(
prop
->
name
,
"time-pos"
)
&&
prop
->
format
==
MPV_FORMAT_INT64
)
{
*
time_pos
=
*
(
int
*
)
prop
->
data
;
database_config_queue
(
db
,
"elapsed"
,
*
(
int
*
)
prop
->
data
);
}
// Pause state //
if
(
!
strcmp
(
prop
->
name
,
"pause"
)
&&
prop
->
format
==
MPV_FORMAT_FLAG
)
database_queue_set_paused
(
db
,
*
(
bool
*
)
prop
->
data
);
break
;
default:
fprintf
(
stderr
,
" ! Unhandled mpv event: %s
\n
"
,
mpv_event_name
(
event
->
event_id
));
break
;
}
goto
loop
;
/* A loop without indentation. */
sta
=
true
;
end:
return
sta
;
}
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