- ALSA code cleanup: removed unused client and queue
[bochs-mirror.git] / iodev / soundlnx.h
blob26373f49dd85af977affa2a31fea73abf53e0130
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: soundlnx.h,v 1.11 2008/07/20 08:08:23 vruppert Exp $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (C) 2001 MandrakeSoft S.A.
6 //
7 // MandrakeSoft S.A.
8 // 43, rue d'Aboukir
9 // 75002 Paris - France
10 // http://www.linux-mandrake.com/
11 // http://www.mandrakesoft.com/
13 // This library is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU Lesser General Public
15 // License as published by the Free Software Foundation; either
16 // version 2 of the License, or (at your option) any later version.
18 // This library is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 // Josef Drexler coded the original version of the lowlevel sound support
28 // for Linux using OSS. The current version also supports OSS on FreeBSD and
29 // ALSA PCM output on Linux.
31 #if (defined(linux) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__))
33 #define BX_SOUND_LINUX_BUFSIZE BX_SOUND_OUTPUT_WAVEPACKETSIZE * 2
35 #if BX_HAVE_ALSASOUND
36 #define ALSA_PCM_NEW_HW_PARAMS_API
37 #include <alsa/asoundlib.h>
38 #endif
40 class bx_sound_linux_c : public bx_sound_output_c {
41 public:
42 bx_sound_linux_c(bx_sb16_c *sb16);
43 BX_SOUND_VIRTUAL ~bx_sound_linux_c();
45 // if virtual functions are used, we have to override them
46 // and define our own. Otherwise this file will just implement
47 // the original functions
48 #ifdef BX_USE_SOUND_VIRTUAL
49 BX_SOUND_VIRTUAL int waveready();
50 BX_SOUND_VIRTUAL int midiready();
52 BX_SOUND_VIRTUAL int openmidioutput(char *device);
53 BX_SOUND_VIRTUAL int sendmidicommand(int delta, int command, int length, Bit8u data[]);
54 BX_SOUND_VIRTUAL int closemidioutput();
56 BX_SOUND_VIRTUAL int openwaveoutput(char *device);
57 BX_SOUND_VIRTUAL int startwaveplayback(int frequency, int bits, int stereo, int format);
58 BX_SOUND_VIRTUAL int sendwavepacket(int length, Bit8u data[]);
59 BX_SOUND_VIRTUAL int stopwaveplayback();
60 BX_SOUND_VIRTUAL int closewaveoutput();
61 #endif
63 private:
64 #if BX_HAVE_ALSASOUND
65 int alsa_seq_open(char *device);
66 int alsa_seq_output(int delta, int command, int length, Bit8u data[]);
67 int alsa_pcm_open(int frequency, int bits, int stereo, int format);
68 int alsa_pcm_write();
69 #endif
70 bx_sb16_c *sb16;
71 #if BX_HAVE_ALSASOUND
72 bx_bool use_alsa_seq;
73 bx_bool use_alsa_pcm;
74 struct {
75 snd_seq_t *handle;
76 int source_port;
77 } alsa_seq;
78 struct {
79 snd_pcm_t *handle;
80 snd_pcm_uframes_t frames;
81 } alsa_pcm;
82 int dir, alsa_bufsize, audio_bufsize;
83 char *alsa_buffer;
84 #endif
85 FILE *midi;
86 char *wavedevice;
87 int wave;
88 Bit8u audio_buffer[BX_SOUND_LINUX_BUFSIZE];
89 int oldfreq,oldbits,oldstereo,oldformat;
92 #endif