View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002680 | FSSCP | sound | public | 2012-07-05 02:03 | 2012-07-06 01:47 |
Reporter | iss_mneur | Assigned To | iss_mneur | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | assigned | Resolution | open | ||
Platform | Homebrew PC | OS | Microsoft Windows | OS Version | 7 x64 Ultimate |
Product Version | 3.6.14 RC6 | ||||
Summary | 0002680: FSO does not correctly detect a sound card that does not support MIN_SOURCES | ||||
Description | FSO does not correctly detect a sound card that does not support MIN_SOURCES (currently 48 sources). Attached is a patch to fix it in a different way than Niffiwan proposes in Mantis 2266. | ||||
Steps To Reproduce | Using OpenALSoft set the channels to 47 in alsoftrc (see http://repo.or.cz/w/openal-soft.git/blob_plain/HEAD:/alsoftrc.sample) and notice that FSO does not fail the sound card. Note you will have to look in the debug log because the "Generic Software" devices on windows are not affected by the settings in alsoftrc. | ||||
Additional Information | Was noticed by Niffiwan in mantis 2266. | ||||
Tags | No tags attached. | ||||
|
openal_sources_checking.patch (2,189 bytes)
Index: code/sound/ds.cpp =================================================================== --- code/sound/ds.cpp (revision 8846) +++ code/sound/ds.cpp (working copy) @@ -1408,39 +1408,56 @@ } if ( (first_free_channel >= 0) && (Channels[first_free_channel].source_id == 0) ) { - OpenAL_ErrorCheck( alGenSources(1, &Channels[first_free_channel].source_id), return -1 ); + alGenSources(1, &Channels[first_free_channel].source_id); + ALenum i = alGetError(); + if (i == AL_OUT_OF_MEMORY) { + nprintf(("Warning", + "SOUND: Ran out of sources too soon. " + "Capping MAX_CHANNELS to %d (was %d)\n", + first_free_channel, MAX_CHANNELS)); + MAX_CHANNELS = first_free_channel; + first_free_channel = -1; + } else if (i != AL_NO_ERROR) { + const char *error_text = (const char*)alGetString(i); + nprintf(("Warning", "SOUND: %s:%d - OpenAL error = '%s'\n", + __FILE__, __LINE__, error_text)); + first_free_channel = -1; + } } return first_free_channel; } Index: code/sound/openal.cpp =================================================================== --- code/sound/openal.cpp (revision 8846) +++ code/sound/openal.cpp (working copy) @@ -195,21 +195,28 @@ alcGetError(device); // check how many sources we can create - static const int MIN_SOURCES = 48; // MAX_CHANNELS + 16 spare + // With 24 or more sources, FSO sounds okay in a sound heavy + // environment + static const int MIN_SOURCES = 24; int si = 0; - for (si = 0; si < MIN_SOURCES; si++) { - ALuint source_id = 0; - alGenSources(1, &source_id); + for (si = 1; si <= MIN_SOURCES; si++) { + ALuint source_id[MIN_SOURCES] = {0}; + alGenSources(si, source_id); - if (alGetError() != AL_NO_ERROR) { + const char *error_text = openal_error_string(0); + if (error_text != NULL) { + mprintf(("OpenAL device '%s' failed to create %d sources with message '%s'\n", + pdev->device_name.c_str(), + si, + error_text)); break; } - alDeleteSources(1, &source_id); + alDeleteSources(si, source_id); } - if (si == MIN_SOURCES) { + if (si > MIN_SOURCES) { // ok, it supports our minimum requirements pdev->usable = true; |
|
My justification for the different implementation in Mantis 2266: "I don't know how many hardware sound cards we would find that can actually do 48 voices so I think just disabling the sound if we don't have 48 is not really a valid solution espcially when FSO is actually able to dynamically use a smaller or larger number of max channels." |
|
I like the approach, however it doesn't seem to work properly so far. ALsoft 1.13 doesn't seem to generate the same error codes as 1.14 (sigh). When testing with sources=25 in .alsoftrc I get lots of this in the fs2_open.log: SOUND: sound/ds.cpp:1441 - OpenAL error = 'Invalid Value' When testing with ALSoft 1.14, it seems to cap MAX_CHANNELS too early. i.e. I get this in the log: SOUND: Ran out of sources too soon. Capping MAX_CHANNELS to 12 (was 32) This is with sources=25 in .alsoftrc so I thought it should cap at 25. In two other tests, it capped once at 11, and once at 12. Could it be possible that they are sounds which are started without respecting MAX_CHANNELS? Would that be the original reason for setting MIN_SOURCES to 32+16? FYI, if I set the default sources=256 then no errors are logged (as would be expected). I wasn't sure which branch the patch is based on (r8846 was antipodes?), and I couldn't get it to apply cleanly to 3.6.14, antipodes or trunk (kept complaining about line 28 being invalid?) so I applied this by hand to trunk, r8983. Lastly, with dynamic channel detection in place, would it be worthwhile either removing the initial setting of MAX_CHANNELS, or setting it to something very high, so that those people running ALSoft could make use of all those extra channels? :) (ps - how can you find out how many channels a sound card supports? I had a bit of a google and couldn't find the info for the Xi-Fi - which is just the 1st card I picked to look for) |
|
I have no doubt that there is stuff using sources that don't use the channels array (which is where the capping is coming from). I know for sure that the built in but disabled multiplayer player-to-player voice stuff just calls alGenSources directly. Also, as far as I know, the music system also bypasses ds.cpp. That is probably the reason that min sources is 32+16. The patch was against the 3.6.14 branch with the patch from 2266 applied, sorry about that. I have no idea. I also tried googling and it doesn't seem to be something that they (Creative at least) give away freely, I would have thought it would be listed on the spec sheets. You may have more luck googling for the number of "voices" that the card can do, which is how I found that a Creative Card (some X-Fi) does 128 in software, but there was no information about what the hardware could actually do. |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-07-05 02:03 | iss_mneur | New Issue | |
2012-07-05 02:03 | iss_mneur | Status | new => assigned |
2012-07-05 02:03 | iss_mneur | Assigned To | => iss_mneur |
2012-07-05 02:03 | iss_mneur | File Added: openal_sources_checking.patch | |
2012-07-05 02:09 | iss_mneur | Relationship added | related to 0002266 |
2012-07-05 02:10 | iss_mneur | Note Added: 0013826 | |
2012-07-05 12:57 | niffiwan | Note Added: 0013831 | |
2012-07-06 01:47 | iss_mneur | Note Added: 0013835 |