Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 7b07dfecf62868efcd2df88487b00d322675b6d5
  • master par défaut
  • script
  • new-devel
  • devel
  • timingView-edit
  • fix-mpv
7 résultats

IrExpression.cc

Blame
  • module_sdl2.c 14,38 Kio
    #define _POSIX_C_SOURCE 200809L
    
    #define __LKT_MODULE_MAIN_SOURCE__
    #include <lektor/lktmodule.h>
    
    #include "mpv.h"
    #include "thread.h"
    
    #include <sqlite3.h>
    #include <sched.h>
    #include <string.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <stdarg.h>
    #include <SDL.h>
    #include <mpv/render_gl.h>
    #include <mpv/client.h>
    
    #define WIDTH   400
    #define HEIGHT  200
    
    static volatile Uint32 wakeup_on_mpv_render_update, wakeup_on_mpv_events;
    
    struct module_sdl2_window {
        /* Related to SDL2 */
        volatile SDL_Window *window;
        volatile SDL_GLContext glcontext;
        int is_fullscreen;
    
        /* Mpv related */
        volatile mpv_handle *mpv;
        volatile mpv_render_context *mpv_gl;
        volatile int mpv_time_pos;  /* Don't write it in the database       */
        volatile int mpv_duration;  /* Because don't need to be persistent  */
        volatile int state;
    
        /* Thread related */
        struct poller_thread self;
        volatile int launched;  /* SDL you sucks */
    
        /* Things from the server */
        struct queue *queue;
        volatile sqlite3 *db;
    };
    
    /************************
     * Function definitions *
     ************************/
    
    static bool module_sdl2_get_elapsed(struct module_sdl2_window *, int *);
    static bool module_sdl2_get_duration(struct module_sdl2_window *, int *);
    static bool module_sdl2_set_volume(struct module_sdl2_window *, int);
    static bool module_sdl2_load_file(struct module_sdl2_window *, const char *);
    static bool module_sdl2_toggle_pause(struct module_sdl2_window *);
    static void module_sdl2_free(struct module_sdl2_window *);
    static void module_sdl2_close(struct module_sdl2_window *);
    static bool module_sdl2_new(struct module_sdl2_window **, struct queue *, volatile sqlite3 *);
    
    /*********************
     * Private functions *
     *********************/
    
    static inline void *
    get_proc_address_mpv(void UNUSED *fn_ctx, const char *name)
    {
        return SDL_GL_GetProcAddress(name);
    }
    
    static inline void