mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
Fix OSS build for BSD.
This commit is contained in:
parent
753d2057bb
commit
75d1155a23
4
Makefile
4
Makefile
@ -46,6 +46,10 @@ endif
|
|||||||
ifeq ($(HAVE_OSS), 1)
|
ifeq ($(HAVE_OSS), 1)
|
||||||
OBJ += audio/oss.o
|
OBJ += audio/oss.o
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(HAVE_OSS_BSD), 1)
|
||||||
|
OBJ += audio/oss.o
|
||||||
|
LIBS += -lossaudio
|
||||||
|
endif
|
||||||
ifeq ($(HAVE_ALSA), 1)
|
ifeq ($(HAVE_ALSA), 1)
|
||||||
OBJ += audio/alsa.o
|
OBJ += audio/alsa.o
|
||||||
LIBS += -lasound
|
LIBS += -lasound
|
||||||
|
42
audio/oss.c
42
audio/oss.c
@ -15,28 +15,43 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_OSS_BSD
|
||||||
|
#include <soundcard.h>
|
||||||
|
#else
|
||||||
#include <sys/soundcard.h>
|
#include <sys/soundcard.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_OSS_BSD
|
||||||
|
#define DEFAULT_OSS_DEV "/dev/audio"
|
||||||
|
#else
|
||||||
|
#define DEFAULT_OSS_DEV "/dev/dsp"
|
||||||
|
#endif
|
||||||
|
|
||||||
static void* __oss_init(const char* device, unsigned rate, unsigned latency)
|
static void* __oss_init(const char* device, unsigned rate, unsigned latency)
|
||||||
{
|
{
|
||||||
int *fd = calloc(1, sizeof(int));
|
int *fd = calloc(1, sizeof(int));
|
||||||
if ( fd == NULL )
|
if (fd == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const char *oss_device = "/dev/dsp";
|
const char *oss_device = DEFAULT_OSS_DEV;
|
||||||
|
|
||||||
if ( device != NULL )
|
if (device != NULL)
|
||||||
oss_device = device;
|
oss_device = device;
|
||||||
|
|
||||||
if ( (*fd = open(oss_device, O_WRONLY)) < 0 )
|
if ((*fd = open(oss_device, O_WRONLY)) < 0)
|
||||||
{
|
{
|
||||||
free(fd);
|
free(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -45,7 +60,7 @@ static void* __oss_init(const char* device, unsigned rate, unsigned latency)
|
|||||||
int frags = (latency * rate * 4)/(1000 * (1 << 9));
|
int frags = (latency * rate * 4)/(1000 * (1 << 9));
|
||||||
int frag = (frags << 16) | 9;
|
int frag = (frags << 16) | 9;
|
||||||
|
|
||||||
if ( ioctl(*fd, SNDCTL_DSP_SETFRAGMENT, &frag) < 0 )
|
if (ioctl(*fd, SNDCTL_DSP_SETFRAGMENT, &frag) < 0)
|
||||||
{
|
{
|
||||||
close(*fd);
|
close(*fd);
|
||||||
free(fd);
|
free(fd);
|
||||||
@ -55,21 +70,21 @@ static void* __oss_init(const char* device, unsigned rate, unsigned latency)
|
|||||||
int channels = 2;
|
int channels = 2;
|
||||||
int format = AFMT_S16_LE;
|
int format = AFMT_S16_LE;
|
||||||
|
|
||||||
if ( ioctl(*fd, SNDCTL_DSP_CHANNELS, &channels) < 0 )
|
if (ioctl(*fd, SNDCTL_DSP_CHANNELS, &channels) < 0)
|
||||||
{
|
{
|
||||||
close(*fd);
|
close(*fd);
|
||||||
free(fd);
|
free(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ioctl(*fd, SNDCTL_DSP_SETFMT, &format) < 0 )
|
if (ioctl(*fd, SNDCTL_DSP_SETFMT, &format) < 0)
|
||||||
{
|
{
|
||||||
close(*fd);
|
close(*fd);
|
||||||
free(fd);
|
free(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ioctl(*fd, SNDCTL_DSP_SPEED, &rate) < 0 )
|
if (ioctl(*fd, SNDCTL_DSP_SPEED, &rate) < 0)
|
||||||
{
|
{
|
||||||
close(*fd);
|
close(*fd);
|
||||||
free(fd);
|
free(fd);
|
||||||
@ -83,13 +98,13 @@ static ssize_t __oss_write(void* data, const void* buf, size_t size)
|
|||||||
{
|
{
|
||||||
int *fd = data;
|
int *fd = data;
|
||||||
|
|
||||||
if ( size == 0 )
|
if (size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
if ( (ret = write(*fd, buf, size)) <= 0 )
|
if ((ret = write(*fd, buf, size)) <= 0)
|
||||||
{
|
{
|
||||||
if ( (fcntl(*fd, F_GETFL) & O_NONBLOCK) && errno == EAGAIN )
|
if ((fcntl(*fd, F_GETFL) & O_NONBLOCK) && errno == EAGAIN)
|
||||||
return 0;
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -139,9 +154,4 @@ const audio_driver_t audio_oss = {
|
|||||||
.free = __oss_free,
|
.free = __oss_free,
|
||||||
.ident = "oss"
|
.ident = "oss"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ static const bool _alsa_supp = true;
|
|||||||
static const bool _alsa_supp = false;
|
static const bool _alsa_supp = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_OSS
|
#if defined(HAVE_OSS) || defined(HAVE_OSS_BSD)
|
||||||
static const bool _oss_supp = true;
|
static const bool _oss_supp = true;
|
||||||
#else
|
#else
|
||||||
static const bool _oss_supp = false;
|
static const bool _oss_supp = false;
|
||||||
|
2
driver.c
2
driver.c
@ -32,7 +32,7 @@ static const audio_driver_t *audio_drivers[] = {
|
|||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
&audio_alsa,
|
&audio_alsa,
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_OSS
|
#if defined(HAVE_OSS) || defined(HAVE_OSS_BSD)
|
||||||
&audio_oss,
|
&audio_oss,
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_RSOUND
|
#ifdef HAVE_RSOUND
|
||||||
|
@ -26,6 +26,12 @@ check_lib NETPLAY -lc socket
|
|||||||
|
|
||||||
check_lib ALSA -lasound snd_pcm_open
|
check_lib ALSA -lasound snd_pcm_open
|
||||||
check_header OSS sys/soundcard.h
|
check_header OSS sys/soundcard.h
|
||||||
|
check_header OSS_BSD soundcard.h
|
||||||
|
check_lib OSS_LIB -lossaudio
|
||||||
|
|
||||||
|
if [ "$HAVE_OSS_BSD" = "yes" ]; then
|
||||||
|
check_critical OSS_LIB "Have BSD-style OSS, but -lossaudio is not present."
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$OS" = "Darwin" ]; then
|
if [ "$OS" = "Darwin" ]; then
|
||||||
check_lib AL "-framework OpenAL" alcOpenDevice
|
check_lib AL "-framework OpenAL" alcOpenDevice
|
||||||
@ -72,7 +78,7 @@ check_lib STRL -lc strlcpy
|
|||||||
check_pkgconf PYTHON python3
|
check_pkgconf PYTHON python3
|
||||||
|
|
||||||
# Creates config.mk and config.h.
|
# Creates config.mk and config.h.
|
||||||
VARS="ALSA OSS AL RSOUND ROAR JACK PULSE SDL DYLIB CG XML SDL_IMAGE DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE SRC CONFIGFILE FREETYPE XVIDEO NETPLAY FBO STRL PYTHON"
|
VARS="ALSA OSS OSS_BSD AL RSOUND ROAR JACK PULSE SDL DYLIB CG XML SDL_IMAGE DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE SRC CONFIGFILE FREETYPE XVIDEO NETPLAY FBO STRL PYTHON"
|
||||||
create_config_make config.mk $VARS
|
create_config_make config.mk $VARS
|
||||||
create_config_header config.h $VARS
|
create_config_header config.h $VARS
|
||||||
|
|
||||||
|
@ -41,9 +41,13 @@ check_lib()
|
|||||||
eval tmpval=\$$tmpval
|
eval tmpval=\$$tmpval
|
||||||
[ "$tmpval" = "no" ] && return 0
|
[ "$tmpval" = "no" ] && return 0
|
||||||
|
|
||||||
echo -n "Checking function $3 in $2 ... "
|
if [ -z "$3" ]; then
|
||||||
echo "void $3(void); int main(void) { $3(); return 0; }" > $TEMP_C
|
echo -n "Checking existence of $2 ..."
|
||||||
|
echo "int main(void) { return 0; }" > $TEMP_C
|
||||||
|
else
|
||||||
|
echo -n "Checking function $3 in $2 ... "
|
||||||
|
echo "void $3(void); int main(void) { $3(); return 0; }" > $TEMP_C
|
||||||
|
fi
|
||||||
|
|
||||||
eval HAVE_$1=no
|
eval HAVE_$1=no
|
||||||
answer=no
|
answer=no
|
||||||
@ -67,8 +71,13 @@ check_lib_cxx()
|
|||||||
eval tmpval=\$$tmpval
|
eval tmpval=\$$tmpval
|
||||||
[ "$tmpval" = "no" ] && return 0
|
[ "$tmpval" = "no" ] && return 0
|
||||||
|
|
||||||
echo -n "Checking function $3 in $2 ... "
|
if [ -z "$3" ]; then
|
||||||
echo "extern \"C\" { void $3(void); } int main() { $3(); }" > $TEMP_CXX
|
echo -n "Checking existence of $2 ..."
|
||||||
|
echo "int main(void) { return 0; }" > $TEMP_C
|
||||||
|
else
|
||||||
|
echo -n "Checking function $3 in $2 ... "
|
||||||
|
echo "extern \"C\" { void $3(void); } int main() { $3(); }" > $TEMP_CXX
|
||||||
|
fi
|
||||||
|
|
||||||
eval HAVE_$1=no
|
eval HAVE_$1=no
|
||||||
answer=no
|
answer=no
|
||||||
|
Loading…
x
Reference in New Issue
Block a user