• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 
21 #include "quakedef.h"
22 
23 extern int desired_speed;
24 extern int desired_bits;
25 
SNDDMA_Init(void)26 qboolean SNDDMA_Init(void)
27 {
28 	int size;
29 
30 	size = 16384 + sizeof(dma_t);
31 	shm = malloc (size);
32 	memset((void*)shm, 0, size);
33 
34 	shm->buffer = (char*)shm + sizeof(dma_t);
35 	shm->channels = 2;
36 	shm->speed = desired_speed;
37 	shm->samplebits = desired_bits;
38 	shm->samples = 16384 / (desired_bits / 8);
39 	shm->submission_chunk = 1;
40 
41 	return true;
42 }
43 
44 // return the current sample position (in mono samples read)
45 // inside the recirculating dma buffer
SNDDMA_GetDMAPos(void)46 int SNDDMA_GetDMAPos(void)
47 {
48 	shm->samplepos = (int)(realtime*shm->speed*shm->channels) & (shm->samples-1);
49 
50 	return shm->samplepos;
51 }
52 
SNDDMA_Shutdown(void)53 void SNDDMA_Shutdown(void)
54 {
55 }
56