AudioAdapterImpl.cpp revision cf019459b310b1984c29946678f59920b11feda9
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "AudioAdapterImpl.h"
#include "MachineImpl.h"
#include "Logging.h"
#include <iprt/cpputils.h>
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
return S_OK;
}
void AudioAdapter::FinalRelease()
{
uninit ();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
/**
* Initializes the audio adapter object.
*
* @param aParent Handle of the parent object.
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan (this);
/* mPeer is left null */
/* Confirm a successful initialization */
return S_OK;
}
/**
* Initializes the audio adapter object given another audio adapter object
* (a kind of copy constructor). This object shares data with
* the object passed as an argument.
*
* @note This object must be destroyed before the original object
* it shares data with is destroyed.
*
* @note Locks @a aThat object for reading.
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan (this);
/* Confirm a successful initialization */
return S_OK;
}
/**
* Initializes the guest object given another guest object
* (a kind of copy constructor). This object makes a private copy of data
* of the original object passed as an argument.
*
* @note Locks @a aThat object for reading.
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan (this);
/* mPeer is left null */
/* Confirm a successful initialization */
return S_OK;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
void AudioAdapter::uninit()
{
LogFlowThisFunc (("\n"));
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan (this);
if (autoUninitSpan.uninitDone())
return;
}
// IAudioAdapter properties
/////////////////////////////////////////////////////////////////////////////
{
if (!aEnabled)
return E_POINTER;
AutoCaller autoCaller (this);
AutoReaderLock alock (this);
return S_OK;
}
{
AutoCaller autoCaller (this);
/* the machine needs to be mutable */
{
}
return S_OK;
}
{
if (!aAudioDriver)
return E_POINTER;
AutoCaller autoCaller (this);
AutoReaderLock alock (this);
return S_OK;
}
{
AutoCaller autoCaller (this);
/* the machine needs to be mutable */
{
/*
* which audio driver type are we supposed to use?
*/
switch (aAudioDriver)
{
#ifdef RT_OS_WINDOWS
# ifdef VBOX_WITH_WINMM
# endif
#endif /* RT_OS_WINDOWS */
#ifdef RT_OS_LINUX
# ifdef VBOX_WITH_ALSA
# endif
# ifdef VBOX_WITH_PULSE
# endif
#endif /* RT_OS_LINUX */
#ifdef RT_OS_DARWIN
#endif
#ifdef RT_OS_OS2
#endif
{
break;
}
default:
{
AssertMsgFailed (("Wrong audio driver type %d\n",
aAudioDriver));
}
}
}
return rc;
}
// IAudioAdapter methods
/////////////////////////////////////////////////////////////////////////////
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
/**
* @note Locks this object for writing.
*/
bool AudioAdapter::rollback()
{
/* sanity */
AutoCaller autoCaller (this);
bool changed = false;
if (mData.isBackedUp())
{
/* we need to check all data to see whether anything will be changed
* after rollback */
}
return changed;
}
/**
* @note Locks this object for writing, together with the peer object (also
* for writing) if there is one.
*/
void AudioAdapter::commit()
{
/* sanity */
AutoCaller autoCaller (this);
/* sanity too */
/* lock both for writing since we modify both */
if (mData.isBackedUp())
{
if (mPeer)
{
/* attach new data to the peer and reshare it */
}
}
}
/**
* @note Locks this object for writing, together with the peer object
* represented by @a aThat (locked for reading).
*/
{
/* sanity */
AutoCaller autoCaller (this);
/* sanity too */
/* peer is not modified, lock it for reading */
/* this will back up current data */
}