mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2025-02-19 07:31:01 +00:00
remove unused files from previous Mini vMac source import
This commit is contained in:
parent
dead799d16
commit
bf2cde331d
@ -1,121 +0,0 @@
|
||||
/*
|
||||
PBUFSTDC.h
|
||||
|
||||
Copyright (C) 2018 Paul C. Pratt
|
||||
|
||||
You can redistribute this file and/or modify it under the terms
|
||||
of version 2 of the GNU General Public License as published by
|
||||
the Free Software Foundation. You should have received a copy
|
||||
of the license along with this file; see the file COPYING.
|
||||
|
||||
This file 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
|
||||
license for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
Parameter BUFfers implemented with STanDard C library
|
||||
*/
|
||||
|
||||
|
||||
#if IncludePbufs
|
||||
LOCALVAR void *PbufDat[NumPbufs];
|
||||
#endif
|
||||
|
||||
#if IncludePbufs
|
||||
LOCALFUNC tMacErr PbufNewFromPtr(void *p, ui5b count, tPbuf *r)
|
||||
{
|
||||
tPbuf i;
|
||||
tMacErr err;
|
||||
|
||||
if (! FirstFreePbuf(&i)) {
|
||||
free(p);
|
||||
err = mnvm_miscErr;
|
||||
} else {
|
||||
*r = i;
|
||||
PbufDat[i] = p;
|
||||
PbufNewNotify(i, count);
|
||||
err = mnvm_noErr;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IncludePbufs
|
||||
LOCALPROC PbufKillToPtr(void **p, ui5r *count, tPbuf r)
|
||||
{
|
||||
*p = PbufDat[r];
|
||||
*count = PbufSize[r];
|
||||
|
||||
PbufDisposeNotify(r);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IncludePbufs
|
||||
GLOBALOSGLUFUNC tMacErr PbufNew(ui5b count, tPbuf *r)
|
||||
{
|
||||
tMacErr err = mnvm_miscErr;
|
||||
|
||||
void *p = calloc(1, count);
|
||||
if (NULL != p) {
|
||||
err = PbufNewFromPtr(p, count, r);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IncludePbufs
|
||||
GLOBALOSGLUPROC PbufDispose(tPbuf i)
|
||||
{
|
||||
void *p;
|
||||
ui5r count;
|
||||
|
||||
PbufKillToPtr(&p, &count, i);
|
||||
|
||||
free(p);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IncludePbufs
|
||||
LOCALPROC UnInitPbufs(void)
|
||||
{
|
||||
tPbuf i;
|
||||
|
||||
for (i = 0; i < NumPbufs; ++i) {
|
||||
if (PbufIsAllocated(i)) {
|
||||
PbufDispose(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IncludePbufs
|
||||
#define PbufHaveLock 1
|
||||
#endif
|
||||
|
||||
#if IncludePbufs
|
||||
LOCALFUNC ui3p PbufLock(tPbuf i)
|
||||
{
|
||||
return (ui3p)PbufDat[i];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IncludePbufs
|
||||
#define PbufUnlock(i)
|
||||
#endif
|
||||
|
||||
#if IncludePbufs
|
||||
GLOBALOSGLUPROC PbufTransfer(ui3p Buffer,
|
||||
tPbuf i, ui5r offset, ui5r count, blnr IsWrite)
|
||||
{
|
||||
void *p = ((ui3p)PbufDat[i]) + offset;
|
||||
if (IsWrite) {
|
||||
(void) memcpy(p, Buffer, count);
|
||||
} else {
|
||||
(void) memcpy(Buffer, p, count);
|
||||
}
|
||||
}
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,228 +0,0 @@
|
||||
/*
|
||||
SGLUDDSP.h
|
||||
|
||||
Copyright (C) 2012 Paul C. Pratt
|
||||
|
||||
You can redistribute this file and/or modify it under the terms
|
||||
of version 2 of the GNU General Public License as published by
|
||||
the Free Software Foundation. You should have received a copy
|
||||
of the license along with this file; see the file COPYING.
|
||||
|
||||
This file 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
|
||||
license for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
Sound GLUe for "/Dev/DSP"
|
||||
OSS and related, accessed through "/dev/dsp"
|
||||
*/
|
||||
|
||||
LOCALVAR int audio_fd = -1;
|
||||
LOCALVAR blnr audio_started;
|
||||
|
||||
#if 4 == kLn2SoundSampSz
|
||||
LOCALPROC ConvertSoundBlockToNative(tpSoundSamp p)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = kOneBuffLen; --i >= 0; ) {
|
||||
*p++ -= 0x8000;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define ConvertSoundBlockToNative(p)
|
||||
#endif
|
||||
|
||||
LOCALPROC MySound_WriteOut(void)
|
||||
{
|
||||
int retry_count = 32;
|
||||
|
||||
label_retry:
|
||||
if (--retry_count > 0) {
|
||||
int err;
|
||||
struct audio_buf_info info;
|
||||
|
||||
if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) != 0) {
|
||||
fprintf(stderr, "SNDCTL_DSP_GETOSPACE fails\n");
|
||||
} else {
|
||||
tpSoundSamp NextPlayPtr;
|
||||
ui4b PlayNowSize = 0;
|
||||
ui4b MaskedFillOffset = ThePlayOffset & kOneBuffMask;
|
||||
ui4b PrivateBuffUsed = TheFillOffset - ThePlayOffset;
|
||||
int used = (info.fragstotal * info.fragsize) - info.bytes;
|
||||
|
||||
if (audio_started) {
|
||||
ui4b TotPendBuffs = used >> kLnOneBuffSz;
|
||||
|
||||
if (TotPendBuffs < MinFilledSoundBuffs) {
|
||||
MinFilledSoundBuffs = TotPendBuffs;
|
||||
}
|
||||
/* fprintf(stderr, "buffer used %d\n", (int)used); */
|
||||
} else {
|
||||
if (PrivateBuffUsed >= kAllBuffLen - kOneBuffLen) {
|
||||
audio_started = trueblnr;
|
||||
} else {
|
||||
info.bytes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (MaskedFillOffset != 0) {
|
||||
/* take care of left overs */
|
||||
PlayNowSize = kOneBuffLen - MaskedFillOffset;
|
||||
NextPlayPtr =
|
||||
TheSoundBuffer + (ThePlayOffset & kAllBuffMask);
|
||||
} else if (0 !=
|
||||
((TheFillOffset - ThePlayOffset) >> kLnOneBuffLen))
|
||||
{
|
||||
PlayNowSize = kOneBuffLen;
|
||||
NextPlayPtr =
|
||||
TheSoundBuffer + (ThePlayOffset & kAllBuffMask);
|
||||
} else {
|
||||
/* nothing to play now */
|
||||
}
|
||||
|
||||
#if 4 == kLn2SoundSampSz
|
||||
PlayNowSize <<= 1;
|
||||
#endif
|
||||
|
||||
if (PlayNowSize > info.bytes) {
|
||||
PlayNowSize = info.bytes;
|
||||
}
|
||||
|
||||
if (0 != PlayNowSize) {
|
||||
err = write(
|
||||
audio_fd, NextPlayPtr, PlayNowSize);
|
||||
if (err < 0) {
|
||||
if (- EAGAIN == err) {
|
||||
/* buffer full, try again later */
|
||||
fprintf(stderr, "pcm write: EAGAIN\n");
|
||||
} else if (- EPIPE == err) {
|
||||
/* buffer seems to have emptied */
|
||||
fprintf(stderr, "pcm write emptied\n");
|
||||
goto label_retry;
|
||||
} else {
|
||||
fprintf(stderr, "audio_fd write error: %d\n",
|
||||
err);
|
||||
}
|
||||
} else {
|
||||
ThePlayOffset += err
|
||||
#if 4 == kLn2SoundSampSz
|
||||
>> 1
|
||||
#endif
|
||||
;
|
||||
goto label_retry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOCALPROC MySound_Start(void)
|
||||
{
|
||||
if (audio_fd >= 0) {
|
||||
MySound_Start0();
|
||||
audio_started = falseblnr;
|
||||
}
|
||||
}
|
||||
|
||||
LOCALPROC MySound_Stop(void)
|
||||
{
|
||||
if (audio_fd >= 0) {
|
||||
if (0 !=
|
||||
ioctl(audio_fd, SNDCTL_DSP_RESET /* SNDCTL_DSP_HALT */,
|
||||
NULL))
|
||||
{
|
||||
fprintf(stderr, "SNDCTL_DSP_RESET fails\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 4 == kLn2SoundSampSz
|
||||
#define MyDesiredFormat AFMT_S16_NE
|
||||
#else
|
||||
#define MyDesiredFormat AFMT_U8
|
||||
#endif
|
||||
|
||||
LOCALFUNC blnr MySound_Init(void)
|
||||
{
|
||||
blnr IsOk = falseblnr;
|
||||
|
||||
audio_fd = open(AudioDevPath, O_WRONLY, 0);
|
||||
if (audio_fd < 0) {
|
||||
fprintf(stderr, "open /dev/dsp fails: %d\n", audio_fd);
|
||||
} else {
|
||||
int fragment_value = (16 /* 16 fragments */ << 16)
|
||||
#if 4 == kLn2SoundSampSz
|
||||
| 10 /* of 1024 bytes */
|
||||
#else
|
||||
| 9 /* of 512 bytes */
|
||||
#endif
|
||||
;
|
||||
int channels_value = 1;
|
||||
int fmt_value = MyDesiredFormat;
|
||||
int speed_value = SOUND_SAMPLERATE;
|
||||
|
||||
/* fprintf(stderr, "open /dev/dsp works\n"); */
|
||||
|
||||
if (0 !=
|
||||
ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &fragment_value))
|
||||
{
|
||||
fprintf(stderr, "SNDCTL_DSP_SETFRAGMENT fails\n");
|
||||
} else if ((0 !=
|
||||
ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &channels_value))
|
||||
|| (channels_value != 1))
|
||||
{
|
||||
fprintf(stderr, "SNDCTL_DSP_CHANNELS fails\n");
|
||||
} else if ((0 !=
|
||||
ioctl(audio_fd, SNDCTL_DSP_SETFMT, &fmt_value))
|
||||
|| (fmt_value != MyDesiredFormat))
|
||||
{
|
||||
fprintf(stderr, "SNDCTL_DSP_SETFMT fails\n");
|
||||
} else if ((0 !=
|
||||
ioctl(audio_fd, SNDCTL_DSP_SPEED, &speed_value))
|
||||
|| (speed_value != SOUND_SAMPLERATE))
|
||||
{
|
||||
fprintf(stderr, "SNDCTL_DSP_SPEED fails\n");
|
||||
} else
|
||||
{
|
||||
IsOk = trueblnr;
|
||||
}
|
||||
|
||||
if (! IsOk) {
|
||||
(void) close(audio_fd);
|
||||
audio_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return trueblnr; /* keep going, even if no sound */
|
||||
}
|
||||
|
||||
LOCALPROC MySound_UnInit(void)
|
||||
{
|
||||
if (audio_fd >= 0) {
|
||||
if (close(audio_fd) != 0) {
|
||||
fprintf(stderr, "close /dev/dsp fails\n");
|
||||
}
|
||||
audio_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
GLOBALOSGLUPROC MySound_EndWrite(ui4r actL)
|
||||
{
|
||||
if (MySound_EndWrite0(actL)) {
|
||||
ConvertSoundBlockToNative(TheSoundBuffer
|
||||
+ ((TheFillOffset - kOneBuffLen) & kAllBuffMask));
|
||||
if (audio_fd >= 0) {
|
||||
MySound_WriteOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOCALPROC MySound_SecondNotify(void)
|
||||
{
|
||||
if (audio_fd >= 0) {
|
||||
MySound_SecondNotify0();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user