microsoft / microsoft/FFmpegInterop
Exception thrown after calling FFmpegInteropMSS.Dispose()
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 319
- PR merge metrics
- No merged PRs in 30d
Description
I'm streaming files in my C# player project, here is related code:
private FFmpegInteropMSS ffmpeg;
private void setMediaStreamSource(string url)
{
mediaElement.Stop();
ffmpeg?.Dispose();
ffmpeg = FFmpegInteropMSS.CreateFFmpegInteropMSSFromUri(url, false, false);
mediaElement.SetMediaStreamSource(ffmpeg.GetMediaStreamSource());
}
But after calling ffmpeg?.Dispose();, sometimes an exception is thrown, here is the exception info:
0xC0000008 occurred
Message: Exception thrown at 0x25DC764A in Player.exe: 0xC0000008: An invalid handle was specified.
> avformat-57.dll!tcp_read(URLContext* h, unsigned char* buf, int size) Line 199 C
avformat-57.dll!retry_transfer_wrapper(URLContext* h, unsigned char* buf, int size, int size_min, int (URLContext*, unsigned char*, int) * transfer_func) Line 326 C
avformat-57.dll!ffurl_read(URLContext* h, unsigned char* buf, int size) Line 357 C
avformat-57.dll!http_buf_read(URLContext* h, unsigned char* buf, int size) Line 1161 C
avformat-57.dll!http_read_stream(URLContext* h, unsigned char* buf, int size) Line 1251 C
avformat-57.dll!http_read(URLContext* h, unsigned char* buf, int size) Line 1362 C
avformat-57.dll!retry_transfer_wrapper(URLContext* h, unsigned char* buf, int size, int size_min, int (URLContext*, unsigned char*, int) * transfer_func) Line 326 C
avformat-57.dll!ffurl_read(URLContext* h, unsigned char* buf, int size) Line 357 C
avformat-57.dll!fill_buffer(AVIOContext* s) Line 480 C
avformat-57.dll!avio_r8(AVIOContext* s) Line 532 C
avformat-57.dll!flv_read_packet(AVFormatContext* s, AVPacket* pkt) Line 805 C
avformat-57.dll!ff_read_packet(AVFormatContext* s, AVPacket* pkt) Line 672 C
avformat-57.dll!read_frame_internal(AVFormatContext* s, AVPacket* pkt) Line 1322 C
avformat-57.dll!av_read_frame(AVFormatContext* s, AVPacket* pkt) Line 1480 C
FFmpegInterop.dll!FFmpegInterop::FFmpegReader::ReadPacket() Line 45 C++
FFmpegInterop.dll!FFmpegInterop::MediaSampleProvider::GetNextSample() Line 79 C++
FFmpegInterop.dll!FFmpegInterop::FFmpegInteropMSS::OnSampleRequested(Windows::Media::Core::MediaStreamSource ^ sender, Windows::Media::Core::MediaStreamSourceSampleRequestedEventArgs ^ args) Line 469 C++
Maybe a race condition has happened?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing FFmpegInterop::FFmpegReader::ReadPacket(), MediaSampleProvider::GetNextSample(), and FFmpegInteropMSS::OnSampleRequested() while reproducing repeated media-source changes and disposal. Check whether a sample request can overlap ffmpeg?.Dispose(); done means the sequence no longer produces the invalid-handle exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100