K3b::Msf K3b::AudioDataSource::length() const { if( originalLength() == 0 ) return 0; else if( lastSector() < m_startOffset ) return 1; else return lastSector() - m_startOffset + 1; }
static void compute_all_sequences_for_size(struct params *fd, int *offset, int tracksize, int sizecode, int gap, int mask, int tailsize) { int base = *offset; int i; /* no sectors of this size */ if(!nrSectorsForSize(fd, tailsize)) return; fd[*offset] = fd[0]; if(compute_chunks_per_sect(fd + *offset, tracksize, sizecode, &gap, /* gap. expressed in 1/256 bytes */ mask, tailsize) < 0) { /* not enough raw space for this arrangement */ return; } for(i = firstSector(fd, tailsize); i < lastSector(fd, tailsize); i++) { fd[*offset] = fd[base]; compute_sector_sequence(fd+*offset, i, gap); (*offset)++; } }
bool K3bAudioCdTrackSource::initParanoia() { if( !m_initialized ) { if( !m_cdParanoiaLib ) m_cdParanoiaLib = K3bCdparanoiaLib::create(); if( m_cdParanoiaLib ) { m_lastUsedDevice = searchForAudioCD(); // ask here for the cd since searchForAudioCD() may also be called from outside if( !m_lastUsedDevice ) { // could not find the CD, so ask for it QString s = i18n("Please insert Audio CD %1%2") .arg(m_discId, 0, 16) .arg(m_cddbEntry.cdTitle.isEmpty() || m_cddbEntry.cdArtist.isEmpty() ? QString::null : " (" + m_cddbEntry.cdArtist + " - " + m_cddbEntry.cdTitle + ")"); while( K3bDevice::Device* dev = K3bThreadWidget::selectDevice( track()->doc()->view(), s ) ) { if( searchForAudioCD( dev ) ) { m_lastUsedDevice = dev; break; } } } // user canceled if( !m_lastUsedDevice ) return false; k3bcore->blockDevice( m_lastUsedDevice ); if( m_toc.isEmpty() ) m_toc = m_lastUsedDevice->readToc(); if( !m_cdParanoiaLib->initParanoia( m_lastUsedDevice, m_toc ) ) { k3bcore->unblockDevice( m_lastUsedDevice ); return false; } if( doc() ) { m_cdParanoiaLib->setParanoiaMode( doc()->audioRippingParanoiaMode() ); m_cdParanoiaLib->setNeverSkip( !doc()->audioRippingIgnoreReadErrors() ); m_cdParanoiaLib->setMaxRetries( doc()->audioRippingRetries() ); } m_cdParanoiaLib->initReading( m_toc[m_cdTrackNumber-1].firstSector().lba() + startOffset().lba() + m_position.lba(), m_toc[m_cdTrackNumber-1].firstSector().lba() + lastSector().lba() ); // we only block during the initialization because we cannot determine the end of the reading process :( k3bcore->unblockDevice( m_lastUsedDevice ); m_initialized = true; kdDebug() << "(K3bAudioCdTrackSource) initialized." << endl; } } return m_initialized; }
/** Checks if this CopySourceDevice overlaps with the given CopyTarget @param target the CopyTarget to check overlapping with @return true if overlaps */ bool CopySourceDevice::overlaps(const CopyTarget& target) const { try { const CopyTargetDevice& t = dynamic_cast<const CopyTargetDevice&>(target); if (device().deviceNode() != t.device().deviceNode()) return false; // overlapping at the front? if (firstSector() <= t.firstSector() && lastSector() >= t.firstSector()) return true; // overlapping at the back? if (firstSector() <= t.lastSector() && lastSector() >= t.lastSector()) return true; } catch (...) { } return false; }
bool K3bAudioCdTrackSource::seek( const K3b::Msf& msf ) { // HACK: to reinitialize every time we restart the decoding if( msf == 0 && m_cdParanoiaLib ) closeParanoia(); m_position = msf; if( m_cdParanoiaLib ) m_cdParanoiaLib->initReading( m_toc[m_cdTrackNumber-1].firstSector().lba() + startOffset().lba() + m_position.lba(), m_toc[m_cdTrackNumber-1].firstSector().lba() + lastSector().lba() ); return true; }
/** Returns the length of this CopySource @return length of the copy source */ qint64 CopySourceDevice::length() const { return lastSector() - firstSector() + 1; }
static inline int nrSectorsForSize(struct params *fd, int i) { return lastSector(fd, i) - firstSector(fd, i); }
K3b::Msf K3b::Device::Toc::length() const { // +1 since the last sector is included return lastSector() - firstSector() + 1; }