Skip to content

Commit

Permalink
Add _separateBulkWrites option and disable passing container header a…
Browse files Browse the repository at this point in the history
…nd data in separate bulk writes.

Even though it's standard, this seems to break many new devices, and it was added for Zune.
Set it only if DeviceInfo::Manufacturer is set to "Microsoft".
  • Loading branch information
whoozle committed Dec 12, 2020
1 parent 3a6db91 commit 8f643d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mtp/ptp/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ namespace mtp

Session::Session(usb::BulkPipePtr pipe, u32 sessionId):
_packeter(pipe), _sessionId(sessionId), _nextTransactionId(1), _transaction(),
_getObjectModificationTimeBuggy(false),
_getObjectModificationTimeBuggy(false), _separateBulkWrites(false),
_defaultTimeout(DefaultTimeout)
{
_deviceInfo = GetDeviceInfoImpl();
if (_deviceInfo.Manufacturer == "Microsoft")
_separateBulkWrites = true;

_getPartialObject64Supported = _deviceInfo.Supports(OperationCode::GetPartialObject64);
_getObjectPropertyListSupported = _deviceInfo.Supports(OperationCode::GetObjectPropList);
_editObjectSupported = _deviceInfo.Supports(OperationCode::BeginEditObject) &&
Expand Down Expand Up @@ -126,8 +129,12 @@ namespace mtp
{
DataRequest req(code, transaction.Id);
Container container(req, inputStream);
_packeter.Write(std::make_shared<ByteArrayObjectInputStream>(container.Data), timeout);
_packeter.Write(inputStream, timeout);
if (_separateBulkWrites)
{
_packeter.Write(std::make_shared<ByteArrayObjectInputStream>(container.Data), timeout);
_packeter.Write(inputStream, timeout);
} else
_packeter.Write(std::make_shared<JoinedObjectInputStream>(std::make_shared<ByteArrayObjectInputStream>(container.Data), inputStream), timeout);
}
return Get(transaction.Id, response);
}
Expand Down
1 change: 1 addition & 0 deletions mtp/ptp/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace mtp
bool _editObjectSupported;
bool _getObjectPropertyListSupported;
bool _getObjectModificationTimeBuggy;
bool _separateBulkWrites;
int _defaultTimeout;

public:
Expand Down

0 comments on commit 8f643d2

Please sign in to comment.