avifil32: Only add the first stream reference to the parent.
Signed-off-by: Esme Povirk <esme@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
dfa4c07941
commit
bfa143a203
|
@ -699,7 +699,7 @@ static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream *iface)
|
|||
TRACE("(%p) ref=%d\n", This, ref);
|
||||
|
||||
/* also add ref to parent, so that it doesn't kill us */
|
||||
if (This->paf != NULL)
|
||||
if (This->paf != NULL && ref == 1)
|
||||
IAVIFile_AddRef(&This->paf->IAVIFile_iface);
|
||||
|
||||
return ref;
|
||||
|
@ -712,7 +712,7 @@ static ULONG WINAPI IAVIStream_fnRelease(IAVIStream *iface)
|
|||
|
||||
TRACE("(%p) ref=%d\n", This, ref);
|
||||
|
||||
if (This->paf != NULL)
|
||||
if (This->paf != NULL && ref == 0)
|
||||
IAVIFile_Release(&This->paf->IAVIFile_iface);
|
||||
|
||||
return ref;
|
||||
|
|
|
@ -352,6 +352,12 @@ static void create_avi_file(const COMMON_AVI_HEADERS *cah, char *filename)
|
|||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
static ULONG get_file_refcount(PAVIFILE file)
|
||||
{
|
||||
AVIFileAddRef(file);
|
||||
return AVIFileRelease(file);
|
||||
}
|
||||
|
||||
static void test_default_data(void)
|
||||
{
|
||||
COMMON_AVI_HEADERS cah;
|
||||
|
@ -363,6 +369,7 @@ static void test_default_data(void)
|
|||
PAVISTREAM pStream1;
|
||||
AVISTREAMINFOA asi0, asi1;
|
||||
WAVEFORMATEX wfx;
|
||||
ULONG refcount;
|
||||
|
||||
GetTempPathA(MAX_PATH, filename);
|
||||
strcpy(filename+strlen(filename), testfilename);
|
||||
|
@ -443,9 +450,34 @@ static void test_default_data(void)
|
|||
ok(wfx.nAvgBytesPerSec == 22050, "got %u (expected 22050)\n",wfx.nAvgBytesPerSec);
|
||||
ok(wfx.nBlockAlign == 2, "got %u (expected 2)\n",wfx.nBlockAlign);
|
||||
|
||||
refcount = get_file_refcount(pFile);
|
||||
ok(refcount == 3, "got %u (expected 3)\n", refcount);
|
||||
|
||||
AVIStreamRelease(pStream0);
|
||||
|
||||
refcount = get_file_refcount(pFile);
|
||||
ok(refcount == 2, "got %u (expected 2)\n", refcount);
|
||||
|
||||
AVIStreamAddRef(pStream1);
|
||||
|
||||
refcount = get_file_refcount(pFile);
|
||||
ok(refcount == 2, "got %u (expected 2)\n", refcount);
|
||||
|
||||
AVIStreamRelease(pStream1);
|
||||
AVIFileRelease(pFile);
|
||||
AVIStreamRelease(pStream1);
|
||||
|
||||
refcount = get_file_refcount(pFile);
|
||||
ok(refcount == 1, "got %u (expected 1)\n", refcount);
|
||||
|
||||
refcount = AVIStreamRelease(pStream1);
|
||||
ok(refcount == (ULONG)-1, "got %u (expected 4294967295)\n", refcount);
|
||||
|
||||
refcount = get_file_refcount(pFile);
|
||||
ok(refcount == 1, "got %u (expected 1)\n", refcount);
|
||||
|
||||
refcount = AVIFileRelease(pFile);
|
||||
ok(refcount == 0, "got %u (expected 0)\n", refcount);
|
||||
|
||||
ok(DeleteFileA(filename) !=0, "Deleting file %s failed\n", filename);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue