/* * audio.cpp - Audio support * * Basilisk II (C) 1997-1999 Christian Bauer * Portions (C) 1997-1999 Marc Hellwig * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * SEE ALSO * Inside Macintosh: Sound, chapter 5 "Sound Components" */ #include "sysdeps.h" #include "cpu_emulation.h" #include "macos_util.h" #include "emul_op.h" #include "main.h" #include "audio.h" #include "audio_defs.h" #define DEBUG 0 #include "debug.h" // Global variables struct audio_status AudioStatus; // Current audio status (sample rate etc.) bool audio_open = false; // Flag: audio is initialized and ready int audio_frames_per_block; // Number of audio frames per block uint32 audio_component_flags; // Component feature flags uint32 audio_data = 0; // Mac address of global data area static int open_count = 0; // Open/close nesting count bool AudioAvailable = false; // Flag: audio output available (from the software point of view) /* * Get audio info */ static int32 AudioGetInfo(uint32 infoPtr, uint32 selector, uint32 sourceID) { D(bug(" AudioGetInfo %c%c%c%c, infoPtr %08lx, source ID %08lx\n", selector >> 24, (selector >> 16) & 0xff, (selector >> 8) & 0xff, selector & 0xff, infoPtr, sourceID)); M68kRegisters r; int i; switch (selector) { case siSampleSize: WriteMacInt16(infoPtr, AudioStatus.sample_size); break; case siSampleSizeAvailable: { r.d[0] = audio_num_sample_sizes * 2; Execute68kTrap(0xa122, &r); // NewHandle() uint32 h = r.a[0]; if (h == 0) return memFullErr; WriteMacInt16(infoPtr + sil_count, audio_num_sample_sizes); WriteMacInt32(infoPtr + sil_infoHandle, h); uint32 sp = ReadMacInt32(h); for (i=0; i> 24, (selector >> 16) & 0xff, (selector >> 8) & 0xff, selector & 0xff, infoPtr, sourceID)); M68kRegisters r; int i; switch (selector) { case siSampleSize: D(bug(" set sample size %08lx\n", infoPtr)); if (AudioStatus.num_sources) return siDeviceBusyErr; for (i=0; i