2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-02-08 12:05:52 +03:00
|
|
|
// $Id: soundlnx.h,v 1.13 2009-02-08 09:05:52 vruppert Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2001-04-10 06:20:02 +04:00
|
|
|
// Copyright (C) 2001 MandrakeSoft S.A.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// MandrakeSoft S.A.
|
|
|
|
// 43, rue d'Aboukir
|
|
|
|
// 75002 Paris - France
|
|
|
|
// http://www.linux-mandrake.com/
|
|
|
|
// http://www.mandrakesoft.com/
|
|
|
|
//
|
|
|
|
// 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
|
2009-02-08 00:05:31 +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
|
|
|
|
// for Linux using OSS. The current version also supports OSS on FreeBSD and
|
|
|
|
// ALSA PCM output on Linux.
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-09-11 19:39:53 +04:00
|
|
|
#if (defined(linux) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__))
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-07-12 19:21:36 +04:00
|
|
|
#define BX_SOUND_LINUX_BUFSIZE BX_SOUND_OUTPUT_WAVEPACKETSIZE * 2
|
|
|
|
|
|
|
|
#if BX_HAVE_ALSASOUND
|
|
|
|
#define ALSA_PCM_NEW_HW_PARAMS_API
|
|
|
|
#include <alsa/asoundlib.h>
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
class bx_sound_linux_c : public bx_sound_output_c {
|
|
|
|
public:
|
|
|
|
bx_sound_linux_c(bx_sb16_c *sb16);
|
|
|
|
BX_SOUND_VIRTUAL ~bx_sound_linux_c();
|
|
|
|
|
|
|
|
// if virtual functions are used, we have to override them
|
|
|
|
// and define our own. Otherwise this file will just implement
|
|
|
|
// the original functions
|
|
|
|
#ifdef BX_USE_SOUND_VIRTUAL
|
|
|
|
BX_SOUND_VIRTUAL int waveready();
|
|
|
|
BX_SOUND_VIRTUAL int midiready();
|
|
|
|
|
|
|
|
BX_SOUND_VIRTUAL int openmidioutput(char *device);
|
|
|
|
BX_SOUND_VIRTUAL int sendmidicommand(int delta, int command, int length, Bit8u data[]);
|
|
|
|
BX_SOUND_VIRTUAL int closemidioutput();
|
|
|
|
|
|
|
|
BX_SOUND_VIRTUAL int openwaveoutput(char *device);
|
|
|
|
BX_SOUND_VIRTUAL int startwaveplayback(int frequency, int bits, int stereo, int format);
|
|
|
|
BX_SOUND_VIRTUAL int sendwavepacket(int length, Bit8u data[]);
|
|
|
|
BX_SOUND_VIRTUAL int stopwaveplayback();
|
|
|
|
BX_SOUND_VIRTUAL int closewaveoutput();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
2008-07-12 19:21:36 +04:00
|
|
|
#if BX_HAVE_ALSASOUND
|
2008-07-19 16:01:54 +04:00
|
|
|
int alsa_seq_open(char *device);
|
|
|
|
int alsa_seq_output(int delta, int command, int length, Bit8u data[]);
|
2008-07-12 19:21:36 +04:00
|
|
|
int alsa_pcm_open(int frequency, int bits, int stereo, int format);
|
|
|
|
int alsa_pcm_write();
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_sb16_c *sb16;
|
2008-07-12 19:21:36 +04:00
|
|
|
#if BX_HAVE_ALSASOUND
|
2008-07-19 16:01:54 +04:00
|
|
|
bx_bool use_alsa_seq;
|
2008-07-13 19:37:19 +04:00
|
|
|
bx_bool use_alsa_pcm;
|
2008-07-19 16:01:54 +04:00
|
|
|
struct {
|
|
|
|
snd_seq_t *handle;
|
|
|
|
int source_port;
|
|
|
|
} alsa_seq;
|
|
|
|
struct {
|
|
|
|
snd_pcm_t *handle;
|
|
|
|
snd_pcm_uframes_t frames;
|
|
|
|
} alsa_pcm;
|
2008-07-12 19:21:36 +04:00
|
|
|
int dir, alsa_bufsize, audio_bufsize;
|
|
|
|
char *alsa_buffer;
|
2008-07-13 19:37:19 +04:00
|
|
|
#endif
|
2008-07-19 16:01:54 +04:00
|
|
|
FILE *midi;
|
2001-04-10 05:04:59 +04:00
|
|
|
char *wavedevice;
|
|
|
|
int wave;
|
|
|
|
Bit8u audio_buffer[BX_SOUND_LINUX_BUFSIZE];
|
|
|
|
int oldfreq,oldbits,oldstereo,oldformat;
|
|
|
|
};
|
|
|
|
|
2008-07-12 19:21:36 +04:00
|
|
|
#endif
|