Make VoiceEngineImpl inherit from VoiceEngine.

This associates the two types instead of incorrectly reinterpret casting
VoiceEngineImpl* to VoiceEngine* (since these types were previously unrelated).

Please see more details in the bug for how this is currently causing problems
with security tools.

BUG=38612
Review URL: https://webrtc-codereview.appspot.com/1099013

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3520 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tommi@webrtc.org 2013-02-15 15:07:32 +00:00
parent 17238576ba
commit 0989fb7bfa
17 changed files with 19 additions and 19 deletions

View File

@ -86,7 +86,7 @@ public:
protected: protected:
VoiceEngine() {} VoiceEngine() {}
virtual ~VoiceEngine() {} ~VoiceEngine() {}
}; };
// VoEBase // VoEBase

View File

@ -51,7 +51,7 @@ VoEAudioProcessing* VoEAudioProcessing::GetInterface(VoiceEngine* voiceEngine) {
if (NULL == voiceEngine) { if (NULL == voiceEngine) {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -40,7 +40,7 @@ VoEBase* VoEBase::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
} }

View File

@ -30,7 +30,7 @@ VoECallReport* VoECallReport::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -29,7 +29,7 @@ VoECodec* VoECodec::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -29,7 +29,7 @@ VoEDtmf* VoEDtmf::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -28,7 +28,7 @@ VoEEncryption* VoEEncryption::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -29,7 +29,7 @@ VoEExternalMedia* VoEExternalMedia::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -31,7 +31,7 @@ VoEFile* VoEFile::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -30,7 +30,7 @@ VoEHardware* VoEHardware::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -29,7 +29,7 @@ VoENetEqStats* VoENetEqStats::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -28,7 +28,7 @@ VoENetwork* VoENetwork::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -29,7 +29,7 @@ VoERTP_RTCP* VoERTP_RTCP::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -27,7 +27,7 @@ VoEVideoSync* VoEVideoSync::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -29,7 +29,7 @@ VoEVolumeControl* VoEVolumeControl::GetInterface(VoiceEngine* voiceEngine)
{ {
return NULL; return NULL;
} }
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
s->AddRef(); s->AddRef();
return s; return s;
#endif #endif

View File

@ -31,13 +31,12 @@ WEBRTC_DLLEXPORT VoiceEngine* GetVoiceEngine();
VoiceEngine* GetVoiceEngine() VoiceEngine* GetVoiceEngine()
{ {
VoiceEngineImpl* self = new VoiceEngineImpl(); VoiceEngineImpl* self = new VoiceEngineImpl();
VoiceEngine* ve = reinterpret_cast<VoiceEngine*>(self); if (self != NULL)
if (ve != NULL)
{ {
self->AddRef(); // First reference. Released in VoiceEngine::Delete. self->AddRef(); // First reference. Released in VoiceEngine::Delete.
gVoiceEngineInstanceCounter++; gVoiceEngineInstanceCounter++;
} }
return ve; return self;
} }
} // extern "C" } // extern "C"
@ -128,7 +127,7 @@ bool VoiceEngine::Delete(VoiceEngine*& voiceEngine)
if (voiceEngine == NULL) if (voiceEngine == NULL)
return false; return false;
VoiceEngineImpl* s = reinterpret_cast<VoiceEngineImpl*>(voiceEngine); VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
// Release the reference that was added in GetVoiceEngine. // Release the reference that was added in GetVoiceEngine.
int ref = s->Release(); int ref = s->Release();
voiceEngine = NULL; voiceEngine = NULL;

View File

@ -59,6 +59,7 @@ namespace webrtc
{ {
class VoiceEngineImpl : public voe::SharedData, // Must be the first base class class VoiceEngineImpl : public voe::SharedData, // Must be the first base class
public VoiceEngine,
#ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API #ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
public VoEAudioProcessingImpl, public VoEAudioProcessingImpl,
#endif #endif