I got Lazarus installed on Mac Os X 10.6.8 and I'm trying to take a picture using Canon EDSDK.
The problem I'm facing is that after setting parameter to save a photo into host:
saveTo := Integer(EdsSaveTo.kEdsSaveTo_Host);
err := EdsSetPropertyData(camera, kEdsPropID_SaveTo, 0, SizeOf(saveTo) , #saveTo);
and setting capacity of free disk space:
capacity.numberOfFreeClusters := $7FFFFFFF;
capacity.bytesPerSector := $1000;
capacity.reset := 1;
err := EdsSetCapacity(camera, capacity);
I'm taking a picture by:
err := EdsSendCommand(camera, kEdsCameraCommand_TakePicture, 0);
and I'm getting an err code 36103 which if "PC FULL" (also shown on camera LCD).
Any advice about how to set camera capacity on Mac OS X at Pascal?
I got an example on Object C (as XCode project, and above it works as designed):
EdsCapacity capacity = {0x7FFFFFFF, 0x1000, 1};
error = EdsSetCapacity([_model camera], capacity);
But I can't get it to work on Lazarus ;(
Any sugesstions, experience???
Cheers
It seems hex(36103) => '0x8d07', resolves to EDSDK label EDS_ERR_TAKE_PICTURE_CARD_NG. Reported issues around this include the fix that you describe, must be a Lazarus specific issue.
Related
ImageMagick 7 dropped this call, but I can't find any example of how to replicate its functionality in the new version. My aim is to composite two images with a mask. Here's vastly simplified go code for what I was doing in version 6.
func CleanUpImage(originalImage, maskImage *imagick.MagickWand) (*imagick.MagickWand, error) {
err error;
targetImage = imagick.NewMagickWand();
pw = imagick.NewPixelWand();
width = originalImage.GetImageWidth();
height = originalImage.GetImageHeight();
_ = pw.SetColor("white");
_ = targetImage.NewImage(width, height, pw);
_ = targetImage.SetImageClipMask(maskImage);
_ = targetImage.CompositeImage(originalImage, imagick.COMPOSITE_OP_COPY, 0, 0);
return targetImage, err;
}
Can anyone give me guidance about getting this running in version 7?
Thanks!
I'm unfamiliar with the GO bindings, but MagickSetImageClipMask() was replaced with MagickSetImageMask() in ImageMagick-7. The only difference is that users can define the direction (Read/Write) of the mask.
To match ImageMagick-6's ClipMask, you would set the image mask to write.
MagickSetImageMask(image_wand, WritePixelMask, mask_wand);
In Media Player Classic I found a way to jump to a point in a video/audio programmatically, avoiding the Go To... box.
The jump distances are available at Options → Tweaks,
and HKEY_CURRENT_USER\Software\MPC-HC\MPC-HC\Settings
(JumpDistL/JumpDistM/JumpDistS).
What I do is find the jump distances in the address space of Media Player Classic, and set the value of the large jump distance such
that if you applied it to the elapsed time you would get the desired time.
I then send a WM_COMMAND message with parameter 903/904 (all via AutoHotkey. I get the elapsed time by retrieving/parsing the contents of the Edit control.)
Because the jump is relative to the current point, it is imprecise,
and arrives within a second of the right time, but doesn't arrive
at exactly the same point each time.
Is there a more direct way of accomplishing this and if not,
would any Media Player Classic users/programmers
consider discussing on the forum, introducing new WM_COMMAND messages
that allow jump to point (in milliseconds),
or that retrieve the numerical values listed here
(state, position, duration, volumelevel, muted, playbackrate, reloadtime).
(The method found here is too slow to get the time accurately, and requires special options be set).
Thanks to the message from wOxxOm, below the question,
I have been able to create this AutoHotkey script,
which solves my original problem:
to set the elapsed time in Media Player Classic programmatically,
directly, without using the Go To... box.
It also solves the problem of retrieving
information about the video.
The hotkeys are:
- Ctrl+Q to start the MPC API,
- Ctrl+W to retrieve information,
- the number keys to jump partway through the video.
;==================================================
^q:: ;start MPC API
hWnd := A_ScriptHwnd+0
OnMessage(WM_COPYDATA:=74, "On_WM_COPYDATA")
;64-bit
Run, "C:\Program Files (x86)\K-Lite Codec Pack\MPC-HC64\mpc-hc64.exe" /slave %hWnd%
;32-bit
;Run, "C:\Program Files (x86)\K-Lite Codec Pack\MPC-HC\mpc-hc.exe" /slave %hWnd%
Return
;==================================================
^w:: ;display information
Send(vMPCApiHWnd, 0xA0003004, "") ;CMD_GETCURRENTPOSITION := 0xA0003004
vElapsed := 19990101
vDuration := 19990101
vElapsed += vMPCApiCurrent, S
vDuration += vMPCApiDuration, S
if (vMPCApiCurrent >= 3600) OR (vMPCApiDuration >= 3600)
vFormat := "HH:mm:ss"
else
vFormat := "mm:ss"
FormatTime, vElapsed, %vElapsed%, %vFormat%
FormatTime, vDuration, %vDuration%, %vFormat%
SplitPath, vMPCApiPath, vName, vDir, vExt, vNameNoExt, vDrive
vText = ;continuation section
(
title: %vMPCApiTitle%
author: %vMPCApiAuthor%
description: %vMPCApiDesc%
name: %vName%
path: %vMPCApiPath%
elapsed: %vElapsed% (%vMPCApiCurrent%)
duration: %vDuration% (%vMPCApiDuration%)
)
MsgBox %vText%
Return
;==================================================
#IfWinActive, ahk_class MediaPlayerClassicW
0:: ;skip to point
1::
2::
3::
4::
5::
6::
7::
8::
9::
vNum := SubStr(A_ThisHotkey, 1-1)
vElapsed2 := Round(vMPCApiDuration*(vNum/10))
Send(vMPCApiHWnd, 0xA0002000, "" vElapsed2) ;CMD_SETPOSITION := 0xA0002000
Return
#IfWinActive
;==================================================
On_WM_COPYDATA(wParam, lParam, msg, hwnd)
{
global vMPCApiHWnd
global vMPCApiTitle
global vMPCApiAuthor
global vMPCApiDesc
global vMPCApiPath
global vMPCApiDuration
global vMPCApiCurrent
dwData := NumGet(lParam+0, 0)
cbData := NumGet(lParam+A_PtrSize)
lpData := NumGet(lParam + 2*A_PtrSize)
lpData := StrGet(lpData)
if (dwData = 0x50000000) ;CMD_CONNECT := 0x50000000
{
vMPCApiHWnd := lpData
WinGetClass, vWinClass, ahk_id %vMPCApiHWnd%
if (vWinClass = "MediaPlayerClassicW")
MsgBox, , , MPC API on, 3
}
if (dwData = 0x50000003) ;CMD_NOWPLAYING := 0x50000003
{
StringSplit, lpData, lpData, |
vMPCApiTitle := lpData1
vMPCApiAuthor := lpData2
vMPCApiDesc := lpData3
vMPCApiPath := lpData4
vMPCApiDuration := lpData5
}
if (dwData = 0x50000007) ;CMD_CURRENTPOSITION := 0x50000007
vMPCApiCurrent := lpData
Return true
}
;==================================================
Send(Hwnd, dwData, lpData)
{
static WM_COPYDATA := 0x4a
VarSetCapacity(COPYDATASTRUCT, 3*A_PtrSize, 0)
cbData := (StrLen(lpData) + 1) * (A_IsUnicode ? 2 : 1)
NumPut(dwData, COPYDATASTRUCT, 0)
NumPut(cbData, COPYDATASTRUCT, A_PtrSize)
NumPut(&lpData, COPYDATASTRUCT, 2*A_PtrSize)
SendMessage, % WM_COPYDATA, % A_ScriptHwnd , ©DATASTRUCT,, % "ahk_id " Hwnd
return ErrorLevel == "FAIL" ? false : true
}
;==================================================
;USEFUL LINKS
;Sending Strings Via SendMessage - Ask for Help - AutoHotkey Community
;https://autohotkey.com/board/topic/98334-sending-strings-via-sendmessage/
;Media Player Classic - Homecinema MPC remote API (via WM_COPYDATA) - AutoIt Example Scripts - AutoIt Forums
;https://www.autoitscript.com/forum/topic/85354-media-player-classic-homecinema-mpc-remote-api-via-wm_copydata/
;mpcapi.h
;https://raw.githubusercontent.com/jeeb/mpc-be/master/src/apps/mplayerc/mpcapi.h
;winapi - media player classic - jump to point in video/audio programmatically - Stack Overflow
;http://stackoverflow.com/questions/41310778/media-player-classic-jump-to-point-in-video-audio-programmatically
;==================================================
USEFUL LINKS:
Sending Strings Via SendMessage - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/98334-sending-strings-via-sendmessage/
Media Player Classic - Homecinema MPC remote API (via WM_COPYDATA) - AutoIt Example Scripts - AutoIt Forums
https://www.autoitscript.com/forum/topic/85354-media-player-classic-homecinema-mpc-remote-api-via-wm_copydata/
mpcapi.h
https://raw.githubusercontent.com/jeeb/mpc-be/master/src/apps/mplayerc/mpcapi.h
I'm surprised by the behaviour of clCreateCommandQueue() on my macbook pro running OpenCL1.2.
I can supply a CL_QUEUE_PROFILING_ENABLE queue property without a problem.
But if I try to set the CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE property, the queue fails to be created.
I could understand if it were to fail with CL_INVALID_QUEUE_PROPERTIES, according to the API documentation. Yet, it fails with CL_INVALID_VALUE which makes on sense. It claims the property is invalid, instead of just merely being unsupported by device.
This happens on both the Iris GPU device, and the Intel CPU device.
The code:
context = clCreateContext( 0, 1, &device_id, opencl_notify, NULL, &err );
CHECK_CL
if ( !context )
{
LOGE( "Failed to create CL context. err=0x%x", err );
return 0;
}
cl_command_queue_properties queue_properties =
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE |
CL_QUEUE_PROFILING_ENABLE |
0;
commands = clCreateCommandQueue( context, device_id, queue_properties, &err );
CHECK_CL
The output:
Found 1 OpenCL platforms.
Platform FULL_PROFILE OpenCL 1.2 (Sep 20 2014 22:01:02) Apple Apple had 2 devices:
Intel(R) Core(TM) i5-4278U CPU # 2.60GHz Intel(R) Core(TM) i5-4278U CPU # 2.60GHz with [4 units]
Iris Iris with [40 units]
ERR OpenCL called back with error: [CL_INVALID_VALUE] : OpenCL Error : clCreateCommandQueue failed: Device failed to create queue (cld returned: -35).
ERR OpenCL called back with error: [CL_INVALID_VALUE] : OpenCL Error : clCreateCommandQueue failed: Device failed to create queue: -30
CL_INVALID_VALUE
ERR Failed to create a command queue. err=0xffffffe2
I believe clGetDeviceInfo with CL_DEVICE_QUEUE_PROPERTIES on OS
X will return CL_QUEUE_PROFILING_ENABLE, but not CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, so it is apparently not supported.
The confusing error message could be a bug.
Anyone know how to stream audio to multiple AirPlay destinations? Apparently, this was possible through Core Audio at some point in the past, but on 10.9 and 10.10, this does not seem possible. iTunes does it, so what's the secret? Here is some code I tried to see if I could get this to work:
OSStatus err = 0;
UInt32 size = sizeof(UInt32);
SSAudioSource * targetSource = airplayDevice.airplaySources[0];
AudioDeviceID airPlayDeviceID = targetSource.deviceID;
SSAudioSource * source1 = airplayDevice.airplaySources[0];
SSAudioSource * source2 = airplayDevice.airplaySources[1];
SSAudioSource * source3 = airplayDevice.airplaySources[2];
AudioDeviceID alldevices[] = {source3.sourceID, source2.sourceID, source1.sourceID};
AudioObjectPropertyAddress addr;
addr.mSelector = kAudioDevicePropertyDataSource;
addr.mScope = kAudioDevicePropertyScopeOutput;
addr.mElement = kAudioObjectPropertyElementMaster;
// Set the 'AirPlay' device to point to all of its sources...
err = AudioObjectSetPropertyData(airPlayDeviceID, &addr, 0, nil, size, alldevices);
AudioObjectPropertyAddress audioDevicesAddress = {
kAudioHardwarePropertyDefaultOutputDevice,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
// ...now set the system output to point at the 'AirPlay' device
err = AudioObjectSetPropertyData(kAudioObjectSystemObject, &audioDevicesAddress, 0, nil, size, &airPlayDeviceID);
No matter how I arrange the devices in the array, sound only comes out of the first device (index 0) of the array. So what's the secret?
Thanks
I raised a bug report with Apple for this back in July and got a reply in October:
Engineering has determined that there are no plans to address this
issue.
I've gone back to Apple asking why the functionality has been removed but not hopeful for a (timely) response.
For what it's worth I think your approach is correct, it's similar to the way I had it working in the past for an app. I suspect iTunes uses Audio Units or something similar to do multiple speakers.
Is there a programmatic way to find out what architecture another process is running as on Mac OS X 10.5 and later?
Examining the process's image file is not a solution, as the image is likely to contain multiple architectures, and between arch(1) and the “Open in Rosetta” and “Open in 32-bit mode” checkboxes, there's no way to tell from the image alone which architecture is actually running.
Can you use NSRunningApplication on OSes where it is available, and fall back to sysctl stuff when it isn't? I don't think sysctl stuff is supportable API the way most stuff is, but if you're only using it on old OSes you should be okay.
Try this to get the CPU type of the process:
cpu_type_t cpuType
size_t cpuTypeSize;
int mib[CTL_MAXNAME];
size_t mibLen;
mibLen = CTL_MAXNAME;
err = sysctlnametomib("sysctl.proc_cputype", mib, &mibLen);
if (err == -1) {
err = errno;
}
if (err == 0) {
assert(mibLen < CTL_MAXNAME);
mib[mibLen] = pid;
mibLen += 1;
cpuTypeSize = sizeof(cpuType);
err = sysctl(mib, mibLen, &cpuType, &cpuTypeSize, 0, 0);
if (err == -1) {
err = errno;
}
}
And test CPU_ARCH_ABI64 to check for 64-bit.
You don't say what your requirements are, but the NSRunningApplication class introduced in 10.6 offers a really easy interface for this. The docs are currently a little off, but it is there.