I suppose the code I posted at the start isn't much help. I've changed the code somewhat so the c++ main() does all the work, and passes the object pointers to the c code.
here's the main:
Code:
int main(int argc, char* argv[])
{
TToiVideoMixerCaller* videoMixer;
......
......
videoMixer = new TToiVideoMixerCaller(&ipcClient, videoMixerAddress);
videoMixer->SetFullVideoWindow();
video_driver_class kvd;
//set the videoMixer of the new object
kvd.set_video_mixer(videoMixer);
//call the init method
kvd.init_video_driver_obj();
//pass the pointer to the c function
set_kvd_pointer(&kvd);
//call the c code
the_main (argc, argv);
}
So the main creates a videoMixer object as well as a video_driver_class. It then passes a pointer of the videoMixer to the video_driver_class.
Here's the c++ file:
Code:
class video_driver_class
{
TToiVideoMixerCaller* videoMixer;
public:
virtual void init_video_driver_obj();
virtual int get_colour_key();
virtual void set_video_mixer(TToiVideoMixerCaller *pVmx);
video_driver_class();
video_driver_class(const video_driver_class&);
private:
protected:
};
void video_driver_class::set_video_mixer(TToiVideoMixerCaller *pVmx)
{
videoMixer = pVmx;
}
int video_driver_class::get_colour_key()
{
fprintf(stderr, "entered get_colour_key\n");
int colourKey;
videoMixer->GetColorKey(colourKey);
return colourKey;
fprintf(stderr, "leaving get_colour_key\n");
}
void video_driver_class::init_video_driver_obj()
{
videoMixer->SetFullVideoWindow();
int colourKey;
videoMixer->GetColorKey(colourKey);
fprintf(stderr,"videoMixer colourKey = %d\n",colourKey);
fprintf(stderr, "leaving init_kreatel_video_driver_obj()\n");
}
extern "C"
{
int get_colourkey_kvd_video_window(video_driver_class* kvd)
{
return kvd->get_colour_key();
}
}
And here's the c file:
Code:
#include "video_driver_obj_mapping.h"
/* create a pointer that will actually be a pointer to the c++ object */
struct video_driver_class* pVideoStruct;
void set_kvd_pointer(video_driver_class* kvd)
{
pVideoStruct = kvd;
}
BOOLEAN
driver_PlatformPorts_device_video_init ()
{
fprintf(stderr, "video window colour key = %d\n" + get_colourkey_kvd_video_window(pVideoStruct));
}
return TRUE;
}
So, when the main() calls: kvd.init_video_driver_obj(), I see the colourkey. But then, when the c function calls: get_colourkey_kvd_video_window(pVideoStruct) The application dies.
I'd appreciate any and all help. Thanks!