Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows works, but crashes on exit ... #45

Open
moebiussurfing opened this issue Aug 25, 2022 · 10 comments
Open

Windows works, but crashes on exit ... #45

moebiussurfing opened this issue Aug 25, 2022 · 10 comments

Comments

@moebiussurfing
Copy link

moebiussurfing commented Aug 25, 2022

Hey @roymacdonald ,
How is going on? Hope all fine there!

I am just trying to start using this add-on and probably integrate also your new ofxSoundDevicesManager aswell,
as I have a similar one.
I am thinking about bundle all this features together.
(I am just doing a sound analyzer app, with smoothing and bang detectors)

ofxSoundObjects It's working fine, on Release but also in Debug mode.
(Just using the PG without props or nothing more.)

Currently I am using ofxSoundObjects experimental branch.
Windows10 / VS 2022 / oF patch-release

image

But when closing the app window it crashes like that:

image

image

Do you think that could be easy to fix?

I think it happens in all the examples, but in this case I made the initialization like that:

	ofSoundStream stream;

	ofxSoundInput input;
	ofxSoundOutput output;

	ofSoundStreamSettings settings;
	std::vector<ofSoundDevice> devices;
//--------------------------------------------------------------
void ofApp::setup() {
	stream.printDeviceList();

	int sampleRate = 48000;
	int bufferSize = 256;
	int numBuffers = 4;

	settings.setApi(ofSoundDevice::Api::MS_DS);
	devices = stream.getDeviceList(ofSoundDevice::Api::MS_DS);
	/*
	[notice ] [MS DirectShow: 0] Default Device [in:2 out:2] (default in) (default out)
	[MS DirectShow: 1] VoiceMeeter Input (VB-Audio VoiceMeeter VAIO) [in:0 out:2]
	[MS DirectShow: 2] Speakers (Realtek(R) Audio) [in:0 out:2]
	[MS DirectShow: 3] 1 - Panasonic-TV (AMD High Definition Audio Device) [in:0 out:2]
	[MS DirectShow: 4] Microphone Array (Xbox NUI Sensor) [in:2 out:0]
	[MS DirectShow: 5] Line (NewTek NDI Audio) [in:2 out:0]
	[MS DirectShow: 6] Microphone (Iriun Webcam) [in:2 out:0]
	[MS DirectShow: 7] VoiceMeeter Output (VB-Audio VoiceMeeter VAIO) [in:2 out:0]
	[MS DirectShow: 8] Microphone (USB Camera-B4.09.24.1) [in:2 out:0]
	*/
	ofLogNotice() << devices;

	settings.sampleRate = sampleRate;
	settings.bufferSize = bufferSize;
	settings.numBuffers = numBuffers;

	settings.numOutputChannels = 2;
	settings.numInputChannels = 2;
	settings.setInListener(this);
	settings.setOutListener(this);

	int deviceIn_Port = 7; // 7 VoiceMeeter Output
	int deviceOut_Port = 3; // 3 Panasonic - TV

	settings.setInDevice(devices[deviceIn_Port]);
	settings.setOutDevice(devices[deviceOut_Port]);

	stream.setup(settings);

	stream.setInput(input);
	stream.setOutput(output);

	//-

	input.connectTo(waveFrom);
	waveFrom.connectTo(vuMeter);
	vuMeter.connectTo(fft);
	fft.connectTo(output);
}

Saludos!

@roymacdonald
Copy link
Owner

Hi!
All good here. Hope you are as well.
funny that we both have an addon with the same name. I did not even searched to see if there was anotherone named the same. I would be glad to merge both. What mine essentially does is to give you a gui to select the different interfaces and their options and save that so the next time you run the app it is able to load the same settings.

As for this error you mention, I have also seen it. It might have to do with threading, maybe the sound stream should be stopped upon exit before the soundObjects get destroyed.
I am actually working on a project now using this addon and I've seen that error, or a very similar one.

I'll keep you posted.

@moebiussurfing
Copy link
Author

Hey, just in case, I tried to close the stream before exit the app, but it crashes in the same way:

	if (key == OF_KEY_BACKSPACE) {
		ofLogNotice() << "Stream Close";
		stream.stop();
		stream.close();
	}

@roymacdonald
Copy link
Owner

Hi. I've been seeing this too on macos. So the objects are supposed to disconnect upon destruction but sometimes the object from which it is trying to disconnect has already been destroyed.
the non-elegant way would be to stop and close the audio stream and then go through each object and disconnect it.

@moebiussurfing
Copy link
Author

yes, that worked:

	if (key == OF_KEY_BACKSPACE) {
		ofLogNotice() << "Stream Close";
		stream.stop();
		stream.close();

		input.disconnect();
		waveFrom.disconnect();
		vuMeter.disconnect();
		fft.disconnect();
		output.disconnect();
	}

@moebiussurfing
Copy link
Author

It works also without closing the stream:

//--------------------------------------------------------------
void ofApp::exit() {
	input.disconnect();
	waveFrom.disconnect();
	vuMeter.disconnect();
	fft.disconnect();
	output.disconnect();
}

@roymacdonald
Copy link
Owner

Hi, thanks. It is supposed that the objects disconnect themselves upon destruction.
I think that is I add a listener of ofExit on each object It can call desconnect and that should work.
I will let you know once I push taht

@moebiussurfing
Copy link
Author

now it's working

void ofApp::exit() {
	//input.disconnect();
	//waveFrom.disconnect();
	//vuMeter.disconnect();
	//fft.disconnect();
	//output.disconnect();
}

@moebiussurfing
Copy link
Author

moebiussurfing commented Dec 16, 2023

Hello, I am back to testing on Windows, and crashes on exit again here:

image

this is with or without selecting any device settled on setup.

@moebiussurfing
Copy link
Author

btw.. also crashes when touching speed

@roymacdonald
Copy link
Owner

Hi. sorry for not replying earlier.
Yes it crashes upon exit if the objects are not properly disconected. The order of creation/thus destruction matters. Can you check again, because I pushed recently and it fixed this crashing issue on some cases. I need to find a way to reliably destroy/disconnect objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants