Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PTPObjectInfo related improvements #1039

Merged
merged 11 commits into from
Oct 10, 2024
Merged

Conversation

axxel
Copy link
Contributor

@axxel axxel commented Oct 10, 2024

Details see commit messages. Please note the two TODOs mentioned in the first commit.

axxel added 10 commits October 10, 2024 12:31
The (Object) Handle member is not part of the "ObjectInfo dataset" in the
specification but added here to avoid having to carry it around by
separate means throughout the code base, as it is regularly required in
combination. While the spec always refers to this item as "ObjectHandle",
the term "Handle" is only used in this context, so we omit the
"Object"-prefix for brevity.

Switching from oid/ObjectID, which is nowere to be found the spec,
increases consistency with the spec and the rest of the code base.

This allows to remove the struct _PTPCanon_New_Object from the codebase.

@msmeissn I added 2 TODO comments for you take a close look, pointing out:
 * a memory leak that I did not want to touch because I can't test it
 * a presumed bug fix where newobject was 0 when passed to ptp_getobject
See last commit for reasoning of choosing this terminology.

TLDR: consistency spec / other API
This should better be fixed once and for all by replacing the heap
allocated `char* Filename` with a statically sized buffer. If only I
knew the 'correct' size for that.

See also here: petabyt/camlib@20fb75a#r147761481
This adds a set of macros implementing a generic array or list of TYPE.
This is basically a TYPE* pointer and a length integer. This structure
together with the typical use-cases repeats regularly throughout the
codebase. It raises the level of abstraction and improves code
readabilty. I'm a c++ developer and miss my STL ;).

I'm starting here with PTPObjectHandles and PTPStorageIDs as those were
already modeling an array abstraction. There are other arrays of stuff
that can benefit from this later.
Looks like they changed the build image...
 * apparently reallocarray() is not supported
 * the compiler seems to have an issue with a goto label position
@Sija
Copy link
Contributor

Sija commented Oct 10, 2024

macOS CI is failing 🔴

@axxel
Copy link
Contributor Author

axxel commented Oct 10, 2024

macOS CI is failing 🔴

Thanks, I was aware... ;)

@@ -440,14 +439,17 @@ camera_prepare_canon_eos_capture(Camera *camera, GPContext *context) {
ptp_free_deviceinfo (&params->deviceinfo);
C_PTP (ptp_getdeviceinfo(params, &params->deviceinfo));
CR (fixup_cached_deviceinfo (camera, &params->deviceinfo));

/* TODO: the following block of code seems to have no effect, remove? */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can comment it out.
it mirrors what the Canon EOS is doing, but its likely not going to break anything to disable it.

return GP_ERROR;
GP_LOG_D ("object has OFC 0x%x", oi.ObjectFormat);

if (oi.StorageID) /* all done above */
if (oi.StorageID) /* all done above (TODO: the meaning of this comment / code is unclear) */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik with StoageID set we have "to card" capture and can now exit.
the code below is the "to SDRAM" capture and synthesizes a virtual filename.

@@ -6956,6 +6940,8 @@ camera_wait_for_event (Camera *camera, int timeout,
free (ob->oi.Filename);
C_MEM (ob->oi.Filename = strdup (path->name));
strcpy (path->folder,"/");
/* TODO: @msmeissn the following goto will leak the `path` memory and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this came from commit 46adf5b refactoring. I need to check and rewrite this a bit.

@msmeissn msmeissn merged commit e6af170 into gphoto:master Oct 10, 2024
5 checks passed
@axxel axxel deleted the ptp-objectinfo branch October 10, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants