Unix: new prefs options "dsp" and "mixer" to set the OSS device names instead

of the hardcoded '/dev/dsp' and '/dev/mixer'
This commit is contained in:
cebix 2002-10-15 16:25:04 +00:00
parent 2cb7e02c9e
commit 466fc971f6
8 changed files with 63 additions and 23 deletions

View File

@ -5,13 +5,15 @@ V1.0 (snapshot) - <date>
- Unix: add large file support for 2+ GB hard disk images
- Unix: cleaned up pthread attributes [Brian Johnson]
- Unix: fixed floppy problems under Linux
- Unix: implement "ignoresegv" feature on Linux/x86, Linux/ppc, Darwin/ppc
- Unix: implemented "ignoresegv" feature on Linux/x86, Linux/ppc, Darwin/ppc
- Unix: serial port baud rates are now set correctly
- Unix: it is now possible to make the serial drivers pipe their input/output
to programs by using a '|' followed by a command line as the modem or
printer port setting (instead of a device name like '/dev/ttyS0')
[Brian Johnson]
- Unix: the option "--config FILE" tells B2 to use a different config file
- Unix: new prefs options "dsp" and "mixer" to set the OSS device names
instead of the hardcoded '/dev/dsp' and '/dev/mixer'
V1.0 (snapshot) - 15.Jan.2002
- added support for on-the-fly video resolution and depth switching, and

View File

@ -285,7 +285,6 @@ screen <video mode>
application via Alt-Tab, Basilisk II is put in "snooze" mode (i.e. MacOS
is frozen).
Mac OS X:
The "video mode" is one of the following:
win/<width>/<height>
@ -302,7 +301,6 @@ screen <video mode>
opengl/<width>/<height>/<bits per pixel>
Currently unimplemented, will be a fast windowed mode.
seriala <serial port description>
This item describes the serial port to be used as Port A (Modem Port)
@ -580,6 +578,13 @@ Unix:
is "false". This feature is only implemented on the following
platforms: Linux/x86, Linux/ppc, Darwin/ppc.
dsp <device name>
mixer <device name>
Under Linux and FreeBSD, this specifies the devices to be used for sound
output and volume control, respectively. The defaults are "/dev/dsp" and
"/dev/mixer".
AmigaOS:
sound <sound output description>

View File

@ -28,7 +28,6 @@ AmigaOS:
- Input handler instead of IDCMP?
- Last sound buffer is not played
- Sound output rate/bits/channels switching
- Video depth/resolution switching
BeOS:
- clip_beos.cpp: clip BeOS->Basilisk

View File

