1 /*	MikMod sound library
2 	(c) 1998, 1999, 2000 Miodrag Vallat and others - see file AUTHORS for
3 	complete list.
4 
5 	This library is free software; you can redistribute it and/or modify
6 	it under the terms of the GNU Library General Public License as
7 	published by the Free Software Foundation; either version 2 of
8 	the License, or (at your option) any later version.
9 
10 	This program is distributed in the hope that it will be useful,
11 	but WITHOUT ANY WARRANTY; without even the implied warranty of
12 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 	GNU Library General Public License for more details.
14 
15 	You should have received a copy of the GNU Library General Public
16 	License along with this library; if not, write to the Free Software
17 	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 	02111-1307, USA.
19 */
20 
21 /*==============================================================================
22 
23   $Id$
24 
25   Output data to stdout
26 
27 ==============================================================================*/
28 
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32 
33 #ifdef DRV_STDOUT
34 
35 #ifdef HAVE_UNISTD_H
36 #include <unistd.h>
37 #endif
38 #include <stdlib.h>
39 
40 #include "mikmod_internals.h"
41 
42 #define BUFFERSIZE 32768
43 
44 static	SBYTE *audiobuffer=NULL;
45 
stdout_IsThere(void)46 static BOOL stdout_IsThere(void)
47 {
48 	/* only allow this driver on pipes */
49 	return 1-isatty(1);
50 }
51 
stdout_Init(void)52 static int stdout_Init(void)
53 {
54 	if(!(audiobuffer=(SBYTE*)MikMod_malloc(BUFFERSIZE)))
55 		return 1;
56 #ifdef __EMX__
57 	_fsetmode(stdout,"b");
58 #endif
59 	return VC_Init();
60 }
61 
stdout_Exit(void)62 static void stdout_Exit(void)
63 {
64 	VC_Exit();
65 #ifdef __EMX__
66 	_fsetmode(stdout,"t");
67 #endif
68 	MikMod_free(audiobuffer);
69 	audiobuffer=NULL;
70 }
71 
stdout_Update(void)72 static void stdout_Update(void)
73 {
74 #ifdef _WIN32
75 	_write
76 #else
77 	write
78 #endif
79 	     (1,audiobuffer,VC_WriteBytes((SBYTE*)audiobuffer,BUFFERSIZE));
80 }
81 
stdout_Reset(void)82 static int stdout_Reset(void)
83 {
84 	VC_Exit();
85 	return VC_Init();
86 }
87 
88 MIKMODAPI MDRIVER drv_stdout={
89 	NULL,
90 	"stdout",
91 	"Standard output driver v1.1",
92 	0,255,
93 	"stdout",
94 	NULL,
95 	NULL,
96 	stdout_IsThere,
97 	VC_SampleLoad,
98 	VC_SampleUnload,
99 	VC_SampleSpace,
100 	VC_SampleLength,
101 	stdout_Init,
102 	stdout_Exit,
103 	stdout_Reset,
104 	VC_SetNumVoices,
105 	VC_PlayStart,
106 	VC_PlayStop,
107 	stdout_Update,
108 	NULL,
109 	VC_VoiceSetVolume,
110 	VC_VoiceGetVolume,
111 	VC_VoiceSetFrequency,
112 	VC_VoiceGetFrequency,
113 	VC_VoiceSetPanning,
114 	VC_VoiceGetPanning,
115 	VC_VoicePlay,
116 	VC_VoiceStop,
117 	VC_VoiceStopped,
118 	VC_VoiceGetPosition,
119 	VC_VoiceRealVolume
120 };
121 
122 #else
123 
124 #include "mikmod_internals.h"
125 MISSING(drv_stdout);
126 
127 #endif
128 
129 /* ex:set ts=4: */
130