Default device frequency changes between calls.
Troy Watson <[email protected]> Wed, 9 Jan 2013 11:02:39 +1000
| Newsgroups | gmane.comp.lib.openal |
|---|---|
| Message-ID | <CAFGK7-Hy7gbDkzRMAiAbkfJeHeM4McG9gyQ00+Du5a4sMYqcdw@mail.gmail.com> |
--===============0096073719==
Content-Type: multipart/alternative; boundary=14dae93995476ea8a504d2d09e74
--14dae93995476ea8a504d2d09e74
Content-Type: text/plain; charset=ISO-8859-1
I've noticed when using the default install of OpenAL Soft 1.4 on Kubuntu
GNU/Linux 12.10 that the device frequency is sometimes 44100Hz and other
times 48000Hz.
Here's a simple example to open al AL device and print the frequency it
uses:
#include <AL/al.h>
#include <AL/alc.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
/* Create device and context using defaults. */
ALCdevice* device = alcOpenDevice( NULL );
ALCcontext* context = alcCreateContext( device, NULL );
alcMakeContextCurrent( context );
/* Get the size of the attributes array. */
ALCint attributes_size;
alcGetIntegerv( device, ALC_ATTRIBUTES_SIZE, 1, &attributes_size );
/* Get the attributes. */
ALCint* attributes = (ALCint*) malloc( attributes_size * sizeof( ALCint ) );
alcGetIntegerv( device, ALC_ALL_ATTRIBUTES, attributes_size, &attributes[
0 ] );
/* Find and print the frequency attribute. */
for ( ALCint i = 0; i < attributes_size; i += 2 )
{
if ( attributes[ i ] == ALC_FREQUENCY )
{
printf( "Frequency: %dHz\n", attributes[ i + 1 ] );
}
}
/* Release resources. */
free( attributes );
alcMakeContextCurrent( NULL );
alcDestroyContext( context );
alcCloseDevice( device );
}
I can run this several times and the frequency changes between 44100Hz an
48000Hz. I may get 44100Hz a dozen times in a row, then it switches to
48000Hz for several runs and then back again.
Is this normal behaviour? What could be causing it?
--14dae93995476ea8a504d2d09e74
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I've noticed when using the default install of OpenAL =
Soft 1.4 on Kubuntu GNU/Linux 12.10 that the device frequency is sometimes =
44100Hz and other times 48000Hz.<div><br></div><div>Here's a simple exa=
mple to open al AL device and print the frequency it uses:<br>
</div>
<div><br></div><div><div>#include <AL/al.h></div><div>#include <AL=
/alc.h></div><div>#include <stdio.h><br></div><div>#include <st=
dlib.h></div><div><br></div><div>int main()</div><div>{</div><div><span =
style=3D"white-space:pre-wrap"> </span>/* Create device and context using d=
efaults. */</div>
<div><span style=3D"white-space:pre-wrap"> </span>ALCdevice* device =3D alc=
OpenDevice( NULL );</div><div><span style=3D"white-space:pre-wrap"> </span>=
ALCcontext* context =3D alcCreateContext( device, NULL );</div><div><span s=
tyle=3D"white-space:pre-wrap"> </span>alcMakeContextCurrent( context );</di=
v>
<div><br></div><div><span style=3D"white-space:pre-wrap"> </span>/* Get the=
size of the attributes array. */</div><div><span style=3D"white-space:pre-=
wrap"> </span>ALCint attributes_size;</div><div><span style=3D"white-space:=
pre-wrap"> </span>alcGetIntegerv( device, ALC_ATTRIBUTES_SIZE, 1, &attr=
ibutes_size );</div>
<div><br></div><div><span style=3D"white-space:pre-wrap"> </span>/* Get the=
attributes. */</div><div><span style=3D"white-space:pre-wrap"> </span>ALCi=
nt* attributes =3D (ALCint*) malloc( attributes_size * sizeof( ALCint ) );<=
/div>
<div><span style=3D"white-space:pre-wrap"> </span>alcGetIntegerv( device, A=
LC_ALL_ATTRIBUTES, attributes_size, &attributes[ 0 ] );</div><div><br><=
/div><div><span style=3D"white-space:pre-wrap"> </span>/* Find and print th=
e frequency attribute. */</div>
<div><span style=3D"white-space:pre-wrap"> </span>for ( ALCint i =3D 0; i &=
lt; attributes_size; i +=3D 2 )</div><div><span style=3D"white-space:pre-wr=
ap"> </span>{</div><div><span style=3D"white-space:pre-wrap"> </span>if ( =
attributes[ i ] =3D=3D ALC_FREQUENCY )</div>
<div><span style=3D"white-space:pre-wrap"> </span>{</div><div><span style=
=3D"white-space:pre-wrap"> </span>printf( "Frequency: %dHz\n", =
attributes[ i + 1 ] );</div><div><span style=3D"white-space:pre-wrap"> </s=
pan>}</div>
<div><span style=3D"white-space:pre-wrap"> </span>}</div><div><br></div><di=
v><span style=3D"white-space:pre-wrap"> </span>/* Release resources. */</di=
v><div><span style=3D"white-space:pre-wrap"> </span>free( attributes );</di=
v>
<div><span style=3D"white-space:pre-wrap"> </span>alcMakeContextCurrent( NU=
LL );</div><div><span style=3D"white-space:pre-wrap"> </span>alcDestroyCont=
ext( context );</div><div><span style=3D"white-space:pre-wrap"> </span>alcC=
loseDevice( device );</div>
<div>}</div></div><div><br></div><div>I can run this several times and the =
frequency changes between 44100Hz an 48000Hz. I may get 44100Hz a dozen tim=
es in a row, then it switches to 48000Hz for several runs and then back aga=
in.</div>
<div><br></div><div>Is this normal behaviour? What could be causing it?</di=
v></div>
--14dae93995476ea8a504d2d09e74--
--===============0096073719==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Openal mailing list
[email protected]
http://opensource.creative.com/mailman/listinfo/openal
--===============0096073719==--