newlib-cygwin/winsup/cygwin/fhandler/dsp.cc

1534 lines
37 KiB
C++
Raw Normal View History

2011-06-06 13:02:13 +08:00
/* fhandler_dev_dsp: code to emulate OSS sound model /dev/dsp
Written by Andy Younger (andy@snoogie.demon.co.uk)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
Extended by Gerd Spalink (Gerd.Spalink@t-online.de)
to support recording from the audio input
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <sys/soundcard.h>
#include "cygerrno.h"
#include "security.h"
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
#include "path.h"
#include "fhandler.h"
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
#include "dtable.h"
#include "cygheap.h"
#include "sigproc.h"
#include "cygwait.h"
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
/*------------------------------------------------------------------------
Simple encapsulation of the win32 audio device.
Implementation Notes
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
1. Audio structures are malloced just before the first read or
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
write to /dev/dsp. The actual buffer size is determined at that time,
such that one buffer holds about 125ms of audio data.
At the time of this writing, 12 buffers are allocated,
so that up to 1.5 seconds can be buffered within Win32.
The buffer size can be queried with the ioctl SNDCTL_DSP_GETBLKSIZE,
but for this implementation only returns meaningful results if
sampling rate, number of channels and number of bits per sample
are not changed afterwards.
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
The audio structures are freed when the device is reset or closed,
and they are not passed to exec'ed processes.
The dev_ member is cleared after a fork. This forces the child
to reopen the audio device._
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
2. Every open call creates a new instance of the handler. After a
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
successful open, every subsequent open from the same process
to the device fails with EBUSY.
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
The structures are shared between duped handles, but not with
children. They only inherit the settings from the parent.
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
*/
enum { DEFAULT_BLOCKS = 12, MAX_BLOCKS = 256 };
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
class fhandler_dev_dsp::Audio
{ // This class contains functionality common to Audio_in and Audio_out
public:
Audio (fhandler_dev_dsp *my_fh);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
~Audio ();
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
class queue;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
bool isvalid ();
void setconvert (int format);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void convert_none (unsigned char *buffer, int size_bytes) { }
void convert_U8_S8 (unsigned char *buffer, int size_bytes);
void convert_S16LE_U16LE (unsigned char *buffer, int size_bytes);
void convert_S16LE_U16BE (unsigned char *buffer, int size_bytes);
void convert_S16LE_S16BE (unsigned char *buffer, int size_bytes);
void fillFormat (WAVEFORMATEX * format,
int rate, int bits, int channels);
static unsigned blockSize (int rate, int bits, int channels);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void (fhandler_dev_dsp::Audio::*convert_)
(unsigned char *buffer, int size_bytes);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
int bufferIndex_; // offset into pHdr_->lpData
WAVEHDR *pHdr_; // data to be filled by write
WAVEHDR wavehdr_[MAX_BLOCKS];
char *bigwavebuffer_; // audio samples only
// Member variables below must be locked
queue *Qisr2app_; // blocks passed from wave callback
fhandler_dev_dsp *fh;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
};
class fhandler_dev_dsp::Audio::queue
{ // non-blocking fixed size queues for buffer management
public:
queue (int depth = 4);
~queue ();
bool send (WAVEHDR *); // queue an item, returns true if successful
bool recv (WAVEHDR **); // retrieve an item, returns true if successful
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
void reset ();
int query (); // return number of items queued
inline void lock () { EnterCriticalSection (&lock_); }
inline void unlock () { LeaveCriticalSection (&lock_); }
inline void dellock () { debug_printf ("Deleting Critical Section"); DeleteCriticalSection (&lock_); }
bool isvalid () { return storage_; }
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
private:
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
CRITICAL_SECTION lock_;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
int head_;
int tail_;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
int depth_;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
WAVEHDR **storage_;
};
2013-04-23 17:44:36 +08:00
static void CALLBACK waveOut_callback (HWAVEOUT hWave, UINT msg,
DWORD_PTR instance, DWORD_PTR param1,
DWORD_PTR param2);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
class fhandler_dev_dsp::Audio_out: public Audio
{
public:
Audio_out (fhandler_dev_dsp *my_fh) : Audio (my_fh) {}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
void fork_fixup (HANDLE parent);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
bool query (int rate, int bits, int channels);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
bool start ();
void stop (bool immediately = false);
int write (const char *pSampleData, int nBytes);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void buf_info (audio_buf_info *p, int rate, int bits, int channels);
static void default_buf_info (audio_buf_info *p, int rate, int bits, int channels);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void callback_sampledone (WAVEHDR *pHdr);
bool parsewav (const char *&pData, int &nBytes,
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
int rate, int bits, int channels);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
private:
void init (unsigned blockSize);
void waitforallsent ();
bool waitforspace ();
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
bool sendcurrent ();
HWAVEOUT dev_; // The wave device
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
/* Private copies of audiofreq_, audiobits_, audiochannels_,
possibly set from wave file */
int freq_;
int bits_;
int channels_;
friend fhandler_dev_dsp;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
};
2013-04-23 17:44:36 +08:00
static void CALLBACK waveIn_callback (HWAVEIN hWave, UINT msg,
DWORD_PTR instance, DWORD_PTR param1,
DWORD_PTR param2);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
class fhandler_dev_dsp::Audio_in: public Audio
{
public:
Audio_in (fhandler_dev_dsp *my_fh) : Audio (my_fh) {}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
void fork_fixup (HANDLE parent);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
bool query (int rate, int bits, int channels);
bool start (int rate, int bits, int channels);
void stop ();
bool read (char *pSampleData, int &nBytes);
void buf_info (audio_buf_info *p, int rate, int bits, int channels);
static void default_buf_info (audio_buf_info *p, int rate, int bits, int channels);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void callback_blockfull (WAVEHDR *pHdr);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
private:
bool init (unsigned blockSize);
bool queueblock (WAVEHDR *pHdr);
bool waitfordata (); // blocks until we have a good pHdr_ unless O_NONBLOCK
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
HWAVEIN dev_;
};
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
/* --------------------------------------------------------------------
Implementation */
// Simple fixed length FIFO queue implementation for audio buffer management
fhandler_dev_dsp::Audio::queue::queue (int depth)
{
// allow space for one extra object in the queue
// so we can distinguish full and empty status
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
depth_ = depth;
storage_ = new WAVEHDR *[depth_ + 1];
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
fhandler_dev_dsp::Audio::queue::~queue ()
{
delete[] storage_;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
void
fhandler_dev_dsp::Audio::queue::reset ()
{
/* When starting, after reset and after fork */
head_ = tail_ = 0;
debug_printf ("InitializeCriticalSection");
memset (&lock_, 0, sizeof (lock_));
InitializeCriticalSection (&lock_);
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
bool
fhandler_dev_dsp::Audio::queue::send (WAVEHDR *x)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
bool res = false;
lock ();
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (query () == depth_)
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
system_printf ("Queue overflow");
else
{
storage_[tail_] = x;
if (++tail_ > depth_)
tail_ = 0;
res = true;
}
unlock ();
return res;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
bool
fhandler_dev_dsp::Audio::queue::recv (WAVEHDR **x)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
bool res = false;
lock ();
if (query () != 0)
{
*x = storage_[head_];
if (++head_ > depth_)
head_ = 0;
res = true;
}
unlock ();
return res;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
int
fhandler_dev_dsp::Audio::queue::query ()
{
int n = tail_ - head_;
if (n < 0)
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
n += depth_ + 1;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return n;
}
// Audio class implements functionality need for both read and write
fhandler_dev_dsp::Audio::Audio (fhandler_dev_dsp *my_fh)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
bigwavebuffer_ = NULL;
fh = my_fh;
Qisr2app_ = new queue (fh->fragstotal_);
convert_ = &fhandler_dev_dsp::Audio::convert_none;
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio::~Audio ()
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
debug_printf("");
delete Qisr2app_;
delete[] bigwavebuffer_;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
inline bool
fhandler_dev_dsp::Audio::isvalid ()
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
return bigwavebuffer_ && Qisr2app_ && Qisr2app_->isvalid ();
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
fhandler_dev_dsp::Audio::setconvert (int format)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
switch (format)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
case AFMT_S8:
convert_ = &fhandler_dev_dsp::Audio::convert_U8_S8;
debug_printf ("U8_S8");
break;
case AFMT_U16_LE:
convert_ = &fhandler_dev_dsp::Audio::convert_S16LE_U16LE;
debug_printf ("S16LE_U16LE");
break;
case AFMT_U16_BE:
convert_ = &fhandler_dev_dsp::Audio::convert_S16LE_U16BE;
debug_printf ("S16LE_U16BE");
break;
case AFMT_S16_BE:
convert_ = &fhandler_dev_dsp::Audio::convert_S16LE_S16BE;
debug_printf ("S16LE_S16BE");
break;
default:
convert_ = &fhandler_dev_dsp::Audio::convert_none;
debug_printf ("none");
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
void
fhandler_dev_dsp::Audio::convert_U8_S8 (unsigned char *buffer,
int size_bytes)
{
while (size_bytes-- > 0)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
*buffer ^= (unsigned char)0x80;
buffer++;
}
}
void
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio::convert_S16LE_U16BE (unsigned char *buffer,
int size_bytes)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
int size_samples = size_bytes / 2;
unsigned char hi, lo;
while (size_samples-- > 0)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
hi = buffer[0];
lo = buffer[1];
*buffer++ = lo;
*buffer++ = hi ^ (unsigned char)0x80;
}
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void
fhandler_dev_dsp::Audio::convert_S16LE_U16LE (unsigned char *buffer,
int size_bytes)
{
int size_samples = size_bytes / 2;
while (size_samples-- > 0)
{
buffer++;
*buffer ^= (unsigned char)0x80;
buffer++;
}
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void
fhandler_dev_dsp::Audio::convert_S16LE_S16BE (unsigned char *buffer,
int size_bytes)
{
int size_samples = size_bytes / 2;
unsigned char hi, lo;
while (size_samples-- > 0)
{
hi = buffer[0];
lo = buffer[1];
*buffer++ = lo;
*buffer++ = hi;
}
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void
fhandler_dev_dsp::Audio::fillFormat (WAVEFORMATEX * format,
int rate, int bits, int channels)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
memset (format, 0, sizeof (*format));
format->wFormatTag = WAVE_FORMAT_PCM;
format->wBitsPerSample = bits;
format->nChannels = channels;
format->nSamplesPerSec = rate;
format->nAvgBytesPerSec = format->nSamplesPerSec * format->nChannels
* (bits / 8);
format->nBlockAlign = format->nChannels * (bits / 8);
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
// calculate a good block size
unsigned
fhandler_dev_dsp::Audio::blockSize (int rate, int bits, int channels)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
unsigned blockSize;
blockSize = ((bits / 8) * channels * rate) / 8; // approx 125ms per block
// round up to multiple of 64
blockSize += 0x3f;
blockSize &= ~0x3f;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return blockSize;
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
//=======================================================================
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
void
fhandler_dev_dsp::Audio_out::fork_fixup (HANDLE parent)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
/* Null dev_.
It will be necessary to reset the queue, open the device
and create a lock when writing */
2013-04-23 17:44:36 +08:00
debug_printf ("parent=%p", parent);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
dev_ = NULL;
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
bool
fhandler_dev_dsp::Audio_out::query (int rate, int bits, int channels)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
WAVEFORMATEX format;
MMRESULT rc;
fillFormat (&format, rate, bits, channels);
rc = waveOutOpen (NULL, WAVE_MAPPER, &format, 0L, 0L, WAVE_FORMAT_QUERY);
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveOutOpen(freq=%d bits=%d channels=%d)", rc, rate, bits, channels);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return (rc == MMSYSERR_NOERROR);
}
bool
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
fhandler_dev_dsp::Audio_out::start ()
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
WAVEFORMATEX format;
MMRESULT rc;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (dev_)
return true;
/* In case of fork bigwavebuffer may already exist */
if (!bigwavebuffer_)
bigwavebuffer_ = new char[fh->fragstotal_ * fh->fragsize_];
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (!isvalid ())
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return false;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
fillFormat (&format, freq_, bits_, channels_);
2013-04-23 17:44:36 +08:00
rc = waveOutOpen (&dev_, WAVE_MAPPER, &format, (DWORD_PTR) waveOut_callback,
(DWORD_PTR) this, CALLBACK_FUNCTION);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (rc == MMSYSERR_NOERROR)
init (fh->fragsize_);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveOutOpen(freq=%d bits=%d channels=%d)", rc, freq_, bits_, channels_);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return (rc == MMSYSERR_NOERROR);
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void
fhandler_dev_dsp::Audio_out::stop (bool immediately)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
MMRESULT rc;
WAVEHDR *pHdr;
2013-04-23 17:44:36 +08:00
debug_printf ("dev_=%p", dev_);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (dev_)
{
if (!immediately)
{
sendcurrent (); // force out last block whatever size..
waitforallsent (); // block till finished..
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
rc = waveOutReset (dev_);
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveOutReset()", rc);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
while (Qisr2app_->recv (&pHdr))
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
rc = waveOutUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR));
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveOutUnprepareHeader(%p)", rc, pHdr);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
no_thread_exit_protect for_now (true);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
rc = waveOutClose (dev_);
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveOutClose()", rc);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
Qisr2app_->dellock ();
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
void
fhandler_dev_dsp::Audio_out::init (unsigned blockSize)
{
int i;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
// internally queue all of our buffer for later use by write
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
Qisr2app_->reset ();
for (i = 0; i < fh->fragstotal_; i++)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
wavehdr_[i].lpData = &bigwavebuffer_[i * blockSize];
wavehdr_[i].dwUser = (int) blockSize;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
wavehdr_[i].dwFlags = 0;
if (!Qisr2app_->send (&wavehdr_[i]))
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
system_printf ("Internal Error i=%d", i);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
break; // should not happen
}
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
pHdr_ = NULL;
}
int
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio_out::write (const char *pSampleData, int nBytes)
{
int bytes_to_write = nBytes;
while (bytes_to_write != 0)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{ // Block if all blocks used until at least one is free
if (!waitforspace ())
{
if (bytes_to_write != nBytes)
break;
return -1;
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
int sizeleft = (int)pHdr_->dwUser - bufferIndex_;
if (bytes_to_write < sizeleft)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{ // all data fits into the current block, with some space left
memcpy (&pHdr_->lpData[bufferIndex_], pSampleData, bytes_to_write);
bufferIndex_ += bytes_to_write;
bytes_to_write = 0;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
break;
}
else
{ // data will fill up the current block
memcpy (&pHdr_->lpData[bufferIndex_], pSampleData, sizeleft);
bufferIndex_ += sizeleft;
sendcurrent ();
pSampleData += sizeleft;
bytes_to_write -= sizeleft;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
}
return nBytes - bytes_to_write;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void
fhandler_dev_dsp::Audio_out::buf_info (audio_buf_info *p,
int rate, int bits, int channels)
{
if (dev_)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
/* If the device is running we use the internal values,
possibly set from the wave file. */
p->fragstotal = fh->fragstotal_;
p->fragsize = fh->fragsize_;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
p->fragments = Qisr2app_->query ();
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (pHdr_ != NULL)
p->bytes = (int)pHdr_->dwUser - bufferIndex_
+ p->fragsize * p->fragments;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
else
p->bytes = p->fragsize * p->fragments;
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
else
{
default_buf_info(p, rate, bits, channels);
}
}
void fhandler_dev_dsp::Audio_out::default_buf_info (audio_buf_info *p,
int rate, int bits, int channels)
{
p->fragstotal = DEFAULT_BLOCKS;
p->fragsize = blockSize (rate, bits, channels);
p->fragments = p->fragstotal;
p->bytes = p->fragsize * p->fragments;
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
/* This is called on an interupt so use locking.. Note Qisr2app_
is used so we should wrap all references to it in locks. */
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
inline void
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio_out::callback_sampledone (WAVEHDR *pHdr)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
Qisr2app_->send (pHdr);
ReleaseSemaphore (fh->get_select_sem (),
get_obj_handle_count (fh->get_select_sem ()) - 1, NULL);
}
bool
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio_out::waitforspace ()
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
WAVEHDR *pHdr;
MMRESULT rc = WAVERR_STILLPLAYING;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (pHdr_ != NULL)
return true;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
while (!Qisr2app_->recv (&pHdr))
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
if (fh->is_nonblocking ())
{
set_errno (EAGAIN);
return false;
}
debug_printf ("1ms");
switch (cygwait (1))
{
case WAIT_SIGNALED:
if (!_my_tls.call_signal_handler ())
{
set_errno (EINTR);
return false;
}
break;
case WAIT_CANCELED:
pthread::static_cancel_self ();
/*NOTREACHED*/
default:
break;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
}
if (pHdr->dwFlags)
{
/* Errors are ignored here. They will probbaly cause a failure
in the subsequent PrepareHeader */
rc = waveOutUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR));
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveOutUnprepareHeader(%p)", rc, pHdr);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
pHdr_ = pHdr;
bufferIndex_ = 0;
return true;
}
void
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio_out::waitforallsent ()
{
while (Qisr2app_->query () != fh->fragstotal_)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
debug_printf ("%d blocks in Qisr2app", Qisr2app_->query ());
cygwait (1);
sendcurrent ();
}
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
// send the block described by pHdr_ and bufferIndex_ to wave device
bool
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio_out::sendcurrent ()
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
WAVEHDR *pHdr = pHdr_;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
MMRESULT rc;
2013-04-23 17:44:36 +08:00
debug_printf ("pHdr=%p bytes=%d", pHdr, bufferIndex_);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (pHdr_ == NULL)
return false;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
pHdr_ = NULL;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
// Sample buffer conversion
(this->*convert_) ((unsigned char *)pHdr->lpData, bufferIndex_);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
// Send internal buffer out to the soundcard
pHdr->dwBufferLength = bufferIndex_;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
rc = waveOutPrepareHeader (dev_, pHdr, sizeof (WAVEHDR));
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveOutPrepareHeader(%p)", rc, pHdr);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (rc == MMSYSERR_NOERROR)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
rc = waveOutWrite (dev_, pHdr, sizeof (WAVEHDR));
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveOutWrite(%p)", rc, pHdr);
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (rc == MMSYSERR_NOERROR)
return true;
/* FIXME: Should we return an error instead ?*/
pHdr->dwFlags = 0; /* avoid calling UnprepareHeader again */
Qisr2app_->send (pHdr);
return false;
}
//------------------------------------------------------------------------
// Call back routine
static void CALLBACK
2013-04-23 17:44:36 +08:00
waveOut_callback (HWAVEOUT hWave, UINT msg, DWORD_PTR instance,
DWORD_PTR param1, DWORD_PTR param2)
{
if (msg == WOM_DONE)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio_out *ptr =
(fhandler_dev_dsp::Audio_out *) instance;
ptr->callback_sampledone ((WAVEHDR *) param1);
}
}
//------------------------------------------------------------------------
// wav file detection..
#pragma pack(1)
struct wavchunk
{
char id[4];
unsigned int len;
};
struct wavformat
{
unsigned short wFormatTag;
unsigned short wChannels;
unsigned int dwSamplesPerSec;
unsigned int dwAvgBytesPerSec;
unsigned short wBlockAlign;
unsigned short wBitsPerSample;
};
#pragma pack()
bool
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio_out::parsewav (const char * &pData, int &nBytes,
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
int dev_freq, int dev_bits, int dev_channels)
{
int len;
const char *end = pData + nBytes;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
const char *pDat;
int skip = 0;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
/* Start with default values from the device handler */
freq_ = dev_freq;
bits_ = dev_bits;
channels_ = dev_channels;
setconvert (bits_ == 8 ? AFMT_U8 : AFMT_S16_LE);
// Check alignment first: A lot of the code below depends on it
2013-04-23 17:44:36 +08:00
if (((uintptr_t)pData & 0x3) != 0)
return false;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (!(pData[0] == 'R' && pData[1] == 'I'
&& pData[2] == 'F' && pData[3] == 'F'))
return false;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (!(pData[8] == 'W' && pData[9] == 'A'
&& pData[10] == 'V' && pData[11] == 'E'))
return false;
len = *(int *) &pData[4];
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
len -= 12;
pDat = pData + 12;
skip = 12;
while ((len > 0) && (pDat + sizeof (wavchunk) < end))
{ /* We recognize two kinds of wavchunk:
"fmt " for the PCM parameters (only PCM supported here)
"data" for the start of PCM data */
wavchunk * pChunk = (wavchunk *) pDat;
int blklen = pChunk-> len;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (pChunk->id[0] == 'f' && pChunk->id[1] == 'm'
&& pChunk->id[2] == 't' && pChunk->id[3] == ' ')
{
wavformat *format = (wavformat *) (pChunk + 1);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if ((char *) (format + 1) >= end)
return false;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
// We have found the parameter chunk
if (format->wFormatTag == 0x0001)
{ // Micr*s*ft PCM; check if parameters work with our device
if (query (format->dwSamplesPerSec, format->wBitsPerSample,
format->wChannels))
{ // return the parameters we found
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
freq_ = format->dwSamplesPerSec;
bits_ = format->wBitsPerSample;
channels_ = format->wChannels;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
}
}
else
{
if (pChunk->id[0] == 'd' && pChunk->id[1] == 'a'
&& pChunk->id[2] == 't' && pChunk->id[3] == 'a')
{ // throw away all the header & not output it to the soundcard.
skip += sizeof (wavchunk);
debug_printf ("Discard %d bytes wave header", skip);
pData += skip;
nBytes -= skip;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
setconvert (bits_ == 8 ? AFMT_U8 : AFMT_S16_LE);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return true;
}
}
pDat += blklen + sizeof (wavchunk);
skip += blklen + sizeof (wavchunk);
len -= blklen + sizeof (wavchunk);
}
return false;
}
/* ========================================================================
Buffering concept for Audio_in:
On the first read, we queue all blocks of our bigwavebuffer
for reception and start the wave-in device.
We manage queues of pointers to WAVEHDR
When a block has been filled, the callback puts the corresponding
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
WAVEHDR pointer into a queue.
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
The function read() blocks (polled, sigh) until at least one good buffer
has arrived, then the data is copied into the buffer provided to read().
After a buffer has been fully used by read(), it is queued again
to the wave-in device immediately.
The function read() iterates until all data requested has been
received, there is no way to interrupt it */
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
void
fhandler_dev_dsp::Audio_in::fork_fixup (HANDLE parent)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
/* Null dev_.
It will be necessary to reset the queue, open the device
and create a lock when reading */
2013-04-23 17:44:36 +08:00
debug_printf ("parent=%p", parent);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
dev_ = NULL;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
bool
fhandler_dev_dsp::Audio_in::query (int rate, int bits, int channels)
{
WAVEFORMATEX format;
MMRESULT rc;
fillFormat (&format, rate, bits, channels);
rc = waveInOpen (NULL, WAVE_MAPPER, &format, 0L, 0L, WAVE_FORMAT_QUERY);
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveInOpen(freq=%d bits=%d channels=%d)", rc, rate, bits, channels);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return (rc == MMSYSERR_NOERROR);
}
bool
fhandler_dev_dsp::Audio_in::start (int rate, int bits, int channels)
{
WAVEFORMATEX format;
MMRESULT rc;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (dev_)
return true;
/* In case of fork bigwavebuffer may already exist */
if (!bigwavebuffer_)
bigwavebuffer_ = new char[fh->fragstotal_ * fh->fragsize_];
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (!isvalid ())
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return false;
fillFormat (&format, rate, bits, channels);
2013-04-23 17:44:36 +08:00
rc = waveInOpen (&dev_, WAVE_MAPPER, &format, (DWORD_PTR) waveIn_callback,
(DWORD_PTR) this, CALLBACK_FUNCTION);
debug_printf ("%u = waveInOpen(rate=%d bits=%d channels=%d)", rc, rate, bits, channels);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (rc == MMSYSERR_NOERROR)
{
if (!init (fh->fragsize_))
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
return false;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
return (rc == MMSYSERR_NOERROR);
}
void
fhandler_dev_dsp::Audio_in::stop ()
{
MMRESULT rc;
WAVEHDR *pHdr;
2013-04-23 17:44:36 +08:00
debug_printf ("dev_=%p", dev_);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (dev_)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
/* Note that waveInReset calls our callback for all incomplete buffers.
Since all the win32 wave functions appear to use a common lock,
we must not call into the wave API from the callback.
Otherwise we end up in a deadlock. */
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
rc = waveInReset (dev_);
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveInReset()", rc);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
while (Qisr2app_->recv (&pHdr))
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
rc = waveInUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR));
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveInUnprepareHeader(%p)", rc, pHdr);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
no_thread_exit_protect for_now (true);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
rc = waveInClose (dev_);
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveInClose()", rc);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
Qisr2app_->dellock ();
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
}
bool
fhandler_dev_dsp::Audio_in::queueblock (WAVEHDR *pHdr)
{
MMRESULT rc;
rc = waveInPrepareHeader (dev_, pHdr, sizeof (WAVEHDR));
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveInPrepareHeader(%p)", rc, pHdr);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (rc == MMSYSERR_NOERROR)
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
{
rc = waveInAddBuffer (dev_, pHdr, sizeof (WAVEHDR));
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveInAddBuffer(%p)", rc, pHdr);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
}
if (rc == MMSYSERR_NOERROR)
return true;
/* FIXME: Should the calling function return an error instead ?*/
pHdr->dwFlags = 0; /* avoid calling UnprepareHeader again */
pHdr->dwBytesRecorded = 0; /* no data will have been read */
Qisr2app_->send (pHdr);
return false;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
bool
fhandler_dev_dsp::Audio_in::init (unsigned blockSize)
{
MMRESULT rc;
int i;
// try to queue all of our buffer for reception
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
Qisr2app_->reset ();
for (i = 0; i < fh->fragstotal_; i++)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
wavehdr_[i].lpData = &bigwavebuffer_[i * blockSize];
wavehdr_[i].dwBufferLength = blockSize;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
wavehdr_[i].dwFlags = 0;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (!queueblock (&wavehdr_[i]))
break;
}
pHdr_ = NULL;
rc = waveInStart (dev_);
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveInStart(), queued=%d", rc, i);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return (rc == MMSYSERR_NOERROR);
}
bool
fhandler_dev_dsp::Audio_in::read (char *pSampleData, int &nBytes)
{
int bytes_to_read = nBytes;
nBytes = 0;
2013-04-23 17:44:36 +08:00
debug_printf ("pSampleData=%p nBytes=%d", pSampleData, bytes_to_read);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
while (bytes_to_read != 0)
{ // Block till next sound has been read
if (!waitfordata ())
2011-06-06 13:02:13 +08:00
{
if (nBytes)
return true;
nBytes = -1;
return false;
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
// Handle gathering our blocks into smaller or larger buffer
int sizeleft = pHdr_->dwBytesRecorded - bufferIndex_;
if (bytes_to_read < sizeleft)
{ // The current buffer holds more data than requested
memcpy (pSampleData, &pHdr_->lpData[bufferIndex_], bytes_to_read);
(this->*convert_) ((unsigned char *)pSampleData, bytes_to_read);
nBytes += bytes_to_read;
bufferIndex_ += bytes_to_read;
debug_printf ("got %d", bytes_to_read);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
break; // done; use remaining data in next call to read
}
else
{ // not enough or exact amount in the current buffer
if (sizeleft)
{ // use up what we have
memcpy (pSampleData, &pHdr_->lpData[bufferIndex_], sizeleft);
(this->*convert_) ((unsigned char *)pSampleData, sizeleft);
nBytes += sizeleft;
bytes_to_read -= sizeleft;
pSampleData += sizeleft;
debug_printf ("got %d", sizeleft);
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
queueblock (pHdr_); // re-queue this block to ISR
pHdr_ = NULL; // need to wait for a new block
// if more samples are needed, we need a new block now
}
}
debug_printf ("end nBytes=%d", nBytes);
return true;
}
bool
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio_in::waitfordata ()
{
WAVEHDR *pHdr;
MMRESULT rc;
if (pHdr_ != NULL)
return true;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
while (!Qisr2app_->recv (&pHdr))
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
if (fh->is_nonblocking ())
{
set_errno (EAGAIN);
return false;
}
debug_printf ("1ms");
switch (cygwait (1))
{
case WAIT_SIGNALED:
if (!_my_tls.call_signal_handler ())
{
set_errno (EINTR);
return false;
}
break;
case WAIT_CANCELED:
pthread::static_cancel_self ();
/*NOTREACHED*/
default:
break;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
}
if (pHdr->dwFlags) /* Zero if queued following error in queueblock */
{
/* Errors are ignored here. They will probbaly cause a failure
in the subsequent PrepareHeader */
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
rc = waveInUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR));
2013-04-23 17:44:36 +08:00
debug_printf ("%u = waveInUnprepareHeader(%p)", rc, pHdr);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
pHdr_ = pHdr;
bufferIndex_ = 0;
return true;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
void fhandler_dev_dsp::Audio_in::default_buf_info (audio_buf_info *p,
int rate, int bits, int channels)
{
p->fragstotal = DEFAULT_BLOCKS;
p->fragsize = blockSize (rate, bits, channels);
p->fragments = 0;
p->bytes = 0;
}
void
fhandler_dev_dsp::Audio_in::buf_info (audio_buf_info *p,
int rate, int bits, int channels)
{
if (dev_)
{
p->fragstotal = fh->fragstotal_;
p->fragsize = fh->fragsize_;
p->fragments = Qisr2app_->query ();
if (pHdr_ != NULL)
p->bytes = pHdr_->dwBytesRecorded - bufferIndex_
+ p->fragsize * p->fragments;
else
p->bytes = p->fragsize * p->fragments;
}
else
{
default_buf_info(p, rate, bits, channels);
}
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
inline void
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
fhandler_dev_dsp::Audio_in::callback_blockfull (WAVEHDR *pHdr)
{
Qisr2app_->send (pHdr);
ReleaseSemaphore (fh->get_select_sem (),
get_obj_handle_count (fh->get_select_sem ()) - 1, NULL);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
static void CALLBACK
2013-04-23 17:44:36 +08:00
waveIn_callback (HWAVEIN hWave, UINT msg, DWORD_PTR instance, DWORD_PTR param1,
DWORD_PTR param2)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
if (msg == WIM_DATA)
{
fhandler_dev_dsp::Audio_in *ptr =
(fhandler_dev_dsp::Audio_in *) instance;
ptr->callback_blockfull ((WAVEHDR *) param1);
}
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
/* ------------------------------------------------------------------------
/dev/dsp handler
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
------------------------------------------------------------------------ */
fhandler_dev_dsp::fhandler_dev_dsp ():
* devices.cc: New file. * devices.gperf: New file. * devices.shilka: New file. * cygwin-gperf: New file. * cygwin-shilka: New file. * fhandler_fifo.cc: New file. * fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes fhandler.h throughout. Remove device argument and unit arguments from fhandler constructors throughout. Remove pc arguments to fhandler functions and use internal pc element instead, throughout. Use dev element in pc throughout. Use major/minor elements rather than units and device numbers previously in fhandler class. Use correct methods for fhandler file names rather than directly accessing file name variables, throughout. * Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o * dcrt0.cc (dll_crt0_1): Call device::init. * devices.h: Renumber devices based on more Linux-like major/minor numbers. Add more devices. Declare standard device storage. (device): Declare struct. * dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type. * dtable.cc (dtable::get_debugger_info): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::release): Remove special FH_SOCKET case in favor of generic "need_fixup_before" test. (dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name to build standard fhandler. (dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move out of dtable class. Don't accept a path_conv argument. Just build it here and pass it to: (build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class. Use intrinsic device type in path_conv to create new fhandler. (build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class. Simplify arguments to just take new 'device' type and a name. Just return pointer to fhandler rather than trying to insert into dtable. (dtable::dup_worker): Accommodate above build_fh name changes. (dtable::find_fifo): New (currently broken) function. (handle_to_fn): Use strechr for efficiency. * dtable.h: Reflect above build_fh name changes and argument differences. (fhandler_base *&operator []): Return self rather than copy of self. * fhandler.cc (fhandler_base::operator =): Use pc element to set normalized path. (fhandler_base::set_name): Ditto. (fhandler_base::raw_read): Use method to access name. (fhandler_base::write): Correctly use get_output_handle rather than get_handle. (handler_base::device_access_denied): New function. (fhandler_base::open): Eliminate pc argument and use pc element of fhandler_base throughout. (fhandler_base::fstat): Detect if device is based in filesystem and use fstat_fs to calculate stat, if so. (fhandler_base::fhandler_base): Eliminate handling of file names and, instead, just free appropriate component from pc. (fhandler_base::opendir): Remove path_conv parameter. * fhandler.h: Remove all device flags. (fhandler_base::pc): New element. (fhandler_base::set_name): Change argument to path_conv. (fhandler_base::error): New function. (fhandler_base::exists): New function. (fhandler_base::pc_binmode): New function. (fhandler_base::dev): New function. (fhandler_base::open_fs): New function. (fhandler_base::fstat_fs): New function. (fhandler_base::fstat_by_name): New function. (fhandler_base::fstat_by_handle): New function. (fhandler_base::isfifo): New function. (fhandler_base::is_slow): New function. (fhandler_base::is_auto_device): New function. (fhandler_base::is_fs_special): New function. (fhandler_base::device_access_denied): New function. (fhandler_base::operator DWORD&): New operator. (fhandler_base::get_name): Return normalized path from pc. (fhandler_base::get_win32_name): Return windows path from pc. (fhandler_base::isdevice): Renamed from is_device. (fhandler_base::get_native_name): Return device format. (fhandler_fifo): New class. (fhandler_nodevice): New class. (select_stuff::device_specific): Remove array. (select_stuff::device_specific_pipe): New class element. (select_stuff::device_specific_socket): New class element. (select_stuff::device_specific_serial): New class element. (select_stuff::select_stuff): Initialize new elements. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class from fhandler_disk_file. (fhandler_base::fstat_by_name): Ditto. (fhandler_base::fstat_by_name): Ditto. (fhandler_disk_file::open): Move most functionality into fhandler_base::open_fs. (fhandler_base::open_fs): New function. (fhandler_disk_file::close): Move most functionality into fhandler_base::close_fs. (fhandler_base::close_fs): New function. * fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging output. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard urandom device into appropriate place. (fhandler_socket::accept): Reflect change in fdsock return value. * fhandler_tty.cc: See "throughouts" above. * net.cc: Accommodate fdsock change throughout. (fdsock): Return success or failure, accept fd argument and device argument. * path.cc (symlink_info::major): New element. (symlink_info::minor): New element. (symlink_info::parse_device): Declare new function. (fs_info::update): Accommodate changes in path_conv class. (path_conv::fillin): Ditto. (path_conv::return_and_clear_normalized_path): Eliminate. (path_conv::set_normalized_path): New function. (path_conv::path_conv): Set info in dev element. Use path_conv methods Check for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff. where appropriate rather than direct access. Use set_normalized_path to set normalized path. (windows_device_names): Eliminate. (get_dev): Ditto. (get_raw_device_number): Ditto. (get_device_number): Ditto. (win32_device_name): Call new device name parser to do most of the heavy lifting. (mount_info::conv_to_win32_path): Fill in dev field as appropriate. (symlink_worker): Handle new device files. (symlink_info::check): Ditto. (symlink_info::parse_device): Define new function. * path.h (executable_states): Move here from fhandler.h. (fs_info): Rename variables to *_storage and create methods for accessing same. (path_conv): Add dev element, remove devn and unit and adjust inline methods to accommodate. (set_normalized_path): Declare new function. * pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos. (_pinfo::commune_send): Ditto. * pipe.cc (fhandler_pipe::close): check for existence of handle before closing it. (handler_pipe::create): Rename from make_pipe. Change arguments to accept fhandler_pipe array. Accommodate fifos. (pipe): Rework to deal with fhandler_pipe::create changes. (_pipe): Ditto. * select.cc: Use individual device_specific types throughout rather than indexing with obsolete device number. (set_bits): Use is_socket call rather than checking device number. * shared_info.h (CURR_MOUNT_MAGIC): Update. (conv_to_win32_path): Reflect addition of device argument. * syscalls.cc (mknod_worker): New function. (open): Use build_fh_name to build fhandler. (chown_worker): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (chmod_device): New function. (chmod): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. Use chmod_device to set mode of in-filesystem devices. (stat_worker): Eliminate path_conv argument. Call build_fh_name to construct fhandler. Use fh->error() rather than pc->error to detect errors in fhandler construction. (access_worker): New function pulled from access. Accommodate in-filesystem devices. (access): Use access_worker. (fpathconf): Detect if this is an 'auto' device rather than an on-filesystem device and handle appropriately. (mknod_worker): New function. (mknod32): New function. (chroot): Free normalized path -- assuming it was actually cmalloced. * tty.cc (create_tty_master): Tweak for new device class. (tty::common_init): Ditto. * winsup.h (stat_worker): Remove. (symlink_worker): Declare. * exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't worry about pending_signals since sig_dispatch_pending should always do the right thing now. (sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3. * pinfo.h: Move __SIG enum to sigproc.h. (PICOM_FIFO): New enum element. (_pinfo): Remove 'thread2signal' stuff throughout class. (_pinfo::commune_send): Make varargs. (_pinfo::sigtodo): Eliminate. (_pinfo::thread2signal): Ditto. * signal.cc (kill_worker): Eliminate call to setthread2signal. * sigproc.cc (local_sigtodo): Eliminate. (getlocal_sigtodo): Ditto. (sigelem): New class. (pending_signals): New class. (sigqueue): New variable, start of sigqueue linked list. (sigcatch_nonmain): Eliminate. (sigcatch_main): Eliminate. (sigcatch_nosync): Eliminate. (sigcomplete_nonmain): Eliminate. (pending_signals): Eliminate. (sig_clear): Call signal thread to clear pending signals, unless already in signal thread. (sigpending): Call signal thread to get pending signals. (sig_dispatch_pending): Eliminate use of pending_signals and just check sigqueue. (sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close signal pipe handle. (sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send signals. (getevent): Eliminate. (pending_signals::add): New function. (pending_signals::del): New function. (pending_signals::next): New function. (wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to communicate and maintain a linked list of signals. * sigproc.h: Move __SIG defines here. Add __SIGPENDING. (sig_dispatch_pending): Remove "C" specifier. (sig_handle): Accept a mask argument. * thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
fhandler_base ()
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
audio_in_ = NULL;
audio_out_ = NULL;
dev ().parse (FH_OSS_DSP);
}
ssize_t
fhandler_dev_dsp::write (const void *ptr, size_t len)
{
return base ()->_write (ptr, len);
}
void
fhandler_dev_dsp::read (void *ptr, size_t& len)
{
base ()->_read (ptr, len);
}
int
fhandler_dev_dsp::ioctl (unsigned int cmd, void *buf)
{
return base ()->_ioctl (cmd, buf);
}
int
fhandler_dev_dsp::fcntl (int cmd, intptr_t arg)
{
return base ()->_fcntl (cmd, arg);
}
void
fhandler_dev_dsp::fixup_after_fork (HANDLE parent)
{
base ()->_fixup_after_fork (parent);
}
void
fhandler_dev_dsp::fixup_after_exec ()
{
base ()->_fixup_after_exec ();
}
int
fhandler_dev_dsp::open (int flags, mode_t mode)
{
int ret = -1, err = 0;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
UINT num_in = 0, num_out = 0;
set_flags ((flags & ~O_TEXT) | O_BINARY);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
// Work out initial sample format & frequency, /dev/dsp defaults
audioformat_ = AFMT_U8;
* dcrt0.cc (dll_crt0_1): Don't close hexec_proc if it is NULL. * fork.cc (vfork): Add debugging statements. * path.cc (get_device_number): Make static. Rewrite to inspect both unix and windows paths. (get_raw_device_number): Just check for parts of raw device that we care about. (get_devn): New function, pulled from get_device_number. (win32_device_name): Accomodate arg changes to get_device_number. (mount_info::get_device_number): Call get_device_number on translated Windows path. * spawn.cc (spawn_guts): Don't treat P_VFORK differently from P_NOWAIT. Add handle to child's shared region to child so that it will be preserved if the parent goes away. * fhandler.h: Throughout, simplify to one open method for all fhandler classes, requiring a path_conv first element. * fhandler.cc (fhandler_base::open): Remove obsolete method. Generalize to require path_conv * as first argument. (fhandler_disk_file::open): Remove obsolete method. (fhandler_disk_file::open): Use path_conv pointer rather than reference. * fhandler_clipboard.cc (fhandler_dev_clipboard::dup): Use new open method. (fhandler_dev_clipboard::open): Accomodate new argument for open methods. * fhandler_console.cc (fhandler_console::open): Ditto. (fhandler_console::dup): Use new open method. (fhandler_console::fixup_after_fork): Ditto. (fhandler_console::fixup_after_exec): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::open): Accomodate new argument for open methods. * fhandler_floppy.cc (fhandler_dev_floppy::open): Ditto. * fhandler_mem.cc (fhandler_dev_mem::open): Ditto. * fhandler_random (fhandler_dev_random::open): Ditto. * fhandler_raw.cc (fhandler_dev_raw::open): Ditto. * fhandler_serial.cc (fhandler_serial::open): Ditto. * fhandler_tape.cc (fhandler_dev_tape::open): Ditto. * fhandler_tty.cc (fhandler_tty_slave::open): Ditto. (fhandler_pty_master::open): Ditto. * fhandler_windows.cc (fhandler_windows::open): Ditto. * fhandler_zero.cc (fhandler_dev_zero::open): Ditto. * fhandler_socket.cc (fhandler_socket::set_connect_secret): Accomodate new argument for open methods. * syscalls.cc (_open): Ditto. (stat_worker): Ditto.
2001-10-04 10:34:20 +08:00
audiofreq_ = 8000;
audiobits_ = 8;
audiochannels_ = 1;
fragstotal_ = DEFAULT_BLOCKS;
fragment_has_been_set = false;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
switch (flags & O_ACCMODE)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
case O_RDWR:
if ((num_in = waveInGetNumDevs ()) == 0)
err = ENXIO;
fallthrough;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
case O_WRONLY:
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if ((num_out = waveOutGetNumDevs ()) == 0)
err = ENXIO;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
break;
case O_RDONLY:
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if ((num_in = waveInGetNumDevs ()) == 0)
err = ENXIO;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
break;
default:
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
err = EINVAL;
}
if (err)
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
set_errno (err);
else
ret = open_null (flags);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
select_sem = CreateSemaphore (sec_none_cloexec (mode), 0, INT32_MAX, NULL);
debug_printf ("ACCMODE=%y audio_in=%d audio_out=%d, err=%d, ret=%d",
flags & O_ACCMODE, num_in, num_out, err, ret);
if (ret >= 0)
being_closed = false;
return ret;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
#define IS_WRITE() ((get_flags() & O_ACCMODE) != O_RDONLY)
#define IS_READ() ((get_flags() & O_ACCMODE) != O_WRONLY)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
ssize_t
fhandler_dev_dsp::_write (const void *ptr, size_t len)
{
2013-04-23 17:44:36 +08:00
debug_printf ("ptr=%p len=%ld", ptr, len);
int len_s = len;
const char *ptr_s = static_cast <const char *> (ptr);
if (being_closed)
{
set_errno (EBADF);
return -1;
}
* cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error. * dtable.cc (handle_to_fn): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_console::scroll_screen): Ditto. (dev_console::set_color): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. * hookapi.cc (find_first_notloaded_dll): Ditto. * mmap.cc (msync): Ditto. * pipe.cc (pipesync::pipesync): Ditto. * sec_acl.cc (getace): Ditto. * sec_auth.cc (create_token): Ditto. (lsaauth): Ditto. * select.cc (peek_pipe): Ditto. * spawn.cc (av::fixup): Ditto. * syscalls.cc (popen): Ditto. * tty.cc (tty::init_session): Ditto. * uinfo.cc (pwdgrp::load): Ditto. * fhandler.cc (fhandler_base::setup_overlapped): Ditto. (fhandler_base::wait_overlapped): Rename second use of res variable to wres or errors are not returned correctly. * dcrt0.cc: Remove obsolete variable. * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler warning regarding coercing type-punned variables. (fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo. (fhandler_fifo::wait): Add all conditions to switch statement to avoid a compiler warning. * fhandler_process.cc: Avoid unneeded initialization of variables to zero. (fhandler_socket::listen): Add braces around initializer. * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler warning. Fix problem with EWOULDBLOCK error return. * path.cc (GUID_shortcut): Use braces around struct initializer. (cygwin_conv_path): Reorganize to avoid a compiler warning. * random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized" warning. * libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to do the right thing with them. * libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments to avoid a compiler warning.
2008-09-11 12:34:24 +08:00
if (audio_out_)
/* nothing to do */;
else if (IS_WRITE ())
{
if (!fragment_has_been_set)
fragsize_ = Audio::blockSize (audiofreq_, audiobits_, audiochannels_);
* cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error. * dtable.cc (handle_to_fn): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_console::scroll_screen): Ditto. (dev_console::set_color): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. * hookapi.cc (find_first_notloaded_dll): Ditto. * mmap.cc (msync): Ditto. * pipe.cc (pipesync::pipesync): Ditto. * sec_acl.cc (getace): Ditto. * sec_auth.cc (create_token): Ditto. (lsaauth): Ditto. * select.cc (peek_pipe): Ditto. * spawn.cc (av::fixup): Ditto. * syscalls.cc (popen): Ditto. * tty.cc (tty::init_session): Ditto. * uinfo.cc (pwdgrp::load): Ditto. * fhandler.cc (fhandler_base::setup_overlapped): Ditto. (fhandler_base::wait_overlapped): Rename second use of res variable to wres or errors are not returned correctly. * dcrt0.cc: Remove obsolete variable. * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler warning regarding coercing type-punned variables. (fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo. (fhandler_fifo::wait): Add all conditions to switch statement to avoid a compiler warning. * fhandler_process.cc: Avoid unneeded initialization of variables to zero. (fhandler_socket::listen): Add braces around initializer. * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler warning. Fix problem with EWOULDBLOCK error return. * path.cc (GUID_shortcut): Use braces around struct initializer. (cygwin_conv_path): Reorganize to avoid a compiler warning. * random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized" warning. * libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to do the right thing with them. * libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments to avoid a compiler warning.
2008-09-11 12:34:24 +08:00
debug_printf ("Allocating");
if (!(audio_out_ = new Audio_out (this)))
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
return -1;
* cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error. * dtable.cc (handle_to_fn): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_console::scroll_screen): Ditto. (dev_console::set_color): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. * hookapi.cc (find_first_notloaded_dll): Ditto. * mmap.cc (msync): Ditto. * pipe.cc (pipesync::pipesync): Ditto. * sec_acl.cc (getace): Ditto. * sec_auth.cc (create_token): Ditto. (lsaauth): Ditto. * select.cc (peek_pipe): Ditto. * spawn.cc (av::fixup): Ditto. * syscalls.cc (popen): Ditto. * tty.cc (tty::init_session): Ditto. * uinfo.cc (pwdgrp::load): Ditto. * fhandler.cc (fhandler_base::setup_overlapped): Ditto. (fhandler_base::wait_overlapped): Rename second use of res variable to wres or errors are not returned correctly. * dcrt0.cc: Remove obsolete variable. * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler warning regarding coercing type-punned variables. (fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo. (fhandler_fifo::wait): Add all conditions to switch statement to avoid a compiler warning. * fhandler_process.cc: Avoid unneeded initialization of variables to zero. (fhandler_socket::listen): Add braces around initializer. * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler warning. Fix problem with EWOULDBLOCK error return. * path.cc (GUID_shortcut): Use braces around struct initializer. (cygwin_conv_path): Reorganize to avoid a compiler warning. * random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized" warning. * libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to do the right thing with them. * libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments to avoid a compiler warning.
2008-09-11 12:34:24 +08:00
/* check for wave file & get parameters & skip header if possible. */
if (audio_out_->parsewav (ptr_s, len_s,
audiofreq_, audiobits_, audiochannels_))
2013-04-23 17:44:36 +08:00
debug_printf ("=> ptr_s=%p len_s=%d", ptr_s, len_s);
* cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error. * dtable.cc (handle_to_fn): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_console::scroll_screen): Ditto. (dev_console::set_color): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. * hookapi.cc (find_first_notloaded_dll): Ditto. * mmap.cc (msync): Ditto. * pipe.cc (pipesync::pipesync): Ditto. * sec_acl.cc (getace): Ditto. * sec_auth.cc (create_token): Ditto. (lsaauth): Ditto. * select.cc (peek_pipe): Ditto. * spawn.cc (av::fixup): Ditto. * syscalls.cc (popen): Ditto. * tty.cc (tty::init_session): Ditto. * uinfo.cc (pwdgrp::load): Ditto. * fhandler.cc (fhandler_base::setup_overlapped): Ditto. (fhandler_base::wait_overlapped): Rename second use of res variable to wres or errors are not returned correctly. * dcrt0.cc: Remove obsolete variable. * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler warning regarding coercing type-punned variables. (fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo. (fhandler_fifo::wait): Add all conditions to switch statement to avoid a compiler warning. * fhandler_process.cc: Avoid unneeded initialization of variables to zero. (fhandler_socket::listen): Add braces around initializer. * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler warning. Fix problem with EWOULDBLOCK error return. * path.cc (GUID_shortcut): Use braces around struct initializer. (cygwin_conv_path): Reorganize to avoid a compiler warning. * random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized" warning. * libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to do the right thing with them. * libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments to avoid a compiler warning.
2008-09-11 12:34:24 +08:00
}
else
{
set_errno (EBADF); // device was opened for read?
return -1;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
/* Open audio device properly with callbacks.
Private parameters were set in call to parsewav.
This is a no-op when there are successive writes in the same process */
if (!audio_out_->start ())
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
set_errno (EIO);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return -1;
}
int written = audio_out_->write (ptr_s, len_s);
if (written < 0)
{
if (len - len_s > 0)
return len - len_s;
return -1;
}
return len - len_s + written;
}
void
fhandler_dev_dsp::_read (void *ptr, size_t& len)
{
2013-04-23 17:44:36 +08:00
debug_printf ("ptr=%p len=%ld", ptr, len);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
* cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error. * dtable.cc (handle_to_fn): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_console::scroll_screen): Ditto. (dev_console::set_color): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. * hookapi.cc (find_first_notloaded_dll): Ditto. * mmap.cc (msync): Ditto. * pipe.cc (pipesync::pipesync): Ditto. * sec_acl.cc (getace): Ditto. * sec_auth.cc (create_token): Ditto. (lsaauth): Ditto. * select.cc (peek_pipe): Ditto. * spawn.cc (av::fixup): Ditto. * syscalls.cc (popen): Ditto. * tty.cc (tty::init_session): Ditto. * uinfo.cc (pwdgrp::load): Ditto. * fhandler.cc (fhandler_base::setup_overlapped): Ditto. (fhandler_base::wait_overlapped): Rename second use of res variable to wres or errors are not returned correctly. * dcrt0.cc: Remove obsolete variable. * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler warning regarding coercing type-punned variables. (fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo. (fhandler_fifo::wait): Add all conditions to switch statement to avoid a compiler warning. * fhandler_process.cc: Avoid unneeded initialization of variables to zero. (fhandler_socket::listen): Add braces around initializer. * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler warning. Fix problem with EWOULDBLOCK error return. * path.cc (GUID_shortcut): Use braces around struct initializer. (cygwin_conv_path): Reorganize to avoid a compiler warning. * random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized" warning. * libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to do the right thing with them. * libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments to avoid a compiler warning.
2008-09-11 12:34:24 +08:00
if (audio_in_)
/* nothing to do */;
else if (IS_READ ())
{
if (!fragment_has_been_set)
fragsize_ = Audio::blockSize (audiofreq_, audiobits_, audiochannels_);
* cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error. * dtable.cc (handle_to_fn): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_console::scroll_screen): Ditto. (dev_console::set_color): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. * hookapi.cc (find_first_notloaded_dll): Ditto. * mmap.cc (msync): Ditto. * pipe.cc (pipesync::pipesync): Ditto. * sec_acl.cc (getace): Ditto. * sec_auth.cc (create_token): Ditto. (lsaauth): Ditto. * select.cc (peek_pipe): Ditto. * spawn.cc (av::fixup): Ditto. * syscalls.cc (popen): Ditto. * tty.cc (tty::init_session): Ditto. * uinfo.cc (pwdgrp::load): Ditto. * fhandler.cc (fhandler_base::setup_overlapped): Ditto. (fhandler_base::wait_overlapped): Rename second use of res variable to wres or errors are not returned correctly. * dcrt0.cc: Remove obsolete variable. * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler warning regarding coercing type-punned variables. (fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo. (fhandler_fifo::wait): Add all conditions to switch statement to avoid a compiler warning. * fhandler_process.cc: Avoid unneeded initialization of variables to zero. (fhandler_socket::listen): Add braces around initializer. * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler warning. Fix problem with EWOULDBLOCK error return. * path.cc (GUID_shortcut): Use braces around struct initializer. (cygwin_conv_path): Reorganize to avoid a compiler warning. * random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized" warning. * libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to do the right thing with them. * libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments to avoid a compiler warning.
2008-09-11 12:34:24 +08:00
debug_printf ("Allocating");
if (!(audio_in_ = new Audio_in (this)))
* cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error. * dtable.cc (handle_to_fn): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_console::scroll_screen): Ditto. (dev_console::set_color): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. * hookapi.cc (find_first_notloaded_dll): Ditto. * mmap.cc (msync): Ditto. * pipe.cc (pipesync::pipesync): Ditto. * sec_acl.cc (getace): Ditto. * sec_auth.cc (create_token): Ditto. (lsaauth): Ditto. * select.cc (peek_pipe): Ditto. * spawn.cc (av::fixup): Ditto. * syscalls.cc (popen): Ditto. * tty.cc (tty::init_session): Ditto. * uinfo.cc (pwdgrp::load): Ditto. * fhandler.cc (fhandler_base::setup_overlapped): Ditto. (fhandler_base::wait_overlapped): Rename second use of res variable to wres or errors are not returned correctly. * dcrt0.cc: Remove obsolete variable. * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler warning regarding coercing type-punned variables. (fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc (fhandler_fifo::open_nonserver): Fix = vs. == typo. (fhandler_fifo::wait): Add all conditions to switch statement to avoid a compiler warning. * fhandler_process.cc: Avoid unneeded initialization of variables to zero. (fhandler_socket::listen): Add braces around initializer. * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler warning. Fix problem with EWOULDBLOCK error return. * path.cc (GUID_shortcut): Use braces around struct initializer. (cygwin_conv_path): Reorganize to avoid a compiler warning. * random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized" warning. * libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to do the right thing with them. * libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments to avoid a compiler warning.
2008-09-11 12:34:24 +08:00
{
len = (size_t)-1;
return;
}
audio_in_->setconvert (audioformat_);
}
else
{
len = (size_t)-1;
set_errno (EBADF); // device was opened for write?
return;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
/* Open audio device properly with callbacks.
This is a noop when there are successive reads in the same process */
if (!audio_in_->start (audiofreq_, audiobits_, audiochannels_))
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
len = (size_t)-1;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
set_errno (EIO);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
int res = len;
audio_in_->read ((char *)ptr, res);
len = (size_t)res;
}
void
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
fhandler_dev_dsp::close_audio_in ()
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (audio_in_)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
audio_in_->stop ();
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
delete audio_in_;
audio_in_ = NULL;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
}
void
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
fhandler_dev_dsp::close_audio_out (bool immediately)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (audio_out_)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
audio_out_->stop (immediately);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
delete audio_out_;
audio_out_ = NULL;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
}
int
fhandler_dev_dsp::close ()
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
{
2013-04-23 17:44:36 +08:00
debug_printf ("audio_in=%p audio_out=%p", audio_in_, audio_out_);
being_closed = true;
* cygheap.cc (cygheap::close_ctty): Close ctty via close_with_arch(). * debug.cc (close_handle): Call debugger on failure. * devices.in (device::tty_to_real_device): Delete. * devices.h (device::tty_to_real_device): Ditto. * devices.cc: Regenerate. * dtable.cc: Delete old ifdef'ed vfork code. (dtable::release): Don't handle archetype here. (dtable::init_std_file_from_handle): Consolidate console tests. Generate major/minor for tty ASAP. Fix incorrect setting of DEV_TTYS* for serial. (fh_alloc): New function derived from build_fh_pc. Pass current tty when building tty. (build_pc_pc): Use fh_alloc to create. Set name from fh->dev if appropriate. Generate an archetype or point to one here. (dtable::dup_worker): Deal with archetypes. Rely on = operator copying whole class rather than just fhandler_base. (dtable::fixup_after_exec): Call close_with_arch to handle closing of fhandlers with archetypes. * fhandler.cc (fhandler_base::operator =): Call memcpy with fhandler's size() rather than sizeof fhandler_base. (fhandler_base::open_with_arch): New function. Handles opening of fhandler's with archetypes, dealing with usecounts, etc. (fhandler_base::close_with_arch): Ditto for close. * fhandler.h: Many changes for archetypes. (fhandler_base::set_name): Set both normalized path and regular path. (fhandler_base::open_with_arch): New function. (fhandler_base::open_setup): Ditto. (fhandler_base::use_archetype): Ditto. (fhandler_base::_archetype_usecount): Ditto. (fhandler_*::size): Ditto. (fhandler_dev_tape::open): Remove virtual decoration. (fhandler_console::use_archetype): New function. Return true. (fhandler_console::open_setup): New function. (fhandler_console::dup): Delete. (fhandler_tty_slave::fhandler_tty_slave): Redeclare to take an argument. (fhandler_tty_slave::use_archetype): New function. Return true. (fhandler_tty_slave::cleanup): New function. (fhandler_pty_master::use_archetype): New function. Return true. (fhandler_pty_master::cleanup): New function. (fhandler_pty_master::is_tty_master): New function. Return false. (fhandler_tty_master::is_tty_master): New function. Return true. (fhandler_dev_dsp::fhandler_dev_dsp): New function. Return true. (report_tty_counts): Only report on archetype's usecount if there is one. * fhandler_console.cc (fhandler_console::get_tty_stuff): Remove handling of setsid, set_ctty, set_flags, and manage_console_count. (fhandler_console::open_setup): New function. Implement functionality removed from get_tty_stuff. (fhandler_console::dup): Delete. (fhandler_console::output_tcsetattr): Set errno on error. (fhandler_console::fhandler_console): Set device early. (fhandler_console::init): Use open_with_arch to open console handles. (fhandler_console::fixup_after_fork_exec): Nuke most of the stuff for dealing with console handles. * fhandler_dsp.cc (fhandler_dev_dsp::open): Remove archetype handling. (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. (fhandler_dev_dsp::close): Ditto. (fhandler_dev_dsp::dup): Ditto. (fhandler_dev_dsp::ioctl): Ditto. (fhandler_dev_dsp::fixup_after_fork): Ditto. (fhandler_dev_dsp::fixup_after_exec): Ditto. * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Add a little more debugging. (fhandler_tty_common::__release_output_mutex): Ditto. (fhandler_pty_master::process_slave_output): Ditto. Don't do signal handling or pthread_cancel handling in the tty master thread. (process_output): Minor reorg. (fhandler_tty_slave::fhandler_tty_slave): Set device based on new ntty argument. (fhandler_tty_slave::open): Remove archetype handling. Move some processing into open_setup(). (fhandler_tty_slave::open_setup): New function. (fhandler_tty_slave::cleanup): New function. (fhandler_tty_slave::close): Remove archetype handling. Move some processing into cleanup(). (fhandler_tty_slave::init): Rename argument from f to h. Open device using open_with_arch(). Remove archetype handling. (fhandler_pty_master::dup): Ditto. (fhandler_pty_master::open): Ditto. (fhandler_pty_master::close): Ditto. Move some handling to cleanup(). (fhandler_pty_master::cleanup): New function. (fhandler_tty_master::init_console): Give unique name to captive console fhandler. * pinfo.cc (_pinfo::set_ctty): Rename argument from arch to fh. Eliminate archetype assumption. * syscalls.cc (close_all_files): Use close_with_arch for closing. (open): Use open_with_arch() rather than open(). (close): Use close_with_arch() rather than close().
2011-05-06 06:30:53 +08:00
close_audio_in ();
close_audio_out ();
ReleaseSemaphore (select_sem, get_obj_handle_count (select_sem) - 1, NULL);
CloseHandle (select_sem);
select_sem = NULL;
return fhandler_base::close ();
}
int
fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
{
2013-04-23 17:44:36 +08:00
debug_printf ("audio_in=%p audio_out=%p", audio_in_, audio_out_);
int *intbuf = (int *) buf;
switch (cmd)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
#define CASE(a) case a : debug_printf ("/dev/dsp: ioctl %s", #a);
CASE (SNDCTL_DSP_RESET)
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
close_audio_in ();
close_audio_out (true);
return 0;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
break;
CASE (SNDCTL_DSP_GETBLKSIZE)
if (!fragment_has_been_set)
fragsize_ = Audio::blockSize (audiofreq_, audiobits_, audiochannels_);
*intbuf = fragsize_;
2001-11-05 14:09:15 +08:00
return 0;
CASE (SNDCTL_DSP_SETFMT)
{
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
int nBits;
switch (*intbuf)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
case AFMT_QUERY:
*intbuf = audioformat_;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return 0;
break;
case AFMT_U16_BE:
case AFMT_U16_LE:
case AFMT_S16_BE:
case AFMT_S16_LE:
nBits = 16;
break;
case AFMT_U8:
case AFMT_S8:
nBits = 8;
break;
default:
nBits = 0;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (nBits && IS_WRITE ())
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
close_audio_out ();
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (audio_out_->query (audiofreq_, nBits, audiochannels_))
{
audiobits_ = nBits;
audioformat_ = *intbuf;
}
else
{
*intbuf = audiobits_;
return -1;
}
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (nBits && IS_READ ())
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
close_audio_in ();
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (audio_in_->query (audiofreq_, nBits, audiochannels_))
{
audiobits_ = nBits;
audioformat_ = *intbuf;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
else
{
*intbuf = audiobits_;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return -1;
}
}
return 0;
}
CASE (SNDCTL_DSP_SPEED)
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (IS_WRITE ())
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
close_audio_out ();
if (audio_out_->query (*intbuf, audiobits_, audiochannels_))
audiofreq_ = *intbuf;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
else
{
*intbuf = audiofreq_;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return -1;
}
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (IS_READ ())
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
close_audio_in ();
if (audio_in_->query (*intbuf, audiobits_, audiochannels_))
audiofreq_ = *intbuf;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
else
{
*intbuf = audiofreq_;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return -1;
}
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return 0;
CASE (SNDCTL_DSP_STEREO)
{
int nChannels = *intbuf + 1;
int res = _ioctl (SNDCTL_DSP_CHANNELS, &nChannels);
*intbuf = nChannels - 1;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
return res;
}
CASE (SNDCTL_DSP_CHANNELS)
{
int nChannels = *intbuf;
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (IS_WRITE ())
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
close_audio_out ();
if (audio_out_->query (audiofreq_, audiobits_, nChannels))
audiochannels_ = nChannels;
else
{
*intbuf = audiochannels_;
return -1;
}
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (IS_READ ())
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
close_audio_in ();
if (audio_in_->query (audiofreq_, audiobits_, nChannels))
audiochannels_ = nChannels;
else
{
*intbuf = audiochannels_;
return -1;
}
}
return 0;
}
CASE (SNDCTL_DSP_GETOSPACE)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (!IS_WRITE ())
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
set_errno(EBADF);
return -1;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
}
audio_buf_info *p = (audio_buf_info *) buf;
if (audio_out_)
audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
else if (fragment_has_been_set)
{
p->bytes = fragsize_ * fragstotal_;
p->fragsize = fragsize_;
p->fragstotal = fragstotal_;
p->fragments = fragstotal_;
}
else
Audio_out::default_buf_info(p, audiofreq_, audiobits_, audiochannels_);
debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
buf, p->fragments, p->fragsize, p->bytes);
return 0;
}
CASE (SNDCTL_DSP_GETISPACE)
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (!IS_READ ())
{
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
set_errno(EBADF);
return -1;
}
audio_buf_info *p = (audio_buf_info *) buf;
if (audio_in_)
audio_in_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
else if (fragment_has_been_set)
{
p->bytes = 0;
p->fragsize = fragsize_;
p->fragstotal = fragstotal_;
p->fragments = 0;
}
else
Audio_in::default_buf_info(p, audiofreq_, audiobits_, audiochannels_);
debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
buf, p->fragments, p->fragsize, p->bytes);
return 0;
}
CASE (SNDCTL_DSP_SETFRAGMENT)
{
if (audio_out_ || audio_in_)
return 0; /* Too late to set fragment. Ignore. */
int *p = (int *) buf;
fragstotal_ = min (*p >> 16, MAX_BLOCKS);
fragsize_ = 1 << (*p & 0xffff);
fragment_has_been_set = true;
return 0;
}
CASE (SNDCTL_DSP_GETFMTS)
*intbuf = AFMT_S16_LE | AFMT_U8; // only native formats returned here
return 0;
CASE (SNDCTL_DSP_GETCAPS)
*intbuf = DSP_CAP_BATCH | DSP_CAP_DUPLEX;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
return 0;
CASE (SNDCTL_DSP_POST)
if (audio_out_)
audio_out_->sendcurrent (); // force out last block whatever size..
return 0;
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
CASE (SNDCTL_DSP_SYNC)
if (audio_out_)
{
audio_out_->sendcurrent (); // force out last block whatever size..
audio_out_->waitforallsent (); // block till finished..
}
return 0;
default:
return fhandler_base::ioctl (cmd, buf);
break;
#undef CASE
}
}
int
fhandler_dev_dsp::_fcntl (int cmd, intptr_t arg)
{
return fhandler_base::fcntl(cmd, arg);
}
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
void
fhandler_dev_dsp::_fixup_after_fork (HANDLE parent)
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
{ // called from new child process
2013-04-23 17:44:36 +08:00
debug_printf ("audio_in=%p audio_out=%p",
audio_in_, audio_out_);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
fhandler_base::fixup_after_fork (parent);
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
if (audio_in_)
* cygheap.cc (cygheap::close_ctty): Close ctty via close_with_arch(). * debug.cc (close_handle): Call debugger on failure. * devices.in (device::tty_to_real_device): Delete. * devices.h (device::tty_to_real_device): Ditto. * devices.cc: Regenerate. * dtable.cc: Delete old ifdef'ed vfork code. (dtable::release): Don't handle archetype here. (dtable::init_std_file_from_handle): Consolidate console tests. Generate major/minor for tty ASAP. Fix incorrect setting of DEV_TTYS* for serial. (fh_alloc): New function derived from build_fh_pc. Pass current tty when building tty. (build_pc_pc): Use fh_alloc to create. Set name from fh->dev if appropriate. Generate an archetype or point to one here. (dtable::dup_worker): Deal with archetypes. Rely on = operator copying whole class rather than just fhandler_base. (dtable::fixup_after_exec): Call close_with_arch to handle closing of fhandlers with archetypes. * fhandler.cc (fhandler_base::operator =): Call memcpy with fhandler's size() rather than sizeof fhandler_base. (fhandler_base::open_with_arch): New function. Handles opening of fhandler's with archetypes, dealing with usecounts, etc. (fhandler_base::close_with_arch): Ditto for close. * fhandler.h: Many changes for archetypes. (fhandler_base::set_name): Set both normalized path and regular path. (fhandler_base::open_with_arch): New function. (fhandler_base::open_setup): Ditto. (fhandler_base::use_archetype): Ditto. (fhandler_base::_archetype_usecount): Ditto. (fhandler_*::size): Ditto. (fhandler_dev_tape::open): Remove virtual decoration. (fhandler_console::use_archetype): New function. Return true. (fhandler_console::open_setup): New function. (fhandler_console::dup): Delete. (fhandler_tty_slave::fhandler_tty_slave): Redeclare to take an argument. (fhandler_tty_slave::use_archetype): New function. Return true. (fhandler_tty_slave::cleanup): New function. (fhandler_pty_master::use_archetype): New function. Return true. (fhandler_pty_master::cleanup): New function. (fhandler_pty_master::is_tty_master): New function. Return false. (fhandler_tty_master::is_tty_master): New function. Return true. (fhandler_dev_dsp::fhandler_dev_dsp): New function. Return true. (report_tty_counts): Only report on archetype's usecount if there is one. * fhandler_console.cc (fhandler_console::get_tty_stuff): Remove handling of setsid, set_ctty, set_flags, and manage_console_count. (fhandler_console::open_setup): New function. Implement functionality removed from get_tty_stuff. (fhandler_console::dup): Delete. (fhandler_console::output_tcsetattr): Set errno on error. (fhandler_console::fhandler_console): Set device early. (fhandler_console::init): Use open_with_arch to open console handles. (fhandler_console::fixup_after_fork_exec): Nuke most of the stuff for dealing with console handles. * fhandler_dsp.cc (fhandler_dev_dsp::open): Remove archetype handling. (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::read): Ditto. (fhandler_dev_dsp::close): Ditto. (fhandler_dev_dsp::dup): Ditto. (fhandler_dev_dsp::ioctl): Ditto. (fhandler_dev_dsp::fixup_after_fork): Ditto. (fhandler_dev_dsp::fixup_after_exec): Ditto. * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Add a little more debugging. (fhandler_tty_common::__release_output_mutex): Ditto. (fhandler_pty_master::process_slave_output): Ditto. Don't do signal handling or pthread_cancel handling in the tty master thread. (process_output): Minor reorg. (fhandler_tty_slave::fhandler_tty_slave): Set device based on new ntty argument. (fhandler_tty_slave::open): Remove archetype handling. Move some processing into open_setup(). (fhandler_tty_slave::open_setup): New function. (fhandler_tty_slave::cleanup): New function. (fhandler_tty_slave::close): Remove archetype handling. Move some processing into cleanup(). (fhandler_tty_slave::init): Rename argument from f to h. Open device using open_with_arch(). Remove archetype handling. (fhandler_pty_master::dup): Ditto. (fhandler_pty_master::open): Ditto. (fhandler_pty_master::close): Ditto. Move some handling to cleanup(). (fhandler_pty_master::cleanup): New function. (fhandler_tty_master::init_console): Give unique name to captive console fhandler. * pinfo.cc (_pinfo::set_ctty): Rename argument from arch to fh. Eliminate archetype assumption. * syscalls.cc (close_all_files): Use close_with_arch for closing. (open): Use open_with_arch() rather than open(). (close): Use close_with_arch() rather than close().
2011-05-06 06:30:53 +08:00
audio_in_->fork_fixup (parent);
* autoload.cc: Load eight more functions for waveIn support. * fhandler.h (class fhandler_dev_dsp): Add class Audio, class Audio_in and class Audio_out members and audio_in_, audio_out_ pointers so that future changes are restricted to file fhandler_dsp.cc. * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add this class to treat things common to audio recording and playback. Add more format conversions. (fhandler_dev_dsp::Audio::queue): New queues for buffer management to fix incomplete cleanup of buffers passed to the wave device. (fhandler_dev_dsp::Audio_in): New, added class to implement audio recording. (fhandler_dev_dsp::Audio_out): Rework to use functionality provided by fhandler_dev_dsp::Audio. Allocate memory audio buffers late, just before write. (fhandler_dev_dsp::Audio_out::start): Size of wave buffer allocated here depends on audio rate/bits/channels. (fhandler_dev_dsp::Audio_in::start): Ditto. (fhandler_dev_dsp::setupwav): Replaced by following function. (fhandler_dev_dsp::Audio_out::parsewav): Does not setup wave device any more. Discard wave header properly. (fhandler_dev_dsp::open): Add O_RDONLY and_RDWR as legal modes. Protect against re-open. Activate fork_fixup. (fhandler_dev_dsp::ioctl): Protect against actions when audio is active. SNDCTL_DSP_GETFMTS only returns formats supported by mmsystem wave API, not all supported formats. SNDCTL_DSP_GETBLKSIZE result now depends on current audio format. (fhandler_dev_dsp::fixup_after_fork): Call fork_fixup for the Audio classes to let them duplicate the CRITICAL_SECTION.
2004-03-23 19:05:56 +08:00
if (audio_out_)
audio_out_->fork_fixup (parent);
}
void
fhandler_dev_dsp::_fixup_after_exec ()
{
2013-04-23 17:44:36 +08:00
debug_printf ("audio_in=%p audio_out=%p, close_on_exec %d",
audio_in_, audio_out_, close_on_exec ());
* cygheap.h (init_cygheap::manage_console_count): Declare new function. (init_cygheap::console_count): Renamed from open_fhs. Make private. * cygheap.cc (init_cygheap::manage_console_count): Define new function. * dtable.cc (dtable::fixup_after_exec): Always call fixup_after_exec on elements of fd even when they are about to be closed. * fhandler.h (report_tty_counts): Remove open_fhs from debugging output. * fhandler_console.cc (fhandler_console::open): Use manage_console_count rather than manipulating count directly. (fhandler_console::close): Ditto. (fhandler_console::fixup_after_fork): Ditto. (fhandler_console::fixup_after_exec): Ditto. Don't close handles if close_on_exec. * fhandler_tty.cc (fhandler_tty_slave::open): Use manage_console_count() rather than manipulating count directly. Reflect change in arguments to report_tty_counts(). (fhandler_tty_slave::close): Ditto for both. (fhandler_tty_slave::dup): Ditto for both. (fhandler_tty_slave::ioctl): Use myctty() rather than raw ctty #. (fhandler_tty_slave::fixup_after_fork): Reflect change in arguments to report_tty_counts(). (fhandler_tty_master::init_console): Use manage_console_count() rather than manipulating count directly. * fhandler_clipboard.cc (fhandler_dev_clipboard::fixup_after_exec): Don't perform any operations if close_on_exec. * fhandler_dsp.cc (fhandler_dev_dsp::fixup_after_exec): Ditto. * fhandler_raw.cc (fhandler_dev_raw::fixup_after_exec): Ditto. * fhandler_serial.cc (fhandler_serial::fixup_after_exec): Ditto. * pinfo.h (_pinfo::_ctty): Declare new function. (myctty): Declare new macro. (__ctty): Declare new macro. * pinfo.cc (_pinfo::_ctty): Define new function. (_pinfo::set_ctty): Use manage_console_count() rather than manipulating count directly. * signal.cc (kill_pgrp): Use myctty() and __ctty() macros rather than raw ctty #. * syscalls.cc (setsid): Ditto. Use manage_console_count() rather than manipulating count directly.
2005-11-14 12:28:45 +08:00
if (!close_on_exec ())
{
audio_in_ = NULL;
audio_out_ = NULL;
}
* fhandler.h (fhandler_dev_dsp:~fhandler_dev_dsp): Delete. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::close_audio_in): New method declaration. (fhandler_dev_dsp::close_audio_in): Ditto. * fhandler_dsp.cc: Add and edit debug_printf throughout. (fhandler_dev_dsp::Audio::denyAccess): Delete. (fhandler_dev_dsp::Audio::fork_fixup): Ditto. (fhandler_dev_dsp::Audio::getOwner): Ditto. (fhandler_dev_dsp::Audio::clearOwner): Ditto. (fhandler_dev_dsp::Audio::owner_): Ditto. (fhandler_dev_dsp::Audio::setformat): Ditto, rename to setconvert. (fhandler_dev_dsp::Audio::lock): Ditto, move to queue. (fhandler_dev_dsp::Audio::unlock): Ditto. (fhandler_dev_dsp::Audio::lock_): Ditto. (fhandler_dev_dsp::Audio::bufferIndex_): New member, from Audio_out and Audio_in. (fhandler_dev_dsp::Audio::pHdr_): Ditto. (fhandler_dev_dsp::Audio::wavehdr_): Ditto. (fhandler_dev_dsp::Audio::bigwavebuffer_): ditto. (fhandler_dev_dsp::Audio::Qisr2app_): Ditto. (fhandler_dev_dsp::Audio::setconvert): New method, from old setformat. (fhandler_dev_dsp::Audio::queue::lock): New method. (fhandler_dev_dsp::Audio::queue::unlock): Ditto. (fhandler_dev_dsp::Audio::queue::dellock): Ditto. (fhandler_dev_dsp::Audio::queue::isvalid): Ditto. (fhandler_dev_dsp::Audio::queue::lock_): New member. (fhandler_dev_dsp::Audio::queue::depth1_): Delete. (fhandler_dev_dsp::Audio_out::fork_fixup): New method. (fhandler_dev_dsp::Audio_out::isvalid): New method. (fhandler_dev_dsp::Audio_out::start): Remove arguments. (fhandler_dev_dsp::Audio_out::parsewav): Change arguments and set internal state. (fhandler_dev_dsp::Audio_out::emptyblocks): Delete. (fhandler_dev_dsp::Audio_out::Qapp2app_): Ditto. (fhandler_dev_dsp::Audio_out::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_out::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_out::pHdr_): Ditto. (fhandler_dev_dsp::Audio_out::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_out::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio_out::freq_): New member. (fhandler_dev_dsp::Audio_out::bits_): New member. (fhandler_dev_dsp::Audio_out::channels_): New member. (fhandler_dev_dsp::Audio_in::fork_fixup): New method. (fhandler_dev_dsp::Audio_in::isvalid): New method. (fhandler_dev_dsp::Audio_in::Qapp2app_): Delete. (fhandler_dev_dsp::Audio_in::Qisr2app_): Ditto, move to Audio. (fhandler_dev_dsp::Audio_in::bufferIndex_): Ditto. (fhandler_dev_dsp::Audio_in::pHdr_): Ditto. (fhandler_dev_dsp::Audio_in::wavehdr_): Ditto. (fhandler_dev_dsp::Audio_in::bigwavefuffer_): Ditto. (fhandler_dev_dsp::Audio::queue::queue): Simplify. (fhandler_dev_dsp::Audio::queue::send): Use lock. (fhandler_dev_dsp::Audio::queue::query): Do not use depth1_. (fhandler_dev_dsp::Audio::queue::recv): Ditto. (fhandler_dev_dsp::Audio::Audio): Adapt to new class members. (fhandler_dev_dsp::Audio::~Audio): Ditto (fhandler_dev_dsp::Audio_out::start): Reorganize. (fhandler_dev_dsp::Audio_out::stop): Simplify. (fhandler_dev_dsp::Audio_out::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_out::write): Reorganize to allocate audio_out. (fhandler_dev_dsp::Audio_out::buf_info): Use appropriate block size. (fhandler_dev_dsp::Audio_out::callback_sampledone): Do not use lock. (fhandler_dev_dsp::Audio_out::waitforspace): Simplify. (fhandler_dev_dsp::Audio_out::waitforallsent):Ditto. (fhandler_dev_dsp::Audio_out::sendcurrent): Reorganize. Clear flag before requeuing. (fhandler_dev_dsp::Audio_out::parsewav): (fhandler_dev_dsp::Audio_in::start): Reorganize. (fhandler_dev_dsp::Audio_in::stop): Simplify. (fhandler_dev_dsp::Audio_in::queueblock): Ditto. Requeue header in case of error. (fhandler_dev_dsp::Audio_in::init): Reset the queue and clear flag. (fhandler_dev_dsp::Audio_in::waitfordata): Simplify. Do not UnprepareHeader if the flag is zero. (fhandler_dev_dsp::Audio_in::buf_info): Ditto. (fhandler_dev_dsp::Audio_in::callback_blockfull): Do not use lock. (fhandler_dev_dsp::open_count): Delete. (fhandler_dev_dsp::open): Only check existence, do not allocate anything. Set flags appropriately. Create archetype. (fhandler_dev_dsp::write): Call archetype as needed. Create audio_out. (fhandler_dev_dsp::read): Call archetype as needed. Create audio_in. (fhandler_dev_dsp::close): Call archetype as needed. Call close_audio_in and close_audio_out. (fhandler_dev_dsp::close_audio_in): New function. (fhandler_dev_dsp::close_audio_out): New function. (fhandler_dev_dsp::dup): Use archetypes. (fhandler_dev_dsp::ioctl): Call archetype as needed. Reorganize for new structures. (fhandler_dev_dsp::fixup_after_fork): Call archetype as needed. (fhandler_dev_dsp::fixup_after_exec): Call archetype as needed. Clear audio_in and audio_out.
2004-08-17 17:52:50 +08:00
}
bool
fhandler_dev_dsp::_write_ready ()
{
audio_buf_info info;
if (audio_out_)
{
audio_out_->buf_info (&info, audiofreq_, audiobits_, audiochannels_);
return info.bytes > 0;
}
else
return true;
}
bool
fhandler_dev_dsp::_read_ready ()
{
audio_buf_info info;
if (audio_in_)
{
audio_in_->buf_info (&info, audiofreq_, audiobits_, audiochannels_);
return info.bytes > 0;
}
else
return true;
}
bool
fhandler_dev_dsp::write_ready ()
{
return base ()->_write_ready ();
}
bool
fhandler_dev_dsp::read_ready ()
{
return base ()->_read_ready ();
}