Skip to content
Snippets Groups Projects
Commit 5a25698b authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Add the HOME dir to scan for codecs at boot

parent cc6a6a91
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,6 @@ CodecDescriptor::deleteHandlePointer( void )
void
CodecDescriptor::init()
{
_debug("Scanning %s to find audio codecs....\n", CODECS_DIR);
std::vector<AudioCodec*> CodecDynamicList = scanCodecDirectory();
_nbCodecs = CodecDynamicList.size();
if( _nbCodecs <= 0 ){
......@@ -194,30 +193,39 @@ CodecDescriptor::scanCodecDirectory( void )
{
std::vector<AudioCodec*> codecs;
std::string tmp;
std::string codecDir = CODECS_DIR;
codecDir.append("/");
std::string current = ".";
std::string previous = "..";
DIR *dir = opendir( codecDir.c_str() );
AudioCodec* audioCodec;
if( dir ){
dirent *dirStruct;
while( dirStruct = readdir( dir )) {
tmp = dirStruct -> d_name ;
if( tmp == current || tmp == previous){}
else{
if( seemsValid( tmp ) )
{
//_debug("Codec : %s\n", tmp.c_str());
audioCodec = loadCodec( codecDir.append(tmp) );
codecs.push_back( audioCodec );
codecDir = CODECS_DIR;
codecDir.append("/");
int i;
std::string libDir = std::string(CODECS_DIR).append("/");
std::string homeDir = std::string(HOMEDIR) + DIR_SEPARATOR_STR + "." + PROGDIR + "/";
std::vector<std::string> dirToScan;
dirToScan.push_back(homeDir);
dirToScan.push_back(libDir);
for( i = 0 ; i < dirToScan.size() ; i++ )
{
std::string dirStr = dirToScan[i];
_debug("Scanning %s to find audio codecs....\n", dirStr.c_str());
DIR *dir = opendir( dirStr.c_str() );
AudioCodec* audioCodec;
if( dir ){
dirent *dirStruct;
while( dirStruct = readdir( dir )) {
tmp = dirStruct -> d_name ;
if( tmp == CURRENT_DIR || tmp == PARENT_DIR){}
else{
if( seemsValid( tmp ) && !alreadyInCache( tmp ))
{
//_debug("Codec : %s\n", tmp.c_str());
_Cache.push_back( tmp );
audioCodec = loadCodec( dirStr.append(tmp) );
codecs.push_back( audioCodec );
dirStr = dirToScan[i];
}
}
}
}
closedir( dir );
}
closedir( dir );
return codecs;
}
......@@ -280,3 +288,15 @@ CodecDescriptor::seemsValid( std::string lib)
else
return false;
}
bool
CodecDescriptor::alreadyInCache( std::string lib )
{
int i;
for( i = 0 ; i < _Cache.size() ; i++ )
{
if( _Cache[i] == lib ){
return true;}
}
return false;
}
......@@ -30,6 +30,7 @@
#include <dirent.h>
#include "../global.h"
#include "../user_cfg.h"
#include "codecs/audiocodec.h"
typedef enum {
......@@ -203,7 +204,7 @@ private:
void unloadCodec( CodecHandlePointer );
bool seemsValid( std::string );
bool alreadyInCache( std::string );
/*
* Map the payload of a codec and its name
*/
......@@ -219,6 +220,8 @@ private:
*/
CodecOrder _codecOrder;
std::vector<std::string> _Cache;
/*
* Number of codecs loaded
*/
......
......@@ -85,6 +85,8 @@ typedef short int16;
#define SFL_CODEC_VALID_PREFIX "libcodec_"
#define SFL_CODEC_VALID_EXTEN ".so"
#define CURRENT_DIR "."
#define PARENT_DIR ".."
#define SFL_PCM_BOTH 0x0021
#define SFL_PCM_PLAYBACK 0x0022
......
......@@ -88,12 +88,10 @@
#define DFT_PULSE_LENGTH_STR "250"
#define SIP_INFO_STR "0"
#define DFT_DRIVER_STR "0"
#define DFT_NB_CODEC_STR "3"
// volume by default 100%
#define DFT_VOL_SPKR_STR "100"
#define DFT_VOL_MICRO_STR "100"
#define DFT_CODECS "0/8/3" // liste ordonnée de payload
#define DFT_RINGTONE "konga.ul"
#define DFT_SKIN "metal"
#define DFT_ZONE "North America"
......@@ -101,8 +99,6 @@
#define DFT_FRAME_SIZE "20"
#define DFT_SAMPLE_RATE "44100"
#define SAMPLE_RATE1 "44100"
#define SAMPLE_RATE2 "48000"
#define SAMPLE_RATE3 "96000"
// zeroconfig default value
#ifdef USE_ZEROCONF
#define CONFIG_ZEROCONF_DEFAULT_STR "1"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment