From a9ddfabe0b48762842529cca6056acd87cc0078d Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 3 Nov 2021 19:53:08 +0100 Subject: [PATCH 1/5] translation updates (taken from Matrix) --- audiodecoder.2sf/addon.xml.in | 8 +++ .../resource.language.da_dk/strings.po | 8 +-- .../resource.language.ko_kr/strings.po | 6 +- .../resource.language.pt_pt/strings.po | 15 ++--- .../resource.language.zh_cn/strings.po | 59 ++++++++++--------- 5 files changed, 53 insertions(+), 43 deletions(-) diff --git a/audiodecoder.2sf/addon.xml.in b/audiodecoder.2sf/addon.xml.in index 02c0919..b350f47 100644 --- a/audiodecoder.2sf/addon.xml.in +++ b/audiodecoder.2sf/addon.xml.in @@ -18,13 +18,21 @@ icon.png + Nintendo DS dekoder til lydfiler Nintendo DS Audiodateidecoder Nintendo DS audio file decoder Nintendo DS -äänitiedoston dekooderi + 닌텐도 DS 오디오 파일 디코더 + Decodificador dos ficheiros áudio no Nintendo DS Декодер аудиофайлов Nintendo DS Bộ giải mã tập tin âm thanh Nintendo DS + 任天堂 DS 音频文件解码器 + Understøttelse af spillydfiler, der bruges af nogle Nintendo DS-spil.[CR][CR]Dual Screen Sound Format er et lydformat baseret på PSF. Det gemmer lyd, der er rippet fra ROM'erne i Nintendo DS-spil. Musikinstruktioner gemmes .2sflib-filer, og musiknotationen gemmes i .mini2sf-filer. Zur Unterstützung von Audiodateien, die von einigen Nintendo DS-Spielen verwendet werden.[CR][CR]Das Dual Screen Sound Format ist ein auf PSF basierendes Audioformat. Es speichert Audio, das aus den ROMs von Nintendo DS-Spielen gerippt wurde. Musikanweisungen werden in Dateien mit der Erweiterung .2sflib gespeichert, und die Musiknotation wird in Dateien mit der Erweiterung .mini2sf gespeichert. To support game audio file used by some Nintendo DS games.[CR][CR]Dual Screen Sound Format is an audio format based on PSF. It stores audio ripped from the ROMs of Nintendo DS games. Music instructions are stored in files with a .2sflib extension and the music notation is stored in files with a .mini2sf extension. + 일부 Nintendo DS 게임에서 사용하는 게임 오디오 파일을 지원합니다.[CR][CR]듀얼 스크린 사운드 포맷은 PSF 기반의 오디오 포맷입니다. Nintendo DS 게임의 ROM에서 추출한 오디오를 저장합니다. 음악 설명은 .2sflib 확장자를 가진 파일에 저장되고 악보는 .mini2sf 확장자를 가진 파일에 저장됩니다. + Para fornecer suporte aos ficheiros de áudio utilizados por alguns jogos de Nintendo DS.[CR][CR]Dual Screen Sound Format é um formato de áudio baseado em PSF, armazena áudio copiado dos ROMs de jogos Nintendo DS. As instruções musicais são armazenadas em ficheiros com uma extensão .2sflib e a notação musical é armazenada em ficheiros com uma extensão .mini2sf. Предназначен для поддержки звукового файла, используемого некоторыми играми Nintendo DS.[CR][CR]Dual Screen Sound Format - это аудиоформат, основанный на PSF. В нем хранятся аудиозаписи, извлеченные из ПЗУ игр Nintendo DS. Музыкальные инструкции хранятся в файлах с расширением .2sflib, а музыкальная запись - в файлах с расширением .mini2sf. + 支持某些任天堂 DS 游戏使用的游戏音频文件。[CR][CR]双屏声音格式是基于 PSF 的音频格式。它存储从任天堂 DS 游戏 ROM 中提取的音频。音乐指令存储在扩展名为.2sflib的文件中,音乐符号存储在扩展名为.mini2sf的文件中。 diff --git a/audiodecoder.2sf/resources/language/resource.language.da_dk/strings.po b/audiodecoder.2sf/resources/language/resource.language.da_dk/strings.po index 4d1f2cb..cb1637d 100644 --- a/audiodecoder.2sf/resources/language/resource.language.da_dk/strings.po +++ b/audiodecoder.2sf/resources/language/resource.language.da_dk/strings.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: KODI Addons\n" "Report-Msgid-Bugs-To: translations@kodi.tv\n" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" -"PO-Revision-Date: 2021-07-29 19:23+0000\n" +"PO-Revision-Date: 2021-10-21 12:30+0000\n" "Last-Translator: Christian Gade \n" "Language-Team: Danish \n" "Language: da_dk\n" @@ -15,15 +15,15 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.7.2\n" +"X-Generator: Weblate 4.8\n" msgctxt "Addon Summary" msgid "Nintendo DS audio file decoder" -msgstr "" +msgstr "Nintendo DS afkoder til lydfiler" msgctxt "Addon Description" msgid "To support game audio file used by some Nintendo DS games.[CR][CR]Dual Screen Sound Format is an audio format based on PSF. It stores audio ripped from the ROMs of Nintendo DS games. Music instructions are stored in files with a .2sflib extension and the music notation is stored in files with a .mini2sf extension." -msgstr "" +msgstr "Understøttelse af spillydfiler, der bruges af nogle Nintendo DS-spil.[CR][CR]Dual Screen Sound Format er et lydformat baseret på PSF. Det gemmer lyd, der er rippet fra ROM'erne i Nintendo DS-spil. Musikinstruktioner gemmes .2sflib-filer, og musiknotationen gemmes i .mini2sf-filer." # [Consistency] Make terms, settings names, brands and other minutiae, consistent throughout file. # [Capitalization] Avoid capitalizing every second word. See http://grammarist.com/capitalization/ diff --git a/audiodecoder.2sf/resources/language/resource.language.ko_kr/strings.po b/audiodecoder.2sf/resources/language/resource.language.ko_kr/strings.po index 404d09c..9515855 100644 --- a/audiodecoder.2sf/resources/language/resource.language.ko_kr/strings.po +++ b/audiodecoder.2sf/resources/language/resource.language.ko_kr/strings.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: KODI Addons\n" "Report-Msgid-Bugs-To: translations@kodi.tv\n" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" -"PO-Revision-Date: 2021-08-24 13:29+0000\n" +"PO-Revision-Date: 2021-09-06 13:29+0000\n" "Last-Translator: Minho Park \n" "Language-Team: Korean \n" "Language: ko_kr\n" @@ -19,11 +19,11 @@ msgstr "" msgctxt "Addon Summary" msgid "Nintendo DS audio file decoder" -msgstr "" +msgstr "닌텐도 DS 오디오 파일 디코더" msgctxt "Addon Description" msgid "To support game audio file used by some Nintendo DS games.[CR][CR]Dual Screen Sound Format is an audio format based on PSF. It stores audio ripped from the ROMs of Nintendo DS games. Music instructions are stored in files with a .2sflib extension and the music notation is stored in files with a .mini2sf extension." -msgstr "" +msgstr "일부 Nintendo DS 게임에서 사용하는 게임 오디오 파일을 지원합니다.[CR][CR]듀얼 스크린 사운드 포맷은 PSF 기반의 오디오 포맷입니다. Nintendo DS 게임의 ROM에서 추출한 오디오를 저장합니다. 음악 설명은 .2sflib 확장자를 가진 파일에 저장되고 악보는 .mini2sf 확장자를 가진 파일에 저장됩니다." # [Consistency] Make terms, settings names, brands and other minutiae, consistent throughout file. # [Capitalization] Avoid capitalizing every second word. See http://grammarist.com/capitalization/ diff --git a/audiodecoder.2sf/resources/language/resource.language.pt_pt/strings.po b/audiodecoder.2sf/resources/language/resource.language.pt_pt/strings.po index ea03a88..a6d95b9 100644 --- a/audiodecoder.2sf/resources/language/resource.language.pt_pt/strings.po +++ b/audiodecoder.2sf/resources/language/resource.language.pt_pt/strings.po @@ -5,24 +5,25 @@ msgid "" msgstr "" "Project-Id-Version: KODI Addons\n" -"Report-Msgid-Bugs-To: https://github.com/xbmc/audiodecoder.ssf/issues/\n" +"Report-Msgid-Bugs-To: translations@kodi.tv\n" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" +"PO-Revision-Date: 2021-10-03 11:47+0000\n" +"Last-Translator: Peter J. Mello \n" +"Language-Team: Portuguese (Portugal) \n" "Language: pt_pt\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.8\n" msgctxt "Addon Summary" msgid "Nintendo DS audio file decoder" -msgstr "" +msgstr "Decodificador dos ficheiros áudio no Nintendo DS" msgctxt "Addon Description" msgid "To support game audio file used by some Nintendo DS games.[CR][CR]Dual Screen Sound Format is an audio format based on PSF. It stores audio ripped from the ROMs of Nintendo DS games. Music instructions are stored in files with a .2sflib extension and the music notation is stored in files with a .mini2sf extension." -msgstr "" +msgstr "Para fornecer suporte aos ficheiros de áudio utilizados por alguns jogos de Nintendo DS.[CR][CR]Dual Screen Sound Format é um formato de áudio baseado em PSF, armazena áudio copiado dos ROMs de jogos Nintendo DS. As instruções musicais são armazenadas em ficheiros com uma extensão .2sflib e a notação musical é armazenada em ficheiros com uma extensão .mini2sf." # [Consistency] Make terms, settings names, brands and other minutiae, consistent throughout file. # [Capitalization] Avoid capitalizing every second word. See http://grammarist.com/capitalization/ @@ -33,7 +34,7 @@ msgstr "" # For example, "Press \"OK\" for \"All seasons\"" instead of "Press OK for All seasons" after first word. msgctxt "#30000" msgid "Default length" -msgstr "" +msgstr "Duração padrão" msgctxt "#30001" msgid "Used if specified file does not provide the length." diff --git a/audiodecoder.2sf/resources/language/resource.language.zh_cn/strings.po b/audiodecoder.2sf/resources/language/resource.language.zh_cn/strings.po index a9dc595..1d9380c 100644 --- a/audiodecoder.2sf/resources/language/resource.language.zh_cn/strings.po +++ b/audiodecoder.2sf/resources/language/resource.language.zh_cn/strings.po @@ -5,24 +5,25 @@ msgid "" msgstr "" "Project-Id-Version: KODI Addons\n" -"Report-Msgid-Bugs-To: https://github.com/xbmc/audiodecoder.ssf/issues/\n" +"Report-Msgid-Bugs-To: translations@kodi.tv\n" "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" +"PO-Revision-Date: 2021-09-17 02:30+0000\n" +"Last-Translator: taxigps \n" +"Language-Team: Chinese (China) \n" "Language: zh_cn\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.8\n" msgctxt "Addon Summary" msgid "Nintendo DS audio file decoder" -msgstr "" +msgstr "任天堂 DS 音频文件解码器" msgctxt "Addon Description" msgid "To support game audio file used by some Nintendo DS games.[CR][CR]Dual Screen Sound Format is an audio format based on PSF. It stores audio ripped from the ROMs of Nintendo DS games. Music instructions are stored in files with a .2sflib extension and the music notation is stored in files with a .mini2sf extension." -msgstr "" +msgstr "支持某些任天堂 DS 游戏使用的游戏音频文件。[CR][CR]双屏声音格式是基于 PSF 的音频格式。它存储从任天堂 DS 游戏 ROM 中提取的音频。音乐指令存储在扩展名为.2sflib的文件中,音乐符号存储在扩展名为.mini2sf的文件中。" # [Consistency] Make terms, settings names, brands and other minutiae, consistent throughout file. # [Capitalization] Avoid capitalizing every second word. See http://grammarist.com/capitalization/ @@ -33,92 +34,92 @@ msgstr "" # For example, "Press \"OK\" for \"All seasons\"" instead of "Press OK for All seasons" after first word. msgctxt "#30000" msgid "Default length" -msgstr "" +msgstr "默认长度" msgctxt "#30001" msgid "Used if specified file does not provide the length." -msgstr "" +msgstr "用于未提供长度的特定文件。" msgctxt "#30002" msgid "unused" -msgstr "" +msgstr "未使用" msgctxt "#30003" msgid "{0:d} s" -msgstr "" +msgstr "{0:d} 秒" msgctxt "#30004" msgid "Default fade out time" -msgstr "" +msgstr "默认淡出时间" msgctxt "#30005" msgid "Used if specified file does not provide the length and fade." -msgstr "" +msgstr "用于未提供长度和淡出的特定文件。" msgctxt "#30006" msgid "unused" -msgstr "" +msgstr "未使用" msgctxt "#30007" msgid "{0:d} ms" -msgstr "" +msgstr "{0:d} 毫秒" msgctxt "#30008" msgid "Suppress opening silence" -msgstr "" +msgstr "抑制起始静默" msgctxt "#30009" msgid "Some files start with silent data, this prevents it and looks for the beginning." -msgstr "" +msgstr "有些文件以静默数据开头,这会阻止它并查找真实的起点。" msgctxt "#30010" msgid "Suppress end silence" -msgstr "" +msgstr "抑制结尾静默" msgctxt "#30011" msgid "Some files end with silent data, this prevents it and looks for the end." -msgstr "" +msgstr "有些文件以静默数据结尾,这会阻止它并查找真实的结尾。" msgctxt "#30012" msgid "Second of silence to check" -msgstr "" +msgstr "静默秒检测" msgctxt "#30013" msgid "How many silent seconds are allowed before playback is stopped." -msgstr "" +msgstr "播放停止前允许静默多少秒。" msgctxt "#30014" msgid "{0:d} s" -msgstr "" +msgstr "{0:d} 秒" msgctxt "#30015" msgid "Resampling mode" -msgstr "" +msgstr "重采样模式" msgctxt "#30016" msgid "Used resampling quality about processing." -msgstr "" +msgstr "用于处理的重采样质量。" msgctxt "#30017" msgid "Zero order hold" -msgstr "" +msgstr "零阶保持" msgctxt "#30018" msgid "Blep synthesis" -msgstr "" +msgstr "Blep 合成" msgctxt "#30019" msgid "Linear" -msgstr "" +msgstr "线性" msgctxt "#30020" msgid "Blam synthesis" -msgstr "" +msgstr "Blam 合成" msgctxt "#30021" msgid "Cubic" -msgstr "" +msgstr "三次" msgctxt "#30022" msgid "Ainc" -msgstr "" +msgstr "智能降噪" From b9d68e1324f4a8e67001e3ff139f01e0a23ce624 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 3 Nov 2021 19:55:03 +0100 Subject: [PATCH 2/5] add debian package test build on github --- .github/workflows/build.yml | 61 +++++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0265b92 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,61 @@ +name: Build and run tests +on: [push, pull_request] +env: + app_id: audiodecoder.2sf + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - name: "Debian package test" + os: ubuntu-18.04 + CC: gcc + CXX: g++ + DEBIAN_BUILD: true + #- os: ubuntu-18.04 + #CC: gcc + #CXX: g++ + #- os: ubuntu-18.04 + #CC: clang + #CXX: clang++ + #- os: macos-10.15 + steps: + - name: Install needed ubuntu depends + env: + DEBIAN_BUILD: ${{ matrix.DEBIAN_BUILD }} + run: | + if [[ $DEBIAN_BUILD == true ]]; then sudo add-apt-repository -y ppa:team-xbmc/xbmc-nightly; fi + if [[ $DEBIAN_BUILD == true ]]; then sudo apt-get update; fi + if [[ $DEBIAN_BUILD == true ]]; then sudo apt-get install fakeroot; fi + - name: Checkout Kodi repo + uses: actions/checkout@v2 + with: + repository: xbmc/xbmc + ref: master + path: xbmc + - name: Checkout audiodecoder.asap repo + uses: actions/checkout@v2 + with: + path: ${{ env.app_id }} + - name: Configure + env: + CC: ${{ matrix.CC }} + CXX: ${{ matrix.CXX }} + DEBIAN_BUILD: ${{ matrix.DEBIAN_BUILD }} + run: | + if [[ $DEBIAN_BUILD != true ]]; then cd ${app_id} && mkdir -p build && cd build; fi + if [[ $DEBIAN_BUILD != true ]]; then cmake -DADDONS_TO_BUILD=${app_id} -DADDON_SRC_PREFIX=${{ github.workspace }} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/xbmc/addons -DPACKAGE_ZIP=1 ${{ github.workspace }}/xbmc/cmake/addons; fi + if [[ $DEBIAN_BUILD == true ]]; then wget https://raw.githubusercontent.com/xbmc/xbmc/master/xbmc/addons/kodi-dev-kit/tools/debian-addon-package-test.sh && chmod +x ./debian-addon-package-test.sh; fi + if [[ $DEBIAN_BUILD == true ]]; then sudo apt-get build-dep ${{ github.workspace }}/${app_id}; fi + - name: Build + env: + CC: ${{ matrix.CC }} + CXX: ${{ matrix.CXX }} + DEBIAN_BUILD: ${{ matrix.DEBIAN_BUILD }} + run: | + if [[ $DEBIAN_BUILD != true ]]; then cd ${app_id}/build; fi + if [[ $DEBIAN_BUILD != true ]]; then make; fi + if [[ $DEBIAN_BUILD == true ]]; then ./debian-addon-package-test.sh ${{ github.workspace }}/${app_id}; fi diff --git a/README.md b/README.md index 5dbe75e..40f740e 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ ------------------ [![License: GPL-2.0-or-later](https://img.shields.io/badge/License-GPL%20v2+-blue.svg)](LICENSE.md) +[![Build and run tests](https://github.com/xbmc/audiodecoder.2sf/actions/workflows/build.yml/badge.svg?branch=Nexus)](https://github.com/xbmc/audiodecoder.2sf/actions/workflows/build.yml) [![Build Status](https://dev.azure.com/teamkodi/binary-addons/_apis/build/status/xbmc.audiodecoder.2sf?branchName=Nexus)](https://dev.azure.com/teamkodi/binary-addons/_build/latest?definitionId=3&branchName=Nexus) [![Build Status](https://jenkins.kodi.tv/view/Addons/job/xbmc/job/audiodecoder.2sf/job/Nexus/badge/icon)](https://jenkins.kodi.tv/blue/organizations/jenkins/xbmc%2Faudiodecoder.2sf/branches/) From 733d7754d80dca4e11f966a6a6da5962803004a6 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Sun, 17 Oct 2021 15:46:50 +0200 Subject: [PATCH 3/5] audiodecoder API Version 4.0.0 update --- audiodecoder.2sf/addon.xml.in | 14 ++++++++++++-- .../language/resource.language.en_gb/strings.po | 12 ++++++++++++ src/2SFCodec.cpp | 14 +++++++------- src/2SFCodec.h | 4 ++-- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/audiodecoder.2sf/addon.xml.in b/audiodecoder.2sf/addon.xml.in index b350f47..2c0ef2e 100644 --- a/audiodecoder.2sf/addon.xml.in +++ b/audiodecoder.2sf/addon.xml.in @@ -8,9 +8,19 @@ + library_@PLATFORM@="@LIBRARY_FILENAME@"> + + + 30100 + icon.png + + + 30101 + icon.png + + + @PLATFORM@ GPL-2.0-or-later diff --git a/audiodecoder.2sf/resources/language/resource.language.en_gb/strings.po b/audiodecoder.2sf/resources/language/resource.language.en_gb/strings.po index 8f2aa34..b55117d 100644 --- a/audiodecoder.2sf/resources/language/resource.language.en_gb/strings.po +++ b/audiodecoder.2sf/resources/language/resource.language.en_gb/strings.po @@ -123,3 +123,15 @@ msgstr "" msgctxt "#30022" msgid "Ainc" msgstr "" + +#. Supported file extension description about ".2sf" +#: audiodecoder.2sf/addon.xml.in +msgctxt "#30100" +msgid "Game audio file used by some Nintendo DS games." +msgstr "" + +#. Supported file extension description about ".mini2sf" +#: audiodecoder.2sf/addon.xml.in +msgctxt "#30101" +msgid "Nintendo DS Sound Information File - With their corresponding 2SFLIB file can be played." +msgstr "" diff --git a/src/2SFCodec.cpp b/src/2SFCodec.cpp index 9dfc047..cf96d3d 100644 --- a/src/2SFCodec.cpp +++ b/src/2SFCodec.cpp @@ -547,15 +547,15 @@ void C2SFCodec::Shutdown() } } -int C2SFCodec::ReadPCM(uint8_t* buffer, int size, int& actualsize) +int C2SFCodec::ReadPCM(uint8_t* buffer, size_t size, size_t& actualsize) { if (m_eof && !m_silenceTestBuffer.data_available()) - return 1; + return AUDIODECODER_READ_ERROR; if (m_noLoop && m_tagSongMs && (m_posDelta + mul_div(m_dataWritten, 1000, m_cfgDefaultSampleRate)) >= m_tagSongMs + m_tagFadeMs) - return -1; + return AUDIODECODER_READ_EOF; unsigned int written = 0; @@ -613,7 +613,7 @@ int C2SFCodec::ReadPCM(uint8_t* buffer, int size, int& actualsize) if (m_silenceTestBuffer.test_silence()) { m_eof = true; - return -1; + return AUDIODECODER_READ_EOF; } written = m_silenceTestBuffer.data_available() / 2; @@ -673,14 +673,14 @@ int C2SFCodec::ReadPCM(uint8_t* buffer, int size, int& actualsize) if (!written) { m_eof = true; - return -1; + return AUDIODECODER_READ_EOF; } actualsize = written * 2 * sizeof(int16_t); memcpy(buffer, ptr, actualsize); - return 0; + return AUDIODECODER_READ_SUCCESS; } int64_t C2SFCodec::Seek(int64_t time) @@ -759,7 +759,7 @@ bool C2SFCodec::ReadTag(const std::string& file, kodi::addon::AudioDecoderInfoTa //------------------------------------------------------------------------------ -class ATTRIBUTE_HIDDEN CMyAddon : public kodi::addon::CAddonBase +class ATTR_DLL_LOCAL CMyAddon : public kodi::addon::CAddonBase { public: CMyAddon() = default; diff --git a/src/2SFCodec.h b/src/2SFCodec.h index 2806e06..1a82c3f 100644 --- a/src/2SFCodec.h +++ b/src/2SFCodec.h @@ -62,7 +62,7 @@ struct TSFContext int tagFadeMs = 0; }; -class ATTRIBUTE_HIDDEN C2SFCodec : public kodi::addon::CInstanceAudioDecoder +class ATTR_DLL_LOCAL C2SFCodec : public kodi::addon::CInstanceAudioDecoder { public: C2SFCodec(KODI_HANDLE instance, const std::string& version); @@ -78,7 +78,7 @@ class ATTRIBUTE_HIDDEN C2SFCodec : public kodi::addon::CInstanceAudioDecoder int& bitrate, AudioEngineDataFormat& format, std::vector& channellist) override; - int ReadPCM(uint8_t* buffer, int size, int& actualsize) override; + int ReadPCM(uint8_t* buffer, size_t size, size_t& actualsize) override; int64_t Seek(int64_t time) override; bool ReadTag(const std::string& file, kodi::addon::AudioDecoderInfoTag& tag) override; From 7b8706cf01f6ca95711ceaaf42b7a36e815f70e8 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 3 Nov 2021 21:56:09 +0100 Subject: [PATCH 4/5] add possibility to get track number by filename --- .../resource.language.en_gb/strings.po | 12 ++++ audiodecoder.2sf/resources/settings.xml | 4 ++ src/2SFCodec.cpp | 59 +++++++++++++++++++ src/2SFCodec.h | 1 + 4 files changed, 76 insertions(+) diff --git a/audiodecoder.2sf/resources/language/resource.language.en_gb/strings.po b/audiodecoder.2sf/resources/language/resource.language.en_gb/strings.po index b55117d..49fc3d5 100644 --- a/audiodecoder.2sf/resources/language/resource.language.en_gb/strings.po +++ b/audiodecoder.2sf/resources/language/resource.language.en_gb/strings.po @@ -124,6 +124,18 @@ msgctxt "#30022" msgid "Ainc" msgstr "" +#. Boolean setting to allow scan of title number by file name (default is enabled) +#: audiodecoder.2sf/resources/settings.xml +msgctxt "#30023" +msgid "Get track number from filename" +msgstr "" + +#. Help text about setting on id 30023 +#: audiodecoder.2sf/resources/settings.xml +msgctxt "#30024" +msgid "If activated, tries to read the used song track number from file names. Note: This cannot always be determined 100% correctly." +msgstr "" + #. Supported file extension description about ".2sf" #: audiodecoder.2sf/addon.xml.in msgctxt "#30100" diff --git a/audiodecoder.2sf/resources/settings.xml b/audiodecoder.2sf/resources/settings.xml index 5c533d1..f9440e7 100644 --- a/audiodecoder.2sf/resources/settings.xml +++ b/audiodecoder.2sf/resources/settings.xml @@ -65,6 +65,10 @@ + + true + + diff --git a/src/2SFCodec.cpp b/src/2SFCodec.cpp index cf96d3d..04be6df 100644 --- a/src/2SFCodec.cpp +++ b/src/2SFCodec.cpp @@ -742,6 +742,8 @@ bool C2SFCodec::ReadTag(const std::string& file, kodi::addon::AudioDecoderInfoTa return false; } + if (kodi::GetSettingBoolean("tracknumbersearch", true)) + tag.SetTrack(GetTrackNumber(file)); tag.SetTitle(info_state.title); if (!info_state.artist.empty()) tag.SetArtist(info_state.artist); @@ -757,6 +759,63 @@ bool C2SFCodec::ReadTag(const std::string& file, kodi::addon::AudioDecoderInfoTa return true; } +int C2SFCodec::GetTrackNumber(const std::string& filename) +{ + // Try to get track number from file name. + // + // On test files found following conditions: + // - "01 Explore a New World.mini2sf" - With decimal number on begin + // - "0000 ALERT_SEQ.mini2sf" - With hexadecimal on begin (always as 4 characters) + // - "NTR-ANNJ-JPN-000b.mini2sf" - With hexadecimal on end (always as 4 characters) + + bool hexDigit = true; + std::string number; + std::string name = kodi::vfs::GetFileName(filename); + name = name.substr(0, name.rfind('.')); + if (name.length() >= 4) + { + for (size_t i = 0; i < 4; ++i) + { + if (!kodi::tools::StringUtils::IsAsciiXDigit(name[i])) + { + hexDigit = false; + break; + } + } + if (hexDigit) + { + number = kodi::tools::StringUtils::Format("0x%c%c%c%c", name[0], name[1], name[2], name[3]); + } + else if (isdigit(name[0])) + { + return std::stoul(name, nullptr, 10); + } + else + { + hexDigit = true; + size_t startPos = name.size()-4; + for (size_t i = 0; i < 4; ++i) + { + if (!kodi::tools::StringUtils::IsAsciiXDigit(name[startPos+i])) + { + hexDigit = false; + break; + } + } + if (hexDigit) + { + number = kodi::tools::StringUtils::Format("0x%c%c%c%c", name[startPos+0], name[startPos+1], name[startPos+2], name[startPos+3]); + } + } + } + if (!number.empty()) + { + return std::stoul(number, nullptr, 16)+1; + } + + return 0; +} + //------------------------------------------------------------------------------ class ATTR_DLL_LOCAL CMyAddon : public kodi::addon::CAddonBase diff --git a/src/2SFCodec.h b/src/2SFCodec.h index 1a82c3f..a156bab 100644 --- a/src/2SFCodec.h +++ b/src/2SFCodec.h @@ -85,6 +85,7 @@ class ATTR_DLL_LOCAL C2SFCodec : public kodi::addon::CInstanceAudioDecoder private: bool Load(); void Shutdown(); + int GetTrackNumber(const std::string& filename); inline uint64_t time_to_samples(double p_time, uint32_t p_sample_rate) { From 34c4c783753717667375f93e6d0074790cd3c188 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Sun, 17 Oct 2021 15:47:08 +0200 Subject: [PATCH 5/5] increase version to 20.1.0 --- audiodecoder.2sf/addon.xml.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audiodecoder.2sf/addon.xml.in b/audiodecoder.2sf/addon.xml.in index 2c0ef2e..c0c2e36 100644 --- a/audiodecoder.2sf/addon.xml.in +++ b/audiodecoder.2sf/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@