evr/allocator: Fix reference counting for returned samples.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2ef767dcee
commit
0066be78ae
|
@ -459,7 +459,6 @@ static void sample_allocator_release_samples(struct sample_allocator *allocator)
|
|||
LIST_FOR_EACH_ENTRY_SAFE(iter, iter2, &allocator->used_samples, struct queued_sample, entry)
|
||||
{
|
||||
list_remove(&iter->entry);
|
||||
IMFSample_Release(iter->sample);
|
||||
heap_free(iter);
|
||||
}
|
||||
}
|
||||
|
@ -676,8 +675,10 @@ static HRESULT WINAPI sample_allocator_AllocateSample(IMFVideoSampleAllocator *i
|
|||
list_add_tail(&allocator->used_samples, head);
|
||||
allocator->free_sample_count--;
|
||||
|
||||
/* Reference counter is not increased when sample is returned, so next release could trigger
|
||||
tracking condition. This is balanced by incremented reference counter when sample is returned
|
||||
back to the free list. */
|
||||
*out = sample;
|
||||
IMFSample_AddRef(*out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -816,6 +817,7 @@ static HRESULT WINAPI sample_allocator_tracking_callback_Invoke(IMFAsyncCallback
|
|||
{
|
||||
list_remove(&iter->entry);
|
||||
list_add_tail(&allocator->free_samples, &iter->entry);
|
||||
IMFSample_AddRef(iter->sample);
|
||||
allocator->free_sample_count++;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1326,13 +1326,13 @@ static void test_MFCreateVideoSampleAllocator(void)
|
|||
IDirect3DSurface9 *surface;
|
||||
IDirect3DDevice9 *device;
|
||||
IMFMediaBuffer *buffer;
|
||||
LONG refcount, count;
|
||||
unsigned int token;
|
||||
IMFGetService *gs;
|
||||
IDirect3D9 *d3d;
|
||||
IUnknown *unk;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
LONG count;
|
||||
BYTE *data;
|
||||
|
||||
hr = MFCreateVideoSampleAllocator(&IID_IUnknown, (void **)&unk);
|
||||
|
@ -1397,7 +1397,7 @@ todo_wine
|
|||
sample = NULL;
|
||||
hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(get_refcount(sample) == 3, "Unexpected refcount %u.\n", get_refcount(sample));
|
||||
refcount = get_refcount(sample);
|
||||
|
||||
hr = IMFVideoSampleAllocator_AllocateSample(allocator, &sample2);
|
||||
ok(hr == MF_E_SAMPLEALLOCATOR_EMPTY, "Unexpected hr %#x.\n", hr);
|
||||
|
@ -1405,8 +1405,7 @@ todo_wine
|
|||
/* Reinitialize with active sample. */
|
||||
hr = IMFVideoSampleAllocator_InitializeSampleAllocator(allocator, 4, video_type);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
todo_wine
|
||||
ok(get_refcount(sample) == 3, "Unexpected refcount %u.\n", get_refcount(sample));
|
||||
ok(refcount == get_refcount(sample), "Unexpected refcount %u.\n", get_refcount(sample));
|
||||
|
||||
hr = IMFVideoSampleAllocatorCallback_GetFreeSampleCount(allocator_cb, &count);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
|
Loading…
Reference in New Issue