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

sfxGetAvailableDevices breaks after console changes #915

Closed
crabmusket opened this Issue Nov 7, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@crabmusket
Contributor

crabmusket commented Nov 7, 2014

After the changes merged in #842, sfxGetAvailableDevices becomes very broken. This is due to the use of Con::getReturnBuffer both to store an intermediate result and when converting types, which happens inside Con::getIntArg.

An easy solution would be to use a StringBuilder or std::string for intermediate results, and then only use Con::getReturnBuffer at the end of the function call. However there may be other instances of this error, and it might be nice to fix the system's reliance on the global mutable Con::mArgBuffer in both these functions.

@Azaezel, @jamesu

@jamesu

This comment has been minimized.

Show comment
Hide comment
@jamesu

jamesu Nov 8, 2014

Contributor

Fixed this. The problem was Con::getIntArg was used to convert an integer to a string when printing out audio devices (which was a pretty bad idea to start off with!). Since this function was changed to directly push values to the console stack, strange things happened.

The console code probably needs to be vetted for cases where the arg buffer is used more than once.

Note that there is actually a very good reason for using the arg buffer for value conversion - it avoids having to allocate memory on the heap which StringBuilder or std::string usually does.

Contributor

jamesu commented Nov 8, 2014

Fixed this. The problem was Con::getIntArg was used to convert an integer to a string when printing out audio devices (which was a pretty bad idea to start off with!). Since this function was changed to directly push values to the console stack, strange things happened.

The console code probably needs to be vetted for cases where the arg buffer is used more than once.

Note that there is actually a very good reason for using the arg buffer for value conversion - it avoids having to allocate memory on the heap which StringBuilder or std::string usually does.

@crabmusket

This comment has been minimized.

Show comment
Hide comment
@crabmusket

crabmusket Nov 8, 2014

Contributor

I guess I was thinking maybe we should have separate arg and return buffers.

Contributor

crabmusket commented Nov 8, 2014

I guess I was thinking maybe we should have separate arg and return buffers.

@crabmusket crabmusket closed this Nov 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment