By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release. View | Details | Raw Unified | Return to bug 2159
Collapse All | Expand All

(-) (+115 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2010 Jacob Meuser <jakemsr@sdf.lonestar.org>
3
 *
4
 * Permission to use, copy, modify, and distribute this software for any
5
 * purpose with or without fee is hereby granted, provided that the above
6
 * copyright notice and this permission notice appear in all copies.
7
 *
8
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
 */
16
17
#include <unistd.h>
18
#include <stdio.h>
19
#include <sndio.h>
20
21
#include "audioIO.h"
22
23
static struct sio_hdl *hdl;
24
static struct sio_par par;
25
26
int
27
audioConstruct()
28
{
29
	hdl = NULL;
30
	return true;
31
}
32
33
void
34
audioDestruct()
35
{
36
}
37
38
int
39
audioOpen()
40
{
41
	hdl = sio_open(NULL, SIO_PLAY, 0);
42
	if (hdl == NULL) {
43
		fprintf(stderr, "unable to open audio device\n");
44
		return 0;
45
	}
46
47
	return true;
48
}
49
50
inline void
51
audioFlush()
52
{
53
}
54
55
void
56
audioClose()
57
{
58
	if (hdl != NULL)
59
		sio_close(hdl);
60
}
61
62
void
63
audioInit(int sampleSize, int frequency, int stereo, int sign, int big)
64
{
65
	sio_initpar(&par);
66
67
	par.bits = sampleSize;
68
	par.sig = sign ? 1 : 0;
69
	par.le = big ? 0 : 1;
70
	par.rate = frequency;
71
	par.pchan = stereo ? 2 : 1;
72
73
	if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par))
74
		fprintf(stderr, "error setting sndio parameters\n");
75
  
76
	if (par.bits != sampleSize ||
77
	    par.sig != sign ? 1 : 0 ||
78
	    par.le != big ? 0 : 1 ||
79
	    par.rate != frequency ||
80
	    par.pchan != stereo ? 2 : 1)
81
		fprintf(stderr, "could not set requested audio parameters");
82
83
	if (!sio_start(hdl))
84
		fprintf(stderr, "could not start audio");
85
}
86
87
int
88
getAudioBufferSize()
89
{
90
	return (par.appbufsz * par.bps * par.pchan);
91
}
92
93
94
void
95
mixerSetVolume(int leftVolume, int rightVolume)
96
{
97
	/* values from 0..100 */
98
}
99
100
int
101
mixerOpen()
102
{
103
	return false;
104
}
105
106
void
107
mixerClose()
108
{
109
}
110
111
int
112
audioWrite(char *buffer, int count)
113
{
114
	return(sio_write(hdl, buffer, count));
115
}

Return to bug 2159