diff -Nru kodi-audiodecoder-fluidsynth-1.1.0/appveyor.yml kodi-audiodecoder-fluidsynth-2.0.0/appveyor.yml --- kodi-audiodecoder-fluidsynth-1.1.0/appveyor.yml 1970-01-01 00:00:00.000000000 +0000 +++ kodi-audiodecoder-fluidsynth-2.0.0/appveyor.yml 2017-10-04 11:03:35.000000000 +0000 @@ -0,0 +1,27 @@ +version: BuildNr.{build} + +image: Visual Studio 2015 + +shallow_clone: true + +clone_folder: c:\projects\audiodecoder.fluidsynth + +environment: + app_id: audiodecoder.fluidsynth + + matrix: + - GENERATOR: "Visual Studio 14" + CONFIG: Release + - GENERATOR: "Visual Studio 14 Win64" + CONFIG: Release + +build_script: + - cd .. + - git clone --depth=1 https://github.com/xbmc/xbmc.git + - cd %app_id% + - mkdir build + - cd build + - mkdir -p definition\%app_id% + - echo %app_id% %APPVEYOR_BUILD_FOLDER% %APPVEYOR_REPO_COMMIT% > definition\%app_id%\%app_id%.txt + - cmake -T host=x64 -G "%GENERATOR%" -DADDONS_TO_BUILD=%app_id% -DCMAKE_BUILD_TYPE=%CONFIG% -DADDONS_DEFINITION_DIR=%APPVEYOR_BUILD_FOLDER%/build/definition -DADDON_SRC_PREFIX=../.. -DCMAKE_INSTALL_PREFIX=../../xbmc/addons -DPACKAGE_ZIP=1 ../../xbmc/cmake/addons + - cmake --build . --config %CONFIG% --target %app_id% diff -Nru kodi-audiodecoder-fluidsynth-1.1.0/audiodecoder.fluidsynth/addon.xml.in kodi-audiodecoder-fluidsynth-2.0.0/audiodecoder.fluidsynth/addon.xml.in --- kodi-audiodecoder-fluidsynth-1.1.0/audiodecoder.fluidsynth/addon.xml.in 2016-11-05 16:41:25.000000000 +0000 +++ kodi-audiodecoder-fluidsynth-2.0.0/audiodecoder.fluidsynth/addon.xml.in 2017-10-04 11:03:35.000000000 +0000 @@ -1,12 +1,10 @@ - - - + @ADDON_DEPENDS@ Fri, 10 Feb 2017 22:04:41 +0100 + -- wsnipex Mon, 05 Mar 2018 09:50:33 +0100 diff -Nru kodi-audiodecoder-fluidsynth-1.1.0/debian/changelog.tmp kodi-audiodecoder-fluidsynth-2.0.0/debian/changelog.tmp --- kodi-audiodecoder-fluidsynth-1.1.0/debian/changelog.tmp 2017-02-10 21:04:38.000000000 +0000 +++ kodi-audiodecoder-fluidsynth-2.0.0/debian/changelog.tmp 2018-03-05 08:50:20.000000000 +0000 @@ -1,4 +1,4 @@ -kodi-audiodecoder-fluidsynth (1.1.0-1~#DIST#) #DIST#; urgency=low +kodi-audiodecoder-fluidsynth (2.0.0-1~#DIST#) #DIST#; urgency=low [ xbmc ] * autogenerated dummy changelog diff -Nru kodi-audiodecoder-fluidsynth-1.1.0/debian/control kodi-audiodecoder-fluidsynth-2.0.0/debian/control --- kodi-audiodecoder-fluidsynth-1.1.0/debian/control 2016-11-05 16:41:25.000000000 +0000 +++ kodi-audiodecoder-fluidsynth-2.0.0/debian/control 2017-10-04 11:03:35.000000000 +0000 @@ -1,7 +1,7 @@ Source: kodi-audiodecoder-fluidsynth Priority: extra Maintainer: wsnipex -Build-Depends: debhelper (>= 8.0.0), cmake, kodi-addon-dev, kodi-audio-dev, libfluidsynth-dev +Build-Depends: debhelper (>= 8.0.0), cmake, kodi-addon-dev, libfluidsynth-dev Standards-Version: 3.9.8 Section: libs Homepage: http://kodi.tv diff -Nru kodi-audiodecoder-fluidsynth-1.1.0/README.md kodi-audiodecoder-fluidsynth-2.0.0/README.md --- kodi-audiodecoder-fluidsynth-1.1.0/README.md 1970-01-01 00:00:00.000000000 +0000 +++ kodi-audiodecoder-fluidsynth-2.0.0/README.md 2017-10-04 11:03:35.000000000 +0000 @@ -0,0 +1,26 @@ +# audiodecoder.fluidsynth addon for Kodi + +This is a [Kodi](http://kodi.tv) audio decoder addon for midi files. + +[![Build Status](https://travis-ci.org/notspiff/audiodecoder.fluidsynth.svg?branch=master)](https://travis-ci.org/notspiff/audiodecoder.fluidsynth) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/notspiff/audiodecoder.fluidsynth?svg=true)](https://ci.appveyor.com/project/notspiff/audiodecoder-fluidsynth) + +## Build instructions + +When building the addon you have to use the correct branch depending on which version of Kodi you're building against. +For example, if you're building the `master` branch of Kodi you should checkout the `master` branch of this repository. +Also make sure you follow this README from the branch in question. + +### Linux + +The following instructions assume you will have built Kodi already in the `kodi-build` directory +suggested by the README. + +1. `git clone https://github.com/xbmc/xbmc.git` +2. `git clone https://github.com/notspiff/audiodecoder.fluidsynth.git` +3. `cd audiodecoder.fluidsynth && mkdir build && cd build` +4. `cmake -DADDONS_TO_BUILD=audiodecoder.fluidsynth -DADDON_SRC_PREFIX=../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../xbmc/kodi-build/addons -DPACKAGE_ZIP=1 ../../xbmc/cmake/addons` +5. `make` + +The addon files will be placed in `../../xbmc/kodi-build/addons` so if you build Kodi from source and run it directly +the addon will be available as a system addon. diff -Nru kodi-audiodecoder-fluidsynth-1.1.0/src/FluidDecoder.cpp kodi-audiodecoder-fluidsynth-2.0.0/src/FluidDecoder.cpp --- kodi-audiodecoder-fluidsynth-1.1.0/src/FluidDecoder.cpp 2016-11-05 16:41:25.000000000 +0000 +++ kodi-audiodecoder-fluidsynth-2.0.0/src/FluidDecoder.cpp 2017-10-04 11:03:35.000000000 +0000 @@ -17,181 +17,112 @@ * */ -#include "libXBMC_addon.h" +#include +#include +#include #include -extern "C" { -#include -#include - -#include "kodi_audiodec_dll.h" - -ADDON::CHelper_libXBMC_addon *XBMC = NULL; -char soundfont[1024]; - -ADDON_STATUS ADDON_Create(void* hdl, void* props) +struct FluidContext { - if (!XBMC) - XBMC = new ADDON::CHelper_libXBMC_addon; + fluid_settings_t* settings = nullptr; + fluid_synth_t* synth = nullptr; + fluid_player_t* player = nullptr; +}; - if (!XBMC->RegisterMe(hdl)) +class CFluidCodec : public kodi::addon::CInstanceAudioDecoder, + public kodi::addon::CAddonBase +{ +public: + CFluidCodec(KODI_HANDLE instance) : + CInstanceAudioDecoder(instance) { - delete XBMC, XBMC=NULL; - return ADDON_STATUS_PERMANENT_FAILURE; + m_soundfont = kodi::GetSettingString("soundfont"); } - return ADDON_STATUS_NEED_SETTINGS; -} - -//-- Stop --------------------------------------------------------------------- -// This dll must cease all runtime activities -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -void ADDON_Stop() -{ -} - -//-- Destroy ------------------------------------------------------------------ -// Do everything before unload of this add-on -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -void ADDON_Destroy() -{ - delete XBMC; - XBMC = NULL; -} - -//-- HasSettings -------------------------------------------------------------- -// Returns true if this add-on use settings -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -bool ADDON_HasSettings() -{ - return true; -} + virtual ~CFluidCodec() + { + if (ctx.player) + delete_fluid_player(ctx.player); + if (ctx.synth) + delete_fluid_synth(ctx.synth); + if (ctx.settings) + delete_fluid_settings(ctx.settings); + } -//-- GetStatus --------------------------------------------------------------- -// Returns the current Status of this visualisation -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -ADDON_STATUS ADDON_GetStatus() -{ - return ADDON_STATUS_OK; -} + virtual bool Init(const std::string& filename, unsigned int filecache, + int& channels, int& samplerate, + int& bitspersample, int64_t& totaltime, + int& bitrate, AEDataFormat& format, + std::vector& channellist) override + { + if (m_soundfont.empty() || m_soundfont == "OFF") + { + kodi::gui::dialogs::OK::ShowAndGetInput("Soundfont not configured", "Check add-on settings"); + return false; + } + kodi::vfs::CFile file; + if (!file.OpenFile(filename, 0)) + return false; + + ctx.settings = new_fluid_settings(); + ctx.synth = new_fluid_synth(ctx.settings); + fluid_synth_sfload(ctx.synth, m_soundfont.c_str(), 1); + ctx.player = new_fluid_player(ctx.synth); + + size_t size = file.GetLength(); + char* temp = new char[size]; + file.Read(temp, size); + file.Close(); + fluid_player_add_mem(ctx.player, temp, size); + delete[] temp; + fluid_player_play(ctx.player); + format = AE_FMT_FLOAT; + channellist = { AE_CH_FL, AE_CH_FR }; + channels = 2; -//-- GetSettings -------------------------------------------------------------- -// Return the settings for XBMC to display -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -unsigned int ADDON_GetSettings(ADDON_StructSetting ***sSet) -{ - return 0; -} + bitspersample = 32; + bitrate = 0.0; -//-- FreeSettings -------------------------------------------------------------- -// Free the settings struct passed from XBMC -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- + samplerate = 44100; + totaltime = 0; -void ADDON_FreeSettings() -{ -} + return true; + } -//-- SetSetting --------------------------------------------------------------- -// Set a specific Setting value (called from XBMC) -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -ADDON_STATUS ADDON_SetSetting(const char *strSetting, const void* value) -{ - if (strcmp(strSetting,"soundfont") == 0) - strcpy(soundfont, (const char*)value); + virtual int ReadPCM(uint8_t* buffer, int size, int& actualsize) override + { + if (fluid_player_get_status(ctx.player) == FLUID_PLAYER_DONE) + return 1; - return ADDON_STATUS_OK; -} + fluid_synth_write_float(ctx.synth, size/8, buffer, 0, 2, buffer, 1, 2); + actualsize = size; + return 0; + } -//-- Announce ----------------------------------------------------------------- -// Receive announcements from XBMC -// !!! Add-on master function !!! -//----------------------------------------------------------------------------- -void ADDON_Announce(const char *flag, const char *sender, const char *message, const void *data) -{ -} + virtual int64_t Seek(int64_t time) override + { + return -1; + } -struct FluidContext -{ - fluid_settings_t* settings; - fluid_synth_t* synth; - fluid_player_t* player; +private: + FluidContext ctx; + std::string m_soundfont; }; -void* Init(const char* strFile, unsigned int filecache, int* channels, - int* samplerate, int* bitspersample, int64_t* totaltime, - int* bitrate, AEDataFormat* format, const AEChannel** channelinfo) -{ - FluidContext* result = new FluidContext; - result->settings = new_fluid_settings(); - result->synth = new_fluid_synth(result->settings); - fluid_synth_sfload(result->synth, soundfont, 1); - result->player = new_fluid_player(result->synth); - - void* f = XBMC->OpenFile(strFile, 0); - size_t size = XBMC->GetFileLength(f); - char* temp = new char[size]; - XBMC->ReadFile(f, temp, size); - XBMC->CloseFile(f); - fluid_player_add_mem(result->player, temp, size); - delete[] temp; - fluid_player_play(result->player); - static enum AEChannel map[3] = { - AE_CH_FL, AE_CH_FR, AE_CH_NULL - }; - *format = AE_FMT_FLOAT; - *channelinfo = map; - *channels = 2; - - *bitspersample = 32; - *bitrate = 0.0; - - *samplerate = 44100; - *totaltime = 0; - - return result; -} - -int ReadPCM(void* context, uint8_t* pBuffer, int size, int *actualsize) -{ - FluidContext* ssf = (FluidContext*)context; - if (fluid_player_get_status(ssf->player) == FLUID_PLAYER_DONE) - return 1; - fluid_synth_write_float(ssf->synth, size/8, pBuffer, 0, 2, pBuffer, 1, 2); - - *actualsize = size; - return 0; -} - -int64_t Seek(void* context, int64_t time) -{ - return -1; -} -bool DeInit(void* context) +class ATTRIBUTE_HIDDEN CMyAddon : public kodi::addon::CAddonBase { - FluidContext* ssf = (FluidContext*)context; - delete_fluid_player(ssf->player); - delete_fluid_synth(ssf->synth); - delete_fluid_settings(ssf->settings); - delete ssf; - - return true; -} +public: + CMyAddon() { } + virtual ADDON_STATUS CreateInstance(int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE& addonInstance) override + { + addonInstance = new CFluidCodec(instance); + return ADDON_STATUS_OK; + } + virtual ~CMyAddon() + { + } +}; -bool ReadTag(const char* strFile, char* title, char* artist, int* length) -{ - return false; -} -int TrackCount(const char* strFile) -{ - return 1; -} -} +ADDONCREATOR(CMyAddon); diff -Nru kodi-audiodecoder-fluidsynth-1.1.0/.travis.yml kodi-audiodecoder-fluidsynth-2.0.0/.travis.yml --- kodi-audiodecoder-fluidsynth-1.1.0/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ kodi-audiodecoder-fluidsynth-2.0.0/.travis.yml 2017-10-04 11:03:35.000000000 +0000 @@ -0,0 +1,50 @@ +language: cpp + +# +# Define the build matrix +# +# Travis defaults to building on Ubuntu Precise when building on +# Linux. We need Trusty in order to get up to date versions of +# cmake and g++. +# +env: + global: + - app_id=audiodecoder.fluidsynth + +matrix: + include: + - os: linux + dist: trusty + sudo: required + compiler: gcc + - os: linux + dist: trusty + sudo: required + compiler: clang + - os: osx + osx_image: xcode7.3 + - os: osx + osx_image: xcode6.4 + +# +# Some of the OS X images don't have cmake, contrary to what people +# on the Internet say +# +before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then which cmake || brew update ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then which cmake || brew install cmake ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update && brew upgrade cmake || true; fi + +# +# The addon source is automatically checked out in $TRAVIS_BUILD_DIR, +# we'll put the Kodi source on the same level +# +before_script: + - cd $TRAVIS_BUILD_DIR/.. + - git clone --depth=1 https://github.com/xbmc/xbmc.git + - cd ${app_id} && mkdir build && cd build + - mkdir -p definition/${app_id} + - echo ${app_id} $TRAVIS_BUILD_DIR $TRAVIS_COMMIT > definition/${app_id}/${app_id}.txt + - cmake -DADDONS_TO_BUILD=${app_id} -DADDON_SRC_PREFIX=$TRAVIS_BUILD_DIR/.. -DADDONS_DEFINITION_DIR=$TRAVIS_BUILD_DIR/build/definition -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$TRAVIS_BUILD_DIR/../xbmc/addons -DPACKAGE_ZIP=1 $TRAVIS_BUILD_DIR/../xbmc/cmake/addons + +script: make