- use timer functions for recording only if the record handler is not NULL
- added sound recording framework in the soundosx.* files. I hope someone wil be able to add the required platform specific code.
This commit is contained in:
parent
69c022380f
commit
0638a4174d
@ -39,14 +39,20 @@ Bochs repository moved to the SVN version control !
|
||||
"READ NATIVE MAX ADDRESS EXT"
|
||||
- Sound
|
||||
- ported ES1370 soundcard emulation from Qemu, to enable configure with
|
||||
--enable-es1370 option
|
||||
- sound input implemented in the sound lowlevel module 'linux' (ALSA / OSS)
|
||||
the option --enable-es1370
|
||||
- sound input implemented in the sound lowlevel modules for Windows and
|
||||
Linux (ALSA / OSS)
|
||||
|
||||
- LGPL'd VGABIOS updated to current CVS
|
||||
- fixed DAC palette in 8 bpp VBE and Cirrus modes (using the same palette
|
||||
as VGA mode 0x13)
|
||||
- VBE: added HDTV resolutions (patch by Tristan Schmelcher)
|
||||
|
||||
- GUI and display libraries
|
||||
- vga update interval now uses host timing if the realtime sychronization is
|
||||
enabled with the "clock" option (FIXME: it should always be used - independant
|
||||
from the "clock" setting)
|
||||
|
||||
- SF patches applied
|
||||
[3298173] Breakpoint on VMEXIT event by Jianan Hao
|
||||
[3295737] Fix CopyHost*WordLittleEndian macros by Heikki Lindholm
|
||||
|
@ -536,8 +536,10 @@ int bx_sound_linux_c::closewaveoutput()
|
||||
int bx_sound_linux_c::openwaveinput(const char *wavedev, sound_record_handler_t rh)
|
||||
{
|
||||
record_handler = rh;
|
||||
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "soundlnx");
|
||||
// record timer: inactive, continuous, frequency variable
|
||||
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
|
||||
}
|
||||
#if BX_HAVE_ALSASOUND
|
||||
use_alsa_pcm = !strcmp(wavedev, "alsa");
|
||||
if (use_alsa_pcm) {
|
||||
@ -566,14 +568,16 @@ int bx_sound_linux_c::startwaverecord(int frequency, int bits, bx_bool stereo, i
|
||||
int fmt, ret;
|
||||
int signeddata = format & 1;
|
||||
|
||||
if (bits == 16) shift++;
|
||||
if (stereo) shift++;
|
||||
record_packet_size = (frequency / 10) << shift; // 0.1 sec
|
||||
if (record_packet_size > BX_SOUNDLOW_WAVEPACKETSIZE) {
|
||||
record_packet_size = BX_SOUNDLOW_WAVEPACKETSIZE;
|
||||
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
|
||||
if (bits == 16) shift++;
|
||||
if (stereo) shift++;
|
||||
record_packet_size = (frequency / 10) << shift; // 0.1 sec
|
||||
if (record_packet_size > BX_SOUNDLOW_WAVEPACKETSIZE) {
|
||||
record_packet_size = BX_SOUNDLOW_WAVEPACKETSIZE;
|
||||
}
|
||||
timer_val = (Bit64u)record_packet_size * 1000000 / (frequency << shift);
|
||||
bx_pc_system.activate_timer(record_timer_index, (Bit32u)timer_val, 1);
|
||||
}
|
||||
timer_val = (Bit64u)record_packet_size * 1000000 / (frequency << shift);
|
||||
bx_pc_system.activate_timer(record_timer_index, (Bit32u)timer_val, 1);
|
||||
#if BX_HAVE_ALSASOUND
|
||||
if (use_alsa_pcm) {
|
||||
return alsa_pcm_open(1, frequency, bits, stereo, format);
|
||||
@ -689,7 +693,9 @@ int bx_sound_linux_c::getwavepacket(int length, Bit8u data[])
|
||||
|
||||
int bx_sound_linux_c::stopwaverecord()
|
||||
{
|
||||
bx_pc_system.deactivate_timer(record_timer_index);
|
||||
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
|
||||
bx_pc_system.deactivate_timer(record_timer_index);
|
||||
}
|
||||
#if BX_HAVE_ALSASOUND
|
||||
if (use_alsa_pcm && (alsa_pcm[1].handle != NULL)) {
|
||||
snd_pcm_drain(alsa_pcm[1].handle);
|
||||
|
@ -69,6 +69,7 @@ int bx_soundmod_ctl_c::init_module(const char *type, void **module, logfunctions
|
||||
bx_sound_lowlevel_c::bx_sound_lowlevel_c(logfunctions *dev)
|
||||
{
|
||||
device = dev;
|
||||
record_timer_index = BX_NULL_TIMER_HANDLE;
|
||||
}
|
||||
|
||||
bx_sound_lowlevel_c::~bx_sound_lowlevel_c()
|
||||
@ -141,8 +142,10 @@ int bx_sound_lowlevel_c::openwaveinput(const char *wavedev, sound_record_handler
|
||||
{
|
||||
UNUSED(wavedev);
|
||||
record_handler = rh;
|
||||
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "soundmod");
|
||||
// record timer: inactive, continuous, frequency variable
|
||||
if (rh != NULL) {
|
||||
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "soundmod");
|
||||
// record timer: inactive, continuous, frequency variable
|
||||
}
|
||||
return BX_SOUNDLOW_OK;
|
||||
}
|
||||
|
||||
@ -152,14 +155,16 @@ int bx_sound_lowlevel_c::startwaverecord(int frequency, int bits, bx_bool stereo
|
||||
Bit8u shift = 0;
|
||||
|
||||
UNUSED(format);
|
||||
if (bits == 16) shift++;
|
||||
if (stereo) shift++;
|
||||
record_packet_size = (frequency / 10) << shift; // 0.1 sec
|
||||
if (record_packet_size > BX_SOUNDLOW_WAVEPACKETSIZE) {
|
||||
record_packet_size = BX_SOUNDLOW_WAVEPACKETSIZE;
|
||||
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
|
||||
if (bits == 16) shift++;
|
||||
if (stereo) shift++;
|
||||
record_packet_size = (frequency / 10) << shift; // 0.1 sec
|
||||
if (record_packet_size > BX_SOUNDLOW_WAVEPACKETSIZE) {
|
||||
record_packet_size = BX_SOUNDLOW_WAVEPACKETSIZE;
|
||||
}
|
||||
timer_val = (Bit64u)record_packet_size * 1000000 / (frequency << shift);
|
||||
bx_pc_system.activate_timer(record_timer_index, (Bit32u)timer_val, 1);
|
||||
}
|
||||
timer_val = (Bit64u)record_packet_size * 1000000 / (frequency << shift);
|
||||
bx_pc_system.activate_timer(record_timer_index, (Bit32u)timer_val, 1);
|
||||
return BX_SOUNDLOW_OK;
|
||||
}
|
||||
|
||||
@ -171,7 +176,9 @@ int bx_sound_lowlevel_c::getwavepacket(int length, Bit8u data[])
|
||||
|
||||
int bx_sound_lowlevel_c::stopwaverecord()
|
||||
{
|
||||
bx_pc_system.deactivate_timer(record_timer_index);
|
||||
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
|
||||
bx_pc_system.deactivate_timer(record_timer_index);
|
||||
}
|
||||
return BX_SOUNDLOW_OK;
|
||||
}
|
||||
|
||||
|
@ -571,4 +571,71 @@ void bx_sound_osx_c::nextbuffer (int *outDataSize, void **outData)
|
||||
}
|
||||
#endif
|
||||
|
||||
int bx_sound_osx_c::openwaveinput(const char *wavedev, sound_record_handler_t rh)
|
||||
{
|
||||
UNUSED(wavedev);
|
||||
record_handler = rh;
|
||||
if (rh != NULL) {
|
||||
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "soundosx");
|
||||
// record timer: inactive, continuous, frequency variable
|
||||
}
|
||||
// TODO
|
||||
return BX_SOUNDLOW_OK;
|
||||
}
|
||||
|
||||
int bx_sound_osx_c::startwaverecord(int frequency, int bits, bx_bool stereo, int format)
|
||||
{
|
||||
Bit64u timer_val;
|
||||
Bit8u shift = 0;
|
||||
|
||||
UNUSED(format);
|
||||
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
|
||||
if (bits == 16) shift++;
|
||||
if (stereo) shift++;
|
||||
record_packet_size = (frequency / 10) << shift; // 0.1 sec
|
||||
if (record_packet_size > BX_SOUNDLOW_WAVEPACKETSIZE) {
|
||||
record_packet_size = BX_SOUNDLOW_WAVEPACKETSIZE;
|
||||
}
|
||||
timer_val = (Bit64u)record_packet_size * 1000000 / (frequency << shift);
|
||||
bx_pc_system.activate_timer(record_timer_index, (Bit32u)timer_val, 1);
|
||||
}
|
||||
// TODO
|
||||
return BX_SOUNDLOW_OK;
|
||||
}
|
||||
|
||||
int bx_sound_osx_c::getwavepacket(int length, Bit8u data[])
|
||||
{
|
||||
// TODO
|
||||
memset(data, 0, length);
|
||||
return BX_SOUNDLOW_OK;
|
||||
}
|
||||
|
||||
int bx_sound_osx_c::stopwaverecord()
|
||||
{
|
||||
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
|
||||
bx_pc_system.deactivate_timer(record_timer_index);
|
||||
}
|
||||
// TODO
|
||||
return BX_SOUNDLOW_OK;
|
||||
}
|
||||
|
||||
int bx_sound_osx_c::closewaveinput()
|
||||
{
|
||||
stopwaverecord();
|
||||
// TODO
|
||||
return BX_SOUNDLOW_OK;
|
||||
}
|
||||
|
||||
void bx_sound_osx_c::record_timer_handler(void *this_ptr)
|
||||
{
|
||||
bx_sound_osx_c *class_ptr = (bx_sound_osx_c *) this_ptr;
|
||||
|
||||
class_ptr->record_timer();
|
||||
}
|
||||
|
||||
void bx_sound_osx_c::record_timer(void)
|
||||
{
|
||||
record_handler(this->device, record_packet_size);
|
||||
}
|
||||
|
||||
#endif // defined(macintosh)
|
||||
|
@ -57,6 +57,14 @@ public:
|
||||
void nextbuffer(int *outDataSize, void **outData);
|
||||
#endif
|
||||
|
||||
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);
|
||||
private:
|
||||
int MidiOpen;
|
||||
int WaveOpen;
|
||||
|
@ -515,8 +515,10 @@ int bx_sound_windows_c::openwaveinput(const char *wavedev, sound_record_handler_
|
||||
{
|
||||
UNUSED(wavedev);
|
||||
record_handler = rh;
|
||||
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "soundmod");
|
||||
// record timer: inactive, continuous, frequency variable
|
||||
if (rh != NULL) {
|
||||
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "soundwin");
|
||||
// record timer: inactive, continuous, frequency variable
|
||||
}
|
||||
recording = 0;
|
||||
return BX_SOUNDLOW_OK;
|
||||
}
|
||||
@ -554,15 +556,16 @@ int bx_sound_windows_c::startwaverecord(int frequency, int bits, bx_bool stereo,
|
||||
Bit8u shift = 0;
|
||||
MMRESULT result;
|
||||
|
||||
if (bits == 16) shift++;
|
||||
if (stereo) shift++;
|
||||
record_packet_size = (frequency / 10) << shift; // 0.1 sec
|
||||
if (record_packet_size > BX_SOUNDLOW_WAVEPACKETSIZE) {
|
||||
record_packet_size = BX_SOUNDLOW_WAVEPACKETSIZE;
|
||||
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
|
||||
if (bits == 16) shift++;
|
||||
if (stereo) shift++;
|
||||
record_packet_size = (frequency / 10) << shift; // 0.1 sec
|
||||
if (record_packet_size > BX_SOUNDLOW_WAVEPACKETSIZE) {
|
||||
record_packet_size = BX_SOUNDLOW_WAVEPACKETSIZE;
|
||||
}
|
||||
timer_val = (Bit64u)record_packet_size * 1000000 / (frequency << shift);
|
||||
bx_pc_system.activate_timer(record_timer_index, (Bit32u)timer_val, 1);
|
||||
}
|
||||
timer_val = (Bit64u)record_packet_size * 1000000 / (frequency << shift);
|
||||
bx_pc_system.activate_timer(record_timer_index, (Bit32u)timer_val, 1);
|
||||
|
||||
// check if any of the properties have changed
|
||||
if ((WaveInfo[1].frequency != frequency) ||
|
||||
(WaveInfo[1].bits != bits) ||
|
||||
@ -612,7 +615,9 @@ int bx_sound_windows_c::getwavepacket(int length, Bit8u data[])
|
||||
|
||||
int bx_sound_windows_c::stopwaverecord()
|
||||
{
|
||||
bx_pc_system.deactivate_timer(record_timer_index);
|
||||
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
|
||||
bx_pc_system.deactivate_timer(record_timer_index);
|
||||
}
|
||||
if (WaveInOpen && recording) {
|
||||
do {} while (waveInUnprepareHeader(hWaveIn, WaveInHdr, sizeof(WAVEHDR)) == WAVERR_STILLPLAYING);
|
||||
recording = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user