- Add a new CD:do_lookup attribute. It will be used by userland programs (like

cddblinkd) to know if they should lookup the CD or not. It will be true
  unless:

  1 - The CD has CD-Text information.
  2 - The user (or a userland program) changed the Volume name.
  3 - The user (or a userland program) changed any track names.

- Moved (again) attribute creation to before the stored attributes are read. As
  attribute operations happen in memory in cdda, we don't need to care about
  the IO cost and this way it is more in line with all the other attributes
  created.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27079 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Bruno G. Albuquerque
2008-08-20 13:10:18 +00:00
parent 6960a91cd7
commit 84719cae24
@@ -248,6 +248,7 @@ static const uint32 kMaxAttributeSize = 65536;
static const uint32 kMaxAttributes = 64;
static const char* kCddbIdAttribute = "CD:cddbid";
static const char* kDoLookupAttribute = "CD:do_lookup";
extern fs_volume_ops gCDDAVolumeOps;
extern fs_vnode_ops gCDDAVnodeOps;
@@ -571,9 +572,12 @@ Volume::Mount(const char* device)
return status;
}
bool do_lookup = true;
cdtext text;
if (read_cdtext(fDevice, text) < B_OK)
dprintf("CDDA: no CD-Text found.\n");
else
do_lookup = false;
int32 trackCount = toc->last_track + 1 - toc->first_track;
off_t totalFrames = 0;
@@ -635,13 +639,16 @@ Volume::Mount(const char* device)
inode->AddAttribute("BEOS:TYPE", B_MIME_STRING_TYPE, "audio/x-wav");
}
// Add CD:cddbid attribute.
fRootNode->AddAttribute(kCddbIdAttribute, B_UINT32_TYPE, fDiscID);
// Add CD:do_lookup attribute.
fRootNode->AddAttribute(kDoLookupAttribute, B_BOOL_TYPE, true,
(const uint8*)&do_lookup, sizeof(bool));
_RestoreSharedAttributes();
_RestoreAttributes();
// Only add CD:cddbid attribute if it does not exist yet.
if (fRootNode->FindAttribute(kCddbIdAttribute) == NULL)
fRootNode->AddAttribute(kCddbIdAttribute, B_UINT32_TYPE, fDiscID);
free(toc);
// determine volume title
@@ -1381,8 +1388,18 @@ cdda_write_fs_stat(fs_volume* _volume, const struct fs_info* info, uint32 mask)
status_t status = B_BAD_VALUE;
if ((mask & FS_WRITE_FSINFO_NAME) != 0)
if ((mask & FS_WRITE_FSINFO_NAME) != 0) {
status = volume->SetName(info->volume_name);
if (status == B_OK) {
// The volume had its name changed from outside the filesystem
// add-on. Disable CDDB lookups. Note this will usually mean that
// the user manually renamed the volume or that cddblinkd (or other
// program) did this so we do not want to do it again.
bool do_lookup = false;
volume->RootNode().AddAttribute(kDoLookupAttribute, B_BOOL_TYPE,
true, (const uint8*)&do_lookup, sizeof(bool));
}
}
return status;
}
@@ -1644,7 +1661,18 @@ cdda_rename(fs_volume* _volume, fs_vnode* _oldDir, const char* oldName,
if (volume->Find(newName) != NULL)
return B_NAME_IN_USE;
return inode->SetName(newName);
status_t result = inode->SetName(newName);
if (result == B_OK) {
// One of the tracks had its name edited from outside the filesystem
// add-on. Disable CDDB lookups. Note this will usually mean that the
// user manually renamed a track or that cddblinkd (or other program)
// did this so we do not want to do it again.
bool do_lookup = false;
volume->RootNode().AddAttribute(kDoLookupAttribute, B_BOOL_TYPE, true,
(const uint8*)&do_lookup, sizeof(bool));
}
return result;
}