Mercurial > audlegacy
annotate Plugins/Output/sun/audio.c @ 1208:8014500e2c37 trunk
[svn] - shut a make error up by using sinclude instead of normal include when rules.mk doesn't exist yet
author | nenolod |
---|---|
date | Wed, 14 Jun 2006 00:14:13 -0700 |
parents | f9e8807ea6e5 |
children | f12d7e208b43 |
rev | line source |
---|---|
758
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
1 /* |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
2 * Copyright (C) 2001 CubeSoft Communications, Inc. |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
3 * <http://www.csoft.org> |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
4 * |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
7 * the Free Software Foundation; either version 2 of the License, or |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
8 * (at your option) any later version. |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
9 * |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
13 * GNU General Public License for more details. |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
14 * |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
18 */ |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
19 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
20 /* FIXME: g_error() is used several places, it will exit xmms */ |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
21 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
22 #include <errno.h> |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
23 #include "libaudacious/util.h" |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
24 #include "sun.h" |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
25 #include "resample.h" |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
26 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
27 static int sun_bps(int, int, int); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
28 static int sun_format(AFormat); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
29 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
30 static void sun_setformat(AFormat, int, int); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
31 static void sun_setparams(void); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
32 static void *sun_loop(void *); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
33 static int sun_downsample(gpointer, guint, guint, guint); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
34 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
35 static gboolean prebuffer, remove_prebuffer; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
36 static pthread_t buffer_thread; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
37 static int (*sun_convert)(void **, int); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
38 static int realtime; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
39 static int rd_index, wr_index; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
40 static int buffer_size; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
41 static int prebuffer_size; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
42 static int output_time_offset; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
43 static int device_buffer_used; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
44 static int blocksize; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
45 static char *buffer; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
46 static guint64 output_bytes; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
47 static guint64 written; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
48 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
49 /* |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
50 * The format of the data from the input plugin |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
51 * This will never change during a song. |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
52 */ |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
53 struct sun_format input; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
54 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
55 /* |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
56 * The format we get from the effect plugin. |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
57 * This will be different from input if the effect plugin does |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
58 * some kind of format conversion. |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
59 */ |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
60 struct sun_format effect; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
61 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
62 /* |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
63 * The format of the data we actually send to the soundcard. |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
64 * This might be different from effect if we need to resample or do |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
65 * some other format conversion. |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
66 */ |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
67 struct sun_format output; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
68 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
69 static int sun_bps(int sunfmt, int rate, int nch) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
70 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
71 int bitrate; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
72 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
73 bitrate = rate * nch; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
74 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
75 switch (sunfmt) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
76 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
77 case AUDIO_ENCODING_ULINEAR_BE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
78 case AUDIO_ENCODING_ULINEAR_LE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
79 case AUDIO_ENCODING_SLINEAR_BE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
80 case AUDIO_ENCODING_SLINEAR_LE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
81 bitrate *= 2; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
82 break; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
83 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
84 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
85 return (bitrate); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
86 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
87 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
88 static int sun_format(AFormat fmt) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
89 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
90 switch (fmt) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
91 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
92 case FMT_U8: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
93 return (AUDIO_ENCODING_PCM8); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
94 case FMT_S8: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
95 return (AUDIO_ENCODING_SLINEAR); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
96 case FMT_U16_LE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
97 return (AUDIO_ENCODING_ULINEAR_LE); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
98 case FMT_U16_BE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
99 return (AUDIO_ENCODING_ULINEAR_BE); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
100 case FMT_U16_NE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
101 #ifdef WORDS_BIGENDIAN |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
102 return (AUDIO_ENCODING_ULINEAR_BE); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
103 #else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
104 return (AUDIO_ENCODING_ULINEAR_LE); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
105 #endif |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
106 case FMT_S16_LE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
107 return (AUDIO_ENCODING_SLINEAR_LE); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
108 case FMT_S16_BE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
109 return (AUDIO_ENCODING_SLINEAR_BE); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
110 case FMT_S16_NE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
111 #ifdef WORDS_BIGENDIAN |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
112 return (AUDIO_ENCODING_SLINEAR_BE); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
113 #else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
114 return (AUDIO_ENCODING_SLINEAR_LE); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
115 #endif |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
116 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
117 return -1; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
118 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
119 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
120 static void sun_setformat(AFormat fmt, int rate, int nch) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
121 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
122 int sun; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
123 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
124 sun = sun_format(fmt); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
125 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
126 effect.format.sun = sun; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
127 effect.format.xmms = fmt; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
128 effect.frequency = rate; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
129 effect.channels = nch; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
130 effect.bps = sun_bps(sun, rate, nch); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
131 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
132 output.format.sun = sun; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
133 output.format.xmms = fmt; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
134 output.frequency = rate; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
135 output.channels = nch; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
136 sun_setparams(); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
137 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
138 output.bps = sun_bps(output.format.sun, output.frequency, |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
139 output.channels); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
140 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
141 audio.input = &input; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
142 audio.output = &output; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
143 audio.effect = &effect; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
144 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
145 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
146 void sun_setparams(void) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
147 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
148 audio_info_t info; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
149 audio_encoding_t enc; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
150 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
151 AUDIO_INITINFO(&info); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
152 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
153 info.mode = AUMODE_PLAY; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
154 if (ioctl(audio.fd, AUDIO_SETINFO, &info) != 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
155 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
156 g_error("%s: cannot play (%s)", audio.devaudio, |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
157 strerror(errno)); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
158 return; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
159 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
160 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
161 /* |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
162 * Pass 1: try the preferred encoding, if it is supported. |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
163 */ |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
164 enc.index = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
165 while (ioctl(audio.fd, AUDIO_GETENC, &enc) == 0 && |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
166 enc.encoding != output.format.sun) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
167 enc.index++; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
168 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
169 info.play.encoding = enc.encoding; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
170 info.play.precision = enc.precision; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
171 strcpy(output.name, enc.name); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
172 if (ioctl(audio.fd, AUDIO_SETINFO, &info) != 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
173 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
174 g_error("%s: unsupported encoding: %s (%s)", audio.devaudio, |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
175 output.name, strerror(errno)); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
176 return; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
177 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
178 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
179 info.play.channels = output.channels; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
180 ioctl(audio.fd, AUDIO_SETINFO, &info); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
181 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
182 info.play.sample_rate = output.frequency; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
183 if (ioctl(audio.fd, AUDIO_SETINFO, &info) < 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
184 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
185 g_error("%s: cannot handle %i Hz (%s)", audio.devaudio, |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
186 output.frequency, strerror(errno)); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
187 return; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
188 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
189 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
190 if (ioctl(audio.fd, AUDIO_GETINFO, &info) != 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
191 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
192 blocksize = SUN_DEFAULT_BLOCKSIZE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
193 output.channels = info.play.channels; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
194 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
195 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
196 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
197 blocksize = blocksize; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
198 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
199 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
200 sun_convert = sun_get_convert_func(output.format.sun, |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
201 sun_format(effect.format.xmms)); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
202 #if 0 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
203 if (sun_convert != NULL) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
204 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
205 g_warning("audio conversion (output=0x%x effect=0x%x)", |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
206 output.format.sun, sun_format(effect.format.xmms)); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
207 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
208 #endif |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
209 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
210 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
211 static inline void sun_bufused(void) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
212 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
213 audio_offset_t ooffs; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
214 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
215 if (audio.paused) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
216 device_buffer_used = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
217 else if (ioctl(audio.fd, AUDIO_GETOOFFS, &ooffs) == 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
218 device_buffer_used = ooffs.offset; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
219 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
220 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
221 int sun_written_time(void) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
222 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
223 if (!audio.going) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
224 return 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
225 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
226 return ((written * 1000) / effect.bps); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
227 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
228 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
229 int sun_output_time(void) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
230 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
231 guint64 bytes; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
232 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
233 if (!audio.fd || !audio.going) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
234 return 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
235 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
236 if (realtime) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
237 sun_bufused(); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
238 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
239 bytes = output_bytes < device_buffer_used ? |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
240 0 : output_bytes - device_buffer_used; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
241 return (output_time_offset + ((bytes * 1000) / output.bps)); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
242 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
243 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
244 static inline int sun_used(void) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
245 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
246 if (realtime) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
247 return 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
248 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
249 if (wr_index >= rd_index) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
250 return (wr_index - rd_index); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
251 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
252 return (buffer_size - (rd_index - wr_index)); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
253 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
254 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
255 int sun_playing(void) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
256 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
257 if (!audio.going) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
258 return 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
259 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
260 if (realtime) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
261 sun_bufused(); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
262 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
263 if (!sun_used() && (device_buffer_used - (3 * blocksize)) <= 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
264 return (FALSE); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
265 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
266 return (TRUE); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
267 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
268 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
269 int sun_free(void) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
270 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
271 if (realtime) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
272 return (audio.paused ? 0 : 1000000); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
273 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
274 if (remove_prebuffer && prebuffer) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
275 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
276 prebuffer = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
277 remove_prebuffer = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
278 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
279 if (prebuffer) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
280 remove_prebuffer = TRUE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
281 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
282 if (rd_index > wr_index) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
283 return ((rd_index - wr_index) - blocksize - 1); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
284 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
285 return ((buffer_size - (wr_index - rd_index)) - blocksize - 1); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
286 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
287 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
288 static inline ssize_t write_all(int fd, const void *buf, size_t count) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
289 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
290 static ssize_t done; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
291 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
292 for (done = 0; count > done; ) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
293 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
294 static ssize_t n; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
295 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
296 n = write(fd, buf, count - done); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
297 if (n == -1) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
298 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
299 if (errno == EINTR) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
300 continue; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
301 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
302 break; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
303 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
304 done += n; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
305 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
306 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
307 return (done); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
308 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
309 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
310 static inline void sun_write_audio(gpointer data, int length) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
311 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
312 AFormat new_format; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
313 EffectPlugin *ep; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
314 int new_frequency, new_channels; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
315 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
316 new_format = input.format.xmms; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
317 new_frequency = input.frequency; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
318 new_channels = input.channels; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
319 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
320 ep = get_current_effect_plugin(); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
321 if (effects_enabled() && ep && ep->query_format) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
322 ep->query_format(&new_format, &new_frequency, &new_channels); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
323 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
324 if (new_format != effect.format.xmms || |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
325 new_frequency != effect.frequency || |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
326 new_channels != effect.channels) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
327 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
328 output_time_offset += (output_bytes * 1000) / output.bps; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
329 output_bytes = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
330 close(audio.fd); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
331 audio.fd = open(audio.devaudio, O_RDWR); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
332 sun_setformat(new_format, new_frequency, new_channels); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
333 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
334 if (effects_enabled() && ep && ep->mod_samples) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
335 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
336 length = ep->mod_samples(&data, length, input.format.xmms, |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
337 input.frequency, input.channels); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
338 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
339 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
340 if (sun_convert != NULL) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
341 length = sun_convert(&data, length); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
342 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
343 if (effect.frequency == output.frequency) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
344 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
345 output_bytes += write_all(audio.fd, data, length); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
346 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
347 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
348 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
349 output_bytes += sun_downsample(data, length, |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
350 effect.frequency, output.frequency); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
351 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
352 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
353 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
354 static void sun_bswap16(guint16 *data, int len) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
355 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
356 int i; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
357 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
358 for (i = 0; i < len; i += 2, data++) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
359 *data = GUINT16_SWAP_LE_BE(*data); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
360 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
361 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
362 static int sun_downsample(gpointer ob, guint length, guint speed, guint espeed) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
363 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
364 guint w = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
365 static gpointer nbuffer = NULL; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
366 static int nbuffer_size = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
367 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
368 switch (output.format.sun) { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
369 case AUDIO_ENCODING_SLINEAR_BE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
370 case AUDIO_ENCODING_SLINEAR_LE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
371 if (output.channels == 2) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
372 RESAMPLE_STEREO(gint16); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
373 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
374 RESAMPLE_MONO(gint16); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
375 break; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
376 case AUDIO_ENCODING_ULINEAR_BE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
377 case AUDIO_ENCODING_ULINEAR_LE: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
378 if (output.channels == 2) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
379 RESAMPLE_STEREO(guint16); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
380 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
381 RESAMPLE_MONO(guint16); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
382 break; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
383 case AUDIO_ENCODING_SLINEAR: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
384 if (output.channels == 2) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
385 RESAMPLE_STEREO(gint8); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
386 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
387 RESAMPLE_MONO(gint8); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
388 break; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
389 case AUDIO_ENCODING_ULINEAR: |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
390 if (output.channels == 2) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
391 RESAMPLE_STEREO(guint8); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
392 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
393 RESAMPLE_MONO(guint8); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
394 break; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
395 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
396 return (w); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
397 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
398 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
399 void sun_write(gpointer ptr, int length) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
400 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
401 int cnt, off = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
402 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
403 if (realtime) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
404 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
405 if (audio.paused) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
406 return; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
407 sun_write_audio(ptr, length); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
408 written += length; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
409 return; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
410 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
411 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
412 remove_prebuffer = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
413 written += length; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
414 while (length > 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
415 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
416 cnt = MIN(length, buffer_size - wr_index); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
417 memcpy(buffer + wr_index, (char *) ptr + off, cnt); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
418 wr_index = (wr_index + cnt) % buffer_size; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
419 length -= cnt; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
420 off += cnt; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
421 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
422 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
423 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
424 void sun_close(void) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
425 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
426 if (!audio.going) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
427 return; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
428 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
429 audio.going = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
430 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
431 if (realtime) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
432 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
433 ioctl(audio.fd, AUDIO_FLUSH, NULL); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
434 close(audio.fd); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
435 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
436 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
437 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
438 pthread_join(buffer_thread, NULL); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
439 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
440 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
441 sun_get_convert_buffer(0); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
442 wr_index = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
443 rd_index = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
444 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
445 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
446 void sun_flush(int time) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
447 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
448 ioctl(audio.fd, AUDIO_FLUSH, NULL); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
449 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
450 output_time_offset = time; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
451 written = (guint16)(time / 10) * (guint64)(input.bps / 100); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
452 output_bytes = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
453 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
454 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
455 void sun_pause(short p) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
456 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
457 if (!realtime) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
458 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
459 if (p == TRUE) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
460 audio.do_pause = TRUE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
461 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
462 audio.unpause = TRUE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
463 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
464 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
465 audio.paused = p; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
466 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
467 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
468 static void* sun_loop(void *arg) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
469 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
470 struct timeval tv; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
471 int length, cnt; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
472 fd_set set; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
473 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
474 while (audio.going) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
475 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
476 if (sun_used() > prebuffer_size) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
477 prebuffer = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
478 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
479 if (sun_used() > 0 && !audio.paused && !prebuffer) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
480 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
481 tv.tv_sec = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
482 tv.tv_usec = 10000; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
483 FD_ZERO(&set); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
484 FD_SET(audio.fd, &set); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
485 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
486 if (select(audio.fd + 1, NULL, &set, NULL, &tv) > 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
487 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
488 length = MIN(blocksize, sun_used()); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
489 while (length > 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
490 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
491 cnt = MIN(length, |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
492 buffer_size - rd_index); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
493 sun_write_audio( |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
494 buffer + rd_index, cnt); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
495 rd_index = (rd_index + cnt) % |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
496 buffer_size; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
497 length -= cnt; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
498 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
499 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
500 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
501 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
502 xmms_usleep(10000); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
503 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
504 sun_bufused(); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
505 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
506 if (audio.do_pause && !audio.paused) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
507 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
508 audio.do_pause = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
509 audio.paused = TRUE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
510 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
511 rd_index -= device_buffer_used; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
512 output_bytes -= device_buffer_used; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
513 if (rd_index < 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
514 rd_index += buffer_size; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
515 ioctl(audio.fd, AUDIO_FLUSH, NULL); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
516 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
517 else if (audio.unpause && audio.paused) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
518 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
519 audio.unpause = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
520 close(audio.fd); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
521 audio.fd = open(audio.devaudio, O_RDWR); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
522 sun_setparams(); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
523 audio.paused = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
524 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
525 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
526 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
527 close(audio.fd); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
528 g_free(buffer); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
529 pthread_exit(NULL); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
530 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
531 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
532 int sun_open(AFormat fmt, int rate, int nch) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
533 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
534 audio_info_t info; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
535 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
536 AUDIO_INITINFO(&info); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
537 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
538 if ((audio.fd = open(audio.devaudio, O_RDWR)) < 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
539 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
540 g_error("%s: %s", audio.devaudio, strerror(errno)); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
541 return 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
542 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
543 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
544 input.format.xmms = fmt; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
545 input.frequency = rate; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
546 input.channels = nch; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
547 input.bps = sun_bps(sun_format(fmt), rate, nch); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
548 sun_setformat(fmt, rate, nch); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
549 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
550 realtime = xmms_check_realtime_priority(); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
551 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
552 if (ioctl(audio.fd, AUDIO_GETINFO, &info) != 0) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
553 blocksize = SUN_DEFAULT_BLOCKSIZE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
554 else |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
555 blocksize = info.blocksize; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
556 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
557 if (!realtime) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
558 { |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
559 buffer_size = audio.req_buffer_size; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
560 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
561 if (buffer_size < SUN_MIN_BUFFER_SIZE) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
562 buffer_size = SUN_MIN_BUFFER_SIZE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
563 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
564 prebuffer_size = (buffer_size * audio.req_prebuffer_size) / 100; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
565 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
566 buffer_size += blocksize; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
567 buffer = g_malloc0(buffer_size); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
568 } |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
569 prebuffer = TRUE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
570 wr_index = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
571 rd_index = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
572 output_time_offset = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
573 written = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
574 output_bytes = 0; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
575 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
576 audio.paused = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
577 audio.do_pause = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
578 audio.unpause = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
579 remove_prebuffer = FALSE; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
580 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
581 audio.going++; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
582 if (!realtime) |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
583 pthread_create(&buffer_thread, NULL, sun_loop, NULL); |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
584 |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
585 return 1; |
f9e8807ea6e5
[svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff
changeset
|
586 } |