Mercurial > audlegacy-plugins
annotate src/OSS4/audio.c @ 1686:2e8adf61c54f
remove realtime craq from the code
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Tue, 11 Sep 2007 06:52:53 -0500 |
parents | 8c93d207a4d9 |
children | f86cb7fc1d4f |
rev | line source |
---|---|
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
1 /* BMP - Cross-platform multimedia player |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
2 * Copyright (C) 2003-2004 BMP development team. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
3 * |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
4 * Based on XMMS: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
5 * Copyright (C) 1998-2003 XMMS development team. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
6 * |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
7 * This program is free software; you can redistribute it and/or modify |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
8 * it under the terms of the GNU General Public License as published by |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
9 * the Free Software Foundation; either version 2 of the License, or |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
10 * (at your option) any later version. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
11 * |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
15 * GNU General Public License for more details. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
16 * |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
18 * along with this program; if not, write to the Free Software |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
20 */ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
21 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
22 extern void close_mixer_device(); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
23 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
24 #include <glib.h> |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
25 #include <audacious/util.h> |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
26 #include <string.h> |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
27 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
28 #include <unistd.h> |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
29 #include <fcntl.h> |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
30 #include <errno.h> |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
31 #include <sys/ioctl.h> |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
32 #include <sys/time.h> |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
33 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
34 #include "OSS4.h" |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
35 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
36 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
37 #define NFRAGS 32 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
38 |
1244
d0f1e147cf62
now it saves VMIX volume between sessions
Cristi Magherusan <majeru@atheme-project.org>
parents:
1243
diff
changeset
|
39 static gint fd = 0; |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
40 static char *buffer; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
41 static gboolean going, prebuffer, paused, unpause, do_pause, remove_prebuffer; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
42 static gint device_buffer_used, buffer_size, prebuffer_size, blk_size; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
43 static gint rd_index = 0, wr_index = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
44 static gint output_time_offset = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
45 static guint64 written = 0, output_bytes = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
46 static gint flush; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
47 static gint fragsize, device_buffer_size; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
48 static gchar *device_name; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
49 static GThread *buffer_thread; |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
50 static gboolean select_works; |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
51 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
52 static int (*oss_convert_func) (void **data, int length); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
53 static int (*oss_stereo_convert_func) (void **data, int length, int fmt); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
54 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
55 struct format_info { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
56 union { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
57 AFormat xmms; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
58 int oss; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
59 } format; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
60 int frequency; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
61 int channels; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
62 int bps; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
63 }; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
64 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
65 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
66 /* |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
67 * The format of the data from the input plugin |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
68 * This will never change during a song. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
69 */ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
70 struct format_info input; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
71 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
72 /* |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
73 * The format we get from the effect plugin. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
74 * This will be different from input if the effect plugin does |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
75 * some kind of format conversion. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
76 */ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
77 struct format_info effect; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
78 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
79 /* |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
80 * The format of the data we actually send to the soundcard. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
81 * This might be different from effect if we need to resample or do |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
82 * some other format conversion. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
83 */ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
84 struct format_info output; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
85 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
86 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
87 static void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
88 oss_calc_device_buffer_used(void) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
89 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
90 audio_buf_info buf_info; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
91 if (paused) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
92 device_buffer_used = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
93 else if (!ioctl(fd, SNDCTL_DSP_GETOSPACE, &buf_info)) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
94 device_buffer_used = |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
95 (buf_info.fragstotal * buf_info.fragsize) - buf_info.bytes; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
96 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
97 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
98 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
99 static gint oss_downsample(gpointer ob, guint length, guint speed, |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
100 guint espeed); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
101 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
102 static int |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
103 oss_calc_bitrate(int oss_fmt, int rate, int channels) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
104 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
105 int bitrate = rate * channels; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
106 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
107 if (oss_fmt == AFMT_U16_BE || oss_fmt == AFMT_U16_LE || |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
108 oss_fmt == AFMT_S16_BE || oss_fmt == AFMT_S16_LE) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
109 bitrate *= 2; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
110 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
111 return bitrate; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
112 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
113 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
114 static int |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
115 oss_get_format(AFormat fmt) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
116 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
117 int format = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
118 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
119 switch (fmt) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
120 case FMT_U8: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
121 format = AFMT_U8; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
122 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
123 case FMT_S8: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
124 format = AFMT_S8; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
125 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
126 case FMT_U16_LE: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
127 format = AFMT_U16_LE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
128 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
129 case FMT_U16_BE: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
130 format = AFMT_U16_BE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
131 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
132 case FMT_U16_NE: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
133 #if (G_BYTE_ORDER == G_BIG_ENDIAN) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
134 format = AFMT_U16_BE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
135 #else |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
136 format = AFMT_U16_LE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
137 #endif |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
138 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
139 case FMT_S16_LE: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
140 format = AFMT_S16_LE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
141 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
142 case FMT_S16_BE: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
143 format = AFMT_S16_BE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
144 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
145 case FMT_S16_NE: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
146 #if (G_BYTE_ORDER == G_BIG_ENDIAN) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
147 format = AFMT_S16_BE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
148 #else |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
149 format = AFMT_S16_LE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
150 #endif |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
151 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
152 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
153 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
154 return format; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
155 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
156 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
157 static void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
158 oss_setup_format(AFormat fmt, int rate, int nch) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
159 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
160 effect.format.xmms = fmt; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
161 effect.frequency = rate; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
162 effect.channels = nch; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
163 effect.bps = oss_calc_bitrate(oss_get_format(fmt), rate, nch); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
164 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
165 output.format.oss = oss_get_format(fmt); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
166 output.frequency = rate; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
167 output.channels = nch; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
168 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
169 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
170 fragsize = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
171 while ((1L << fragsize) < effect.bps / 25) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
172 fragsize++; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
173 fragsize--; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
174 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
175 device_buffer_size = ((1L << fragsize) * (NFRAGS + 1)); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
176 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
177 oss_set_audio_params(); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
178 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
179 output.bps = oss_calc_bitrate(output.format.oss, output.frequency, |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
180 output.channels); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
181 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
182 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
183 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
184 gint |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
185 oss_get_written_time(void) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
186 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
187 if (!going) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
188 return 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
189 return (written * 1000) / effect.bps; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
190 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
191 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
192 gint |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
193 oss_get_output_time(void) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
194 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
195 guint64 bytes; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
196 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
197 if (!fd || !going) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
198 return 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
199 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
200 bytes = output_bytes < device_buffer_used ? |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
201 0 : output_bytes - device_buffer_used; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
202 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
203 return output_time_offset + ((bytes * 1000) / output.bps); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
204 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
205 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
206 static int |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
207 oss_used(void) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
208 { |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
209 if (wr_index >= rd_index) |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
210 return wr_index - rd_index; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
211 |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
212 return buffer_size - (rd_index - wr_index); |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
213 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
214 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
215 gint |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
216 oss_playing(void) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
217 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
218 if (!going) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
219 return 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
220 if (!oss_used() && (device_buffer_used - (3 * blk_size)) <= 0) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
221 return FALSE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
222 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
223 return TRUE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
224 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
225 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
226 gint |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
227 oss_free(void) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
228 { |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
229 if (remove_prebuffer && prebuffer) { |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
230 prebuffer = FALSE; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
231 remove_prebuffer = FALSE; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
232 } |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
233 |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
234 if (prebuffer) |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
235 remove_prebuffer = TRUE; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
236 |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
237 if (rd_index > wr_index) |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
238 return (rd_index - wr_index) - device_buffer_size - 1; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
239 |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
240 return (buffer_size - (wr_index - rd_index)) - device_buffer_size - 1; |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
241 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
242 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
243 static inline ssize_t |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
244 write_all(int fd, const void *buf, size_t count) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
245 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
246 size_t done = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
247 do { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
248 ssize_t n = write(fd, (gchar *) buf + done, count - done); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
249 if (n == -1) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
250 if (errno == EINTR) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
251 continue; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
252 else |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
253 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
254 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
255 done += n; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
256 } while (count > done); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
257 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
258 return done; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
259 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
260 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
261 static void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
262 oss_write_audio(gpointer data, int length) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
263 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
264 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
265 audio_buf_info abuf_info; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
266 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
267 if (oss_convert_func != NULL) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
268 length = oss_convert_func(&data, length); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
269 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
270 if (oss_stereo_convert_func != NULL) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
271 length = oss_stereo_convert_func(&data, length, output.format.oss); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
272 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
273 if (effect.frequency == output.frequency) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
274 output_bytes += write_all(fd, data, length); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
275 else |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
276 output_bytes += oss_downsample(data, length, |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
277 effect.frequency, output.frequency); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
278 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
279 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
280 static void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
281 swap_endian(guint16 * data, int length) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
282 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
283 int i; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
284 for (i = 0; i < length; i += 2, data++) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
285 *data = GUINT16_SWAP_LE_BE(*data); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
286 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
287 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
288 #define NOT_NATIVE_ENDIAN ((IS_BIG_ENDIAN && \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
289 (output.format.oss == AFMT_S16_LE || \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
290 output.format.oss == AFMT_U16_LE)) || \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
291 (!IS_BIG_ENDIAN && \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
292 (output.format.oss == AFMT_S16_BE || \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
293 output.format.oss == AFMT_U16_BE))) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
294 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
295 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
296 #define RESAMPLE_STEREO(sample_type) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
297 do { \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
298 const gint shift = sizeof (sample_type); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
299 gint i, in_samples, out_samples, x, delta; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
300 sample_type *inptr = (sample_type *)ob, *outptr; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
301 guint nlen = (((length >> shift) * espeed) / speed); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
302 if (nlen == 0) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
303 break; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
304 nlen <<= shift; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
305 if (NOT_NATIVE_ENDIAN) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
306 swap_endian(ob, length); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
307 if(nlen > nbuffer_size) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
308 { \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
309 nbuffer = g_realloc(nbuffer, nlen); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
310 nbuffer_size = nlen; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
311 } \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
312 outptr = (sample_type *)nbuffer; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
313 in_samples = length >> shift; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
314 out_samples = nlen >> shift; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
315 delta = (in_samples << 12) / out_samples; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
316 for (x = 0, i = 0; i < out_samples; i++) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
317 { \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
318 gint x1, frac; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
319 x1 = (x >> 12) << 12; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
320 frac = x - x1; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
321 *outptr++ = \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
322 (sample_type) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
323 ((inptr[(x1 >> 12) << 1] * \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
324 ((1<<12) - frac) + \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
325 inptr[((x1 >> 12) + 1) << 1] * \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
326 frac) >> 12); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
327 *outptr++ = \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
328 (sample_type) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
329 ((inptr[((x1 >> 12) << 1) + 1] * \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
330 ((1<<12) - frac) + \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
331 inptr[(((x1 >> 12) + 1) << 1) + 1] * \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
332 frac) >> 12); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
333 x += delta; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
334 } \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
335 if (NOT_NATIVE_ENDIAN) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
336 swap_endian(nbuffer, nlen); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
337 w = write_all(fd, nbuffer, nlen); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
338 } while (0) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
339 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
340 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
341 #define RESAMPLE_MONO(sample_type) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
342 do { \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
343 const gint shift = sizeof (sample_type) - 1; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
344 gint i, x, delta, in_samples, out_samples; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
345 sample_type *inptr = (sample_type *)ob, *outptr; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
346 guint nlen = (((length >> shift) * espeed) / speed); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
347 if (nlen == 0) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
348 break; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
349 nlen <<= shift; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
350 if (NOT_NATIVE_ENDIAN) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
351 swap_endian(ob, length); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
352 if(nlen > nbuffer_size) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
353 { \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
354 nbuffer = g_realloc(nbuffer, nlen); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
355 nbuffer_size = nlen; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
356 } \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
357 outptr = (sample_type *)nbuffer; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
358 in_samples = length >> shift; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
359 out_samples = nlen >> shift; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
360 delta = ((length >> shift) << 12) / out_samples; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
361 for (x = 0, i = 0; i < out_samples; i++) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
362 { \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
363 gint x1, frac; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
364 x1 = (x >> 12) << 12; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
365 frac = x - x1; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
366 *outptr++ = \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
367 (sample_type) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
368 ((inptr[x1 >> 12] * ((1<<12) - frac) + \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
369 inptr[(x1 >> 12) + 1] * frac) >> 12); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
370 x += delta; \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
371 } \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
372 if (NOT_NATIVE_ENDIAN) \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
373 swap_endian(nbuffer, nlen); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
374 w = write_all(fd, nbuffer, nlen); \ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
375 } while (0) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
376 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
377 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
378 static gint |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
379 oss_downsample(gpointer ob, guint length, guint speed, guint espeed) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
380 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
381 guint w = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
382 static gpointer nbuffer = NULL; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
383 static guint nbuffer_size = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
384 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
385 switch (output.format.oss) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
386 case AFMT_S16_BE: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
387 case AFMT_S16_LE: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
388 if (output.channels == 2) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
389 RESAMPLE_STEREO(gint16); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
390 else |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
391 RESAMPLE_MONO(gint16); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
392 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
393 case AFMT_U16_BE: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
394 case AFMT_U16_LE: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
395 if (output.channels == 2) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
396 RESAMPLE_STEREO(guint16); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
397 else |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
398 RESAMPLE_MONO(guint16); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
399 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
400 case AFMT_S8: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
401 if (output.channels == 2) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
402 RESAMPLE_STEREO(gint8); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
403 else |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
404 RESAMPLE_MONO(gint8); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
405 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
406 case AFMT_U8: |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
407 if (output.channels == 2) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
408 RESAMPLE_STEREO(guint8); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
409 else |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
410 RESAMPLE_MONO(guint8); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
411 break; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
412 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
413 return w; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
414 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
415 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
416 void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
417 oss_write(gpointer ptr, int length) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
418 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
419 int cnt, off = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
420 |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
421 remove_prebuffer = FALSE; |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
422 |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
423 written += length; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
424 while (length > 0) { |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
425 cnt = MIN(length, buffer_size - wr_index); |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
426 memcpy(buffer + wr_index, (char *) ptr + off, cnt); |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
427 wr_index = (wr_index + cnt) % buffer_size; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
428 length -= cnt; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
429 off += cnt; |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
430 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
431 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
432 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
433 void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
434 oss_close(void) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
435 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
436 if (!going) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
437 return; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
438 going = 0; |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
439 |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
440 g_thread_join(buffer_thread); |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
441 |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
442 g_free(device_name); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
443 oss_free_convert_buffer(); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
444 wr_index = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
445 rd_index = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
446 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
447 close_mixer_device(); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
448 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
449 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
450 void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
451 oss_flush(gint time) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
452 { |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
453 flush = time; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
454 while (flush != -1) |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
455 g_usleep(10000); |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
456 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
457 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
458 void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
459 oss_pause(short p) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
460 { |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
461 if (p == TRUE) |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
462 do_pause = TRUE; |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
463 else |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
464 unpause = TRUE; |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
465 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
466 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
467 gpointer |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
468 oss_loop(gpointer arg) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
469 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
470 gint length, cnt; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
471 fd_set set; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
472 struct timeval tv; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
473 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
474 while (going) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
475 if (oss_used() > prebuffer_size) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
476 prebuffer = FALSE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
477 if (oss_used() > 0 && !paused && !prebuffer) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
478 tv.tv_sec = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
479 tv.tv_usec = 10000; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
480 FD_ZERO(&set); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
481 FD_SET(fd, &set); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
482 if (!select_works || (select(fd + 1, NULL, &set, NULL, &tv) > 0)) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
483 length = MIN(blk_size, oss_used()); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
484 while (length > 0) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
485 cnt = MIN(length, buffer_size - rd_index); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
486 oss_write_audio(buffer + rd_index, cnt); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
487 rd_index = (rd_index + cnt) % buffer_size; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
488 length -= cnt; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
489 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
490 if (!oss_used()) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
491 ioctl(fd, SNDCTL_DSP_POST, 0); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
492 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
493 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
494 else |
1676
aee4ebea943a
xmms_usleep() was removed, use g_usleep()
Matti Hamalainen <ccr@tnsp.org>
parents:
1244
diff
changeset
|
495 g_usleep(10000); |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
496 oss_calc_device_buffer_used(); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
497 if (do_pause && !paused) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
498 do_pause = FALSE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
499 paused = TRUE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
500 /* |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
501 * We lose some data here that is sent to the |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
502 * soundcard, but not yet played. I don't |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
503 * think this is worth fixing. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
504 */ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
505 ioctl(fd, SNDCTL_DSP_RESET, 0); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
506 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
507 else if (unpause && paused) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
508 unpause = FALSE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
509 close(fd); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
510 fd = open(device_name, O_WRONLY); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
511 oss_set_audio_params(); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
512 paused = FALSE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
513 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
514 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
515 if (flush != -1) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
516 /* |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
517 * This close and open is a work around of a |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
518 * bug that exists in some drivers which cause |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
519 * the driver to get fucked up by a reset |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
520 */ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
521 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
522 ioctl(fd, SNDCTL_DSP_RESET, 0); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
523 close(fd); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
524 fd = open(device_name, O_WRONLY); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
525 oss_set_audio_params(); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
526 output_time_offset = flush; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
527 written = ((guint64) flush * input.bps) / 1000; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
528 rd_index = wr_index = output_bytes = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
529 flush = -1; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
530 prebuffer = TRUE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
531 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
532 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
533 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
534 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
535 ioctl(fd, SNDCTL_DSP_RESET, 0); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
536 close(fd); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
537 g_free(buffer); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
538 return NULL; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
539 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
540 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
541 void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
542 oss_set_audio_params(void) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
543 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
544 int frag, stereo, ret; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
545 struct timeval tv; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
546 fd_set set; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
547 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
548 ioctl(fd, SNDCTL_DSP_RESET, 0); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
549 frag = (NFRAGS << 16) | fragsize; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
550 ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
551 /* |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
552 * Set the stream format. This ioctl() might fail, but should |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
553 * return a format that works if it does. |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
554 */ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
555 ioctl(fd, SNDCTL_DSP_SETFMT, &output.format.oss); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
556 if (ioctl(fd, SNDCTL_DSP_SETFMT, &output.format.oss) == -1) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
557 g_warning("SNDCTL_DSP_SETFMT ioctl failed: %s", strerror(errno)); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
558 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
559 stereo = output.channels - 1; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
560 ioctl(fd, SNDCTL_DSP_STEREO, &stereo); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
561 output.channels = stereo + 1; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
562 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
563 oss_stereo_convert_func = oss_get_stereo_convert_func(output.channels, |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
564 effect.channels); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
565 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
566 if (ioctl(fd, SNDCTL_DSP_SPEED, &output.frequency) == -1) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
567 g_warning("SNDCTL_DSP_SPEED ioctl failed: %s", strerror(errno)); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
568 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
569 if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &blk_size) == -1) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
570 blk_size = 1L << fragsize; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
571 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
572 oss_convert_func = |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
573 oss_get_convert_func(output.format.oss, |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
574 oss_get_format(effect.format.xmms)); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
575 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
576 /* |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
577 * Stupid hack to find out if the driver support selects, some |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
578 * drivers won't work properly without a select and some won't |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
579 * work with a select :/ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
580 */ |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
581 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
582 tv.tv_sec = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
583 tv.tv_usec = 50000; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
584 FD_ZERO(&set); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
585 FD_SET(fd, &set); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
586 ret = select(fd + 1, NULL, &set, NULL, &tv); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
587 if (ret > 0) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
588 select_works = TRUE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
589 else |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
590 select_works = FALSE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
591 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
592 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
593 gint |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
594 oss_open(AFormat fmt, gint rate, gint nch) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
595 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
596 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
597 if (oss_cfg.use_alt_audio_device && oss_cfg.alt_audio_device) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
598 device_name = g_strdup(oss_cfg.alt_audio_device); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
599 else { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
600 if (oss_cfg.audio_device > 0) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
601 device_name = |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
602 g_strdup_printf("%s%d", DEV_DSP, oss_cfg.audio_device); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
603 else |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
604 device_name = g_strdup(DEV_DSP); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
605 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
606 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
607 fd = open(device_name, O_WRONLY); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
608 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
609 if (fd == -1) { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
610 g_warning("oss_open(): Failed to open audio device (%s): %s", |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
611 device_name, strerror(errno)); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
612 g_free(device_name); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
613 return 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
614 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
615 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
616 input.format.xmms = fmt; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
617 input.frequency = rate; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
618 input.channels = nch; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
619 input.bps = oss_calc_bitrate(oss_get_format(fmt), rate, nch); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
620 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
621 oss_setup_format(fmt, rate, nch); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
622 |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
623 buffer_size = (oss_cfg.buffer_size * input.bps) / 1000; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
624 |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
625 if (buffer_size < 8192) |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
626 buffer_size = 8192; |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
627 |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
628 prebuffer_size = (buffer_size * oss_cfg.prebuffer) / 100; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
629 if (buffer_size - prebuffer_size < 4096) |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
630 prebuffer_size = buffer_size - 4096; |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
631 |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
632 buffer_size += device_buffer_size; |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
633 buffer = g_malloc0(buffer_size); |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
634 |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
635 flush = -1; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
636 prebuffer = TRUE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
637 wr_index = rd_index = output_time_offset = written = output_bytes = 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
638 paused = FALSE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
639 do_pause = FALSE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
640 unpause = FALSE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
641 remove_prebuffer = FALSE; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
642 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
643 going = 1; |
1686
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
644 |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
645 buffer_thread = g_thread_create(oss_loop, NULL, TRUE, NULL); |
2e8adf61c54f
remove realtime craq from the code
William Pitcock <nenolod@atheme.org>
parents:
1685
diff
changeset
|
646 |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
647 return 1; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
648 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
649 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
650 void oss_tell(AFormat * fmt, gint * rate, gint * nch) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
651 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
652 (*fmt) = input.format.xmms; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
653 (*rate) = input.frequency; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
654 (*nch) = input.channels; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
655 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
656 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
657 //-----------------------------OSS4 MIXER CODE----------------------------- |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
658 static int |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
659 open_mixer_device() //i think we dont need this anymore |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
660 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
661 return 0; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
662 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
663 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
664 void oss_get_volume(int *l, int *r) |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
665 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
666 int v; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
667 long cmd=SNDCTL_DSP_GETPLAYVOL; |
1243
4cf6ccace89c
made OSS report latest set volume when not having opened a vmix device;
Cristi Magherusan <majeru@atheme-project.org>
parents:
1216
diff
changeset
|
668 if(ioctl(fd, cmd, &v) == -1) |
1244
d0f1e147cf62
now it saves VMIX volume between sessions
Cristi Magherusan <majeru@atheme-project.org>
parents:
1243
diff
changeset
|
669 v=vol; |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
670 *r = (v & 0xFF00) >> 8; |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
671 *l = (v & 0x00FF); |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
672 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
673 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
674 void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
675 oss_set_volume(int l, int r) |
1216
cc04ccffaa8d
ignore the VMIX balance setting until it gets fixed by the OSS4 devs
Cristi Magherusan <majeru@atheme-project.org>
parents:
1214
diff
changeset
|
676 { |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
677 long cmd=SNDCTL_DSP_SETPLAYVOL; |
1244
d0f1e147cf62
now it saves VMIX volume between sessions
Cristi Magherusan <majeru@atheme-project.org>
parents:
1243
diff
changeset
|
678 vol = (r << 8) | l; |
d0f1e147cf62
now it saves VMIX volume between sessions
Cristi Magherusan <majeru@atheme-project.org>
parents:
1243
diff
changeset
|
679 ioctl(fd, cmd, &vol); |
1214
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
680 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
681 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
682 void |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
683 close_mixer_device() |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
684 { |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
685 } |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
686 |
2a722c3ccd9e
damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
687 |