Sija / gphoto2.cr

Crystal shard wrapping libgphoto2
https://sija.github.io/gphoto2.cr/
MIT License
16 stars 3 forks source link

Calling Camera#file fails for queued calls #12

Open Sija opened 8 years ago

Sija commented 8 years ago

It happens when (there's no SD card inside? and) we try to use CameraFile which might be unavailable at the time.

Below test code:

queue = [] of CameraFile
# ...
queue.each &.save

Results in:

Unspecified error (GPhoto2::Error)
[4491010242] *CallStack::unwind:Array(Pointer(Void)) +82
[4491010145] *CallStack#initialize:Array(Pointer(Void)) +17
[4491010104] *CallStack::new:CallStack +40
[4490990009] *raise<GPhoto2::Error>:NoReturn +25
[4491164503] *GPhoto2::check!<Int32>:Int32 +919
[4491237226] *GPhoto2::Camera@GPhoto2::Camera::Filesystem#file_get<GPhoto2::CameraFile, LibGPhoto2::CameraFileType>:GPhoto2::CameraFile +250
[4491236967] *GPhoto2::Camera@GPhoto2::Camera::Filesystem#file_get<GPhoto2::CameraFile>:GPhoto2::CameraFile +39
[4491236921] *GPhoto2::Camera@GPhoto2::Camera::Filesystem#file<GPhoto2::CameraFile>:GPhoto2::CameraFile +9
[4491425206] *GPhoto2::CameraFile#data_and_size:Tuple(Pointer(UInt8), UInt64) +134
[4491425040] *GPhoto2::CameraFile#data:Pointer(UInt8) +32
[4491424949] *GPhoto2::CameraFile#to_slice:Slice(UInt8) +21
[4491424546] *GPhoto2::CameraFile#save:Nil +130
[4490921895] __crystal_main +2583
[4490974088] main +40
Sija commented 8 years ago

One way would be to call #data_and_size in CameraFile#initialize to load the data if @camera[:capturetarget]? == "Internal RAM" but it just feels hackish — for instance what about values from different cameras...?

Sija commented 7 years ago

See https://github.com/gphoto/libgphoto2/blob/230e2554f8541df8c324ee889b75a6ce848aacf9/examples/sample-trigger-capture.c#L57

Sija commented 7 years ago

See https://github.com/gphoto/libgphoto2/commit/14041e1af9814cc081ee10658030a1d86dac9e2a