Pointers to Function Members

How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc?

I did not know it is an FAQ, and wasted many hours trying this way and that.

The_C++_Programming_Language,_Fourth_Edition

In the book, the topic appears around here:

pointers

    if (argc == 5) {
        Sound ic7410 {argv[2], argv[3], argv[4]};
    } else if (argc == 8) {
        Sound ic7410 {argv[2], argv[3], argv[4]};
        Sound soft66 {argv[5], argv[6], argv[7]};
    } else {
    	cout << "Usage (IC-7410 only)      : " << argv[0] << " /dev/ttyUSB0 hw:2,0 32000 1 \n";
    	cout << "Usage (IC-7410 and Soft66): " << argv[0] << " /dev/ttyUSB0 hw:2,0 32000 1 hw:0,0 48000 2 \n";
    	return false;
    }

We have two audio devices, ic7410 and soft66, and each requires its callback function.

class Sound {
public:
	Sound(char*, const char*, const char*);
//	void asound_async_callback(snd_async_handler_t * ahandler); /* fix it */
private:
	int  asound_set_hwparams(snd_pcm_t * handle, snd_pcm_hw_params_t * hwparams);
	int  asound_set_swparams(snd_pcm_t * handle, snd_pcm_sw_params_t * swparams);
	snd_pcm_hw_params_t *hwparams;
	snd_pcm_sw_params_t *swparams;
}

Leave a Reply

Your email address will not be published. Required fields are marked *