home *** CD-ROM | disk | FTP | other *** search
- /* Emacs style mode select -*- C++ -*- */
- /* ----------------------------------------------------------------------------- */
- /* */
- /* $Id: linux.c,v 1.3 1997/01/26 07:45:01 b1 Exp $ */
- /* */
- /* Copyright (C) 1993-1996 by id Software, Inc. */
- /* */
- /* This source is available for distribution and/or modification */
- /* only under the terms of the DOOM Source Code License as */
- /* published by id Software. All rights reserved. */
- /* */
- /* The source is distributed in the hope that it will be useful, */
- /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
- /* FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License */
- /* for more details. */
- /* */
- /* */
- /* $Log: linux.c,v $ */
- /* Revision 1.3 1997/01/26 07:45:01 b1 */
- /* 2nd formatting run, fixed a few warnings as well. */
- /* */
- /* Revision 1.2 1997/01/21 19:00:01 b1 */
- /* First formatting run: */
- /* using Emacs cc-mode.el indentation for C++ now. */
- /* */
- /* Revision 1.1 1997/01/19 17:22:45 b1 */
- /* Initial check in DOOM sources as of Jan. 10th, 1997 */
- /* */
- /* */
- /* DESCRIPTION: */
- /* UNIX, soundserver for Linux i386. */
- /* */
- /* ----------------------------------------------------------------------------- */
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <fcntl.h>
- #include <unistd.h>
-
- #include <osbind.h>
- #include <falcon.h>
-
- #include "soundsrv.h"
-
- long dmabuffer[2][1024]; /* Doom send 512 samples */
- int numbuffer=0;
-
-
- void I_InitMusic(void)
- {
- }
-
- void
- I_InitSound
- ( int samplerate,
- int samplesize )
- {
- long *dest=&dmabuffer[0][0];
- int i;
-
- /* Init son : 12292hz, 16 bits, stereo */
-
- Soundcmd(ADDERIN,ADCIN+MATIN);
- Soundcmd(ADCINPUT,ADCRT+ADCLT);
- Devconnect(DMAPLAY,DAC+DMAREC,CLK25M,CLKOLD,1);
- Setinterrupt(SI_NONE,SI_PLAY);
- Settracks(0,0);
- Setmontracks(0);
- Setmode(STEREO16);
- Soundcmd(SETPRESCALE,PRE640);
-
- Buffoper(0);
- Setbuffer(0,&dmabuffer[1][0],&dmabuffer[1][1023]);
-
- for (i=0;i<2*1024;i++)
- *dest++=0;
- }
-
- void
- I_SubmitOutputBuffer
- ( void* samples,
- int samplecount )
- {
- long *src=samples;
- long *dest=&dmabuffer[numbuffer][0];
- int i,j;
-
- /* Jouer le son */
- /*
- write(audio_fd, samples, samplecount*4);
- */
-
- /* Convertir de 11025 a 12292 */
- for (i=0;i<(samplecount>>3);i++)
- {
- for (j=0;j<8;j++)
- {
- *dest++=*src++;
- }
- *dest++=*src;
- }
-
- /* Jouer le son une fois */
- Setbuffer(0,&dmabuffer[numbuffer][0],&dmabuffer[numbuffer][samplecount-1]);
- numbuffer^=1;
- Buffoper(SB_PLA_ENA);
- }
-
- void I_ShutdownSound(void)
- {
- /* Couper le son */
- /*
- close(audio_fd);
- */
- }
-
- void I_ShutdownMusic(void)
- {
- }
-