
/*	Copyright (C) G. Jespersen
	See Licence.txt.*/

#include "stdafx.h"
#include "DsLavSplit.h"
#include "LavSetup.h"


/////////////////////////////////////////////////////////////
// Lav Setup

CLavSetup::CLavSetup()
{
}
CLavSetup::~CLavSetup()
{
}

void CLavSetup::Read(CArchive & ar, int & version)
{
	m_lavAudioSetup.Read(ar, version);
}
void CLavSetup::Write(CArchive & ar, int & version)
{
	m_lavAudioSetup.Write(ar, version);
}

// Set LAV per user settings.
HRESULT CLavSetup::SetDsLavAudio(ILAVAudioSettings * pAudioSettings)
{
	return m_lavAudioSetup.SetDsLavAudio(pAudioSettings);
}


/////////////////////////////////////////////////////////////
// Lav Audio
CLavAudioSetup::CLavAudioSetup()
{
	// Default per DsLAV.
	//  Note LAV defaults to false for all.
	m_bWMA2 = TRUE;
	m_bWMAPRO = TRUE;
	m_bWMALL = TRUE;
	m_bMixing = TRUE;
}
CLavAudioSetup::~CLavAudioSetup()
{
}

// Set LAV per user settings.
HRESULT CLavAudioSetup::SetDsLavAudio(ILAVAudioSettings * pAudioSettings)
{
	HRESULT hrRet = S_OK;	//0x00000000
	HRESULT hr;

	// Set default audio setting per LAV. Changes are not saved.
	hr = pAudioSettings->SetRuntimeConfig(TRUE); 
	if(FAILED(hr))
		hrRet = hr;

	// Enable WMA codecs per user settings.
	// .WMV and .WMA video/audio files will use if MS codecs unavailable. 
	hr = pAudioSettings->SetFormatConfiguration(Codec_WMA2, m_bWMA2);
	if(FAILED(hr))
		hrRet = hr;
	hr = pAudioSettings->SetFormatConfiguration(Codec_WMAPRO, m_bWMAPRO);
	if(FAILED(hr))
		hrRet = hr;
	hr = pAudioSettings->SetFormatConfiguration(Codec_WMALL, m_bWMALL);
	if(FAILED(hr))
		hrRet = hr;

	// Enable mixing (speaker setup) per user settings.
	hr = pAudioSettings->SetMixingEnabled(m_bMixing);
	if(FAILED(hr))
		hrRet = hr;

	return hrRet;
}

void CLavAudioSetup::Read(CArchive & ar, int & version)
{
	ar >> m_bWMA2;
	ar >> m_bWMAPRO;
	ar >> m_bWMALL;
	ar >> m_bMixing;
}
void CLavAudioSetup::Write(CArchive & ar, int & version)
{
	ar << m_bWMA2;
	ar << m_bWMAPRO;
	ar << m_bWMALL;
	ar << m_bMixing;
}




