int cdfs_cdda_file_read(struct inode * inode, char * buf, size_t count, unsigned start, int raw) { unsigned stop=start+count; int status=0; if (raw) //For audio CD raw=0, CDDA will not enter here unless using -option, let raw=1 { //Audio CD will not enter here status=cdfs_copy_from_cd(inode->i_sb, inode->i_ino, start, stop, buf); } else { //#define WAV_HEADER_SIZE 44 @ all.h //PRINT("david: start=%d, stop=%d\n",start,stop); if (start < WAV_HEADER_SIZE) { if (stop > WAV_HEADER_SIZE) { //Enter here once to make the file header //david: recurrsively calling subroutine!! status=cdfs_cdda_file_read( inode, buf, WAV_HEADER_SIZE-start, start , 0 ); status=cdfs_cdda_file_read( inode, buf+WAV_HEADER_SIZE-start, stop-WAV_HEADER_SIZE, WAV_HEADER_SIZE, 0 ); } else { char temp[44]; cdfs_make_header(temp, inode->i_size); memcpy(buf, temp+start, stop-start); } } else { start -= WAV_HEADER_SIZE; stop -= WAV_HEADER_SIZE; status=cdfs_copy_from_cd(inode->i_sb, inode->i_ino, start, stop, buf); } } return status; }
void cdfs_cdda_file_read(struct inode * inode, char * buf, size_t count, unsigned start, int raw){ unsigned stop=start+count; PRINT("cdda_file_read(%x, %x, %d, %d)\n", inode, buf, count, start); if (raw) { cdfs_copy_from_cd(inode->i_sb, inode->i_ino, start, stop, buf); } else { if (start < WAV_HEADER_SIZE) { if (stop > WAV_HEADER_SIZE) { cdfs_cdda_file_read( inode, buf, WAV_HEADER_SIZE-start, start , 0 ); cdfs_cdda_file_read( inode, buf+WAV_HEADER_SIZE-start, stop-WAV_HEADER_SIZE, WAV_HEADER_SIZE, 0 ); } else { char temp[44]; cdfs_make_header(temp, inode->i_size); memcpy(buf, temp+start, stop-start); } } else { start -= WAV_HEADER_SIZE; stop -= WAV_HEADER_SIZE; cdfs_copy_from_cd(inode->i_sb, inode->i_ino, start, stop, buf); } } }