From d5d0cdced039b81d0ca167d26984c5f598224838 Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 29 Jan 2022 18:55:50 +0300 Subject: [PATCH 1/3] add new C api function ModPlug_GetVersion, add version macros to modplug.h --- src/modplug.cpp | 5 +++++ src/modplug.h | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/modplug.cpp b/src/modplug.cpp index bb4ab627..35ac5e1b 100644 --- a/src/modplug.cpp +++ b/src/modplug.cpp @@ -81,6 +81,11 @@ namespace ModPlug } } +long ModPlug_GetVersion(void) +{ + return LIBMODPLUG_VERSION; +} + ModPlugFile* ModPlug_Load(const void* data, int size) { ModPlugFile* result = new ModPlugFile; diff --git a/src/modplug.h b/src/modplug.h index f7f78b7c..5662106e 100644 --- a/src/modplug.h +++ b/src/modplug.h @@ -11,6 +11,16 @@ extern "C" { #endif +#define LIBMODPLUG_MAJOR 0L +#define LIBMODPLUG_MINOR 8L +#define LIBMODPLUG_REVISION 9L +#define LIBMODPLUG_PATCH 1L +#define LIBMODPLUG_VERSION \ + ((LIBMODPLUG_MAJOR <<24) | \ + (LIBMODPLUG_MINOR <<16) | \ + (LIBMODPLUG_REVISION<< 8) | \ + (LIBMODPLUG_PATCH)) + #if defined(_WIN32) || defined(__CYGWIN__) # if defined(MODPLUG_BUILD) && defined(DLL_EXPORT) /* building libmodplug as a dll for windows */ # define MODPLUG_EXPORT __declspec(dllexport) @@ -25,6 +35,8 @@ extern "C" { #define MODPLUG_EXPORT #endif +MODPLUG_EXPORT long ModPlug_GetVersion(void); + struct _ModPlugFile; typedef struct _ModPlugFile ModPlugFile; From 76ce2aa81df075438483b3ba6e4188d2c56e910d Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 29 Jan 2022 18:55:50 +0300 Subject: [PATCH 2/3] add new C api function ModPlug_Tell to get the playing position in msecs the function was originally authored and is provided by Vitaly Novichkov. increase the version number to 0.8.10 so the new functions can be checked easily at compile time. --- src/modplug.cpp | 15 +++++++++++++++ src/modplug.h | 7 +++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/modplug.cpp b/src/modplug.cpp index 35ac5e1b..73490fa6 100644 --- a/src/modplug.cpp +++ b/src/modplug.cpp @@ -270,6 +270,21 @@ void ModPlug_Seek(ModPlugFile* file, int millisecond) file->mSoundFile.SetCurrentPos((int)(millisecond * postime)); } +int ModPlug_Tell(ModPlugFile *file) +{ + int currentPos = (int)file->mSoundFile.GetCurrentPos(); + int maxpos; + int maxtime = (int)file->mSoundFile.GetSongTime() * 1000; + float postime; + maxpos = (int)file->mSoundFile.GetMaxPosition(); + postime = 0.0f; + if (maxtime != 0.0f) + postime = (float)maxpos / (float)maxtime; + if (postime == 0.0f) + return 0; + return (int) ((float)currentPos / postime); +} + void ModPlug_GetSettings(ModPlug_Settings* settings) { memcpy(settings, &ModPlug::gSettings, sizeof(ModPlug_Settings)); diff --git a/src/modplug.h b/src/modplug.h index 5662106e..a525c091 100644 --- a/src/modplug.h +++ b/src/modplug.h @@ -13,8 +13,8 @@ extern "C" { #define LIBMODPLUG_MAJOR 0L #define LIBMODPLUG_MINOR 8L -#define LIBMODPLUG_REVISION 9L -#define LIBMODPLUG_PATCH 1L +#define LIBMODPLUG_REVISION 10L +#define LIBMODPLUG_PATCH 0L #define LIBMODPLUG_VERSION \ ((LIBMODPLUG_MAJOR <<24) | \ (LIBMODPLUG_MINOR <<16) | \ @@ -79,6 +79,9 @@ MODPLUG_EXPORT int ModPlug_GetLength(ModPlugFile* file); * ModPlug_GetLength() does not report the full length. */ MODPLUG_EXPORT void ModPlug_Seek(ModPlugFile* file, int millisecond); +/* Get the absolute playing position in song, in milliseconds. */ +MODPLUG_EXPORT int ModPlug_Tell(ModPlugFile* file); + enum _ModPlug_Flags { MODPLUG_ENABLE_OVERSAMPLING = 1 << 0, /* Enable oversampling (*highly* recommended) */ From 77daf500227230ec1056bba5fd724675567b8bd0 Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 29 Jan 2022 18:55:50 +0300 Subject: [PATCH 3/3] configure.ac, CMakeLists.txt: update version after new api additions. --- CMakeLists.txt | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62d531f5..de98fbe6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.12) project(libmodplug) -set(VERSION "0.8.9.1") +set(VERSION "0.8.10.0") option(BUILD_SHARED_LIBS "Build Shared Library (DLL)" OFF) diff --git a/configure.ac b/configure.ac index c51a591f..57bd9fe4 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.63]) -AC_INIT([libmodplug],[0.8.9.1]) +AC_INIT([libmodplug],[0.8.10.0]) AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE