This is dspmemsize.c in view mode; [Download] [Up]
/*
dspmemsize.c -- report the amount of DSP RAM installed.
92-09-10 Izumi Ohzawa
*/
#import <sound/sound.h>
#import <mach.h>
#import <stdlib.h>
#import <stdio.h>
#define DSP_PROGRAM "dspmemsize.lod" /* DSP program file */
main ()
{
int result;
int src_data = 1234;
int s_err, size;
kern_return_t k_err;
port_t dev_port = 0, owner_port = 0, cmd_port;
SNDSoundStruct *dspStruct;
//
// get the device port for the sound/dsp driver on the local machine
// and try to become owner of the dsp resource. Note that it fails
// if you are logged into a remote machine which is not a "public sound
// server" (as set in the UNIX section of the Preferences application).
//
s_err = SNDAcquire(SND_ACCESS_DSP, 0, 0, 0, NULL_NEGOTIATION_FUN,
0, &dev_port, &owner_port);
if (s_err != KERN_SUCCESS) {
fprintf(stderr,"*** Could not acquire DSP\nSNDAcquire: %s\n",
SNDSoundError(s_err));
exit(1);
}
//
// get the command port
//
k_err = snddriver_get_dsp_cmd_port(dev_port,owner_port,&cmd_port);
if (k_err != KERN_SUCCESS) {
mach_error("Cannot acquire command port ", k_err);
exit(1);
}
//
// parse a the .lod assembly file and boot the dsp with it
//
s_err = SNDReadDSPfile(DSP_PROGRAM, &dspStruct, NULL);
if (s_err != SND_ERR_NONE) {
fprintf(stderr,"Cannot parse DSP load image : %s\n",
SNDSoundError(s_err));
exit(1);
}
s_err = SNDBootDSP(dev_port, owner_port, dspStruct);
if (s_err != SND_ERR_NONE) {
fprintf(stderr,"Cannot boot dsp : %s\n", SNDSoundError(s_err));
exit(1);
}
//
// write just one number to the DSP
//
k_err = snddriver_dsp_write(cmd_port, &src_data, 1, sizeof(int), 0);
if (k_err != KERN_SUCCESS) {
mach_error("Cannot write to DSP ", k_err);
exit(1);
}
//
// read the result from the DSP
//
size = 1;
k_err = snddriver_dsp_read(cmd_port, (void *)(&result), &size,
sizeof(int), 0);
if (k_err != KERN_SUCCESS || size != 1) {
mach_error("Cannot read from DSP ", k_err);
exit(1);
}
printf("%d words of DSP RAM (external) installed\n", result);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.