Merge pull request #1321 from gameblabla/libaosound
Add support for libao
This commit is contained in:
commit
11f76f5fbe
|
@ -0,0 +1,49 @@
|
|||
#include "oslib/audiobackend_libao.h"
|
||||
#ifdef USE_LIBAO
|
||||
|
||||
#include <ao/ao.h>
|
||||
|
||||
static ao_device *aodevice;
|
||||
static ao_sample_format aoformat;
|
||||
|
||||
static void libao_init()
|
||||
{
|
||||
ao_initialize();
|
||||
memset(&aoformat, 0, sizeof(aoformat));
|
||||
|
||||
aoformat.bits = 16;
|
||||
aoformat.channels = 2;
|
||||
aoformat.rate = 44100;
|
||||
aoformat.byte_format = AO_FMT_LITTLE;
|
||||
|
||||
aodevice = ao_open_live(ao_default_driver_id(), &aoformat, NULL); // Live output
|
||||
if (!aodevice)
|
||||
aodevice = ao_open_live(ao_driver_id("null"), &aoformat, NULL);
|
||||
}
|
||||
|
||||
static u32 libao_push(void* frame, u32 samples, bool wait)
|
||||
{
|
||||
if (aodevice)
|
||||
ao_play(aodevice, (char*)frame, samples * 4);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void libao_term()
|
||||
{
|
||||
if (aodevice)
|
||||
{
|
||||
ao_close(aodevice);
|
||||
ao_shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
audiobackend_t audiobackend_libao = {
|
||||
"libao", // Slug
|
||||
"libao", // Name
|
||||
&libao_init,
|
||||
&libao_push,
|
||||
&libao_term
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
#include "oslib/audiostream.h"
|
||||
|
||||
extern audiobackend_t audiobackend_libao;
|
|
@ -9,6 +9,7 @@
|
|||
#include "oslib/audiobackend_pulseaudio.h"
|
||||
#include "oslib/audiobackend_coreaudio.h"
|
||||
#include "oslib/audiobackend_omx.h"
|
||||
#include "oslib/audiobackend_libao.h"
|
||||
|
||||
struct SoundFrame { s16 l;s16 r; };
|
||||
#define SAMPLE_COUNT 512
|
||||
|
@ -90,6 +91,9 @@ void RegisterAllAudioBackends() {
|
|||
#if USE_PULSEAUDIO
|
||||
RegisterAudioBackend(&audiobackend_pulseaudio);
|
||||
#endif
|
||||
#if USE_LIBAO
|
||||
RegisterAudioBackend(&audiobackend_libao);
|
||||
#endif
|
||||
#if HOST_OS == OS_DARWIN
|
||||
RegisterAudioBackend(&audiobackend_coreaudio);
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,7 @@ endfunction()
|
|||
option(USE_SDL "Use SDL" OFF)
|
||||
option(USE_OSS "Use OSS" ON)
|
||||
option(USE_ALSA "Use ALSA" ON)
|
||||
option(USE_LIBAO "Use LibAO" OFF)
|
||||
option(USE_GLES "Use GL ES" OFF)
|
||||
option(USE_PULSEAUDIO "Use PulseAudio" OFF)
|
||||
option(USE_WEBUI "Use WebUI" ON)
|
||||
|
@ -151,6 +152,11 @@ if(USE_PULSEAUDIO)
|
|||
list(APPEND libs pulse-simple)
|
||||
endif()
|
||||
|
||||
if(USE_LIBAO)
|
||||
add_definitions(-DUSE_LIBAO)
|
||||
list(APPEND libs ao)
|
||||
endif()
|
||||
|
||||
# Graphic stuffs:
|
||||
|
||||
if(USE_REND)
|
||||
|
|
|
@ -5,6 +5,7 @@ FOR_LINUX :=1
|
|||
WEBUI :=1
|
||||
USE_OSS := 1
|
||||
#USE_PULSEAUDIO := 1
|
||||
#USE_LIBAO := 1
|
||||
USE_EVDEV := 1
|
||||
|
||||
CXX=${CC_PREFIX}g++
|
||||
|
@ -318,6 +319,11 @@ ifdef USE_PULSEAUDIO
|
|||
LIBS += `pkg-config --libs libpulse-simple`
|
||||
endif
|
||||
|
||||
ifdef USE_LIBAO
|
||||
CXXFLAGS += `pkg-config --cflags ao` -D USE_LIBAO
|
||||
LIBS += `pkg-config --libs ao`
|
||||
endif
|
||||
|
||||
ifdef HAS_SOFTREND
|
||||
CFLAGS += -fopenmp -msse4.1
|
||||
LDFLAGS += -fopenmp
|
||||
|
|
Loading…
Reference in New Issue