Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 9699ef26e4e83c2e092b281d286bce98ffc86442
  • master par défaut protégée
  • rust-playlist-sync
  • rust
  • fix-qt-deprecated-qvariant-type
  • fix-mpris-qtwindow-race-condition
  • rust-appimage-wayland
  • windows-build-rebased
  • v2.5 protégée
  • v2.4 protégée
  • v2.3-1 protégée
  • v2.3 protégée
  • v2.2 protégée
  • v2.1 protégée
  • v2.0 protégée
  • v1.8-3 protégée
  • v1.8-2 protégée
  • v1.8-1 protégée
  • v1.8 protégée
  • v1.7 protégée
  • v1.6 protégée
  • v1.5 protégée
  • v1.4 protégée
  • v1.3 protégée
  • v1.2 protégée
  • v1.1 protégée
  • v1.0 protégée
27 résultats

queue.c

Blame
  • queue.c 20,95 Kio
    #define _POSIX_C_SOURCE 200809L
    
    #include <common/common.h>
    #include <lektor/database.h>
    
    #include <linux/limits.h>
    #include <stdio.h>
    #include <string.h>
    
    /* Find in in database/open.c */
    extern int is_sql_str_invalid(const char *);
    
    bool
    database_queue_state(volatile sqlite3 *db, struct lkt_queue_state *res)
    {
        static const char *SQL_STMT =
            "SELECT"
            "  volume, paused, random, repeat, single, current, duration, consume, "
            "  (SELECT COUNT(*) FROM queue) AS length "
            "FROM queue_state;\n";
        sqlite3_stmt *stmt = 0;
        bool ret = false;
    
        SQLITE_PREPARE(db, stmt, SQL_STMT, error);
        SQLITE_STEP_ROW(db, stmt, error);
    
        res->volume = sqlite3_column_int(stmt, 0);
        res->paused = sqlite3_column_int(stmt, 1);
        res->random = sqlite3_column_int(stmt, 2);
        res->repeat = sqlite3_column_int(stmt, 3);
        res->single = sqlite3_column_int(stmt, 4);
    
        if (sqlite3_column_type(stmt, 5) == SQLITE_NULL)
            res->current = -1;
        else
            res->current = sqlite3_column_int(stmt, 5);
    
        if (sqlite3_column_type(stmt, 6) == SQLITE_NULL)
            res->duration = 0;
        else
            res->duration = sqlite3_column_int(stmt, 6);
    
        res->consume = sqlite3_column_int(stmt, 7);
        res->length = sqlite3_column_int(stmt, 8);
        ret = true;
    error:
        sqlite3_finalize(stmt);
        return ret;
    }
    
    bool
    database_queue_current_kara(volatile sqlite3 *db, struct kara_metadata *res, int *id)
    {
        static const char *SQL_STMT =
            "SELECT song_name, source_name, category, language, author_name, song_type, song_number, kara_id"
            " FROM kara"
            " JOIN queue ON kara_id = kara.id"
            " JOIN queue_state ON current = position";
        sqlite3_stmt *stmt = 0;
        int ret = false;
    
        SQLITE_PREPARE(db, stmt, SQL_STMT, error);
        SQLITE_STEP_ROW(db, stmt, error);
    
        /* Here use gotos because of optimisations done by compilators.
           Most of the time it won't be NULL. */
        if (!res)
            goto no_metadata;
        strncpy(res->song_name,   (const char *) sqlite3_column_text(stmt, 0), LEKTOR_TAG_MAX - 1);
        strncpy(res->source_name, (const char *) sqlite3_column_text(stmt, 1), LEKTOR_TAG_MAX - 1);