Shouldn't be any more crashes when CDDB lookup fails

Lookup now handles inexact matches
CDAudioDevice now detects all available CD drives
Fixed a minor bug in updating the track list when changing CDs
CDDB content files are now stored in R5's location - /boot/home/cd


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13764 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2005-07-19 13:29:54 +00:00
parent 515c369ec9
commit fcccc8d147
3 changed files with 47 additions and 21 deletions
+7 -3
View File
@@ -331,11 +331,15 @@ int32 CDAudioDevice::FindDrives(const char *path)
// ignore floppy -- it is not silent // ignore floppy -- it is not silent
if(strcmp(e.name, "floppy") == 0) if(strcmp(e.name, "floppy") == 0)
continue; continue;
else
if(strcmp(e.name, "ata") == 0)
continue;
int32 count = FindDrives(name); // Note that if we check for the count here, we could
// just search for one drive. However, we want to find *all* drives
// that are available, so we keep searching even if we've found one
FindDrives(name);
if(count > 0)
return count;
} }
else else
{ {
+39 -17
View File
@@ -24,7 +24,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
// #pragma mark - // #pragma mark -
// some glue // some glue
@@ -349,10 +348,7 @@ CDDBQuery::ReadFromServer(BDataIO *stream)
// Format the query // Format the query
BString query; BString query;
query << "cddb query " << discIDStr << ' ' << numTracks << ' ' query << "cddb query " << discIDStr << ' ' << numTracks << ' '
// Add frame offsets << frameOffsetString << ' ' << discLength << '\n';
<< frameOffsetString << ' '
// Finish it off with the total CD length.
<< discLength << '\n';
if (log) if (log)
printf(">%s", query.String()); printf(">%s", query.String());
@@ -362,30 +358,56 @@ CDDBQuery::ReadFromServer(BDataIO *stream)
BString tmp; BString tmp;
ReadLine(tmp); ReadLine(tmp);
BString category;
BString queryDiscID(discIDStr);
if(tmp.FindFirst("200") != 0) if(tmp.FindFirst("200") != 0)
{ {
if(tmp.FindFirst("211") == 0) if(tmp.FindFirst("211") == 0)
{ {
while(tmp.CountChars() > 0) // A 211 means that the query was not exact. To make sure that we don't
{ // have a problem with this in the future, we will choose the first entry that
printf("%s\n",tmp.String()); // the server returns. This may or may not be wise, but in my experience, the first
ReadLine(tmp); // one has been the right one.
}
ReadLine(tmp);
// Get the category from the what the server returned
GetToken(tmp.String(), category);
// Now we will get the disc ID for the CD. We will need this when we query for
// the track name list. If we send the track name query with the real discID, nothing
// will be returned. However, if we send the one from the entry, we'll get the names
// and we can take these names attach them to the disc that we have.
GetToken(tmp.String() + category.CountChars(),queryDiscID);
// This is to suck up any more search results that the server sends us.
BString throwaway;
ReadLine(throwaway);
while(throwaway.ByteAt(0) != '.')
ReadLine(throwaway);
} }
else else
{
printf("Error: %s\n",tmp.String()); printf("Error: %s\n",tmp.String());
return; return;
}
} }
BString category; else
GetToken(tmp.String() + 3, category); {
GetToken(tmp.String() + 3, category);
}
if (!category.Length()) if (!category.Length())
category = "misc"; category = "misc";
query = ""; query = "";
query << "cddb read " << category << ' ' << discIDStr << '\n' ; query << "cddb read " << category << ' ' << queryDiscID << '\n' ;
ThrowIfNotSize( socket.Send(query.String(), query.Length()) ); ThrowIfNotSize( socket.Send(query.String(), query.Length()) );
for (;;) { for (;;)
{
BString tmp; BString tmp;
ReadLine(tmp); ReadLine(tmp);
tmp += '\n'; tmp += '\n';
@@ -547,8 +569,8 @@ CDDBQuery::FindOrCreateContentFileForDisk(BFile *file, entry_ref *fileRef, int32
} }
BPath path; BPath path;
ThrowOnError( find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) ); ThrowOnError( find_directory(B_USER_DIRECTORY, &path, true) );
path.Append("CDContentFiles"); path.Append("cd");
ThrowOnError( create_directory(path.Path(), 0755) ); ThrowOnError( create_directory(path.Path(), 0755) );
BDirectory dir(path.Path()); BDirectory dir(path.Path());
+1 -1
View File
@@ -138,7 +138,7 @@ TrackState::UpdateState()
int32 int32
TrackState::GetNumTracks() const TrackState::GetNumTracks() const
{ {
return sCDDevice.CountTracks(); return sCDDevice.CountTracks()+1;
} }
bool bool