From c3c078aedbd7d32038de5ccb693ee24ce327479d 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 8d549abc..5b475ff0 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 2L +#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) @@ -31,6 +41,8 @@ extern "C" { #define MODPLUG_EXPORT #endif +MODPLUG_EXPORT long ModPlug_GetVersion(void); + struct _ModPlugFile; typedef struct _ModPlugFile ModPlugFile; From e92d7803fea405f2d6de1bf9954cf3bd9c0052d9 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 5b475ff0..8824d739 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 2L +#define LIBMODPLUG_REVISION 10L +#define LIBMODPLUG_PATCH 0L #define LIBMODPLUG_VERSION \ ((LIBMODPLUG_MAJOR <<24) | \ (LIBMODPLUG_MINOR <<16) | \ @@ -85,6 +85,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 9bcd22e35c429b336d9799a181e4b246c6b33aaf 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 2a8a8ced..b94ceffe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12) project(libmodplug) -set(VERSION "0.8.9.2") +set(VERSION "0.8.10.0") option(BUILD_SHARED_LIBS "Build Shared Library (DLL)" OFF) diff --git a/configure.ac b/configure.ac index 846b03f6..9e4cbacd 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.2]) +AC_INIT([libmodplug],[0.8.10.0]) AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE