Archive for June, 2008:
Freakonomics
Freakonomics: A Rogue Economist Explores the Hidden Side of Everything - the book was advertised a number of times by blog buddies, so I wanted to take a look. Torrents offered a scanned 26 megabyte heavy PDF, which is available, but of rather poor quality (low JPEG compression levels used).
A quick search using Google on “staring into a funhouse mirror” brought an OCR’ed copy to the top.
The book looks nice (from the start, I am not even close to the half), maybe just a bit like soap opera.
- The Book
- The Blog
- Freakonomics on Wikipedia
- Amazon Link
- Special Thanks to Skilluminati Research
Ffdshow is getting more annoying
Surprisingly fast I got new problems having ffdshow installed as a part of K-Lite Codec Pack. No wonder though because let us take a look at registration information:
Display Name: @device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\{0F40E1E5-4F79-4988-B1A9-CC98794E6B55}
CLSID: {0F40E1E5-4F79-4988-B1A9-CC98794E6B55}
Friendly Name: ffdshow Audio Decoder
Path: C:\Program Files\K-Lite Codec Pack\ffdshow\ffdshow.ax
Merit: 0×3fffffff
Nice merit, ain’t it? What is merit anyway? Let us check at MSDN:
MERIT_PREFERRED = 0×800000,
MERIT_NORMAL = 0×600000,
…
MERIT_HW_COMPRESSOR = 0×100050
The highest defined value is 0×00800000, while ffdshow is registered with 0×3FFFFFFF, that is on top of everything. No doubt the developers read Guidelines for Registering Filters and decided to get rid of the rest of installed software as unnecessary crap.
Anyway back to the problem: I had an A-law wave file (WAVE_FORMAT_ALAW) to play and make sure its data is valid and quite unexpectedly there was a silence while playing. A quick check confirmed that the sustem has CCITT A-law codec installed, however GraphEdit shown ffdshow Audio Decoder intercepting decoding. Obviously it spoiled the thing!
Finally I decided it was a right time to take an advantage of IAMGraphBuilderCallback interface to detect and reject the bastard.
ATL’s CenterWindow
It appears that ATL does not center window correctly on multi-monitor systems. ATL code checks screen work area coordinates in CWindow::CenterWindow to ensure new position is within visible area, however since SystemParametersInfo/SPI_GETWORKAREA is used target rectangle is always on a primary monitor.
This hotfix works the problem around:
Default Struct Member Alignment surprise with Visual C++.NET 2005
I am compiling C++ project which is using IJG JPEG library using Visual Studio .NET 2005 (yes, 2008 is yet to come) and it came as a surprise that I stumbled upon struct data alignment issue. I am pretty sure this was not a problem with Visual Studio .NET 2003.
The project includes my C++ files and C source from the library. C++ code includes:
extern "C"
{
#undef FAR
#define XMD_H // Otherwise INT32 is redefined
// NOTE: See jmorecfg.h for condition compilation options
#include "cdjpeg.h"
#include "jversion.h"
};
Running this, I receive an error from the library (thanks for pointing this out early anyway!):
JPEG parameter struct mismatch: library thinks size is 360, caller expects 347.
How comes? Project settings are default and set to use default alignment /Zp. It seems as if compiler uses default value of 1 for my C++ code and uses default value of 8 for C code… with a result of break on runtime.
The workaround is in referencing C code with alignment override using #pragma pack:
extern "C"
{
#undef FAR
#define XMD_H // Otherwise INT32 is redefined
//#pragma pack(show)
#pragma pack(push, 8 )
// NOTE: See jmorecfg.h for condition compilation options
#include "cdjpeg.h"
#include "jversion.h"
#pragma pack(pop)
};
Crap around the world: Importing IMAPI2.DLL type library (Part 2)
IMAPI version 2 is well designed - no arguments - file systems, recorders, data streams, notifications, dispatch interfaces to be compatible with scripting, higher level development environments and interoperation layer. Still I am armed with C++ at the very moment and back to type library imports using #import.
I want to know why the hell it is required to sort out mess even between the two API modules: IMAPI2.DLL and IMAPI2FS.dll:
#pragma warning(disable: 4192)
#import “libid:2735412F-7F64-5B0F-8F00-5D77AFBE261E” no_namespace raw_interfaces_only raw_dispinterfaces // IMAPI2
#import “libid:2C941FD0-975B-59BE-A960-9A2A262853A5″ no_namespace raw_interfaces_only raw_dispinterfaces exclude(”_IMAPI_MEDIA_PHYSICAL_TYPE”, “IDiscRecorder2″) // IMAPI2FS
#pragma warning(default: 4192)
In order to import into C++ project, it is required to exclude two items which are duplicate between the modules. OMFG.
Still it is not the end. Since I am subscribing to events using ATL’s IDispEventImpl and SINK_ENTRY_EX, I need DISPID values for the Update methods of DDiscFormat2DataEvents and DFileSystemImageEvents. How do I find them? Type library as usual? No, my dear friend, type library does not mention this useless value… For further reference:
- DFileSystemImageEvents::Update - DISPID is 256
- DDiscFormat2DataEvents::Update - DISPID is 512
Crap around the world: Importing IMAPI2.DLL type library
Trying to import IMAPI2.DLL type library to be able to use IMAPI version 2 in application:
//#pragma warning(disable: 4192)
#import “libid:2735412F-7F64-5B0F-8F00-5D77AFBE261E” no_namespace raw_interfaces_only raw_dispinterfaces // IMAPI2
//#pragma warning(default: 4192)
Compiler output I see:
warning C4192: automatically excluding ‘IConnectionPointContainer’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
warning C4192: automatically excluding ‘IEnumConnectionPoints’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
warning C4192: automatically excluding ‘IConnectionPoint’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
warning C4192: automatically excluding ‘IEnumConnections’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
warning C4192: automatically excluding ‘tagCONNECTDATA’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
warning C4192: automatically excluding ‘IStream’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
warning C4192: automatically excluding ‘ISequentialStream’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
warning C4192: automatically excluding ‘_LARGE_INTEGER’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
warning C4192: automatically excluding ‘_ULARGE_INTEGER’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
warning C4192: automatically excluding ‘tagSTATSTG’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
warning C4192: automatically excluding ‘_FILETIME’ while importing type library ‘2735412F-7F64-5B0F-8F00-5D77AFBE261E’
I was of an opinion that Microsoft people is quite familiar about hiding identifiers from automatic embedding into type library (they are probably using ATL and attributed code) and avoiding duplicating well known identifiers like IConnectionPointContainer.
Subscribe to the comments for this post