@ -31,7 +31,7 @@
#endif
#ifdef __FreeBSD__
#include <sys/soundcard.h>
#include <machine/soundcard.h>
#endif
#include "cpu_emulation.h"
@ -54,12 +54,9 @@ static int audio_sample_rate_index = 0;
static int audio_sample_size_index = 0;
static int audio_channel_count_index = 0;
// Constants
#define DSP_NAME "/dev/dsp"
// Global variables
static int audio_fd = -1; // fd of /dev/dsp or ESD
static int mixer_fd = -1; // fd of /dev/mixer
static int audio_fd = -1; // fd of dsp or ESD
static int mixer_fd = -1; // fd of mixer
static sem_t audio_irq_done_sem; // Signal from interrupt to streaming thread: data block read
static bool sem_inited = false; // Flag: audio_irq_done_sem initialized
static int sound_buffer_size; // Size of sound buffer in bytes
@ -86,17 +83,18 @@ static void set_audio_status_format(void)
AudioStatus.channels = audio_channel_counts[audio_channel_count_index];
}
// Init using /dev/dsp, returns false on error
// Init using the dsp device, returns false on error
static bool open_dsp(void)
{
// Open /dev/dsp
audio_fd = open(DSP_NAME, O_WRONLY);
// Open the device
const char *dsp = PrefsFindString("dsp");
audio_fd = open(dsp, O_WRONLY);
if (audio_fd < 0) {
fprintf(stderr, "WARNING: Cannot open %s (%s)\n", DSP_NAME, strerror(errno));
fprintf(stderr, "WARNING: Cannot open %s (%s)\n", dsp, strerror(errno));
return false;
}
printf("Using " DSP_NAME " audio output\n");
printf("Using %s audio output\n", dsp);
// Get supported sample formats
if (audio_sample_sizes.empty()) {
@ -213,7 +211,7 @@ static bool open_esd(void)
// The reason we do this here is that we don't want to add sample
// rates etc. unless the ESD server connection could be opened
// (if ESD fails, /dev/dsp might be tried next)
// (if ESD fails, dsp might be tried next)
audio_sample_rates.push_back(11025 << 16);
audio_sample_rates.push_back(22050 << 16);
audio_sample_rates.push_back(44100 << 16);
@ -246,12 +244,12 @@ static bool open_audio(void)
goto dev_opened;
#endif
// Try to open /dev/dsp
// Try to open dsp
if (open_dsp())
goto dev_opened;
#ifdef ENABLE_ESD
// Hm, /dev/dsp failed so we try ESD again if ESPEAKER wasn't set
// Hm, dsp failed so we try ESD again if ESPEAKER wasn't set
if (!getenv("ESPEAKER"))
if (open_esd())
goto dev_opened;
@ -294,10 +292,11 @@ void AudioInit(void)
return;
sem_inited = true;
// Try to open /dev/mixer
mixer_fd = open("/dev/mixer", O_RDWR);
// Try to open the mixer device
const char *mixer = PrefsFindString("mixer");
mixer_fd = open(mixer, O_RDWR);
if (mixer_fd < 0)
printf("WARNING: Cannot open /dev/mixer (%s)", strerror(errno));
printf("WARNING: Cannot open %s (%s)\n", mixer, strerror(errno));
// Open and initialize audio device
open_audio();
@ -320,7 +319,7 @@ static void close_audio(void)
stream_thread_active = false;
}
// Close /dev/dsp or ESD socket
// Close dsp or ESD socket
if (audio_fd >= 0) {
close(audio_fd);
audio_fd = -1;
@ -340,7 +339,7 @@ void AudioExit(void)
sem_inited = false;
}
// Close /dev/mixer
// Close mixer device
if (mixer_fd >= 0) {
close(mixer_fd);
mixer_fd = -1;

View File

@ -715,6 +715,8 @@ static GtkWidget *l_fbdev_name, *l_fbdevice_file;
static char fbdev_name[256];
#endif
static GtkWidget *w_dspdevice_file, *w_mixerdevice_file;
// Hide/show graphics widgets
static void hide_show_graphics_widgets(void)
{
@ -761,10 +763,19 @@ static void mn_30hz(...) {PrefsReplaceInt32("frameskip", 2);}
static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);}
static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);}
// Set sensitivity of widgets
static void set_graphics_sensitive(void)
{
const bool sound_enabled = !PrefsFindBool("nosound");
gtk_widget_set_sensitive(w_dspdevice_file, sound_enabled);
gtk_widget_set_sensitive(w_mixerdevice_file, sound_enabled);
}
// "Disable Sound Output" button toggled
static void tb_nosound(GtkWidget *widget)
{
PrefsReplaceBool("nosound", GTK_TOGGLE_BUTTON(widget)->active);
set_graphics_sensitive();
}
// Read graphics preferences
@ -827,6 +838,8 @@ static void read_graphics_settings(void)
else
PrefsRemoveItem("fbdevicefile");
#endif
PrefsReplaceString("dsp", get_file_entry_path(w_dspdevice_file));
PrefsReplaceString("mixer", get_file_entry_path(w_mixerdevice_file));
}
// Create "Graphics/Sound" pane
@ -947,6 +960,10 @@ static void create_graphics_pane(GtkWidget *top)
make_separator(box);
make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound));
w_dspdevice_file = make_file_entry(box, STR_DSPDEVICE_FILE_CTRL, "dsp");
w_mixerdevice_file = make_file_entry(box, STR_MIXERDEVICE_FILE_CTRL, "mixer");
set_graphics_sensitive();
hide_show_graphics_widgets();
}

View File

@ -36,6 +36,8 @@ prefs_desc platform_prefs_items[] = {
{"fbdevicefile", TYPE_STRING, false, "path of frame buffer device specification file"},
{"mousewheelmode", TYPE_INT32, false, "mouse wheel support mode (0=page up/down, 1=cursor up/down)"},
{"mousewheellines", TYPE_INT32, false, "number of lines to scroll in mouse wheel mode 1"},
{"dsp", TYPE_STRING, false, "audio output (dsp) device name"},
{"mixer", TYPE_STRING, false, "audio mixer device name"},
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
{"ignoresegv", TYPE_BOOLEAN, false, "ignore illegal memory accesses"},
#endif
@ -105,6 +107,18 @@ void AddPlatformPrefsDefaults(void)
PrefsReplaceString("extfs", "/");
PrefsReplaceInt32("mousewheelmode", 1);
PrefsReplaceInt32("mousewheellines", 3);
#ifdef __linux__
if (access("/dev/.devfsd", F_OK) < 0) {
PrefsReplaceString("dsp", "/dev/dsp");
PrefsReplaceString("mixer", "/dev/mixer");
} else {
PrefsReplaceString("dsp", "/dev/sound/dsp");
PrefsReplaceString("mixer", "/dev/sound/mixer");
}
#else
PrefsReplaceString("dsp", "/dev/dsp");
PrefsReplaceString("mixer", "/dev/mixer");
#endif
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
PrefsAddBool("ignoresegv", false);
#endif

View File

@ -66,6 +66,8 @@ user_string_def platform_strings[] = {
{STR_FBDEV_NAME_CTRL, "Frame Buffer Name"},
{STR_FBDEVICE_FILE_CTRL, "Frame Buffer Spec File"},
{STR_DSPDEVICE_FILE_CTRL, "Audio Output Device"},
{STR_MIXERDEVICE_FILE_CTRL, "Audio Mixer Device"},
{STR_INPUT_PANE_TITLE, "Mouse/Keyboard"},
{STR_KEYCODES_CTRL, "Use Raw Keycodes"},

View File

@ -57,6 +57,8 @@ enum {
STR_FBDEV_NAME_CTRL,
STR_FBDEVICE_FILE_CTRL,
STR_DSPDEVICE_FILE_CTRL,
STR_MIXERDEVICE_FILE_CTRL,
STR_INPUT_PANE_TITLE,
STR_KEYCODES_CTRL,