Changeset 20847
- Timestamp:
- 09/24/07 16:42:38 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/branches/2.2/modules/sonix/snx/SoundFactory.cpp
r20363 r20847 45 45 #include <vpr/vpr.h> 46 46 #include <vpr/System.h> 47 #include <vpr/Util/FileUtils.h>48 47 #include <vpr/DynLoad/LibraryFinder.h> 49 48 … … 54 53 #include <snx/SoundFactory.h> /* my header. */ 55 54 55 56 namespace fs = boost::filesystem; 56 57 57 58 namespace snx … … 82 83 SoundFactory::SoundFactory() 83 84 { 84 std::vector<std::string> search_paths;85 86 85 const std::string envvar("SNX_BASE_DIR"); 87 std::string dummy_result;88 89 if ( ! vpr::System::getenv(envvar, dummy_result) )86 std::string base_dir_env; 87 88 if ( ! vpr::System::getenv(envvar, base_dir_env) ) 90 89 { 91 90 vprDEBUG(snxDBG, vprDBG_WARNING_LVL) … … 96 95 } 97 96 97 const fs::path snx_base_dir(base_dir_env, fs::native); 98 98 99 #if defined(VPR_OS_IRIX) && defined(_ABIN32) 99 std::string snx_base_dir("${SNX_BASE_DIR}/lib32/");100 const fs::path snx_lib_dir = snx_base_dir / "lib32"; 100 101 #elif defined(VPR_OS_IRIX) && defined(_ABI64) || \ 101 102 defined(VPR_OS_Linux) && defined(__x86_64__) 102 std::string snx_base_dir("${SNX_BASE_DIR}/lib64/"); 103 #else 104 std::string snx_base_dir("${SNX_BASE_DIR}/lib/"); 105 #endif 106 103 const fs::path snx_lib_dir = snx_base_dir / "lib64"; 104 #else 105 const fs::path snx_lib_dir = snx_base_dir / "lib"; 106 #endif 107 107 108 108 #if defined(VPR_OS_Windows) … … 130 130 } 131 131 132 std::string sonix_subdir(sonix_subdir_base + std::string("-") + 133 sonix_ver_str + "/plugins/"); 132 fs::path sonix_subdir( 133 snx_lib_dir / (sonix_subdir_base + "-" + sonix_ver_str) / "plugins" 134 ); 134 135 135 136 // If versioning is not enabled, then the directory containing the 136 137 // Sonix plug-ins will not incorporate version information. 137 138 #else 138 std::string sonix_subdir(sonix_subdir_base + "/plugins/");139 fs::path sonix_subdir(snx_lib_dir / sonix_subdir_base / "plugins"); 139 140 #endif 140 141 141 142 #if defined(SNX_DEBUG) 142 143 #if defined(_DEBUG) 143 std::string sonix_path(snx_base_dir + sonix_subdir + "dbgrt"); 144 #else 145 std::string sonix_path(snx_base_dir + sonix_subdir + "dbg"); 146 #endif 147 #else 148 std::string sonix_path(snx_base_dir + sonix_subdir + "opt"); 149 #endif 150 151 search_paths.push_back(sonix_path); 152 153 search_paths.push_back("${HOME}/.sonix/plugins"); 154 155 for (unsigned int x = 0; x < search_paths.size(); ++x) 156 { 157 search_paths[x] = vpr::replaceEnvVars(search_paths[x]); 158 vprDEBUG(snxDBG, vprDBG_CONFIG_LVL) << "Finding plugins in " 159 << search_paths[x] << std::endl 160 << vprDEBUG_FLUSH; 144 sonix_subdir /= "dbgrt"; 145 #else 146 sonix_subdir /= "dbg"; 147 #endif 148 #else 149 sonix_subdir /= "opt"; 150 #endif 151 152 std::vector<fs::path> search_paths; 153 search_paths.push_back(sonix_subdir); 154 155 std::string home_dir; 156 if ( vpr::System::getenv("HOME", home_dir) ) 157 { 158 search_paths.push_back( 159 fs::path(home_dir, fs::native) / ".sonix" / "plugins" 160 ); 161 } 162 163 typedef std::vector<fs::path>::iterator iter_type; 164 for ( iter_type p = search_paths.begin(); p != search_paths.end(); ++p ) 165 { 166 const std::string cur_dir = (*p).native_directory_string(); 167 vprDEBUG(snxDBG, vprDBG_CONFIG_LVL) << "Finding plug-ins in " << cur_dir 168 << std::endl << vprDEBUG_FLUSH; 161 169 162 170 try 163 171 { 164 boost::filesystem::path dirPath(search_paths[x], boost::filesystem::native); 165 if (boost::filesystem::exists(dirPath)) 172 if ( fs::exists(*p) ) 166 173 { 167 vpr::LibraryFinder finder( search_paths[x], driver_ext);174 vpr::LibraryFinder finder(cur_dir, driver_ext); 168 175 vpr::LibraryFinder::LibraryList libs = finder.getLibraries(); 169 this->loadPlugins( libs);176 this->loadPlugins(libs); 170 177 171 178 #ifdef SNX_DEBUG 172 vprDEBUG(snxDBG, vprDBG_CONFIG_LVL) << " filelist:\n"179 vprDEBUG(snxDBG, vprDBG_CONFIG_LVL) << "Plug-in file list:\n" 173 180 << vprDEBUG_FLUSH; 174 181 for ( unsigned int i = 0; i < libs.size(); ++i ) 175 182 { 176 vprDEBUG(snxDBG, vprDBG_CONFIG_LVL) << "\t" << libs[i] 177 << std::endl 178 << vprDEBUG_FLUSH; 183 vprDEBUG_NEXT(snxDBG, vprDBG_CRITICAL_LVL) 184 << libs[i]->getName() << std::endl << vprDEBUG_FLUSH; 179 185 } 180 186 #endif … … 183 189 { 184 190 vprDEBUG(snxDBG, vprDBG_STATE_LVL) 185 << "The directory does not exist: '" << search_paths[x]<< "'\n"191 << "The directory does not exist: '" << cur_dir << "'\n" 186 192 << vprDEBUG_FLUSH; 187 193 } 188 194 } 189 catch ( boost::filesystem::filesystem_error& fsEx)195 catch (fs::filesystem_error& fsEx) 190 196 { 191 197 vprDEBUG(snxDBG, vprDBG_CRITICAL_LVL)
