2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2015-01-11 23:13:50 +03:00
|
|
|
// Copyright (C) 2001-2015 The Bochs Project
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-02-08 12:05:52 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2008-02-16 01:05:43 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-07-12 19:21:36 +04:00
|
|
|
// Josef Drexler coded the original version of the lowlevel sound support
|
2013-07-14 19:14:53 +04:00
|
|
|
// for Linux using OSS. The current version also supports OSS on FreeBSD.
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2011-02-15 00:14:20 +03:00
|
|
|
#include "iodev.h"
|
2014-11-24 21:25:14 +03:00
|
|
|
#include "soundlow.h"
|
2011-08-18 11:05:09 +04:00
|
|
|
#include "soundlnx.h"
|
2005-12-10 21:37:35 +03:00
|
|
|
|
2015-02-24 00:32:34 +03:00
|
|
|
#if BX_HAVE_SOUND_OSS && BX_SUPPORT_SOUNDLOW
|
2005-12-10 21:37:35 +03:00
|
|
|
|
2015-02-07 00:31:30 +03:00
|
|
|
#ifndef WIN32
|
|
|
|
#include <pthread.h>
|
|
|
|
#endif
|
|
|
|
|
2013-06-24 23:19:12 +04:00
|
|
|
#define LOG_THIS
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/soundcard.h>
|
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
// bx_soundlow_waveout_oss_c class implemenzation
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
bx_soundlow_waveout_oss_c::bx_soundlow_waveout_oss_c()
|
|
|
|
:bx_soundlow_waveout_c()
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2015-02-13 14:30:46 +03:00
|
|
|
waveout_fd = -1;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
bx_soundlow_waveout_oss_c::~bx_soundlow_waveout_oss_c()
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2015-02-13 14:30:46 +03:00
|
|
|
if (waveout_fd != -1) {
|
|
|
|
close(waveout_fd);
|
|
|
|
waveout_fd = -1;
|
2008-02-16 01:05:43 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
int bx_soundlow_waveout_oss_c::openwaveoutput(const char *wavedev)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2015-02-13 14:30:46 +03:00
|
|
|
if (waveout_fd == -1) {
|
|
|
|
waveout_fd = open(wavedev, O_WRONLY);
|
|
|
|
if (waveout_fd == -1) {
|
2015-01-31 13:48:22 +03:00
|
|
|
return BX_SOUNDLOW_ERR;
|
|
|
|
} else {
|
|
|
|
BX_INFO(("OSS: opened output device %s", wavedev));
|
|
|
|
}
|
|
|
|
}
|
2015-02-13 14:30:46 +03:00
|
|
|
set_pcm_params(&real_pcm_param);
|
2015-02-07 00:31:30 +03:00
|
|
|
pcm_callback_id = register_wave_callback(this, pcm_callback);
|
|
|
|
start_mixer_thread();
|
2011-03-20 21:02:12 +03:00
|
|
|
return BX_SOUNDLOW_OK;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
int bx_soundlow_waveout_oss_c::set_pcm_params(bx_pcm_param_t *param)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
int fmt, ret;
|
2015-02-13 14:30:46 +03:00
|
|
|
int frequency = param->samplerate;
|
|
|
|
int channels = param->channels;
|
|
|
|
int signeddata = param->format & 1;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
BX_DEBUG(("set_pcm_params(): %u, %u, %u, %02x", param->samplerate, param->bits,
|
|
|
|
param->channels, param->format));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
if (waveout_fd == -1) {
|
2015-01-31 13:48:22 +03:00
|
|
|
return BX_SOUNDLOW_ERR;
|
2008-07-12 19:21:36 +04:00
|
|
|
}
|
2015-02-13 14:30:46 +03:00
|
|
|
if (param->bits == 16) {
|
2015-01-31 13:48:22 +03:00
|
|
|
if (signeddata == 1) {
|
2001-04-10 05:04:59 +04:00
|
|
|
fmt = AFMT_S16_LE;
|
2015-01-31 13:48:22 +03:00
|
|
|
} else {
|
2001-04-10 05:04:59 +04:00
|
|
|
fmt = AFMT_U16_LE;
|
2015-01-31 13:48:22 +03:00
|
|
|
}
|
2015-02-13 14:30:46 +03:00
|
|
|
} else if (param->bits == 8) {
|
2015-01-31 13:48:22 +03:00
|
|
|
if (signeddata == 1) {
|
2001-04-10 05:04:59 +04:00
|
|
|
fmt = AFMT_S8;
|
2015-01-31 13:48:22 +03:00
|
|
|
} else {
|
2001-04-10 05:04:59 +04:00
|
|
|
fmt = AFMT_U8;
|
2015-01-31 13:48:22 +03:00
|
|
|
}
|
|
|
|
} else {
|
2011-03-20 21:02:12 +03:00
|
|
|
return BX_SOUNDLOW_ERR;
|
2015-01-31 13:48:22 +03:00
|
|
|
}
|
|
|
|
// set frequency etc.
|
2015-02-13 14:30:46 +03:00
|
|
|
ret = ioctl(waveout_fd, SNDCTL_DSP_RESET);
|
2001-04-10 05:04:59 +04:00
|
|
|
if (ret != 0)
|
2015-01-31 13:48:22 +03:00
|
|
|
BX_ERROR(("ioctl(SNDCTL_DSP_RESET): %s", strerror(errno)));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
/*
|
2015-02-13 14:30:46 +03:00
|
|
|
ret = ioctl(waveout_fd], SNDCTL_DSP_SETFRAGMENT, &fragment);
|
2001-04-10 05:04:59 +04:00
|
|
|
if (ret != 0)
|
2011-04-24 22:45:37 +04:00
|
|
|
BX_DEBUG(("ioctl(SNDCTL_DSP_SETFRAGMENT, %d): %s",
|
|
|
|
fragment, strerror(errno)));
|
2001-04-10 05:04:59 +04:00
|
|
|
*/
|
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
ret = ioctl(waveout_fd, SNDCTL_DSP_SETFMT, &fmt);
|
2015-01-31 13:48:22 +03:00
|
|
|
if (ret != 0) { // abort if the format is unknown, to avoid playing noise
|
|
|
|
BX_ERROR(("ioctl(SNDCTL_DSP_SETFMT, %d): %s",
|
|
|
|
fmt, strerror(errno)));
|
|
|
|
return BX_SOUNDLOW_ERR;
|
2008-02-16 01:05:43 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
ret = ioctl(waveout_fd, SNDCTL_DSP_CHANNELS, &channels);
|
2001-04-10 05:04:59 +04:00
|
|
|
if (ret != 0)
|
2015-01-31 13:48:22 +03:00
|
|
|
BX_ERROR(("ioctl(SNDCTL_DSP_CHANNELS, %d): %s",
|
|
|
|
channels, strerror(errno)));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
ret = ioctl(waveout_fd, SNDCTL_DSP_SPEED, &frequency);
|
2001-04-10 05:04:59 +04:00
|
|
|
if (ret != 0)
|
2015-01-31 13:48:22 +03:00
|
|
|
BX_ERROR(("ioctl(SNDCTL_DSP_SPEED, %d): %s",
|
|
|
|
frequency, strerror(errno)));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2011-04-24 22:45:37 +04:00
|
|
|
// ioctl(wave_fd[0], SNDCTL_DSP_GETBLKSIZE, &fragment);
|
2011-02-19 11:48:53 +03:00
|
|
|
// BX_DEBUG(("current output block size is %d", fragment));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2011-03-20 21:02:12 +03:00
|
|
|
return BX_SOUNDLOW_OK;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2008-01-27 01:24:03 +03:00
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
int bx_soundlow_waveout_oss_c::output(int length, Bit8u data[])
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2015-02-07 00:31:30 +03:00
|
|
|
int odelay, delay;
|
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
if (waveout_fd == -1) {
|
2013-08-04 18:35:06 +04:00
|
|
|
return BX_SOUNDLOW_ERR;
|
|
|
|
}
|
2015-02-13 14:30:46 +03:00
|
|
|
if (write(waveout_fd, data, length) == length) {
|
|
|
|
ioctl(waveout_fd, SNDCTL_DSP_GETODELAY, &odelay);
|
2015-02-07 00:31:30 +03:00
|
|
|
delay = odelay * 1000 / (real_pcm_param.samplerate * 4);
|
|
|
|
BX_MSLEEP(delay);
|
2011-03-20 21:02:12 +03:00
|
|
|
return BX_SOUNDLOW_OK;
|
2008-07-12 19:21:36 +04:00
|
|
|
} else {
|
2011-03-20 21:02:12 +03:00
|
|
|
return BX_SOUNDLOW_ERR;
|
2008-07-12 19:21:36 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2015-02-14 20:25:39 +03:00
|
|
|
// bx_soundlow_wavein_oss_c class implemenzation
|
2015-02-13 14:30:46 +03:00
|
|
|
|
2015-02-14 20:25:39 +03:00
|
|
|
bx_soundlow_wavein_oss_c::bx_soundlow_wavein_oss_c()
|
|
|
|
:bx_soundlow_wavein_c()
|
2015-02-13 14:30:46 +03:00
|
|
|
{
|
|
|
|
wavein_fd = -1;
|
|
|
|
}
|
|
|
|
|
2015-02-14 20:25:39 +03:00
|
|
|
bx_soundlow_wavein_oss_c::~bx_soundlow_wavein_oss_c()
|
2015-02-13 14:30:46 +03:00
|
|
|
{
|
2015-02-14 20:25:39 +03:00
|
|
|
if (wavein_fd != -1) {
|
|
|
|
close(wavein_fd);
|
|
|
|
wavein_fd = -1;
|
2015-02-13 14:30:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-14 20:25:39 +03:00
|
|
|
int bx_soundlow_wavein_oss_c::openwaveinput(const char *wavedev, sound_record_handler_t rh)
|
2011-04-22 17:11:47 +04:00
|
|
|
{
|
|
|
|
record_handler = rh;
|
2011-05-24 20:47:07 +04:00
|
|
|
if (rh != NULL) {
|
|
|
|
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "soundlnx");
|
|
|
|
// record timer: inactive, continuous, frequency variable
|
|
|
|
}
|
2015-02-13 14:30:46 +03:00
|
|
|
if (wavein_fd == -1) {
|
|
|
|
wavein_fd = open(wavedev, O_RDONLY);
|
|
|
|
if (wavein_fd == -1) {
|
2015-01-31 13:48:22 +03:00
|
|
|
return BX_SOUNDLOW_ERR;
|
|
|
|
} else {
|
|
|
|
BX_INFO(("OSS: opened input device %s", wavedev));
|
|
|
|
}
|
|
|
|
}
|
2015-02-08 11:53:20 +03:00
|
|
|
wavein_param.samplerate = 0;
|
2011-04-24 22:45:37 +04:00
|
|
|
return BX_SOUNDLOW_OK;
|
2011-04-22 17:11:47 +04:00
|
|
|
}
|
|
|
|
|
2015-02-14 20:25:39 +03:00
|
|
|
int bx_soundlow_wavein_oss_c::startwaverecord(bx_pcm_param_t *param)
|
2011-04-22 17:11:47 +04:00
|
|
|
{
|
|
|
|
Bit64u timer_val;
|
|
|
|
Bit8u shift = 0;
|
2011-04-24 22:45:37 +04:00
|
|
|
int fmt, ret;
|
2015-02-08 11:53:20 +03:00
|
|
|
int frequency = param->samplerate;
|
|
|
|
int channels = param->channels;
|
|
|
|
int signeddata = param->format & 1;
|
2011-04-22 17:11:47 +04:00
|
|
|
|
2011-05-24 20:47:07 +04:00
|
|
|
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
|
2015-02-08 11:53:20 +03:00
|
|
|
if (param->bits == 16) shift++;
|
|
|
|
if (param->channels == 2) shift++;
|
|
|
|
record_packet_size = (param->samplerate / 10) << shift; // 0.1 sec
|
2011-05-24 20:47:07 +04:00
|
|
|
if (record_packet_size > BX_SOUNDLOW_WAVEPACKETSIZE) {
|
|
|
|
record_packet_size = BX_SOUNDLOW_WAVEPACKETSIZE;
|
|
|
|
}
|
2015-02-08 11:53:20 +03:00
|
|
|
timer_val = (Bit64u)record_packet_size * 1000000 / (param->samplerate << shift);
|
2011-05-24 20:47:07 +04:00
|
|
|
bx_pc_system.activate_timer(record_timer_index, (Bit32u)timer_val, 1);
|
2011-04-22 17:11:47 +04:00
|
|
|
}
|
2015-02-13 14:30:46 +03:00
|
|
|
if (wavein_fd == -1) {
|
2015-01-31 13:48:22 +03:00
|
|
|
return BX_SOUNDLOW_ERR;
|
2011-04-24 22:45:37 +04:00
|
|
|
} else {
|
2015-02-08 11:53:20 +03:00
|
|
|
if (memcmp(param, &wavein_param, sizeof(bx_pcm_param_t)) == 0) {
|
2011-04-24 22:45:37 +04:00
|
|
|
return BX_SOUNDLOW_OK; // nothing to do
|
2015-02-08 11:53:20 +03:00
|
|
|
}
|
|
|
|
wavein_param = *param;
|
2011-04-24 22:45:37 +04:00
|
|
|
}
|
|
|
|
|
2015-02-08 11:53:20 +03:00
|
|
|
if (param->bits == 16) {
|
|
|
|
if (signeddata == 1) {
|
2011-04-24 22:45:37 +04:00
|
|
|
fmt = AFMT_S16_LE;
|
2015-02-08 11:53:20 +03:00
|
|
|
} else {
|
2011-04-24 22:45:37 +04:00
|
|
|
fmt = AFMT_U16_LE;
|
2015-02-08 11:53:20 +03:00
|
|
|
}
|
|
|
|
} else if (param->bits == 8) {
|
|
|
|
if (signeddata == 1) {
|
2011-04-24 22:45:37 +04:00
|
|
|
fmt = AFMT_S8;
|
2015-02-08 11:53:20 +03:00
|
|
|
} else {
|
2011-04-24 22:45:37 +04:00
|
|
|
fmt = AFMT_U8;
|
2015-02-08 11:53:20 +03:00
|
|
|
}
|
|
|
|
} else {
|
2011-04-24 22:45:37 +04:00
|
|
|
return BX_SOUNDLOW_ERR;
|
2015-02-08 11:53:20 +03:00
|
|
|
}
|
2011-04-24 22:45:37 +04:00
|
|
|
|
|
|
|
// set frequency etc.
|
2015-02-13 14:30:46 +03:00
|
|
|
ret = ioctl(wavein_fd, SNDCTL_DSP_RESET);
|
2011-04-24 22:45:37 +04:00
|
|
|
if (ret != 0)
|
2015-01-31 13:48:22 +03:00
|
|
|
BX_ERROR(("ioctl(SNDCTL_DSP_RESET): %s", strerror(errno)));
|
2011-04-24 22:45:37 +04:00
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
ret = ioctl(wavein_fd, SNDCTL_DSP_SETFMT, &fmt);
|
2011-04-24 22:45:37 +04:00
|
|
|
if (ret != 0) { // abort if the format is unknown, to avoid playing noise
|
2015-01-31 13:48:22 +03:00
|
|
|
BX_ERROR(("ioctl(SNDCTL_DSP_SETFMT, %d): %s",
|
2011-04-24 22:45:37 +04:00
|
|
|
fmt, strerror(errno)));
|
|
|
|
return BX_SOUNDLOW_ERR;
|
|
|
|
}
|
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
ret = ioctl(wavein_fd, SNDCTL_DSP_CHANNELS, &channels);
|
2011-04-24 22:45:37 +04:00
|
|
|
if (ret != 0) {
|
2015-02-08 11:53:20 +03:00
|
|
|
BX_ERROR(("ioctl(SNDCTL_DSP_CHANNELS, %d): %s",
|
|
|
|
channels, strerror(errno)));
|
2011-04-24 22:45:37 +04:00
|
|
|
return BX_SOUNDLOW_ERR;
|
|
|
|
}
|
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
ret = ioctl(wavein_fd, SNDCTL_DSP_SPEED, &frequency);
|
2011-04-24 22:45:37 +04:00
|
|
|
if (ret != 0) {
|
2015-01-31 13:48:22 +03:00
|
|
|
BX_ERROR(("ioctl(SNDCTL_DSP_SPEED, %d): %s",
|
|
|
|
frequency, strerror(errno)));
|
2011-04-24 22:45:37 +04:00
|
|
|
return BX_SOUNDLOW_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return BX_SOUNDLOW_OK;
|
2011-04-22 17:11:47 +04:00
|
|
|
}
|
|
|
|
|
2015-02-14 20:25:39 +03:00
|
|
|
int bx_soundlow_wavein_oss_c::getwavepacket(int length, Bit8u data[])
|
2011-04-22 17:11:47 +04:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2015-02-13 14:30:46 +03:00
|
|
|
ret = read(wavein_fd, data, length);
|
2011-04-24 22:45:37 +04:00
|
|
|
|
|
|
|
if (ret == length) {
|
|
|
|
return BX_SOUNDLOW_OK;
|
|
|
|
} else {
|
|
|
|
BX_ERROR(("OSS: write error"));
|
|
|
|
return BX_SOUNDLOW_ERR;
|
|
|
|
}
|
2011-04-22 17:11:47 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2015-02-14 20:25:39 +03:00
|
|
|
int bx_soundlow_wavein_oss_c::stopwaverecord()
|
2011-04-22 17:11:47 +04:00
|
|
|
{
|
2011-05-24 20:47:07 +04:00
|
|
|
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
|
|
|
|
bx_pc_system.deactivate_timer(record_timer_index);
|
|
|
|
}
|
2011-03-20 21:02:12 +03:00
|
|
|
return BX_SOUNDLOW_OK;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2015-02-14 20:25:39 +03:00
|
|
|
void bx_soundlow_wavein_oss_c::record_timer_handler(void *this_ptr)
|
2011-04-22 17:11:47 +04:00
|
|
|
{
|
2015-02-14 20:25:39 +03:00
|
|
|
bx_soundlow_wavein_oss_c *class_ptr = (bx_soundlow_wavein_oss_c *) this_ptr;
|
2011-04-24 22:45:37 +04:00
|
|
|
|
2015-02-14 20:25:39 +03:00
|
|
|
class_ptr->record_timer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void bx_soundlow_wavein_oss_c::record_timer(void)
|
|
|
|
{
|
|
|
|
record_handler(this, record_packet_size);
|
|
|
|
}
|
|
|
|
|
2015-02-15 21:32:36 +03:00
|
|
|
// bx_soundlow_midiout_oss_c class implemenzation
|
2015-02-14 20:25:39 +03:00
|
|
|
|
2015-02-15 21:32:36 +03:00
|
|
|
bx_soundlow_midiout_oss_c::bx_soundlow_midiout_oss_c()
|
|
|
|
:bx_soundlow_midiout_c()
|
2015-02-14 20:25:39 +03:00
|
|
|
{
|
|
|
|
midi = NULL;
|
|
|
|
}
|
|
|
|
|
2015-02-15 21:32:36 +03:00
|
|
|
bx_soundlow_midiout_oss_c::~bx_soundlow_midiout_oss_c()
|
2015-02-14 20:25:39 +03:00
|
|
|
{
|
2015-02-17 21:28:25 +03:00
|
|
|
closemidioutput();
|
2015-02-14 20:25:39 +03:00
|
|
|
}
|
|
|
|
|
2015-02-15 21:32:36 +03:00
|
|
|
int bx_soundlow_midiout_oss_c::openmidioutput(const char *mididev)
|
2015-02-14 20:25:39 +03:00
|
|
|
{
|
|
|
|
if ((mididev == NULL) || (strlen(mididev) < 1))
|
|
|
|
return BX_SOUNDLOW_ERR;
|
|
|
|
|
|
|
|
midi = fopen(mididev,"w");
|
|
|
|
|
|
|
|
if (midi == NULL) {
|
|
|
|
BX_ERROR(("Couldn't open midi output device %s: %s",
|
|
|
|
mididev, strerror(errno)));
|
|
|
|
return BX_SOUNDLOW_ERR;
|
|
|
|
}
|
|
|
|
|
2011-04-22 17:11:47 +04:00
|
|
|
return BX_SOUNDLOW_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-14 20:25:39 +03:00
|
|
|
|
2015-02-15 21:32:36 +03:00
|
|
|
int bx_soundlow_midiout_oss_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
|
2015-02-14 20:25:39 +03:00
|
|
|
{
|
|
|
|
UNUSED(delta);
|
|
|
|
|
|
|
|
fputc(command, midi);
|
|
|
|
fwrite(data, 1, length, midi);
|
|
|
|
fflush(midi); // to start playing immediately
|
|
|
|
|
|
|
|
return BX_SOUNDLOW_OK;
|
2011-04-22 17:11:47 +04:00
|
|
|
}
|
|
|
|
|
2015-02-17 21:28:25 +03:00
|
|
|
int bx_soundlow_midiout_oss_c::closemidioutput()
|
|
|
|
{
|
|
|
|
if (midi != NULL) {
|
|
|
|
fclose(midi);
|
|
|
|
midi = NULL;
|
|
|
|
}
|
|
|
|
return BX_SOUNDLOW_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-15 21:32:36 +03:00
|
|
|
// bx_sound_oss_c class implemenzation
|
|
|
|
|
|
|
|
bx_sound_oss_c::bx_sound_oss_c()
|
|
|
|
:bx_sound_lowlevel_c()
|
|
|
|
{
|
|
|
|
BX_INFO(("Sound lowlevel module 'oss' initialized"));
|
|
|
|
}
|
|
|
|
|
|
|
|
bx_soundlow_waveout_c* bx_sound_oss_c::get_waveout()
|
2011-04-22 17:11:47 +04:00
|
|
|
{
|
2015-02-15 21:32:36 +03:00
|
|
|
if (waveout == NULL) {
|
|
|
|
waveout = new bx_soundlow_waveout_oss_c();
|
|
|
|
}
|
|
|
|
return waveout;
|
|
|
|
}
|
2015-02-14 20:25:39 +03:00
|
|
|
|
2015-02-15 21:32:36 +03:00
|
|
|
bx_soundlow_wavein_c* bx_sound_oss_c::get_wavein()
|
|
|
|
{
|
|
|
|
if (wavein == NULL) {
|
|
|
|
wavein = new bx_soundlow_wavein_oss_c();
|
|
|
|
}
|
|
|
|
return wavein;
|
|
|
|
}
|
|
|
|
|
|
|
|
bx_soundlow_midiout_c* bx_sound_oss_c::get_midiout()
|
|
|
|
{
|
|
|
|
if (midiout == NULL) {
|
|
|
|
midiout = new bx_soundlow_midiout_oss_c();
|
|
|
|
}
|
|
|
|
return midiout;
|
2011-04-22 17:11:47 +04:00
|
|
|
}
|
|
|
|
|
2008-07-12 19:21:36 +04:00
|
|
|
#endif
|