1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
|
/*
SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "k3btrack.h"
#include <QSharedData>
class K3b::Device::Track::Private : public QSharedData
{
public:
Private( const K3b::Msf& fs = K3b::Msf(),
const K3b::Msf& ls = K3b::Msf(),
TrackType t = TYPE_UNKNOWN,
DataMode m = UNKNOWN )
: firstSector( fs ),
lastSector( ls ),
type( t ),
mode( m ),
copyPermitted(true),
preEmphasis(false),
session(0) {
}
K3b::Msf firstSector;
K3b::Msf lastSector;
K3b::Msf index0;
K3b::Msf nextWritableAddress;
K3b::Msf freeBlocks;
TrackType type;
DataMode mode;
bool copyPermitted;
bool preEmphasis;
int session;
QList<K3b::Msf> indices;
QByteArray isrc;
};
K3b::Device::Track::Track()
: d( new Private() )
{
}
K3b::Device::Track::Track( const Track& track )
{
d = track.d;
}
K3b::Device::Track::Track( const K3b::Msf& firstSector,
const K3b::Msf& lastSector,
TrackType type,
DataMode mode )
: d( new Private( firstSector,
lastSector,
type,
mode ) )
{
}
K3b::Device::Track::~Track()
{
}
K3b::Device::Track& K3b::Device::Track::operator=( const Track& track )
{
d = track.d;
return *this;
}
K3b::Msf K3b::Device::Track::length() const
{
// +1 since the last sector is included
return d->lastSector - d->firstSector + 1;
}
K3b::Device::Track::TrackType K3b::Device::Track::type() const
{
return d->type;
}
void K3b::Device::Track::setType( TrackType t )
{
d->type = t;
}
K3b::Device::Track::DataMode K3b::Device::Track::mode() const
{
return d->mode;
}
void K3b::Device::Track::setMode( DataMode m )
{
d->mode = m;
}
bool K3b::Device::Track::copyPermitted() const
{
return d->copyPermitted;
}
void K3b::Device::Track::setCopyPermitted( bool b )
{
d->copyPermitted = b;
}
bool K3b::Device::Track::preEmphasis() const
{
return d->preEmphasis;
}
void K3b::Device::Track::setPreEmphasis( bool b )
{
d->preEmphasis = b;
}
bool K3b::Device::Track::recordedIncremental() const
{
return d->preEmphasis;
}
bool K3b::Device::Track::recordedUninterrupted() const
{
return !recordedIncremental();
}
QByteArray K3b::Device::Track::isrc() const
{
return d->isrc;
}
void K3b::Device::Track::setIsrc( const QByteArray& s )
{
d->isrc = s;
}
K3b::Msf K3b::Device::Track::firstSector() const
{
return d->firstSector;
}
K3b::Msf K3b::Device::Track::lastSector() const
{
return d->lastSector;
}
void K3b::Device::Track::setFirstSector( const K3b::Msf& msf )
{
d->firstSector = msf;
}
void K3b::Device::Track::setLastSector( const K3b::Msf& msf )
{
d->lastSector = msf;
}
K3b::Msf K3b::Device::Track::nextWritableAddress() const
{
return d->nextWritableAddress;
}
void K3b::Device::Track::setNextWritableAddress( const K3b::Msf& m )
{
d->nextWritableAddress = m;
}
void K3b::Device::Track::setFreeBlocks( const K3b::Msf& m )
{
d->freeBlocks = m;
}
K3b::Msf K3b::Device::Track::freeBlocks() const
{
return d->freeBlocks;
}
K3b::Msf K3b::Device::Track::realAudioLength() const
{
if( index0() > 0 )
return index0();
else
return length();
}
int K3b::Device::Track::session() const
{
return d->session;
}
void K3b::Device::Track::setSession( int s )
{
d->session = s;
}
K3b::Msf K3b::Device::Track::index0() const
{
return d->index0;
}
QList<K3b::Msf> K3b::Device::Track::indices() const
{
return d->indices;
}
void K3b::Device::Track::setIndices( const QList<K3b::Msf>& il )
{
d->indices = il;
}
void K3b::Device::Track::setIndex0( const K3b::Msf& msf )
{
if( msf <= d->lastSector-d->firstSector )
d->index0 = msf;
}
int K3b::Device::Track::indexCount() const
{
return d->indices.count()-1;
}
bool K3b::Device::Track::operator==( const Track& other ) const
{
return( d->firstSector == other.d->firstSector &&
d->lastSector == other.d->lastSector &&
d->index0 == other.d->index0 &&
d->nextWritableAddress == other.d->nextWritableAddress &&
d->freeBlocks == other.d->freeBlocks &&
d->type == other.d->type &&
d->mode == other.d->mode &&
d->copyPermitted == other.d->copyPermitted &&
d->preEmphasis == other.d->preEmphasis &&
d->session == other.d->session &&
d->indices == other.d->indices &&
d->isrc == other.d->isrc );
}
bool K3b::Device::Track::operator!=( const Track& other ) const
{
return !operator==( other );
}
QDebug operator<<( QDebug s, const K3b::Device::Track& track )
{
s.nospace() << ( track.type() == K3b::Device::Track::TYPE_AUDIO ? " AUDIO" : " DATA" )
<< " " << track.firstSector().lba() << " - " << track.lastSector().lba()
<< " (" << track.length().lba() << ")";
return s;
}
uint qHash( const K3b::Device::Track& key )
{
// this is a dummy implementation to make it compile on windows
return qHash((long)&key);
}
|