[PD-dev] changes in atom_getsymbol between pd 0.40-3 and 0.42.4?

B. Bogart ben at ekran.org
Wed Feb 17 01:11:27 CET 2010


Hello all,

I noticed a bug testing my gphoto code. It was written for 40-3 but does 
no longer work in 42.4.

The problem is passing the A_GIMME arguments from a wrapper function to 
a function that runs in a separate thread.

This is done by populating a structure mimicking the A_GIMME args:

typedef struct gphoto_gimme_struct {
	gphoto_struct *gphoto;
	t_symbol *s;
	int argc;
	t_atom *argv;
} gphoto_gimme_struct;


This struct is populated like so in the function that spawns the thread:

static void wrapCaptureImage(gphoto_struct *gphoto, t_symbol *s, int 
argc, t_atom *argv) {
	int ret;
	pthread_t thread1;
	t_symbol *filename;

	if (!gphoto->busy) {

		// instance of structure
		gphoto_gimme_struct *threadArgs = (gphoto_gimme_struct 
*)malloc(sizeof(gphoto_gimme_struct));

		// packaging arguments into structure
		threadArgs->gphoto = gphoto;
		threadArgs->s = s;
		threadArgs->argc = argc;
		threadArgs->argv = argv;

		// We're busy
		gphoto->busy = 1;

		// Create thread
		ret = pthread_create( &thread1, &gphoto->threadAttr, captureImage, 
threadArgs);
	} else {
		error("gphoto: ERROR: Already executing a command, try again later.");
	}
}

When I print out the value of argv in the above function all is well.

In 42.4 the function that runs in the thread sees argv differently than 
the spawning function.

For example:

post("out: argv: %s", atom_getsymbol(argv)->s_name);

In the spawning function properly prints out the argument supplied in PD 
(for example input.jpg)

In the function that runs in the thread the argument is printed as follows:

post("in: argv: %s", atom_getsymbol(((gphoto_gimme_struct 
*)threadArgs)->argv)->s_name);

"Float" is printed to the console, not "input.jpg" as supplied in PD.

In PD <.0.40.3 the proper argument is printed from both the thread and 
in the spawning function.

I'm at a loss here.

How does the symbol "input.jpg" end up turning into "float" in 0.42.4?

Any ideas for solutions?

All the code is in svn/externals/bbogart/gphoto

Thanks,
B. Bogart





More information about the Pd-dev mailing list