Skip to content
Extraits de code Groupes Projets
Vérifiée Valider a5e2e825 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

CACHE & MKV: The cached duration should be OK now

parent 5a24c34f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!157Caching for karas & refactor & others
......@@ -42,21 +42,7 @@ extern "C" {
#if defined(HAVE_ENDIAN_H) && HAVE_ENDIAN_H == 1
#include <endian.h>
#ifdef LKT_ENDIANES_LITTLE
#undef LKT_ENDIANES_LITTLE
#endif
#ifdef LKT_ENDIANES_BIG
#undef LKT_ENDIANES_BIG
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define LKT_ENDIANES_LITTLE 1
#elif __BYTE_ORDER == __BIG_ENDIAN
#define LKT_ENDIANES_BIG 1
#else
#if !(__BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __BIG_ENDIAN)
#error "Unsuported endiannes"
#endif
......
......@@ -50,10 +50,10 @@ be_float_t(const uint8_t bytes[])
#if defined(LKT_ENDIANES_LITTLE) && (LKT_ENDIANES_LITTLE == 1)
for (size_t i = 0; i < 4; ++i)
ret._data[i] = bytes[i];
ret._data[i] = bytes[3 - i];
#else /* BIG ENDIAN */
for (size_t i = 0; i < 4; ++i)
ret._data[i] = bytes[3 - i];
ret._data[i] = bytes[i];
#endif
return ret._float;
......@@ -70,10 +70,10 @@ be_double_t(const uint8_t bytes[])
#if defined(LKT_ENDIANES_LITTLE) && (LKT_ENDIANES_LITTLE == 1)
for (size_t i = 0; i < 8; ++i)
ret._data[i] = bytes[i];
ret._data[i] = bytes[7 - i];
#else /* BIG ENDIAN */
for (size_t i = 0; i < 8; ++i)
ret._data[i] = bytes[7 - i];
ret._data[i] = bytes[i];
#endif
return ret._float;
......
......@@ -3,6 +3,7 @@
#include <lektor/common.h>
#include <lektor/database.h>
#include <lektor/internal/dbmacro.h>
#include <math.h>
/* Cache operations */
#define _get_ 1
......@@ -50,29 +51,29 @@ database_cache_kara(volatile sqlite3 *db, int id)
char filepath[PATH_MAX];
if (!database_get_kara_path(db, id, filepath)) {
LOG_ERROR("CACHE", "Failed to get a path for kara %ld, don't update cache", id);
LOG_ERROR("CACHE", "Failed to get a path for kara %d, don't update cache", id);
return;
}
if (database_is_kara_cached(db, id)) {
LOG_INFO("CACHE", "Kara %ld is already cached", id);
LOG_INFO("CACHE", "Kara %d is already cached", id);
return;
} else
LOG_INFO("CACHE", "Trying to cache kara %ld", id);
LOG_INFO("CACHE", "Trying to cache kara %d", id);
long mtime = get_mtime(filepath);
if (!database_set_kara_mtime_id(db, id, mtime))
LOG_ERROR("CACHE", "Failed to cache mtime for '%s' kara %ld to %ld", filepath, id, mtime);
LOG_ERROR("CACHE", "Failed to cache mtime for '%s' kara %d to %ld", filepath, id, mtime);
double duration = 0.;
if (kara_read_length(&duration, filepath))
LOG_ERROR("CACHE", "Failed to read lengh of '%s' for kara %ld", filepath, id);
if (kara_read_length(&duration, filepath) || isnan(duration))
LOG_ERROR("CACHE", "Failed to read lengh of '%s' for kara %d", filepath, id);
uint64_t duration_uint = (uint64_t)duration;
if (!database_set_kara_duration_id(db, id, duration_uint))
LOG_ERROR("CACHE", "Failed to cache duration for '%s' kara %ld to %ld", filepath, id, duration_uint);
LOG_ERROR("CACHE", "Failed to cache duration for '%s' kara %d to %ld", filepath, id, duration_uint);
LOG_INFO("CACHE", "Cached mtime %ld and duration %ld for '%s' kara %ld", mtime, duration_uint, filepath, id);
LOG_INFO("CACHE", "Cached mtime %ld and duration %ld for '%s' kara %d", mtime, duration_uint, filepath, id);
}
#pragma message(TODO "Cache the 'get' with the next `N` karas. Use static __thread variables for that.")
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter