WPD MTP data stream hanging on Release

Posted by Jonathan Potter on Stack Overflow See other posts from Stack Overflow or by Jonathan Potter
Published on 2012-11-21T22:58:21Z Indexed on 2012/11/21 22:59 UTC
Read the original article Hit count: 861

Filed under:
|
|
|

I've come across a weird problem when reading data from a MTP-compatible mobile device using the WPD (Windows Portable Devices) API, under Windows 8 (not tried any other Windows versions yet).

The symptom is, when calling Release on an IStream interface obtained via the IPortableDeviceResources::GetStream function, occasionally the Release call will hang and not return until the device is disconnected from the PC.

After some experimentation I've discovered that this never happens as long as the entire contents of the stream have been read. But if the stream has only been partially read (say, the first 256Kb of the file), it can happen seemingly at random (although quite frequently).

This has been reproduced with an iPhone and a Windows Phone 8 mobile, so it does not seem to be device-specific.

Has anyone come across this sort of issue before? And more importantly, does anyone know of a way to solve it other than by always reading the entire contents of the stream?

Thanks!

© Stack Overflow or respective owner

Related posts about winapi

Related posts about com