2011-01-26 02:29:08 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2011-01-26 02:29:08 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2013-07-13 21:37:48 +04:00
|
|
|
// Copyright (C) 2011-2013 The Bochs Project
|
2011-01-26 02:29:08 +03: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
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
2011-03-20 21:02:12 +03:00
|
|
|
// Common code for sound lowlevel modules
|
2011-01-26 02:29:08 +03:00
|
|
|
|
2011-03-20 21:02:12 +03:00
|
|
|
// this is the size of a sound packet used for sending and receiving
|
2011-02-11 01:58:22 +03:00
|
|
|
// it should not be too large to avoid lag, and not too
|
|
|
|
// small to avoid unnecessary overhead.
|
2011-03-20 21:02:12 +03:00
|
|
|
#define BX_SOUNDLOW_WAVEPACKETSIZE 8192
|
2011-02-11 01:58:22 +03:00
|
|
|
|
2011-02-15 00:14:20 +03:00
|
|
|
// Definitions for the output functions
|
2011-03-20 21:02:12 +03:00
|
|
|
#define BX_SOUNDLOW_OK 0
|
|
|
|
#define BX_SOUNDLOW_ERR 1
|
2011-01-26 02:29:08 +03:00
|
|
|
|
2012-06-09 00:49:39 +04:00
|
|
|
// Lowlvel sound modules
|
|
|
|
#define BX_SOUNDLOW_DUMMY 0
|
|
|
|
#define BX_SOUNDLOW_LINUX 1
|
|
|
|
#define BX_SOUNDLOW_OSX 2
|
|
|
|
#define BX_SOUNDLOW_WIN 3
|
|
|
|
#define BX_SOUNDLOW_SDL 4
|
2013-07-14 19:14:53 +04:00
|
|
|
#define BX_SOUNDLOW_ALSA 5
|
2012-06-09 00:49:39 +04:00
|
|
|
|
2011-04-04 20:07:24 +04:00
|
|
|
typedef Bit32u (*sound_record_handler_t)(void *arg, Bit32u len);
|
|
|
|
|
2012-05-20 18:19:49 +04:00
|
|
|
class bx_sound_lowlevel_c;
|
|
|
|
|
2011-02-15 00:14:20 +03:00
|
|
|
// Pseudo device that loads the lowlevel sound module
|
|
|
|
class bx_soundmod_ctl_c : public bx_soundmod_ctl_stub_c {
|
|
|
|
public:
|
2012-05-20 18:19:49 +04:00
|
|
|
bx_soundmod_ctl_c();
|
2013-06-24 23:19:12 +04:00
|
|
|
virtual ~bx_soundmod_ctl_c();
|
|
|
|
virtual void init(void);
|
|
|
|
virtual void* get_module();
|
2012-05-20 18:19:49 +04:00
|
|
|
virtual bx_bool beep_on(float frequency);
|
|
|
|
virtual bx_bool beep_off();
|
2013-07-13 21:37:48 +04:00
|
|
|
virtual void VOC_init_file(FILE *stream);
|
|
|
|
virtual void VOC_write_block(FILE *stream, int block, Bit32u headerlen,
|
|
|
|
Bit8u header[], Bit32u datalen, Bit8u data[]);
|
2012-05-20 18:19:49 +04:00
|
|
|
private:
|
|
|
|
bx_sound_lowlevel_c *soundmod;
|
2011-02-15 00:14:20 +03:00
|
|
|
};
|
|
|
|
|
2011-03-20 21:02:12 +03:00
|
|
|
// The class with the input/output functions
|
2011-03-19 15:57:13 +03:00
|
|
|
class bx_sound_lowlevel_c : public logfunctions {
|
2011-01-26 02:29:08 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
/*
|
2011-03-20 21:02:12 +03:00
|
|
|
These functions are the sound lowlevel functions, sending
|
|
|
|
the music or sending/receiving sound to/from the OS specific driver.
|
2011-01-26 02:29:08 +03:00
|
|
|
They are in a different file (soundxxx.cc) because they are
|
2011-03-20 21:02:12 +03:00
|
|
|
non-portable, while everything in the soundcard code is portable
|
2011-01-26 02:29:08 +03:00
|
|
|
*/
|
|
|
|
|
2013-06-24 23:19:12 +04:00
|
|
|
bx_sound_lowlevel_c();
|
2011-03-19 15:57:13 +03:00
|
|
|
virtual ~bx_sound_lowlevel_c();
|
2011-01-26 02:29:08 +03:00
|
|
|
|
2012-06-09 00:49:39 +04:00
|
|
|
virtual int get_type() {return BX_SOUNDLOW_DUMMY;}
|
|
|
|
|
2011-01-26 02:29:08 +03:00
|
|
|
virtual int waveready();
|
|
|
|
virtual int midiready();
|
|
|
|
|
2011-02-13 20:26:52 +03:00
|
|
|
virtual int openmidioutput(const char *mididev);
|
2011-01-26 02:29:08 +03:00
|
|
|
virtual int sendmidicommand(int delta, int command, int length, Bit8u data[]);
|
|
|
|
virtual int closemidioutput();
|
|
|
|
|
2011-02-13 20:26:52 +03:00
|
|
|
virtual int openwaveoutput(const char *wavedev);
|
2011-03-20 21:02:12 +03:00
|
|
|
virtual int startwaveplayback(int frequency, int bits, bx_bool stereo, int format);
|
2011-01-26 02:29:08 +03:00
|
|
|
virtual int sendwavepacket(int length, Bit8u data[]);
|
|
|
|
virtual int stopwaveplayback();
|
|
|
|
virtual int closewaveoutput();
|
2011-04-04 20:07:24 +04:00
|
|
|
|
|
|
|
virtual int openwaveinput(const char *wavedev, sound_record_handler_t rh);
|
|
|
|
virtual int startwaverecord(int frequency, int bits, bx_bool stereo, int format);
|
|
|
|
virtual int getwavepacket(int length, Bit8u data[]);
|
|
|
|
virtual int stopwaverecord();
|
|
|
|
virtual int closewaveinput();
|
|
|
|
|
|
|
|
static void record_timer_handler(void *);
|
|
|
|
void record_timer(void);
|
2011-01-26 02:29:08 +03:00
|
|
|
protected:
|
2011-04-04 20:07:24 +04:00
|
|
|
int record_timer_index;
|
2011-06-27 00:22:04 +04:00
|
|
|
int record_packet_size;
|
2011-04-04 20:07:24 +04:00
|
|
|
sound_record_handler_t record_handler;
|
2011-01-26 02:29:08 +03:00
|
|
|
};
|