Mercurial > games > semicongine
changeset 181:6faef9195f3a
fix: linux code use new API
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 03 May 2023 00:41:32 +0700 |
parents | fc85ed0abfcf |
children | 315c809c8e60 |
files | src/semicongine/audio.nim src/semicongine/platform/linux/audio.nim |
diffstat | 2 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/semicongine/audio.nim Tue May 02 10:37:26 2023 -0700 +++ b/src/semicongine/audio.nim Wed May 03 00:41:32 2023 +0700 @@ -183,7 +183,7 @@ proc audioWorker() {.thread.} = when defined(linux): - nice(-20) + discard nice(-20) onThreadDestruction(proc() = mixer[].lock.withLock(mixer[].destroy()); freeShared(mixer)) mixer[].setupDevice() while true:
--- a/src/semicongine/platform/linux/audio.nim Tue May 02 10:37:26 2023 -0700 +++ b/src/semicongine/platform/linux/audio.nim Wed May 03 00:41:32 2023 +0700 @@ -41,9 +41,9 @@ type NativeSoundDevice* = object handle: snd_pcm_p - buffer: ptr SoundData + buffers: seq[ptr SoundData] -proc openSoundDevice*(sampleRate: uint32, buffer: ptr SoundData): NativeSoundDevice = +proc openSoundDevice*(sampleRate: uint32, buffers: seq[ptr SoundData]): NativeSoundDevice = var hw_params: snd_pcm_hw_params_p = nil checkAlsaResult snd_pcm_open(addr result.handle, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_BLOCK) @@ -54,13 +54,13 @@ checkAlsaResult snd_pcm_hw_params_set_format(result.handle, hw_params, SND_PCM_FORMAT_S16_LE) checkAlsaResult snd_pcm_hw_params_set_rate(result.handle, hw_params, sampleRate, 0) checkAlsaResult snd_pcm_hw_params_set_channels(result.handle, hw_params, 2) - checkAlsaResult snd_pcm_hw_params_set_buffer_size(result.handle, hw_params, snd_pcm_uframes_t(buffer[].len)) + checkAlsaResult snd_pcm_hw_params_set_buffer_size(result.handle, hw_params, snd_pcm_uframes_t(buffers[0][].len)) checkAlsaResult snd_pcm_hw_params(result.handle, hw_params) snd_pcm_hw_params_free(hw_params) - result.buffer = buffer + result.buffers = buffers -proc writeSoundData*(soundDevice: NativeSoundDevice) = - var ret = snd_pcm_writei(soundDevice.handle, addr soundDevice.buffer[][0], snd_pcm_uframes_t(soundDevice.buffer[].len)) +proc writeSoundData*(soundDevice: NativeSoundDevice, buffer: int) = + var ret = snd_pcm_writei(soundDevice.handle, addr soundDevice.buffers[buffer][][0], snd_pcm_uframes_t(soundDevice.buffers[buffer][].len)) if ret < 0: checkAlsaResult snd_pcm_recover(soundDevice.handle, cint(ret), 0)