diff options
| author | manuel <manuel@mausz.at> | 2015-03-03 16:53:59 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2015-03-03 16:53:59 +0100 |
| commit | ffca21f2743a7b367fa212799c6e2fea6190dd5d (patch) | |
| tree | 0608ea3a29cf644ec9ab204e2b4bb9bfaae1c381 /xbmc/addons/Visualisation.h | |
| download | kodi-pvr-build-ffca21f2743a7b367fa212799c6e2fea6190dd5d.tar.gz kodi-pvr-build-ffca21f2743a7b367fa212799c6e2fea6190dd5d.tar.bz2 kodi-pvr-build-ffca21f2743a7b367fa212799c6e2fea6190dd5d.zip | |
initial commit for kodi master
Diffstat (limited to 'xbmc/addons/Visualisation.h')
| -rw-r--r-- | xbmc/addons/Visualisation.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/xbmc/addons/Visualisation.h b/xbmc/addons/Visualisation.h new file mode 100644 index 0000000..0a2a1cb --- /dev/null +++ b/xbmc/addons/Visualisation.h | |||
| @@ -0,0 +1,111 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2013 Team XBMC | ||
| 3 | * http://xbmc.org | ||
| 4 | * | ||
| 5 | * This Program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | * any later version. | ||
| 9 | * | ||
| 10 | * This Program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with XBMC; see the file COPYING. If not, see | ||
| 17 | * <http://www.gnu.org/licenses/>. | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #pragma once | ||
| 21 | |||
| 22 | #include "AddonDll.h" | ||
| 23 | #include "cores/IAudioCallback.h" | ||
| 24 | #include "include/xbmc_vis_types.h" | ||
| 25 | #include "guilib/IRenderingCallback.h" | ||
| 26 | |||
| 27 | #include <map> | ||
| 28 | #include <list> | ||
| 29 | #include <memory> | ||
| 30 | |||
| 31 | #define AUDIO_BUFFER_SIZE 512 // MUST BE A POWER OF 2!!! | ||
| 32 | #define MAX_AUDIO_BUFFERS 16 | ||
| 33 | |||
| 34 | class CCriticalSection; | ||
| 35 | |||
| 36 | typedef DllAddon<Visualisation, VIS_PROPS> DllVisualisation; | ||
| 37 | |||
| 38 | class CAudioBuffer | ||
| 39 | { | ||
| 40 | public: | ||
| 41 | CAudioBuffer(int iSize); | ||
| 42 | virtual ~CAudioBuffer(); | ||
| 43 | const float* Get() const; | ||
| 44 | void Set(const float* psBuffer, int iSize); | ||
| 45 | private: | ||
| 46 | CAudioBuffer(); | ||
| 47 | float* m_pBuffer; | ||
| 48 | int m_iLen; | ||
| 49 | }; | ||
| 50 | |||
| 51 | namespace ADDON | ||
| 52 | { | ||
| 53 | class CVisualisation : public CAddonDll<DllVisualisation, Visualisation, VIS_PROPS> | ||
| 54 | , public IAudioCallback | ||
| 55 | , public IRenderingCallback | ||
| 56 | { | ||
| 57 | public: | ||
| 58 | CVisualisation(const ADDON::AddonProps &props) : CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>(props) {} | ||
| 59 | CVisualisation(const cp_extension_t *ext) : CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>(ext) {} | ||
| 60 | virtual void OnInitialize(int iChannels, int iSamplesPerSec, int iBitsPerSample); | ||
| 61 | virtual void OnAudioData(const float* pAudioData, int iAudioDataLength); | ||
| 62 | bool Create(int x, int y, int w, int h, void *device); | ||
| 63 | void Start(int iChannels, int iSamplesPerSec, int iBitsPerSample, const std::string &strSongName); | ||
| 64 | void AudioData(const float *pAudioData, int iAudioDataLength, float *pFreqData, int iFreqDataLength); | ||
| 65 | void Render(); | ||
| 66 | void Stop(); | ||
| 67 | void GetInfo(VIS_INFO *info); | ||
| 68 | bool OnAction(VIS_ACTION action, void *param = NULL); | ||
| 69 | bool UpdateTrack(); | ||
| 70 | bool HasSubModules() { return !m_submodules.empty(); } | ||
| 71 | bool IsLocked(); | ||
| 72 | unsigned GetPreset(); | ||
| 73 | std::string GetPresetName(); | ||
| 74 | bool GetPresetList(std::vector<std::string>& vecpresets); | ||
| 75 | bool GetSubModuleList(std::vector<std::string>& vecmodules); | ||
| 76 | static std::string GetFriendlyName(const std::string& vis, const std::string& module); | ||
| 77 | void Destroy(); | ||
| 78 | |||
| 79 | private: | ||
| 80 | void CreateBuffers(); | ||
| 81 | void ClearBuffers(); | ||
| 82 | |||
| 83 | bool GetPresets(); | ||
| 84 | bool GetSubModules(); | ||
| 85 | |||
| 86 | // attributes of the viewport we render to | ||
| 87 | int m_xPos; | ||
| 88 | int m_yPos; | ||
| 89 | int m_width; | ||
| 90 | int m_height; | ||
| 91 | |||
| 92 | // cached preset list | ||
| 93 | std::vector<std::string> m_presets; | ||
| 94 | // cached submodule list | ||
| 95 | std::vector<std::string> m_submodules; | ||
| 96 | int m_currentModule; | ||
| 97 | |||
| 98 | // audio properties | ||
| 99 | int m_iChannels; | ||
| 100 | int m_iSamplesPerSec; | ||
| 101 | int m_iBitsPerSample; | ||
| 102 | std::list<CAudioBuffer*> m_vecBuffers; | ||
| 103 | int m_iNumBuffers; // Number of Audio buffers | ||
| 104 | bool m_bWantsFreq; | ||
| 105 | float m_fFreq[2*AUDIO_BUFFER_SIZE]; // Frequency data | ||
| 106 | bool m_bCalculate_Freq; // True if the vis wants freq data | ||
| 107 | |||
| 108 | // track information | ||
| 109 | std::string m_AlbumThumb; | ||
| 110 | }; | ||
| 111 | } | ||
