Added OSS audio backend
This adds the OSS audio backend and removes OSS code from core/linux-dist/main.cpp and core/sdl/main.cpp. The OSS backend will be included during compilation if the USE_OSS flag is set. Although OSS code in core/linux-dist/main.cpp depended on the TARGET_PANDORA flag instead of USE_OSS, the latter should work too since it is defined in the Pandora Makefile (lines 7 & 83).
This commit is contained in:
parent
e3f1784a0f
commit
f6d2e3fa7e
|
@ -110,9 +110,6 @@ void emit_WriteCodeCache();
|
||||||
|
|
||||||
static int JoyFD = -1; // Joystick file descriptor
|
static int JoyFD = -1; // Joystick file descriptor
|
||||||
static int kbfd = -1;
|
static int kbfd = -1;
|
||||||
#ifdef TARGET_PANDORA
|
|
||||||
static int audio_fd = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define MAP_SIZE 32
|
#define MAP_SIZE 32
|
||||||
|
@ -755,7 +752,6 @@ void clean_exit(int sig_num) {
|
||||||
// close files
|
// close files
|
||||||
if (JoyFD>=0) close(JoyFD);
|
if (JoyFD>=0) close(JoyFD);
|
||||||
if (kbfd>=0) close(kbfd);
|
if (kbfd>=0) close(kbfd);
|
||||||
if(audio_fd>=0) close(audio_fd);
|
|
||||||
|
|
||||||
// Close EGL context ???
|
// Close EGL context ???
|
||||||
if (sig_num!=0)
|
if (sig_num!=0)
|
||||||
|
@ -781,26 +777,6 @@ void clean_exit(int sig_num) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_sound()
|
|
||||||
{
|
|
||||||
if((audio_fd=open("/dev/dsp",O_WRONLY))<0) {
|
|
||||||
printf("Couldn't open /dev/dsp.\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("sound enabled, dsp openned for write\n");
|
|
||||||
int tmp=44100;
|
|
||||||
int err_ret;
|
|
||||||
err_ret=ioctl(audio_fd,SNDCTL_DSP_SPEED,&tmp);
|
|
||||||
printf("set Frequency to %i, return %i (rate=%i)\n", 44100, err_ret, tmp);
|
|
||||||
int channels=2;
|
|
||||||
err_ret=ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &channels);
|
|
||||||
printf("set dsp to stereo (%i => %i)\n", channels, err_ret);
|
|
||||||
int format=AFMT_S16_LE;
|
|
||||||
err_ret=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format);
|
|
||||||
printf("set dsp to %s audio (%i/%i => %i)\n", "16bits signed" ,AFMT_S16_LE, format, err_ret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, wchar* argv[])
|
int main(int argc, wchar* argv[])
|
||||||
|
@ -812,11 +788,6 @@ int main(int argc, wchar* argv[])
|
||||||
#ifdef TARGET_PANDORA
|
#ifdef TARGET_PANDORA
|
||||||
signal(SIGSEGV, clean_exit);
|
signal(SIGSEGV, clean_exit);
|
||||||
signal(SIGKILL, clean_exit);
|
signal(SIGKILL, clean_exit);
|
||||||
|
|
||||||
init_sound();
|
|
||||||
#else
|
|
||||||
void os_InitAudio();
|
|
||||||
os_InitAudio();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USES_HOMEDIR) && HOST_OS != OS_DARWIN
|
#if defined(USES_HOMEDIR) && HOST_OS != OS_DARWIN
|
||||||
|
@ -873,23 +844,6 @@ int main(int argc, wchar* argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
u32 alsa_Push(void* frame, u32 samples, bool wait);
|
|
||||||
u32 PushAudio(void* frame, u32 samples, bool wait)
|
|
||||||
{
|
|
||||||
#ifndef TARGET_PANDORA
|
|
||||||
int audio_fd = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (audio_fd > 0) {
|
|
||||||
write(audio_fd, frame, samples*4);
|
|
||||||
} else {
|
|
||||||
return alsa_Push(frame, samples, wait);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int get_mic_data(u8* buffer) { return 0; }
|
int get_mic_data(u8* buffer) { return 0; }
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
#include "oslib/audiobackend_oss.h"
|
||||||
|
#ifdef USE_OSS
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
|
#include <sys/soundcard.h>
|
||||||
|
|
||||||
|
static int oss_audio_fd = -1;
|
||||||
|
|
||||||
|
static void oss_init()
|
||||||
|
{
|
||||||
|
oss_audio_fd = open("/dev/dsp", O_WRONLY);
|
||||||
|
if (oss_audio_fd < 0)
|
||||||
|
{
|
||||||
|
printf("Couldn't open /dev/dsp.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("sound enabled, dsp openned for write\n");
|
||||||
|
int tmp=44100;
|
||||||
|
int err_ret;
|
||||||
|
err_ret=ioctl(oss_audio_fd,SNDCTL_DSP_SPEED,&tmp);
|
||||||
|
printf("set Frequency to %i, return %i (rate=%i)\n", 44100, err_ret, tmp);
|
||||||
|
int channels=2;
|
||||||
|
err_ret=ioctl(oss_audio_fd, SNDCTL_DSP_CHANNELS, &channels);
|
||||||
|
printf("set dsp to stereo (%i => %i)\n", channels, err_ret);
|
||||||
|
int format=AFMT_S16_LE;
|
||||||
|
err_ret=ioctl(oss_audio_fd, SNDCTL_DSP_SETFMT, &format);
|
||||||
|
printf("set dsp to %s audio (%i/%i => %i)\n", "16bits signed", AFMT_S16_LE, format, err_ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static u32 oss_push(void* frame, u32 samples, bool wait)
|
||||||
|
{
|
||||||
|
write(oss_audio_fd, frame, samples*4);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void oss_term() {
|
||||||
|
if(oss_audio_fd >= 0)
|
||||||
|
{
|
||||||
|
close(oss_audio_fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
audiobackend_t audiobackend_oss = {
|
||||||
|
"oss", // Slug
|
||||||
|
"Open Sound System", // Name
|
||||||
|
&oss_init,
|
||||||
|
&oss_push,
|
||||||
|
&oss_term
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,4 @@
|
||||||
|
#pragma once
|
||||||
|
#include "oslib/audiostream.h"
|
||||||
|
|
||||||
|
extern audiobackend_t audiobackend_oss;
|
|
@ -69,6 +69,9 @@ bool RegisterAudioBackend(audiobackend_t *backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterAllAudioBackends() {
|
void RegisterAllAudioBackends() {
|
||||||
|
#if USE_OSS
|
||||||
|
RegisterAudioBackend(&audiobackend_oss);
|
||||||
|
#endif
|
||||||
audiobackends_registered = true;
|
audiobackends_registered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,6 @@
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
|
|
||||||
#ifdef USE_OSS
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/soundcard.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
|
|
||||||
|
@ -103,11 +98,6 @@ static SDL_Joystick *JoySDL = 0;
|
||||||
|
|
||||||
extern bool FrameSkipping;
|
extern bool FrameSkipping;
|
||||||
|
|
||||||
#ifdef USE_OSS
|
|
||||||
static int audio_fd = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define MAP_SIZE 32
|
#define MAP_SIZE 32
|
||||||
|
|
||||||
const u32 JMapBtn_USB[MAP_SIZE] =
|
const u32 JMapBtn_USB[MAP_SIZE] =
|
||||||
|
@ -426,9 +416,6 @@ void clean_exit(int sig_num) {
|
||||||
|
|
||||||
// close files
|
// close files
|
||||||
if (JoySDL) SDL_JoystickClose(JoySDL);
|
if (JoySDL) SDL_JoystickClose(JoySDL);
|
||||||
#ifdef USE_OSS
|
|
||||||
if (audio_fd>=0) close(audio_fd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Close EGL context ???
|
// Close EGL context ???
|
||||||
if (sig_num!=0)
|
if (sig_num!=0)
|
||||||
|
@ -437,37 +424,6 @@ void clean_exit(int sig_num) {
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_OSS
|
|
||||||
void init_sound()
|
|
||||||
{
|
|
||||||
if((audio_fd=open("/dev/dsp",O_WRONLY))<0)
|
|
||||||
printf("Couldn't open /dev/dsp.\n");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("sound enabled, dsp openned for write\n");
|
|
||||||
int tmp=44100;
|
|
||||||
int err_ret;
|
|
||||||
err_ret=ioctl(audio_fd,SNDCTL_DSP_SPEED,&tmp);
|
|
||||||
printf("set Frequency to %i, return %i (rate=%i)\n", 44100, err_ret, tmp);
|
|
||||||
int channels=2;
|
|
||||||
err_ret=ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &channels);
|
|
||||||
printf("set dsp to stereo (%i => %i)\n", channels, err_ret);
|
|
||||||
int format=AFMT_S16_LE;
|
|
||||||
err_ret=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format);
|
|
||||||
printf("set dsp to %s audio (%i/%i => %i)\n", "16bits signed" ,AFMT_S16_LE, format, err_ret);
|
|
||||||
int frag=(4<<16)|11;
|
|
||||||
int f=frag;
|
|
||||||
err_ret=ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag);
|
|
||||||
printf("set dsp fragment to %i of %i bytes (0x%x => %i)\n", "16bits signed" ,(f>>16), 1<<(f&0xff), frag, err_ret);
|
|
||||||
/*
|
|
||||||
// this doesn't help stutering, and the emu goes too fast after that
|
|
||||||
err_ret=ioctl(audio_fd, SNDCTL_DSP_NONBLOCK, NULL);
|
|
||||||
printf("set dsp to non-blocking ( => %i)\n", err_ret);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main(int argc, wchar* argv[])
|
int main(int argc, wchar* argv[])
|
||||||
{
|
{
|
||||||
//if (argc==2)
|
//if (argc==2)
|
||||||
|
@ -501,10 +457,6 @@ int main(int argc, wchar* argv[])
|
||||||
die("error initializing SDL");
|
die("error initializing SDL");
|
||||||
|
|
||||||
SetupInput();
|
SetupInput();
|
||||||
|
|
||||||
#ifdef USE_OSS
|
|
||||||
init_sound();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FrameSkipping=false;
|
FrameSkipping=false;
|
||||||
|
|
||||||
|
@ -513,19 +465,4 @@ int main(int argc, wchar* argv[])
|
||||||
clean_exit(0);
|
clean_exit(0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
u32 PushAudio(void* frame, u32 samples, bool wait)
|
|
||||||
{
|
|
||||||
#ifdef USE_OSS
|
|
||||||
static bool blocking = true;
|
|
||||||
if (wait!=blocking) {
|
|
||||||
fcntl(audio_fd, F_SETFD, O_WRONLY | wait?0:O_NONBLOCK);
|
|
||||||
blocking=wait;
|
|
||||||
}
|
|
||||||
write(audio_fd, frame, samples*4);
|
|
||||||
#endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue