#include "xaudiopacketaligned.h"

XAudioPacketAligned::XAudioPacketAligned()
    : XAsset()
    , mBuffer()
    , mBufferSize(0)
    , mLoopCount(0)
    , aXmaLoop()
    , mContext()
{
    
}

XAudioPacketAligned::~XAudioPacketAligned()
{
    
}

void XAudioPacketAligned::ParseData(QDataStream *aStream)
{
    qint32 bufferPtr, contextPtr;

    *aStream
        >> bufferPtr
        >> mBufferSize
        >> mLoopCount;

    for (int i = 0; i < 6; i++)
    {
        XAudioXmaLoopRegion loop;
        loop.ParseData(aStream);
    }

    *aStream >> contextPtr;

    if (bufferPtr)
    {
        aStream->readRawData(mBuffer.data(), mBufferSize);
    }
    if (contextPtr)
    {
        *aStream >> mContext;
    }
}

void XAudioPacketAligned::Clear()
{
    mBuffer.clear();
    mBufferSize = 0;
    mLoopCount = 0;
    aXmaLoop.clear();
    mContext = '\0';
}
