Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Fix wrong pointer deletion #165

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/DolbyIO.Comms.Native/video_frame_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ namespace dolbyio::comms::native {
class video_frame_handler : public dolbyio::comms::video_frame_handler {
public:
void sink(video_sink* sink) {
// Aliasing constructor
_sink = std::shared_ptr<dolbyio::comms::native::video_sink>(std::shared_ptr<dolbyio::comms::native::video_sink>{}, sink);
_sink = sink;
}

virtual std::shared_ptr<dolbyio::comms::video_sink> sink() {
return _sink;
return std::shared_ptr<dolbyio::comms::video_sink>(_sink, null_deleter{});
}

virtual std::shared_ptr<dolbyio::comms::video_source> source() {
return nullptr;
}

private:
std::shared_ptr<dolbyio::comms::native::video_sink> _sink;
dolbyio::comms::native::video_sink* _sink;
};

} // namespace dolbyio::comms::native
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public VideoFrameHandlerHandle()

protected override bool ReleaseHandle()
{
return Native.DeleteVideoSink(handle);
return Native.DeleteVideoFrameHandler(handle);
}
}
}
20 changes: 20 additions & 0 deletions src/DolbyIO.Comms.Tests/VideoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace DolbyIO.Comms.Tests
{
class MySink : VideoSink
{
override public void OnFrame(VideoFrame f) {}
}

[Collection("Sdk")]
public class VideoTests
{
Expand All @@ -20,5 +25,20 @@ public async void Test_Video_CanCallScreenShareMethods()
await _fixture.Sdk.Video.Local.StartScreenShareAsync(source, null);
await _fixture.Sdk.Video.Local.StopScreenShareAsync();
}

[Fact]
public void Test_Video_canCreateAndDeleteFrameHandler()
{
using (var sink = new MySink())
{
using(var frameHanbdler = new VideoFrameHandler())
{
frameHanbdler.Sink = sink;
}
}

GC.Collect();
GC.WaitForPendingFinalizers();
}
}
}
Loading