mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-04-02 10:42:14 -04:00
byuu says: Changelog: - added Cocoa target: higan can now be compiled for OS X Lion [Cydrak, byuu] - SNES/accuracy profile hires color blending improvements - fixes Marvelous text [AWJ] - fixed a slight bug in SNES/SA-1 VBR support caused by a typo - added support for multi-pass shaders that can load external textures (requires OpenGL 3.2+) - added game library path (used by ananke->Import Game) to Settings->Advanced - system profiles, shaders and cheats database can be stored in "all users" shared folders now (eg /usr/share on Linux) - all configuration files are in BML format now, instead of XML (much easier to read and edit this way) - main window supports drag-and-drop of game folders (but not game files / ZIP archives) - audio buffer clears when entering a modal loop on Windows (prevents audio repetition with DirectSound driver) - a substantial amount of code clean-up (probably the biggest refactoring to date) One highly desired target for this release was to default to the optimal drivers instead of the safest drivers, but because AMD drivers don't seem to like my OpenGL 3.2 driver, I've decided to postpone that. AMD has too big a market share. Hopefully with v093 officially released, we can get some public input on what AMD doesn't like.
113 lines
2.6 KiB
C++
113 lines
2.6 KiB
C++
/*
|
|
audio.oss (2007-12-26)
|
|
author: Nach
|
|
*/
|
|
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/soundcard.h>
|
|
|
|
//OSS4 soundcard.h includes below SNDCTL defines, but OSS3 does not
|
|
//However, OSS4 soundcard.h does not reside in <sys/>
|
|
//Therefore, attempt to manually define SNDCTL values if using OSS3 header
|
|
//Note that if the defines below fail to work on any specific platform, one can point soundcard.h
|
|
//above to the correct location for OSS4 (usually /usr/lib/oss/include/sys/soundcard.h)
|
|
//Failing that, one can disable OSS4 ioctl calls inside init() and remove the below defines
|
|
|
|
#ifndef SNDCTL_DSP_COOKEDMODE
|
|
#define SNDCTL_DSP_COOKEDMODE _IOW('P', 30, int)
|
|
#endif
|
|
|
|
#ifndef SNDCTL_DSP_POLICY
|
|
#define SNDCTL_DSP_POLICY _IOW('P', 45, int)
|
|
#endif
|
|
|
|
namespace ruby {
|
|
|
|
class pAudioOSS {
|
|
public:
|
|
struct {
|
|
int fd;
|
|
int format;
|
|
int channels;
|
|
const char* name;
|
|
} device;
|
|
|
|
struct {
|
|
unsigned frequency;
|
|
} settings;
|
|
|
|
bool cap(const string& name) {
|
|
if(name == Audio::Frequency) return true;
|
|
return false;
|
|
}
|
|
|
|
any get(const string& name) {
|
|
if(name == Audio::Frequency) return settings.frequency;
|
|
return false;
|
|
}
|
|
|
|
bool set(const string& name, const any& value) {
|
|
if(name == Audio::Frequency) {
|
|
settings.frequency = any_cast<unsigned>(value);
|
|
if(device.fd > 0) init();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void sample(uint16_t sl, uint16_t sr) {
|
|
uint32_t sample = sl + (sr << 16);
|
|
unsigned unused = write(device.fd, &sample, 4);
|
|
}
|
|
|
|
void clear() {
|
|
}
|
|
|
|
bool init() {
|
|
term();
|
|
|
|
device.fd = open(device.name, O_WRONLY, O_NONBLOCK);
|
|
if(device.fd < 0) return false;
|
|
|
|
#if 1 //SOUND_VERSION >= 0x040000
|
|
//attempt to enable OSS4-specific features regardless of version
|
|
//OSS3 ioctl calls will silently fail, but sound will still work
|
|
int cooked = 1, policy = 4; //policy should be 0 - 10, lower = less latency, more CPU usage
|
|
ioctl(device.fd, SNDCTL_DSP_COOKEDMODE, &cooked);
|
|
ioctl(device.fd, SNDCTL_DSP_POLICY, &policy);
|
|
#endif
|
|
int freq = settings.frequency;
|
|
ioctl(device.fd, SNDCTL_DSP_CHANNELS, &device.channels);
|
|
ioctl(device.fd, SNDCTL_DSP_SETFMT, &device.format);
|
|
ioctl(device.fd, SNDCTL_DSP_SPEED, &freq);
|
|
|
|
return true;
|
|
}
|
|
|
|
void term() {
|
|
if(device.fd > 0) {
|
|
close(device.fd);
|
|
device.fd = -1;
|
|
}
|
|
}
|
|
|
|
pAudioOSS() {
|
|
device.fd = -1;
|
|
device.format = AFMT_S16_LE;
|
|
device.channels = 2;
|
|
device.name = "/dev/dsp";
|
|
|
|
settings.frequency = 22050;
|
|
}
|
|
|
|
~pAudioOSS() {
|
|
term();
|
|
}
|
|
};
|
|
|
|
DeclareAudio(OSS)
|
|
|
|
};
|