diff options
author | Chris Robinson <[email protected]> | 2009-03-13 22:16:01 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-03-13 22:16:01 -0700 |
commit | 89ddd7d8e5a3338467c72dce291d8b5531aa6ae2 (patch) | |
tree | 99a3bfc75abdef418b218f10177026c7ebf0566c | |
parent | 8d0c4ccb3b128348446f67b2e2895e51230d27b5 (diff) |
Don't modify the device struct until playback succesfully starts
-rw-r--r-- | Alc/alsa.c | 9 | ||||
-rw-r--r-- | Alc/oss.c | 7 |
2 files changed, 9 insertions, 7 deletions
@@ -320,6 +320,7 @@ static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceNam snd_pcm_hw_params_t *p = NULL; snd_pcm_access_t access; unsigned int periods; + unsigned int rate; alsa_data *data; char driver[64]; const char *str; @@ -394,6 +395,7 @@ open_alsa: periods = GetConfigValueInt("alsa", "periods", 0); bufferSizeInFrames = device->UpdateSize; + rate = device->Frequency; str = GetConfigValue("alsa", "mmap", "true"); allowmmap = (strcasecmp(str, "true") == 0 || @@ -415,7 +417,7 @@ open_alsa: /* set periods (implicitly constrains period/buffer parameters) */ (!periods || ok(psnd_pcm_hw_params_set_periods_near(data->pcmHandle, p, &periods, NULL), "set periods near")) && /* set rate (implicitly constrains period/buffer parameters) */ - ok(psnd_pcm_hw_params_set_rate_near(data->pcmHandle, p, &device->Frequency, NULL), "set rate near") && + ok(psnd_pcm_hw_params_set_rate_near(data->pcmHandle, p, &rate, NULL), "set rate near") && /* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */ ok(psnd_pcm_hw_params_set_buffer_size_near(data->pcmHandle, p, &bufferSizeInFrames), "set buffer size near") && /* install and prepare hardware configuration */ @@ -449,8 +451,6 @@ open_alsa: psnd_pcm_hw_params_free(p); - device->UpdateSize = bufferSizeInFrames; - data->size = psnd_pcm_frames_to_bytes(data->pcmHandle, device->UpdateSize); if(access == SND_PCM_ACCESS_RW_INTERLEAVED) { @@ -491,6 +491,9 @@ open_alsa: return ALC_FALSE; } + device->UpdateSize = bufferSizeInFrames; + device->Frequency = rate; + return ALC_TRUE; } @@ -221,8 +221,6 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName } #undef ok - device->Frequency = ossSpeed; - if((int)aluChannelsFromFormat(device->Format) != numChannels) { AL_PRINT("Could not set %d channels, got %d instead\n", aluChannelsFromFormat(device->Format), numChannels); @@ -240,8 +238,6 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName return ALC_FALSE; } - device->UpdateSize = info.fragsize / frameSize; - data->data_size = device->UpdateSize * frameSize; data->mix_data = calloc(1, data->data_size); @@ -255,6 +251,9 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName return ALC_FALSE; } + device->Frequency = ossSpeed; + device->UpdateSize = info.fragsize / frameSize; + return ALC_TRUE; } |