///////////////////////////////////////////////////////////////////////////////
/// @file deWAV.hpp
///
/// @brief Destiny Sound System WAV file
///
/// @author paradoxnj
///
/// This file is the intellectual property of Novus Delta, LLC.. Usage of the
/// contents of this file is subject to the Destiny3D Member License which
/// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
///
/// This file is distributed "AS IS" without warranty of any kind.  Novus
/// Delta, LLC. does not guarantee the fitness of the contents of this file
/// for any particular purpose.
///
/// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
///
/// <hr>
///                                 Change History
/// <hr>
///
/// @date Jan 2002
/// @author paradoxnj
/// @remarks Creation
///
///////////////////////////////////////////////////////////////////////////////

#ifndef DEWAV_HPP
#define DEWAV_HPP

#include "deSound_priv.hpp"

class IdeFile;
class IdeFSReal;

#pragma pack(push, 2)
struct RiffHeader
{
	long	Tag;
	long	Size;
};
struct WaveFormatInfo
{
	short							FormatTag;
	short							Channels;
	long							SampleRate;
	long							BytesPerSec;
	short							BlockAlign;
	short							BitsPerSample;
};
#pragma pack(pop)

class deWAV : public deSoundData
{
public:
	deWAV();
	deWAV(const char *filename);
	virtual ~deWAV();

private:
	WaveFormatInfo				m_WaveHeader;
	long						m_DataOffset;
	long						m_DataSize;
	IdeFSReal					*m_pSourceSystem;
	IdeFile						*m_pSource;

	int							m_InterfaceType;
	int							m_RefCount;

public:
	void						*GetRscInterface(long interface_id);

	deBoolean					Initialize(const char *filename);
	void						Destroy();

	void						GetFormat(WAVEFORMATEX *format);
	u32							GetLength() { return m_DataSize; }
	int							GetDataChunk(void *ptr, long size, s32 DataOffset);
	uint8						*GetAllData();

	deBoolean					AtEndOfStream();
	void						SetPosition(long NewPos);

	int							GetType()		{	return m_InterfaceType;		}

	IdeResourceBase				*MakeCopy();
};

#endif
