mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 862182 - Hold references to MediaResource in nsRefPtrs (content/media/plugins). r=doublec
This commit is contained in:
parent
f7895b7d0b
commit
b5a5314926
@ -273,15 +273,16 @@ bool MediaPluginHost::FindDecoder(const nsACString& aMimeType, const char* const
|
||||
|
||||
MPAPI::Decoder *MediaPluginHost::CreateDecoder(MediaResource *aResource, const nsACString& aMimeType)
|
||||
{
|
||||
const char *chars;
|
||||
size_t len = NS_CStringGetData(aMimeType, &chars, nullptr);
|
||||
NS_ENSURE_TRUE(aResource, nullptr);
|
||||
|
||||
Decoder *decoder = new Decoder();
|
||||
nsAutoPtr<Decoder> decoder(new Decoder());
|
||||
if (!decoder) {
|
||||
return nullptr;
|
||||
}
|
||||
decoder->mResource = aResource;
|
||||
|
||||
const char *chars;
|
||||
size_t len = NS_CStringGetData(aMimeType, &chars, nullptr);
|
||||
for (size_t n = 0; n < mPlugins.Length(); ++n) {
|
||||
Manifest *plugin = mPlugins[n];
|
||||
const char* const *codecs;
|
||||
@ -289,7 +290,8 @@ MPAPI::Decoder *MediaPluginHost::CreateDecoder(MediaResource *aResource, const n
|
||||
continue;
|
||||
}
|
||||
if (plugin->CreateDecoder(&sPluginHost, decoder, chars, len)) {
|
||||
return decoder;
|
||||
aResource->AddRef();
|
||||
return decoder.forget();
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,6 +301,12 @@ MPAPI::Decoder *MediaPluginHost::CreateDecoder(MediaResource *aResource, const n
|
||||
void MediaPluginHost::DestroyDecoder(Decoder *aDecoder)
|
||||
{
|
||||
aDecoder->DestroyDecoder(aDecoder);
|
||||
MediaResource* resource = GetResource(aDecoder);
|
||||
if (resource) {
|
||||
// resource *shouldn't* be null, but check anyway just in case the plugin
|
||||
// decoder does something stupid.
|
||||
resource->Release();
|
||||
}
|
||||
delete aDecoder;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user