Commit 158c23f2 authored by Warren Dukes's avatar Warren Dukes

when updating, don't cause db reread on adding and then removing empty directories

git-svn-id: https://svn.musicpd.org/mpd/trunk@805 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 4a1fbb45
1) On exploring a directory: 1) resampling audio for compatibility, and better gapless/crossfading
1) detect if any songs were added
2) if no songs added remove explored directory
3) use this info on exploring directory to adjust whether or not an
update happened
4) remove the deleteEmptryDirectories() function
2) resampling audio for compatibility, and better gapless/crossfading
a) write bit conversion stuff (8->16 and 24->16) a) write bit conversion stuff (8->16 and 24->16)
b) mono to stereo conversion b) mono to stereo conversion
c) default audio format is (44.1khz, 16-bit, stereo) c) default audio format is (44.1khz, 16-bit, stereo)
d) option to set default sampling frequency d) option to set default sampling frequency
e) abitility to disable resampling and audio format conversion e) abitility to disable resampling and audio format conversion
3) when writing combined interface for all decodes to use, be sure to add a 2) when writing combined interface for all decodes to use, be sure to add a
common function and abstrct dealing with DecoderControl * and put common function and abstrct dealing with DecoderControl * and put
cycleLogFiles in there, so we cycleLogFiles while decoding, not just when cycleLogFiles in there, so we cycleLogFiles while decoding, not just when
decoding has stopped. decoding has stopped.
4) reaplygain 3) reaplygain
5) streaming and playing in general 4) streaming and playing in general
1) determine a clever interface to play, so that play doesn't block a) determine a clever interface to play, so that play doesn't block
until the file is opened, but just returns when the command until the file is opened, but just returns when the command
is accepted. is accepted.
2) put errors in error stuff of PlayerControl and report this to b) put errors in error stuff of PlayerControl and report this to
status and print to error logs status and print to error logs
3) this will help streaming from blocking indefinetly or waiting c) this will help streaming from blocking indefinetly or waiting
on a response on a response
6) play streams 5) play streams
7) ACK error codes 6) ACK error codes
8) cleanup main() 7) cleanup main()
9) handle '\n' in filenames 8) handle '\n' in filenames
Post-1.0 Post-1.0
......
...@@ -103,7 +103,7 @@ void deleteEmptyDirectoriesInDirectory(Directory * directory); ...@@ -103,7 +103,7 @@ void deleteEmptyDirectoriesInDirectory(Directory * directory);
void removeSongFromDirectory(Directory * directory, char * shortname); void removeSongFromDirectory(Directory * directory, char * shortname);
Directory * addSubDirectoryToDirectory(Directory * directory, char * shortname, int addSubDirectoryToDirectory(Directory * directory, char * shortname,
char * name); char * name);
Directory * getDirectoryDetails(char * name, char ** shortname, Directory * getDirectoryDetails(char * name, char ** shortname,
...@@ -328,8 +328,8 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) { ...@@ -328,8 +328,8 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
if(updateDirectory((Directory *)subDir)>0) return 1; if(updateDirectory((Directory *)subDir)>0) return 1;
} }
else { else {
addSubDirectoryToDirectory(directory,shortname,name); return addSubDirectoryToDirectory(directory,shortname,
return 1; name);
} }
} }
...@@ -434,8 +434,9 @@ Directory * addDirectoryPathToDB(char * utf8path, char ** shortname) { ...@@ -434,8 +434,9 @@ Directory * addDirectoryPathToDB(char * utf8path, char ** shortname) {
if(!findInList(parentDirectory->subDirectories,*shortname, &directory)) if(!findInList(parentDirectory->subDirectories,*shortname, &directory))
{ {
directory = (void *)addSubDirectoryToDirectory(parentDirectory, directory = newDirectory(utf8path);
*shortname,utf8path); insertInList(parentDirectory->subDirectories,*shortname,
directory);
} }
/* if we're adding directory paths, make sure to delete filenames /* if we're adding directory paths, make sure to delete filenames
...@@ -531,9 +532,7 @@ int updatePath(char * utf8path) { ...@@ -531,9 +532,7 @@ int updatePath(char * utf8path) {
*/ */
if(isDir(path) || isMusic(path,NULL)) { if(isDir(path) || isMusic(path,NULL)) {
parentDirectory = addParentPathToDB(path,&shortname); parentDirectory = addParentPathToDB(path,&shortname);
addToDirectory(parentDirectory,shortname,path); if(addToDirectory(parentDirectory,shortname,path)>0) ret = 1;
sortDirectory(parentDirectory);
ret = 1;
} }
free(path); free(path);
...@@ -587,6 +586,11 @@ int updateDirectory(Directory * directory) { ...@@ -587,6 +586,11 @@ int updateDirectory(Directory * directory) {
return ret; return ret;
} }
/* return values:
-1 -> error
0 -> no error, but nothing found
1 -> no error, and stuff found
*/
int exploreDirectory(Directory * directory) { int exploreDirectory(Directory * directory) {
DIR * dir; DIR * dir;
char cwd[2]; char cwd[2];
...@@ -594,6 +598,7 @@ int exploreDirectory(Directory * directory) { ...@@ -594,6 +598,7 @@ int exploreDirectory(Directory * directory) {
char * s; char * s;
char * utf8; char * utf8;
char * dirname = directory->utf8name; char * dirname = directory->utf8name;
int ret = 0;
cwd[0] = '.'; cwd[0] = '.';
cwd[1] = '\0'; cwd[1] = '\0';
...@@ -619,38 +624,41 @@ int exploreDirectory(Directory * directory) { ...@@ -619,38 +624,41 @@ int exploreDirectory(Directory * directory) {
sprintf(s,"%s/%s",directory->utf8name,utf8); sprintf(s,"%s/%s",directory->utf8name,utf8);
} }
else s = strdup(utf8); else s = strdup(utf8);
addToDirectory(directory,utf8,s); if(addToDirectory(directory,utf8,s)>0) ret = 1;
free(utf8); free(utf8);
free(s); free(s);
} }
closedir(dir); closedir(dir);
return 0; return ret;
} }
Directory * addSubDirectoryToDirectory(Directory * directory, char * shortname, int addSubDirectoryToDirectory(Directory * directory, char * shortname,
char * name) char * name)
{ {
Directory * subDirectory = newDirectory(name); Directory * subDirectory = newDirectory(name);
if(exploreDirectory(subDirectory)<1) {
freeDirectory(subDirectory);
return 0;
}
insertInList(directory->subDirectories,shortname,subDirectory); insertInList(directory->subDirectories,shortname,subDirectory);
exploreDirectory(subDirectory);
return subDirectory; return 1;
} }
int addToDirectory(Directory * directory, char * shortname, char * name) { int addToDirectory(Directory * directory, char * shortname, char * name) {
if(isDir(name)) { if(isDir(name)) {
addSubDirectoryToDirectory(directory,shortname,name); return addSubDirectoryToDirectory(directory,shortname,name);
return 0;
} }
else if(isMusic(name,NULL)) { else if(isMusic(name,NULL)) {
Song * song; Song * song;
song = addSongToList(directory->songs,shortname,name); song = addSongToList(directory->songs,shortname,name);
if(!song) return -1; if(!song) return -1;
LOG("added %s\n",name); LOG("added %s\n",name);
return 0; return 1;
} }
DEBUG("addToDirectory: %s is not a directory or music\n",name); DEBUG("addToDirectory: %s is not a directory or music\n",name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment