Fixed newlines in debug messages. Also, backported various Pro edition fixes that belonged in OS edition.

This commit is contained in:
Thulinma 2015-10-08 13:54:54 +02:00
parent 3c409d4b42
commit c20b8f2081
8 changed files with 57 additions and 25 deletions

View file

@ -764,16 +764,13 @@ void DTSC::File::seekNext() {
myPack.null();
return;
}
fseek(F, currentPositions.begin()->bytePos, SEEK_SET);
seekPos thisPos = *currentPositions.begin();
fseek(F, thisPos.bytePos, SEEK_SET);
if (reachedEOF()) {
myPack.null();
return;
}
clearerr(F);
if (!metadata.merged) {
seek_time(currentPositions.begin()->seekTime + 1, currentPositions.begin()->trackID);
fseek(F, currentPositions.begin()->bytePos, SEEK_SET);
}
currentPositions.erase(currentPositions.begin());
lastreadpos = ftell(F);
if (fread(buffer, 4, 1, F) != 1) {
@ -786,7 +783,7 @@ void DTSC::File::seekNext() {
return;
}
if (memcmp(buffer, DTSC::Magic_Header, 4) == 0) {
seek_time(myPack.getTime() + 1, myPack.getTrackId(), true);
seek_time(myPack.getTime(), myPack.getTrackId(), true);
return seekNext();
}
long long unsigned int version = 0;
@ -864,9 +861,12 @@ void DTSC::File::seekNext() {
}
currentPositions.insert(tmpPos);
} else {
seek_time(myPack.getTime() + 1, myPack.getTrackId(), true);
seek_time(myPack.getTime(), myPack.getTrackId(), true);
}
seek_bpos(tempLoc);
}else{
seek_time(thisPos.seekTime, thisPos.trackID);
fseek(F, thisPos.bytePos, SEEK_SET);
}
}
@ -954,7 +954,7 @@ DTSC::Packet & DTSC::File::getPacket() {
bool DTSC::File::seek_time(unsigned int ms, unsigned int trackNo, bool forceSeek) {
seekPos tmpPos;
tmpPos.trackID = trackNo;
if (!forceSeek && myPack && ms > myPack.getTime() && trackNo >= myPack.getTrackId()) {
if (!forceSeek && myPack && ms >= myPack.getTime() && trackNo >= myPack.getTrackId()) {
tmpPos.seekTime = myPack.getTime();
tmpPos.bytePos = getBytePos();
} else {

View file

@ -108,7 +108,7 @@ namespace DTSC {
operator bool() const;
packType getVersion() const;
void reInit(const char * data_, unsigned int len, bool noCopy = false);
void genericFill(long long packTime, long long packOffset, long long packTrack, char * packData, long long packDataSize, long long packBytePos, bool isKeyframe);
void genericFill(long long packTime, long long packOffset, long long packTrack, const char * packData, long long packDataSize, long long packBytePos, bool isKeyframe);
void getString(const char * identifier, char *& result, unsigned int & len) const;
void getString(const char * identifier, std::string & result) const;
void getInt(const char * identifier, int & result) const;

View file

@ -19,7 +19,10 @@ namespace DTSC {
/// Copy constructor for packets, copies an existing packet with same noCopy flag as original.
Packet::Packet(const Packet & rhs) {
Packet(rhs.data, rhs.dataLen, !rhs.master);
master = false;
bufferLen = 0;
data = NULL;
reInit(rhs.data, rhs.dataLen, !rhs.master);
}
/// Data constructor for packets, either references or copies a packet from raw data.
@ -112,7 +115,7 @@ namespace DTSC {
///\param noCopy Determines whether to make a copy or not
void Packet::reInit(const char * data_, unsigned int len, bool noCopy) {
if (!data_) {
DEBUG_MSG(DLVL_DEVEL, "ReInit received a null pointer with len %d, ignoring", len);
HIGH_MSG("ReInit received a null pointer with len %d, ignoring", len);
null();
return;
}
@ -168,7 +171,8 @@ namespace DTSC {
}
/// Re-initializes this Packet to contain a generic DTSC packet with the given data fields.
void Packet::genericFill(long long packTime, long long packOffset, long long packTrack, char * packData, long long packDataSize, long long packBytePos, bool isKeyframe){
/// When given a NULL pointer, the data is reserved and memset to 0
void Packet::genericFill(long long packTime, long long packOffset, long long packTrack, const char * packData, long long packDataSize, long long packBytePos, bool isKeyframe){
null();
master = true;
//time and trackID are part of the 20-byte header.
@ -177,7 +181,7 @@ namespace DTSC {
//bpos, if >= 0, adds 9 bytes (integer type) and 6 bytes (2+namelen)
//keyframe, if true, adds 9 bytes (integer type) and 10 bytes (2+namelen)
//data adds packDataSize+5 bytes (string type) and 6 bytes (2+namelen)
unsigned int sendLen = 24 + (packOffset?17:0) + (packBytePos>=0?15:0) + (isKeyframe?19:0) + packDataSize+11;
unsigned int sendLen = 24 + (packOffset?17:0) + (packBytePos?15:0) + (isKeyframe?19:0) + packDataSize+11;
resize(sendLen);
//set internal variables
version = DTSC_V2;
@ -217,7 +221,11 @@ namespace DTSC {
memcpy(data+offset, "\000\004data\002", 7);
tmpLong = htonl(packDataSize);
memcpy(data+offset+7, (char *)&tmpLong, 4);
memcpy(data+offset+11, packData, packDataSize);
if (packData){
memcpy(data+offset+11, packData, packDataSize);
}else{
memset(data+offset+11, 0, packDataSize);
}
//finish container with 0x0000EE
memcpy(data+offset+11+packDataSize, "\000\000\356", 3);
}
@ -1133,7 +1141,7 @@ namespace DTSC {
unsigned int Track::timeToKeynum(unsigned int timestamp){
unsigned int result = 0;
for (std::deque<Key>::iterator it = keys.begin(); it != keys.end(); it++){
if (it->getTime() >= timestamp){
if (it->getTime() > timestamp){
break;
}
result = it->getNumber();