mirror of
https://github.com/mpv-player/mpv
synced 2025-04-09 19:22:05 +00:00
Set frequency and correct frequency getting
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21565 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
2cfcfc4f22
commit
eb2d97e38a
@ -69,7 +69,8 @@ static int init(int rate, int channels, int format, int flags) {
|
|||||||
};
|
};
|
||||||
ALCdevice *dev = NULL;
|
ALCdevice *dev = NULL;
|
||||||
ALCcontext *ctx = NULL;
|
ALCcontext *ctx = NULL;
|
||||||
ALint bufrate;
|
ALCint freq = 0;
|
||||||
|
ALCint attribs[] = {ALC_FREQUENCY, rate, 0, 0};
|
||||||
int i;
|
int i;
|
||||||
opt_t subopts[] = {
|
opt_t subopts[] = {
|
||||||
{NULL}
|
{NULL}
|
||||||
@ -87,7 +88,7 @@ static int init(int rate, int channels, int format, int flags) {
|
|||||||
mp_msg(MSGT_AO, MSGL_FATAL, "[OpenAL] could not open device\n");
|
mp_msg(MSGT_AO, MSGL_FATAL, "[OpenAL] could not open device\n");
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
ctx = alcCreateContext(dev, NULL);
|
ctx = alcCreateContext(dev, &attribs);
|
||||||
alcMakeContextCurrent(ctx);
|
alcMakeContextCurrent(ctx);
|
||||||
alListenerfv(AL_POSITION, position);
|
alListenerfv(AL_POSITION, position);
|
||||||
alListenerfv(AL_ORIENTATION, direction);
|
alListenerfv(AL_ORIENTATION, direction);
|
||||||
@ -102,8 +103,10 @@ static int init(int rate, int channels, int format, int flags) {
|
|||||||
if (channels == 1)
|
if (channels == 1)
|
||||||
alSource3f(sources[0], AL_POSITION, 0, 0, 1);
|
alSource3f(sources[0], AL_POSITION, 0, 0, 1);
|
||||||
ao_data.channels = channels;
|
ao_data.channels = channels;
|
||||||
alGetBufferi(buffers[0][0], AL_FREQUENCY, &bufrate);
|
alcGetIntegerv(dev, ALC_FREQUENCY, 1, &freq);
|
||||||
ao_data.samplerate = rate = bufrate;
|
if (alcGetError(dev) == ALC_NO_ERROR && freq)
|
||||||
|
rate = freq;
|
||||||
|
ao_data.samplerate = rate;
|
||||||
ao_data.format = AF_FORMAT_S16_NE;
|
ao_data.format = AF_FORMAT_S16_NE;
|
||||||
ao_data.bps = channels * rate * 2;
|
ao_data.bps = channels * rate * 2;
|
||||||
ao_data.buffersize = CHUNK_SIZE * NUM_BUF;
|
ao_data.buffersize = CHUNK_SIZE * NUM_BUF;
|
||||||
|
Loading…
Reference in New Issue
Block a user