* The WAV header is now created correctly (mixed up endian of the fourcc members)
* More or less fixed reading - it now works nicely when you copy the file to the hard drive first, but MediaPlayer cannot handle the files directly from CD for some reason yet to investigate. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21153 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5d2e4044c7
commit
8536d82fb6
@ -413,15 +413,15 @@ dump_toc(scsi_toc_toc *toc)
|
||||
|
||||
|
||||
static status_t
|
||||
read_frames(int fd, off_t frame, uint8 *buffer, size_t count)
|
||||
read_frames(int fd, off_t firstFrame, uint8 *buffer, size_t count)
|
||||
{
|
||||
size_t framesLeft = count;
|
||||
|
||||
while (framesLeft > 0) {
|
||||
scsi_read_cd read;
|
||||
read.start_m = frame / kFramesPerMinute;
|
||||
read.start_s = (frame / kFramesPerSecond) % 60;
|
||||
read.start_f = frame % kFramesPerSecond;
|
||||
read.start_m = firstFrame / kFramesPerMinute;
|
||||
read.start_s = (firstFrame / kFramesPerSecond) % 60;
|
||||
read.start_f = firstFrame % kFramesPerSecond;
|
||||
|
||||
read.length_m = count / kFramesPerMinute;
|
||||
read.length_s = (count / kFramesPerSecond) % 60;
|
||||
@ -445,7 +445,7 @@ read_frames(int fd, off_t frame, uint8 *buffer, size_t count)
|
||||
|
||||
buffer += count * kFrameSize;
|
||||
framesLeft -= count;
|
||||
frame += count;
|
||||
firstFrame += count;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
@ -618,7 +618,7 @@ read_cdda_data(int fd, off_t offset, void *data, size_t length,
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
off_t dataOffset = offset - frame * kFrameSize;
|
||||
off_t dataOffset = offset % kFrameSize;
|
||||
size_t bytes = bufferSize - dataOffset;
|
||||
if (bytes > length)
|
||||
bytes = length;
|
||||
@ -626,6 +626,7 @@ read_cdda_data(int fd, off_t offset, void *data, size_t length,
|
||||
if (user_memcpy(data, (uint8 *)buffer + dataOffset, bytes) < B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
data = (void *)((uint8 *)data + bytes);
|
||||
length -= bytes;
|
||||
offset += bytes;
|
||||
}
|
||||
|
@ -317,11 +317,8 @@ Volume::Mount(const char* device)
|
||||
+ next.second * kFramesPerSecond + next.frame
|
||||
- startFrame;
|
||||
|
||||
const char *artist = text.artists[i] != NULL
|
||||
? text.artists[i] : text.artist;
|
||||
|
||||
if (text.titles[i] != NULL) {
|
||||
if (artist != NULL) {
|
||||
if (text.artists[i] != NULL) {
|
||||
snprintf(title, sizeof(title), "%02ld. %s - %s.wav", track,
|
||||
text.artists[i], text.titles[i]);
|
||||
} else {
|
||||
@ -346,7 +343,8 @@ Volume::Mount(const char* device)
|
||||
|
||||
// add attributes
|
||||
|
||||
inode->AddAttribute("Audio:Artist", B_STRING_TYPE, artist);
|
||||
inode->AddAttribute("Audio:Artist", B_STRING_TYPE,
|
||||
text.artists[i] != NULL ? text.artists[i] : text.artist);
|
||||
inode->AddAttribute("Audio:Title", B_STRING_TYPE, text.titles[i]);
|
||||
inode->AddAttribute("Audio:Genre", B_STRING_TYPE, text.genre);
|
||||
inode->AddAttribute("Audio:Track", track);
|
||||
@ -582,13 +580,13 @@ Inode::Inode(Volume *volume, Inode *parent, const char *name, off_t start,
|
||||
// initialize WAV header
|
||||
|
||||
// RIFF header
|
||||
fWAVHeader.header.magic = B_HOST_TO_LENDIAN_INT32('RIFF');
|
||||
fWAVHeader.header.magic = B_HOST_TO_BENDIAN_INT32('RIFF');
|
||||
fWAVHeader.header.length = B_HOST_TO_LENDIAN_INT32(Size()
|
||||
+ sizeof(wav_header) - sizeof(riff_chunk));
|
||||
fWAVHeader.header.id = B_HOST_TO_LENDIAN_INT32('WAVE');
|
||||
fWAVHeader.header.id = B_HOST_TO_BENDIAN_INT32('WAVE');
|
||||
|
||||
// 'fmt ' format chunk
|
||||
fWAVHeader.format.fourcc = B_HOST_TO_LENDIAN_INT32('fmt ');
|
||||
fWAVHeader.format.fourcc = B_HOST_TO_BENDIAN_INT32('fmt ');
|
||||
fWAVHeader.format.length = B_HOST_TO_LENDIAN_INT32(
|
||||
sizeof(wav_format_chunk) - sizeof(riff_chunk));
|
||||
fWAVHeader.format.format_tag = B_HOST_TO_LENDIAN_INT16(1);
|
||||
@ -600,7 +598,7 @@ Inode::Inode(Volume *volume, Inode *parent, const char *name, off_t start,
|
||||
fWAVHeader.format.bits_per_sample = B_HOST_TO_LENDIAN_INT16(16);
|
||||
|
||||
// 'data' chunk
|
||||
fWAVHeader.data.fourcc = B_HOST_TO_LENDIAN_INT32('data');
|
||||
fWAVHeader.data.fourcc = B_HOST_TO_BENDIAN_INT32('data');
|
||||
fWAVHeader.data.length = B_HOST_TO_LENDIAN_INT32(Size());
|
||||
}
|
||||
}
|
||||
@ -1054,8 +1052,6 @@ cdda_read(fs_volume _volume, fs_vnode _node, fs_cookie _cookie, off_t offset,
|
||||
|
||||
if (S_ISDIR(inode->Type()))
|
||||
return B_IS_A_DIRECTORY;
|
||||
if ((cookie->open_mode & O_RWMASK) != O_RDONLY)
|
||||
return B_NOT_ALLOWED;
|
||||
if (offset < 0)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
@ -1088,12 +1084,15 @@ cdda_read(fs_volume _volume, fs_vnode _node, fs_cookie _cookie, off_t offset,
|
||||
if (user_memcpy(buffer, (uint8 *)inode->WAVHeader() + offset, size) < B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
buffer = (void *)((uint8 *)buffer + size);
|
||||
length -= size;
|
||||
}
|
||||
offset = 0;
|
||||
} else
|
||||
offset -= sizeof(wav_header);
|
||||
|
||||
if (length > 0) {
|
||||
// read actual CD data
|
||||
offset -= sizeof(wav_header);
|
||||
offset += inode->StartFrame() * kFrameSize;
|
||||
|
||||
status = read_cdda_data(volume->Device(), offset, buffer, length,
|
||||
cookie->buffer_offset, cookie->buffer, volume->BufferSize());
|
||||
|
Loading…
x
Reference in New Issue
Block a user