diff options
author | gameblabla | 2019-10-05 03:04:57 +0200 |
---|---|---|
committer | gameblabla | 2019-10-05 03:04:57 +0200 |
commit | d4753076e89d42cdad4a4f1ca4688fad3c56d873 (patch) | |
tree | c8641cf282f427d9329db00325e16609acca8663 /shell/audio/oss | |
parent | 943821f94b9b2e22315fce876c2e369da7a79bcf (diff) | |
download | snesemu-d4753076e89d42cdad4a4f1ca4688fad3c56d873.tar.gz snesemu-d4753076e89d42cdad4a4f1ca4688fad3c56d873.tar.bz2 snesemu-d4753076e89d42cdad4a4f1ca4688fad3c56d873.zip |
Port the libretro core and make it standalone.
TODO :
- Input should use our config file instead.
- Missing audio in some games. (Star Ocean, doesn't happen with stock retroarch code. Odd...)
Diffstat (limited to 'shell/audio/oss')
-rw-r--r-- | shell/audio/oss/sound_output.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/shell/audio/oss/sound_output.c b/shell/audio/oss/sound_output.c new file mode 100644 index 0000000..2d32b1f --- /dev/null +++ b/shell/audio/oss/sound_output.c @@ -0,0 +1,59 @@ +#include <stdio.h> +#include <sys/ioctl.h> +#include <stdint.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/soundcard.h> + +#include "sound_output.h" + +static int32_t oss_audio_fd = -1; + +uint32_t Audio_Init() +{ + uint32_t channels = 2; + uint32_t format = AFMT_S16_LE; + uint32_t tmp = SOUND_OUTPUT_FREQUENCY; + int32_t err_ret; + + oss_audio_fd = open("/dev/dsp", O_WRONLY | O_NONBLOCK); + if (oss_audio_fd < 0) + { + printf("Couldn't open /dev/dsp.\n"); + return 1; + } + + err_ret = ioctl(oss_audio_fd, SNDCTL_DSP_SPEED,&tmp); + if (err_ret == -1) + { + printf("Could not set sound frequency\n"); + return 1; + } + err_ret = ioctl(oss_audio_fd, SNDCTL_DSP_CHANNELS, &channels); + if (err_ret == -1) + { + printf("Could not set channels\n"); + return 1; + } + err_ret = ioctl(oss_audio_fd, SNDCTL_DSP_SETFMT, &format); + if (err_ret == -1) + { + printf("Could not set sound format\n"); + return 1; + } + return 0; +} + +void Audio_Write(int16_t* restrict buffer, uint32_t buffer_size) +{ + write(oss_audio_fd, buffer, buffer_size * 4 ); +} + +void Audio_Close() +{ + if (oss_audio_fd >= 0) + { + close(oss_audio_fd); + oss_audio_fd = -1; + } +} |