[Openal] Serious problem with switching AL contexts
rejcl77A-gmail
rejcl77a at gmail.com
Wed Jun 6 23:15:20 PDT 2007
Hi, guys,
I have a serious problem with switching AL contexts. I cannot switch between
two X-Fi sound cards. May I anyhow change the AL context of the first device
(hardware device 1) to the AL context of the other device (hardware device
2) without errors? When I made it I gave an exception (so I couldn't create
buffer neither source). Can U help me? It is very importatnt to me. Thank U
in advance.
Paul,
The Sound Developer.
I enclosed some demo code to clarify my problem:
----------------------------------------------------------------------------
---------
.
..
...
....
pDefaultDevice = alcOpenDevice("[SB X-Fi Audio [1000]"); // X-fi device 1
ok
pContext = alcCreateContext(pDefaultDevice, NULL);
ok
pInterComDevice = alcOpenDevice("[SB X-Fi Audio [1020]"); // X-fi device 2
ok
pInterComContext = alcCreateContext(pInterComDevice, NULL);
ok
bool bb1 = alcMakeContextCurrent(pContext);
ok -> bb1 == true
if(alcGetError(pDefaultDevice) != ALC_NO_ERROR)
ok
return ALC_FALSE;
alGenBuffers(1, &Buffer);
ok
if(alGetError() != AL_NO_ERROR)
ok
return AL_FALSE;
alutLoadWAVFile("wavdata\\FancyPants.wav", &format, &data, &size, &freq,
&loop);
alBufferData(Buffer, format, data, size, freq);
alutUnloadWAV(format, data, size, freq);
ok
if(alGetError() != AL_NO_ERROR)
ok
return AL_FALSE;
alGenSources(1, &Source);
ok
if(alGetError() != AL_NO_ERROR)
ok
return AL_FALSE;
alSourcei (Source, AL_BUFFER, Buffer );
alSourcef (Source, AL_PITCH, 1.0 );
alSourcef (Source, AL_GAIN, 1.0 );
alSourcefv(Source, AL_POSITION, SourcePos);
alSourcefv(Source, AL_VELOCITY, SourceVel);
alSourcei (Source, AL_LOOPING, true );
ok
if(alGetError() != AL_NO_ERROR)
ok
return AL_FALSE;
bool bb2 = alcMakeContextCurrent(pInterComContext);
ok
alGenBuffers(1, &Buffer2);
!!! bb2 told me no error but there is an Exception !!!
if(alGetError() != AL_NO_ERROR)
return AL_FALSE;
alutLoadWAVFile("wavdata\\FancyPants2.wav", &format2, &data2, &size2,
&freq2, &loop2);
alBufferData(Buffer2, format2, data2, size2, freq2);
alutUnloadWAV(format2, data2, size2, freq2);
if(alGetError() != AL_NO_ERROR)
return AL_FALSE;
alGenSources(1, &Source2);
!!! Exception raising as well !!!
if(alGetError() != AL_NO_ERROR)
return AL_FALSE;
alSourcei (Source2, AL_BUFFER, Buffer2 );
alSourcef (Source2, AL_PITCH, 1.0 );
alSourcef (Source2, AL_GAIN, 1.0 );
alSourcefv(Source2, AL_POSITION, SourcePos);
alSourcefv(Source2, AL_VELOCITY, SourceVel);
alSourcei (Source2, AL_LOOPING, false );
if(alGetError() != AL_NO_ERROR)
return AL_FALSE;
....
...
..
.
----------------------------------------------------------------------------
---------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://opensource.creative.com/pipermail/openal/attachments/20070607/2447f076/attachment-0001.html
More information about the Openal
mailing list