From f9c789e4dbf91d361030cdc4bb35f83ce0ee0428 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 15 Nov 2015 13:12:54 +0100 Subject: [PATCH 1/3] Fixed: Only open supported music formats in music player --HG-- branch : develop --- code/nel/src/sound/audio_decoder.cpp | 7 +- code/nel/src/sound/audio_mixer_user.cpp | 10 ++- .../client/src/interface_v3/music_player.cpp | 75 +++++++++++++++++-- 3 files changed, 83 insertions(+), 9 deletions(-) diff --git a/code/nel/src/sound/audio_decoder.cpp b/code/nel/src/sound/audio_decoder.cpp index 74193949c..d8283c227 100644 --- a/code/nel/src/sound/audio_decoder.cpp +++ b/code/nel/src/sound/audio_decoder.cpp @@ -124,7 +124,12 @@ bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, st /// Get audio/container extensions that are currently supported by the nel sound library. void IAudioDecoder::getMusicExtensions(std::vector &extensions) { - extensions.push_back("ogg"); + // only add ogg format if not already in extensions list + if (std::find(extensions.begin(), extensions.end(), "ogg") == extensions.end()) + { + extensions.push_back("ogg"); + } + // extensions.push_back("wav"); // TODO: Easy. } diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 3a75433f4..bb79359e1 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -54,6 +54,7 @@ #include "nel/sound/sound_bank.h" #include "nel/sound/group_controller.h" #include "nel/sound/containers.h" +#include "nel/sound/audio_decoder.h" using namespace std; using namespace NLMISC; @@ -2751,7 +2752,14 @@ bool CAudioMixerUser::isEventMusicEnded() /// Get audio/container extensions that are currently supported by nel or the used driver implementation. void CAudioMixerUser::getMusicExtensions(std::vector &extensions) { - _SoundDriver->getMusicExtensions(extensions); + if (_SoundDriver) + { + // add file formats supported by driver + _SoundDriver->getMusicExtensions(extensions); + } + + // add 3rd party libraries support file formats + IAudioDecoder::getMusicExtensions(extensions); } /// Add a reverb environment diff --git a/code/ryzom/client/src/interface_v3/music_player.cpp b/code/ryzom/client/src/interface_v3/music_player.cpp index 171fc328e..639c170c0 100644 --- a/code/ryzom/client/src/interface_v3/music_player.cpp +++ b/code/ryzom/client/src/interface_v3/music_player.cpp @@ -181,6 +181,12 @@ public: if (Params == "play_songs") { + std::vector extensions; + SoundMngr->getMixer()->getMusicExtensions(extensions); + + // no format supported + if (extensions.empty()) return; + #ifdef NL_OS_WINDOWS // Backup the current directory string currentPath = CPath::getCurrentPath (); @@ -195,13 +201,68 @@ public: } else { - static char szFilter[] = - "All Supported Files\0*.mp3;*.mp2;*.mp1;*.ogg;*.m3u\0" - "MPEG Audio Files (*.mp3;*.mp2;*.mp1)\0*.mp3;*.mp2;*.mp1\0" - "Vorbis Files (*.ogg)\0*.ogg\0" - "Playlist Files (*.m3u)\0*.m3u\0" - "All Files (*.*)\0*.*\0" - "\0"; + bool oggSupported = false; + bool mp3Supported = false; + + for(uint i = 0; i < extensions.size(); ++i) + { + if (extensions[i] == "ogg") + { + oggSupported = true; + } + else if (extensions[i] == "mp3") + { + mp3Supported = true; + } + } + + std::vector filters; + + // supported formats + filters.push_back("All Supported Files"); + + std::string filter; + if (mp3Supported) filter += "*.mp3;*.mp2;*.mp1;"; + if (oggSupported) filter += "*.ogg;"; + filter += "*.m3u"; + + filters.push_back(filter); + + // mp3 format + if (mp3Supported) + { + filters.push_back("MPEG Audio Files (*.mp3;*.mp2;*.mp1)"); + filters.push_back("*.mp3;*.mp2;*.mp1"); + } + + // ogg format + if (oggSupported) + { + filters.push_back("Vorbis Files (*.ogg)"); + filters.push_back("*.ogg"); + } + + // playlist + filters.push_back("Playlist Files (*.m3u)"); + filters.push_back("*.m3u"); + + // all files + filters.push_back("All Files (*.*)"); + filters.push_back("*.*"); + + filters.push_back(""); + + static char szFilter[1024] = { '\0' }; + + uint offset = 0; + + for(uint i = 0; i < filters.size(); ++i) + { + strcpy(szFilters + offset, filters[i].c_str()); + + // move offset to string length + 1 for \0 + offset += filters[i].length() + 1; + } // Filename buffer char buffer[65535]; From 334f2b43c66195005fa7d52928273377697c1a3d Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 15 Nov 2015 13:13:44 +0100 Subject: [PATCH 2/3] Fixed: Display title and artist name from ogg files in music player --HG-- branch : develop --- code/nel/src/sound/audio_mixer_user.cpp | 33 ++++++++++++------- .../client/src/interface_v3/music_player.cpp | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index bb79359e1..9ac90b3c7 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -2690,21 +2690,30 @@ bool CAudioMixerUser::getSongTitle(const std::string &filename, std::string &res { std::string artist; std::string title; - if (_SoundDriver->getMusicInfo(filename, artist, title)) + + if (!_SoundDriver->getMusicInfo(filename, artist, title)) { - if (!title.empty()) - { - if (!artist.empty()) result = artist + " - " + title; - else result = title; - } - else if (!artist.empty()) - { - result = artist + " - " + CFile::getFilename(filename); - } - else result = CFile::getFilename(filename); - return true; + // use 3rd party libraries supported formats + IAudioDecoder::getInfo(filename, artist, title); + } + + if (!title.empty()) + { + if (!artist.empty()) result = artist + " - " + title; + else result = title; } + else if (!artist.empty()) + { + result = artist + " - " + CFile::getFilename(filename); + } + else + { + result = CFile::getFilename(filename); + } + + return true; } + result = "???"; return false; } diff --git a/code/ryzom/client/src/interface_v3/music_player.cpp b/code/ryzom/client/src/interface_v3/music_player.cpp index 639c170c0..64107a916 100644 --- a/code/ryzom/client/src/interface_v3/music_player.cpp +++ b/code/ryzom/client/src/interface_v3/music_player.cpp @@ -83,7 +83,7 @@ void CMusicPlayer::play () CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text")); if (pVT) - pVT->setText (_Songs[_CurrentSong].Title); + pVT->setText (ucstring::makeFromUtf8(_Songs[_CurrentSong].Title)); } } From 817486538c6502a2df5689577bfeb77229d0d7ad Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 15 Nov 2015 13:29:34 +0100 Subject: [PATCH 3/3] Changed: Minor changes --HG-- branch : develop --- .../src/3d/driver/opengl/driver_opengl_extension.cpp | 11 +++++++++-- code/nel/tools/3d/ig_elevation/main.cpp | 2 +- code/ryzom/client/client_default.cfg.in | 2 +- code/ryzom/client/src/interface_v3/music_player.cpp | 2 +- .../ryzom/client/src/r2/dmc/client_edition_module.cpp | 2 +- .../server/src/frontend_service/client_id_lookup.h | 2 +- code/ryzom/server/src/frontend_service/fe_types.h | 2 +- .../server/src/gpm_service/world_position_manager.h | 2 +- code/ryzom/server/src/pd_lib/pd_utils.h | 2 +- 9 files changed, 17 insertions(+), 10 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index a55b5d720..7342b3efc 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -1793,8 +1793,15 @@ void registerGlExtensions(CGlExtensions &ext) if (ext.NVXGPUMemoryInfo) { -// GPU_MEMORY_INFO_EVICTION_COUNT_NVX; -// GPU_MEMORY_INFO_EVICTED_MEMORY_NVX; + GLint nEvictionCount = 0; +#ifdef GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX + glGetIntegerv(GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX, &nEvictionCount); +#endif + + GLint nEvictionMemory = 0; +#ifdef GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX + glGetIntegerv(GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX, &nEvictionMemory); +#endif GLint nDedicatedMemoryInKB = 0; #ifdef GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX diff --git a/code/nel/tools/3d/ig_elevation/main.cpp b/code/nel/tools/3d/ig_elevation/main.cpp index 3983dc4ec..f44015873 100644 --- a/code/nel/tools/3d/ig_elevation/main.cpp +++ b/code/nel/tools/3d/ig_elevation/main.cpp @@ -53,7 +53,7 @@ using namespace NL3D; // --------------------------------------------------------------------------- // Out a string to the stdout and log.log -void outString (string &sText) +void outString (const string &sText) { createDebug (); InfoLog->displayRaw(sText.c_str()); diff --git a/code/ryzom/client/client_default.cfg.in b/code/ryzom/client/client_default.cfg.in index ec699fe14..8dbd2855d 100644 --- a/code/ryzom/client/client_default.cfg.in +++ b/code/ryzom/client/client_default.cfg.in @@ -483,7 +483,7 @@ XMLR2EDInterfaceFiles = { "r2ed.xml", "r2_triggers.xml", - "r2_logic_entities.xml", + "r2_logic_entities.xml", "r2ed_acts.xml", "r2ed_scenario.xml", "r2ed_connect.xml" diff --git a/code/ryzom/client/src/interface_v3/music_player.cpp b/code/ryzom/client/src/interface_v3/music_player.cpp index 64107a916..39aeea825 100644 --- a/code/ryzom/client/src/interface_v3/music_player.cpp +++ b/code/ryzom/client/src/interface_v3/music_player.cpp @@ -258,7 +258,7 @@ public: for(uint i = 0; i < filters.size(); ++i) { - strcpy(szFilters + offset, filters[i].c_str()); + strcpy(szFilter + offset, filters[i].c_str()); // move offset to string length + 1 for \0 offset += filters[i].length() + 1; diff --git a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp index 45916dd7d..8e2cb5695 100644 --- a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -2475,7 +2475,7 @@ void CClientEditionModule::loadScenarioSucceded(const std::string& filename, con } if (CFile::fileExists(filename)) { - CFile::copyFile("save/r2_buffer.dat", filename.c_str()); + CFile::copyFile("save/r2_buffer.dat", filename); } } diff --git a/code/ryzom/server/src/frontend_service/client_id_lookup.h b/code/ryzom/server/src/frontend_service/client_id_lookup.h index 9c63a60a6..c08524c99 100644 --- a/code/ryzom/server/src/frontend_service/client_id_lookup.h +++ b/code/ryzom/server/src/frontend_service/client_id_lookup.h @@ -116,7 +116,7 @@ private: struct CIdHash { - enum { bucket_size = 4, min_buckets = 8, }; + enum { bucket_size = 4, min_buckets = 8 }; size_t operator () (NLMISC::CEntityId id) const { return (uint32)id.getShortId(); } bool operator() (const NLMISC::CEntityId& left, const NLMISC::CEntityId& right) { return left < right; } }; diff --git a/code/ryzom/server/src/frontend_service/fe_types.h b/code/ryzom/server/src/frontend_service/fe_types.h index d63ef1e42..b015a2d0e 100644 --- a/code/ryzom/server/src/frontend_service/fe_types.h +++ b/code/ryzom/server/src/frontend_service/fe_types.h @@ -71,7 +71,7 @@ typedef uint32 TUid; */ struct CInetAddressHashMapTraits { - enum { bucket_size = 4, min_buckets = 8, }; + enum { bucket_size = 4, min_buckets = 8 }; inline size_t operator() ( const NLNET::CInetAddress& x ) const { //return x.port(); diff --git a/code/ryzom/server/src/gpm_service/world_position_manager.h b/code/ryzom/server/src/gpm_service/world_position_manager.h index 81209357c..31030a582 100644 --- a/code/ryzom/server/src/gpm_service/world_position_manager.h +++ b/code/ryzom/server/src/gpm_service/world_position_manager.h @@ -139,7 +139,7 @@ public: struct CEntityIdHash { - enum { bucket_size = 4, min_buckets = 8, }; + enum { bucket_size = 4, min_buckets = 8 }; size_t operator () (const NLMISC::CEntityId &id) const { return (uint32)id.getShortId(); } size_t operator () (const NLMISC::CEntityId &left, const NLMISC::CEntityId &right) const { return left < right; } }; diff --git a/code/ryzom/server/src/pd_lib/pd_utils.h b/code/ryzom/server/src/pd_lib/pd_utils.h index 85a183753..45cf2025b 100644 --- a/code/ryzom/server/src/pd_lib/pd_utils.h +++ b/code/ryzom/server/src/pd_lib/pd_utils.h @@ -490,7 +490,7 @@ typedef std::vector TIndexList; struct CColumnIndexHashMapTraits { - enum { bucket_size = 4, min_buckets = 8, }; + enum { bucket_size = 4, min_buckets = 8 }; CColumnIndexHashMapTraits() { } size_t operator() (const CColumnIndex &id) const {