* Fixed some naming inconsistencies/typos.
* Some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30741 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007-2008, Axel Dörfler, [email protected].
|
* Copyright 2007-2009, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -509,7 +509,7 @@ read_cdtext(int fd, struct cdtext &cdtext)
|
|||||||
read_table_of_contents(fd, 1, SCSI_TOC_FORMAT_CD_TEXT, buffer,
|
read_table_of_contents(fd, 1, SCSI_TOC_FORMAT_CD_TEXT, buffer,
|
||||||
kBufferSize);
|
kBufferSize);
|
||||||
if (read_table_of_contents(fd, 1, SCSI_TOC_FORMAT_CD_TEXT, buffer,
|
if (read_table_of_contents(fd, 1, SCSI_TOC_FORMAT_CD_TEXT, buffer,
|
||||||
kBufferSize) < B_OK) {
|
kBufferSize) != B_OK) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007-2008, Axel Dörfler, [email protected].
|
* Copyright 2007-2009, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -102,8 +102,8 @@ class Volume {
|
|||||||
size_t BufferSize() const { return 32 * kFrameSize; }
|
size_t BufferSize() const { return 32 * kFrameSize; }
|
||||||
// TODO: for now
|
// TODO: for now
|
||||||
|
|
||||||
static void DetermineName(uint32 cddbId, int DeviceFD, char* name,
|
static void DetermineName(uint32 cddbId, int device, char* name,
|
||||||
size_t length);
|
size_t length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Inode* _CreateNode(Inode* parent, const char* name,
|
Inode* _CreateNode(Inode* parent, const char* name,
|
||||||
@@ -439,7 +439,7 @@ read_attributes(int fd, Inode* inode)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
open_attributes(uint32 cddbId, int deviceFD, int mode,
|
open_attributes(uint32 cddbID, int deviceFD, int mode,
|
||||||
enum attr_mode attrMode)
|
enum attr_mode attrMode)
|
||||||
{
|
{
|
||||||
char* path = (char*)malloc(B_PATH_NAME_LENGTH);
|
char* path = (char*)malloc(B_PATH_NAME_LENGTH);
|
||||||
@@ -460,25 +460,25 @@ open_attributes(uint32 cddbId, int deviceFD, int mode,
|
|||||||
|
|
||||||
if (attrMode == kDiscIDAttributes) {
|
if (attrMode == kDiscIDAttributes) {
|
||||||
char id[64];
|
char id[64];
|
||||||
snprintf(id, sizeof(id), "/%08lx", cddbId);
|
snprintf(id, sizeof(id), "/%08lx", cddbID);
|
||||||
strlcat(path, id, B_PATH_NAME_LENGTH);
|
strlcat(path, id, B_PATH_NAME_LENGTH);
|
||||||
} else if (attrMode == kDeviceAttributes) {
|
} else if (attrMode == kDeviceAttributes) {
|
||||||
uint32 length = strlen(path);
|
uint32 length = strlen(path);
|
||||||
char* device = path + length;
|
char* deviceName = path + length;
|
||||||
if (ioctl(deviceFD, B_GET_PATH_FOR_DEVICE, device,
|
if (ioctl(deviceFD, B_GET_PATH_FOR_DEVICE, deviceName,
|
||||||
B_PATH_NAME_LENGTH - length) < B_OK) {
|
B_PATH_NAME_LENGTH - length) < B_OK) {
|
||||||
free(path);
|
free(path);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
device++;
|
deviceName++;
|
||||||
|
|
||||||
// replace slashes in the device path
|
// replace slashes in the device path
|
||||||
while (device[0]) {
|
while (deviceName[0]) {
|
||||||
if (device[0] == '/')
|
if (deviceName[0] == '/')
|
||||||
device[0] = '_';
|
deviceName[0] = '_';
|
||||||
|
|
||||||
device++;
|
deviceName++;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
strlcat(path, "/shared", B_PATH_NAME_LENGTH);
|
strlcat(path, "/shared", B_PATH_NAME_LENGTH);
|
||||||
@@ -598,33 +598,33 @@ Volume::InitCheck()
|
|||||||
|
|
||||||
|
|
||||||
/*static*/ void
|
/*static*/ void
|
||||||
Volume::DetermineName(uint32 cddbId, int deviceFD, char* name, size_t length)
|
Volume::DetermineName(uint32 cddbID, int device, char* name, size_t length)
|
||||||
{
|
{
|
||||||
int attrFD = open_attributes(cddbId, deviceFD, O_RDONLY,
|
name[0] = '\0';
|
||||||
|
|
||||||
|
int attrFD = open_attributes(cddbID, device, O_RDONLY,
|
||||||
kDiscIDAttributes);
|
kDiscIDAttributes);
|
||||||
if (attrFD < 0) {
|
if (attrFD < 0) {
|
||||||
// We do not have attributes set. Read CD text.
|
// We do not have attributes set. Read CD text.
|
||||||
cdtext text;
|
cdtext text;
|
||||||
read_cdtext(deviceFD, text);
|
if (read_cdtext(device, text) == B_OK) {
|
||||||
if (text.artist != NULL && text.album != NULL)
|
if (text.artist != NULL && text.album != NULL)
|
||||||
snprintf(name, length, "%s - %s", text.artist, text.album);
|
snprintf(name, length, "%s - %s", text.artist, text.album);
|
||||||
else if (text.artist != NULL || text.album != NULL) {
|
else if (text.artist != NULL || text.album != NULL) {
|
||||||
snprintf(name, length, "%s", text.artist != NULL
|
snprintf(name, length, "%s", text.artist != NULL
|
||||||
? text.artist : text.album);
|
? text.artist : text.album);
|
||||||
} else
|
}
|
||||||
strlcpy(name, "Audio CD", length);
|
}
|
||||||
} else {
|
} else {
|
||||||
// We have an attribute file. Read name from it.
|
// We have an attribute file. Read name from it.
|
||||||
char line[B_FILE_NAME_LENGTH];
|
if (!read_line(attrFD, name, length))
|
||||||
if (!read_line(attrFD, line, B_FILE_NAME_LENGTH)) {
|
name[0] = '\0';
|
||||||
// Could not get name from attribute file. use default name.
|
|
||||||
strlcpy(name, "Audio CD", length);
|
|
||||||
} else {
|
|
||||||
// We got a name. Use it.
|
|
||||||
strlcpy(name, line, length);
|
|
||||||
}
|
|
||||||
close(attrFD);
|
close(attrFD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!name[0])
|
||||||
|
strlcpy(name, "Audio CD", length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -644,7 +644,7 @@ Volume::Mount(const char* device)
|
|||||||
if (status == B_OK && count_audio_tracks(toc) == 0)
|
if (status == B_OK && count_audio_tracks(toc) == 0)
|
||||||
status = B_BAD_TYPE;
|
status = B_BAD_TYPE;
|
||||||
|
|
||||||
if (status < B_OK) {
|
if (status != B_OK) {
|
||||||
free(toc);
|
free(toc);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -655,11 +655,11 @@ Volume::Mount(const char* device)
|
|||||||
fRootNode = _CreateNode(NULL, "", 0, 0, S_IFDIR | 0777);
|
fRootNode = _CreateNode(NULL, "", 0, 0, S_IFDIR | 0777);
|
||||||
if (fRootNode == NULL)
|
if (fRootNode == NULL)
|
||||||
status = B_NO_MEMORY;
|
status = B_NO_MEMORY;
|
||||||
if (status >= B_OK) {
|
if (status == B_OK) {
|
||||||
status = publish_vnode(FSVolume(), fRootNode->ID(), fRootNode,
|
status = publish_vnode(FSVolume(), fRootNode->ID(), fRootNode,
|
||||||
&gCDDAVnodeOps, fRootNode->Type(), 0);
|
&gCDDAVnodeOps, fRootNode->Type(), 0);
|
||||||
}
|
}
|
||||||
if (status < B_OK) {
|
if (status != B_OK) {
|
||||||
free(toc);
|
free(toc);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -671,7 +671,7 @@ Volume::Mount(const char* device)
|
|||||||
// We do not seem to have an attribute file so this is probably the
|
// We do not seem to have an attribute file so this is probably the
|
||||||
// first time this CD is inserted. In this case, try to read CD-Text
|
// first time this CD is inserted. In this case, try to read CD-Text
|
||||||
// data.
|
// data.
|
||||||
if (read_cdtext(fDevice, text) < B_OK)
|
if (read_cdtext(fDevice, text) != B_OK)
|
||||||
dprintf("CDDA: no CD-Text found.\n");
|
dprintf("CDDA: no CD-Text found.\n");
|
||||||
else
|
else
|
||||||
doLookup = false;
|
doLookup = false;
|
||||||
@@ -1385,9 +1385,9 @@ cdda_scan_partition(int fd, partition_data* partition, void* _cookie)
|
|||||||
|
|
||||||
// determine volume title
|
// determine volume title
|
||||||
|
|
||||||
uint32 cddbId = compute_cddb_disc_id(*toc);
|
|
||||||
char name[256];
|
char name[256];
|
||||||
Volume::DetermineName(cddbId, fd, name, sizeof(name));
|
Volume::DetermineName(compute_cddb_disc_id(*toc), fd, name, sizeof(name));
|
||||||
|
|
||||||
partition->content_name = strdup(name);
|
partition->content_name = strdup(name);
|
||||||
if (partition->content_name == NULL)
|
if (partition->content_name == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|||||||
Reference in New Issue
Block a user