Alsa asynchronous callback

alsacallback

I was using asynchronous callback for capturing sound signals from IC-7410 and from Soft66LC4. It was working fine before, but with some unknown reasons, my program became less and less stable in the process of my improvement, namely the refinement of the program structure and some additional fancy features.

Is Alsa asynchronous callback not compatible with gtkmm especially with its own callback functions? Not likely, I supoose.

Anyway, I decided to modify the program not to use Alsa callbacks, and it works fine now.

void asound_async_callback0_wrapper(snd_async_handler_t * ahandler) {
//	mysound[0]->asound_async_callback(ahandler);
}

void asound_async_callback1_wrapper(snd_async_handler_t * ahandler) {
//	mysound[1]->asound_async_callback(ahandler);
}
bool Waterfall::on_draw(const Cairo::RefPtr<Cairo::Context> &cr) {
	bool ready[2] = {false, false};
	for(int irep=0;irep<2;irep++) {
		ready[irep] = mysound[irep]->asound_myread();
	}
bool Sound::asound_myread() {
	avail = snd_pcm_avail_update(handle);
	if (avail == -EPIPE) {    /* under-run */
		int err = snd_pcm_recover(handle, -EPIPE, 0);
		return false;
	}

	int loop_count = 0;
	while (avail >= (snd_pcm_sframes_t) period_size) {
		frames_actually_read = snd_pcm_readi(handle, samples, period_size);
		if (frames_actually_read < 0) {
			exit(EXIT_FAILURE);
		}
		if (frames_actually_read != (int) period_size) {
			exit(EXIT_FAILURE);
		}
		for (int i = 0; i < (int) (period_size * channels); i++) {
			audio_signal[i] = samples[i];
		}
		avail = snd_pcm_avail_update(handle);
		cout << myid << "in the while loop, avail = " << avail << endl;
	}
	if(loop_count > 0) {
		return true;
	} else {
		return false;
	}
}