//===========================================================================//
// File:	audiorenderer.hpp                                                //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 03/22/99  SMJ  Initial coding.                                            //
//---------------------------------------------------------------------------//
// Copyright (C) 1999, Microsoft Corporation		                         //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#pragma once

#include "Adept.hpp"

namespace Adept {

	class AudioChannel;
	class AudioCommand;

	//##########################################################################
	//############################    AudioSample    ###########################
	//##########################################################################

	class AudioSample:
		public Stuff::Plug
	{
	public:
		typedef Stuff::Plug BaseClass;

		static void InitializeClass();
		static void TerminateClass();

		static ClassData *DefaultData;

		AudioSample(MemoryStream *stream);
		~AudioSample();
		void Load();

		//
		// Sound buffers and handles
		//
		Resource m_sampleResource;
		gosAudio_ResourceInfo m_sampleInfo;
		gosAudio_ResourceType m_gosType;
		HGOSAUDIO m_gosSample;

		//
		// Sample properties
		//
		bool m_cached;
		bool m_3D;

		//
		// Usage tracking variables
		//
		ChainOf<AudioChannel*> m_activeChannels, m_inactiveChannels;
		ChainOf<AudioCommand*> m_commands;
		int m_timesPlayed, m_referenceCount, m_highestReferenceCount;

		static void BuildSoundPool(NotationFile *hint_file);

		void SetChannelActive(AudioChannel *channel);
		void SetChannelInactive(AudioChannel *channel);
	};

}
