1 | /* $Id: AudioAdapterImpl.h 8155 2008-04-18 15:16:47Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | *
|
---|
19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
20 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
21 | * additional information or have any questions.
|
---|
22 | */
|
---|
23 |
|
---|
24 | #ifndef ____H_AUDIOADAPTER
|
---|
25 | #define ____H_AUDIOADAPTER
|
---|
26 |
|
---|
27 | #include "VirtualBoxBase.h"
|
---|
28 |
|
---|
29 | class Machine;
|
---|
30 |
|
---|
31 | class ATL_NO_VTABLE AudioAdapter :
|
---|
32 | public VirtualBoxBaseNEXT,
|
---|
33 | public VirtualBoxSupportErrorInfoImpl <AudioAdapter, IAudioAdapter>,
|
---|
34 | public VirtualBoxSupportTranslation <AudioAdapter>,
|
---|
35 | public IAudioAdapter
|
---|
36 | {
|
---|
37 | public:
|
---|
38 |
|
---|
39 | struct Data
|
---|
40 | {
|
---|
41 | Data() {
|
---|
42 | mEnabled = false;
|
---|
43 | mAudioDriver = AudioDriverType_Null;
|
---|
44 | mAudioController = AudioControllerType_AC97;
|
---|
45 | }
|
---|
46 |
|
---|
47 | bool operator== (const Data &that) const
|
---|
48 | {
|
---|
49 | return this == &that ||
|
---|
50 | (mEnabled == that.mEnabled &&
|
---|
51 | mAudioDriver == that.mAudioDriver &&
|
---|
52 | mAudioController == that.mAudioController);
|
---|
53 | }
|
---|
54 |
|
---|
55 | BOOL mEnabled;
|
---|
56 | AudioDriverType_T mAudioDriver;
|
---|
57 | AudioControllerType_T mAudioController;
|
---|
58 | };
|
---|
59 |
|
---|
60 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (AudioAdapter)
|
---|
61 |
|
---|
62 | DECLARE_NOT_AGGREGATABLE(AudioAdapter)
|
---|
63 |
|
---|
64 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
65 |
|
---|
66 | BEGIN_COM_MAP(AudioAdapter)
|
---|
67 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
68 | COM_INTERFACE_ENTRY(IAudioAdapter)
|
---|
69 | END_COM_MAP()
|
---|
70 |
|
---|
71 | NS_DECL_ISUPPORTS
|
---|
72 |
|
---|
73 | DECLARE_EMPTY_CTOR_DTOR (AudioAdapter)
|
---|
74 |
|
---|
75 | HRESULT FinalConstruct();
|
---|
76 | void FinalRelease();
|
---|
77 |
|
---|
78 | // public initializer/uninitializer for internal purposes only
|
---|
79 | HRESULT init (Machine *aParent);
|
---|
80 | HRESULT init (Machine *aParent, AudioAdapter *aThat);
|
---|
81 | HRESULT initCopy (Machine *aParent, AudioAdapter *aThat);
|
---|
82 | void uninit();
|
---|
83 |
|
---|
84 | STDMETHOD(COMGETTER(Enabled))(BOOL *aEnabled);
|
---|
85 | STDMETHOD(COMSETTER(Enabled))(BOOL aEnabled);
|
---|
86 | STDMETHOD(COMGETTER(AudioDriver)) (AudioDriverType_T *aAudioDriverType);
|
---|
87 | STDMETHOD(COMSETTER(AudioDriver)) (AudioDriverType_T aAudioDriverType);
|
---|
88 | STDMETHOD(COMGETTER(AudioController)) (AudioControllerType_T *aAudioControllerType);
|
---|
89 | STDMETHOD(COMSETTER(AudioController)) (AudioControllerType_T aAudioControllerType);
|
---|
90 |
|
---|
91 | // public methods only for internal purposes
|
---|
92 |
|
---|
93 | HRESULT loadSettings (const settings::Key &aMachineNode);
|
---|
94 | HRESULT saveSettings (settings::Key &aMachineNode);
|
---|
95 |
|
---|
96 | bool isModified() { AutoWriteLock alock (this); return mData.isBackedUp(); }
|
---|
97 | bool isReallyModified() { AutoWriteLock alock (this); return mData.hasActualChanges(); }
|
---|
98 | bool rollback();
|
---|
99 | void commit();
|
---|
100 | void copyFrom (AudioAdapter *aThat);
|
---|
101 |
|
---|
102 | // public methods for internal purposes only
|
---|
103 | // (ensure there is a caller and a read lock before calling them!)
|
---|
104 |
|
---|
105 | const Backupable <Data> &data() const { return mData; }
|
---|
106 |
|
---|
107 | // for VirtualBoxSupportErrorInfoImpl
|
---|
108 | static const wchar_t *getComponentName() { return L"AudioAdapter"; }
|
---|
109 |
|
---|
110 | private:
|
---|
111 |
|
---|
112 | const ComObjPtr <Machine, ComWeakRef> mParent;
|
---|
113 | const ComObjPtr <AudioAdapter> mPeer;
|
---|
114 |
|
---|
115 | Backupable <Data> mData;
|
---|
116 | };
|
---|
117 |
|
---|
118 | #endif // ____H_AUDIOADAPTER
|
---|