annotate libao2/ao_alsa1x.c @ 5835:104fce2b92b6

fix fullscreen (?)
author pontscho
date Thu, 25 Apr 2002 21:52:47 +0000
parents d141f1e9cc36
children c21948cd027d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
1 /*
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
2 ao_alsa9 - ALSA-0.9.x output plugin for MPlayer
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
3
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
4 (C) Alex Beregszaszi <alex@naxine.org>
1180
c50cd5db2359 added warning message
al3x
parents: 1146
diff changeset
5
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
6 modified for better alsa-0.9.0beta8a-support by Joy Winter <joy@pingfm.org>
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
7
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
8 This driver is still at alpha stage.
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
9 If you want stable sound-support use the OSS emulation instead.
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
10
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
11 Any bugreports regarding to this driver are welcome either to the mplayer-user-mailinglist or directly to the authors.
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
12 */
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
13
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
14 #include <errno.h>
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
15 #include <sys/asoundlib.h>
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
16
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
17 #include "../config.h"
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
18
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
19 #include "audio_out.h"
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
20 #include "audio_out_internal.h"
1058
cab5ba9ffc6c fixed AFMT_ stuff (inclue afmt.h)
arpi_esp
parents: 1050
diff changeset
21 #include "afmt.h"
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
22
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
23 extern int verbose;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
24
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
25 static ao_info_t info =
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
26 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
27 "ALSA-0.9.x audio output",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
28 "alsa9",
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
29 "Alex Beregszaszi <alex@naxine.org>, Joy Winter <joy@pingfm.org>",
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
30 "under developement"
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
31 };
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
32
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
33 LIBAO_EXTERN(alsa9)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
34
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
35
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
36 static snd_pcm_t *alsa_handler;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
37 static snd_pcm_format_t alsa_format;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
38 static snd_pcm_hw_params_t *alsa_hwparams;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
39 static snd_pcm_sw_params_t *alsa_swparams;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
40 static char *alsa_device;
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
41 #define ALSA_DEVICE_SIZE 48
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
42
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
43 static int alsa_fragsize = 8192; /* possible 4096, original 8192 */
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
44 static int alsa_fragcount = 8;
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
45
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
46 static int chunk_size = -1;
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
47 static int start_delay = 1;
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
48
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
49 /* to set/get/query special features/parameters */
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
50 static int control(int cmd, int arg)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
51 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
52 switch(cmd)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
53 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
54 case AOCONTROL_GET_DEVICE:
1146
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
55 return((char *)alsa_device); /* egy kicsit brutalis, dehat :) */
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
56 case AOCONTROL_SET_DEVICE:
1146
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
57 {
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
58 int ret;
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
59
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
60 strncpy(alsa_device, (char *)arg, ALSA_DEVICE_SIZE);
1146
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
61 uninit();
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
62 ret = init(ao_data.samplerate, ao_data.channels, ao_data.format, 0);
1146
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
63 if (ret == 0)
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
64 return(CONTROL_ERROR);
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
65 else
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
66 return(CONTROL_OK);
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
67 }
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
68 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
69 return(CONTROL_UNKNOWN);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
70 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
71
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
72 #undef start /* orig. undef */
3135
168b7ed7ec55 Parse bug fixed (I hope)
anders
parents: 3129
diff changeset
73 #define buffsize
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
74 #define buffertime /* orig. undef? */
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
75 #define set_period
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
76 #define sw_params /* orig. undef */
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
77 #undef set_start_mode /* orig. undef */
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
78
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
79 /*
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
80 open & setup audio device
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
81 return: 1=success 0=fail
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
82 */
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
83 static int init(int rate_hz, int channels, int format, int flags)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
84 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
85 int err;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
86 int cards = -1;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
87 snd_pcm_info_t *alsa_info;
1180
c50cd5db2359 added warning message
al3x
parents: 1146
diff changeset
88
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
89 size_t xfer_align; //new
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
90 snd_pcm_uframes_t start_threshold, stop_threshold; //new
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
91
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
92 printf("alsa-init: this driver is still at alpha-stage. if you want stable sound support use the OSS emulation instead.\n");
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
93 printf("alsa-init: requested format: %d Hz, %d channels, %s\n", rate_hz,
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
94 channels, audio_out_format_name(format));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
95
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
96 alsa_handler = NULL;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
97
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
98 if (verbose)
2059
3c390543302c alsa9 pecs by joy_ping <joy@pingfm.org>
pontscho
parents: 1207
diff changeset
99 printf("alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR);
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
100
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
101 if ((err = snd_card_next(&cards)) < 0 || cards < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
102 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
103 printf("alsa-init: no soundcards found: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
104 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
105 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
106
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
107 ao_data.samplerate = rate_hz;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
108 ao_data.bps = channels; /* really this is bytes per frame so bad varname */
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
109 ao_data.format = format;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
110 ao_data.channels = channels;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
111 ao_data.outburst = OUTBURST;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
112 ao_data.buffersize = 16384;
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
113
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
114 switch (format)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
115 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
116 case AFMT_S8:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
117 alsa_format = SND_PCM_FORMAT_S8;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
118 break;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
119 case AFMT_U8:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
120 alsa_format = SND_PCM_FORMAT_U8;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
121 break;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
122 case AFMT_U16_LE:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
123 alsa_format = SND_PCM_FORMAT_U16_LE;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
124 break;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
125 case AFMT_U16_BE:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
126 alsa_format = SND_PCM_FORMAT_U16_BE;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
127 break;
5790
d141f1e9cc36 AFMT_AC3 autodetect/fallback to S16
arpi
parents: 3135
diff changeset
128 #ifndef WORDS_BIGENDIAN
d141f1e9cc36 AFMT_AC3 autodetect/fallback to S16
arpi
parents: 3135
diff changeset
129 case AFMT_AC3:
d141f1e9cc36 AFMT_AC3 autodetect/fallback to S16
arpi
parents: 3135
diff changeset
130 #endif
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
131 case AFMT_S16_LE:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
132 alsa_format = SND_PCM_FORMAT_S16_LE;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
133 break;
5790
d141f1e9cc36 AFMT_AC3 autodetect/fallback to S16
arpi
parents: 3135
diff changeset
134 #ifdef WORDS_BIGENDIAN
d141f1e9cc36 AFMT_AC3 autodetect/fallback to S16
arpi
parents: 3135
diff changeset
135 case AFMT_AC3:
d141f1e9cc36 AFMT_AC3 autodetect/fallback to S16
arpi
parents: 3135
diff changeset
136 #endif
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
137 case AFMT_S16_BE:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
138 alsa_format = SND_PCM_FORMAT_S16_BE;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
139 break;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
140 default:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
141 alsa_format = SND_PCM_FORMAT_MPEG;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
142 break;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
143 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
144
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
145 switch(alsa_format)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
146 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
147 case SND_PCM_FORMAT_S16_LE:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
148 case SND_PCM_FORMAT_U16_LE:
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
149 ao_data.bps *= 2;
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
150 break;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
151 case -1:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
152 printf("alsa-init: invalid format (%s) requested - output disabled\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
153 audio_out_format_name(format));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
154 return(0);
1115
a16b569f2702 -Wall style cleanups, TEST IT, it can be working by others
al3x
parents: 1058
diff changeset
155 default:
a16b569f2702 -Wall style cleanups, TEST IT, it can be working by others
al3x
parents: 1058
diff changeset
156 break;
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
157 }
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
158
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
159 if ((err = snd_pcm_info_malloc(&alsa_info)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
160 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
161 printf("alsa-init: memory allocation error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
162 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
163 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
164
3129
6d965759dd01 ao_subdevice fixed. 10l...
arpi
parents: 3095
diff changeset
165 if (ao_subdevice != NULL)
6d965759dd01 ao_subdevice fixed. 10l...
arpi
parents: 3095
diff changeset
166 alsa_device = ao_subdevice;
1207
bf18175dfad7 ao_subdevice support added
al3x
parents: 1180
diff changeset
167
1146
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
168 if (alsa_device == NULL)
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
169 {
1146
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
170 if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL)
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
171 {
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
172 printf("alsa-init: memory allocation error: %s\n", strerror(errno));
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
173 return(0);
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
174 }
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
175
1146
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
176 snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d",
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
177 snd_pcm_info_get_device(alsa_info),
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
178 snd_pcm_info_get_subdevice(alsa_info));
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
179
1146
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
180 snd_pcm_info_free(alsa_info);
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
181 }
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
182
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
183 printf("alsa-init: %d soundcard%s found, using: %s\n", cards+1,
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
184 (cards >= 0) ? "" : "s", alsa_device);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
185
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
186 if ((err = snd_pcm_open(&alsa_handler, alsa_device, SND_PCM_STREAM_PLAYBACK,
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
187 0)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
188 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
189 printf("alsa-init: playback open error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
190 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
191 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
192
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
193 snd_pcm_hw_params_malloc(&alsa_hwparams);
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
194 //snd_pcm_sw_params_malloc(&alsa_swparams);
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
195 snd_pcm_sw_params_alloca(&alsa_swparams);
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
196 if ((err = snd_pcm_hw_params_any(alsa_handler, alsa_hwparams)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
197 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
198 printf("alsa-init: unable to get initial parameters: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
199 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
200 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
201 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
202
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
203 if ((err = snd_pcm_hw_params_set_access(alsa_handler, alsa_hwparams,
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
204 SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
205 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
206 printf("alsa-init: unable to set access type: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
207 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
208 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
209 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
210
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
211 if ((err = snd_pcm_hw_params_set_format(alsa_handler, alsa_hwparams,
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
212 alsa_format)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
213 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
214 printf("alsa-init: unable to set format: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
215 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
216 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
217 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
218
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
219 if ((err = snd_pcm_hw_params_set_channels(alsa_handler, alsa_hwparams,
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
220 ao_data.channels)) < 0)
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
221 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
222 printf("alsa-init: unable to set channels: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
223 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
224 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
225 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
226
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
227 if ((err = snd_pcm_hw_params_set_rate_near(alsa_handler, alsa_hwparams, ao_data.samplerate, 0)) < 0)
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
228 /* was originally only snd_pcm_hw_params_set_rate jp*/
2059
3c390543302c alsa9 pecs by joy_ping <joy@pingfm.org>
pontscho
parents: 1207
diff changeset
229 {
3c390543302c alsa9 pecs by joy_ping <joy@pingfm.org>
pontscho
parents: 1207
diff changeset
230 printf("alsa-init: unable to set samplerate-2: %s\n",
3c390543302c alsa9 pecs by joy_ping <joy@pingfm.org>
pontscho
parents: 1207
diff changeset
231 snd_strerror(err));
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
232 //snd_pcm_hw_params_dump(alsa_hwparams, errlog); jp
2059
3c390543302c alsa9 pecs by joy_ping <joy@pingfm.org>
pontscho
parents: 1207
diff changeset
233 return(0);
3c390543302c alsa9 pecs by joy_ping <joy@pingfm.org>
pontscho
parents: 1207
diff changeset
234 }
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
235
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
236 #ifdef set_period
1115
a16b569f2702 -Wall style cleanups, TEST IT, it can be working by others
al3x
parents: 1058
diff changeset
237 {
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
238 if ((err = snd_pcm_hw_params_set_period_size(alsa_handler, alsa_hwparams, alsa_fragsize / 4, 0)) < 0)
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
239 {
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
240 printf("alsa-init: unable to set periodsize: %s\n",
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
241 snd_strerror(err));
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
242 return(0);
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
243 }
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
244 if ((err = snd_pcm_hw_params_set_periods(alsa_handler, alsa_hwparams, alsa_fragcount, 0)) < 0)
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
245 {
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
246 printf("alsa-init: unable to set periods: %s\n",
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
247 snd_strerror(err));
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
248 return(0);
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
249 }
1115
a16b569f2702 -Wall style cleanups, TEST IT, it can be working by others
al3x
parents: 1058
diff changeset
250 }
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
251 #endif
3135
168b7ed7ec55 Parse bug fixed (I hope)
anders
parents: 3129
diff changeset
252 #ifdef buffsize
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
253 if ((err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
254 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
255 printf("alsa-init: unable to get buffer size: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
256 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
257 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
258 } else
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
259 {
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
260 ao_data.buffersize = err;
1146
a84610bb5476 hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents: 1129
diff changeset
261 if (verbose)
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
262 printf("alsa-init: got buffersize %i\n", ao_data.buffersize);
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
263 }
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
264 #endif
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
265
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
266 #ifdef buffertime
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
267 {
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
268 int alsa_buffer_time = 500000; /* original 60 */
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
269
2059
3c390543302c alsa9 pecs by joy_ping <joy@pingfm.org>
pontscho
parents: 1207
diff changeset
270 if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams, alsa_buffer_time, 0)) < 0)
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
271 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
272 printf("alsa-init: unable to set buffer time near: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
273 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
274 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
275 } else
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
276 alsa_buffer_time = err;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
277
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
278 if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, alsa_hwparams, alsa_buffer_time/4, 0)) < 0)
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
279 /* original: alsa_buffer_time/ao_data.bps */
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
280 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
281 printf("alsa-init: unable to set period time: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
282 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
283 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
284 }
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
285 printf("alsa-init: buffer_time: %d, period_time :%d\n",
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
286 alsa_buffer_time, err);
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
287 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
288 #endif
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
289
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
290 if ((err = snd_pcm_hw_params(alsa_handler, alsa_hwparams)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
291 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
292 printf("alsa-init: unable to set parameters: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
293 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
294 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
295 }
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
296
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
297 #ifdef sw_params
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
298 {
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
299 chunk_size = snd_pcm_hw_params_get_period_size(alsa_hwparams, 0);
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
300 start_threshold = (double) ao_data.samplerate * start_delay / 1000000;
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
301 xfer_align = snd_pcm_sw_params_get_xfer_align(alsa_swparams);
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
302
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
303 if ((err = snd_pcm_sw_params_current(alsa_handler, alsa_swparams)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
304 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
305 printf("alsa-init: unable to get parameters: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
306 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
307 return(0);
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
308 }
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
309
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
310 if ((err = snd_pcm_sw_params_set_avail_min(alsa_handler, alsa_swparams, chunk_size)) < 0)
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
311 {
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
312 printf("alsa-init: unable to set avail_min %s\n",snd_strerror(err));
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
313 return(0);
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
314 }
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
315
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
316
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
317
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
318 if ((err = snd_pcm_sw_params_set_start_threshold(alsa_handler, alsa_swparams, start_threshold)) < 0)
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
319 {
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
320 printf("alsa-init: unable to set start_threshold %s\n",snd_strerror(err));
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
321 return(0);
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
322 }
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
323 }
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
324 // if ((err = snd_pcm_sw_params_set_xfer_align(alsa_handler, alsa_swparams, xfer_align)) < 0)
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
325 //{
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
326 // printf("alsa-init: unable to set xfer_align: %s\n",
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
327 // snd_strerror(err));
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
328 // return(0);
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
329 //}
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
330
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
331 #ifdef set_start_mode
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
332 if ((err = snd_pcm_sw_params_set_start_mode(alsa_handler, alsa_swparams,
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
333 SND_PCM_START_DATA)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
334 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
335 printf("alsa-init: unable to set start mode: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
336 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
337 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
338 }
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
339 #endif
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
340
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
341 if ((err = snd_pcm_sw_params(alsa_handler, alsa_swparams)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
342 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
343 printf("alsa-init: unable to set parameters: %s\n",
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
344 snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
345 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
346 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
347
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
348 // snd_pcm_sw_params_default(alsa_handler, alsa_swparams);
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
349 #endif
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
350 if ((err = snd_pcm_prepare(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
351 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
352 printf("alsa-init: pcm prepare error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
353 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
354 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
355
1115
a16b569f2702 -Wall style cleanups, TEST IT, it can be working by others
al3x
parents: 1058
diff changeset
356 #ifdef start
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
357 if ((err = snd_pcm_start(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
358 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
359 printf("alsa-init: pcm start error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
360 if (err != -EPIPE)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
361 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
362 if ((err = snd_pcm_start(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
363 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
364 printf("alsa-init: pcm start error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
365 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
366 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
367 }
1115
a16b569f2702 -Wall style cleanups, TEST IT, it can be working by others
al3x
parents: 1058
diff changeset
368 #endif
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
369 printf("AUDIO: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n",
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
370 ao_data.samplerate, ao_data.channels, ao_data.bps, ao_data.buffersize,
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
371 snd_pcm_format_description(alsa_format));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
372 return(1);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
373 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
374
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
375 /* close audio device */
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
376 static void uninit()
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
377 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
378 int err;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
379
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
380 if (alsa_device != NULL)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
381 free(alsa_device);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
382
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
383 snd_pcm_hw_params_free(alsa_hwparams);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
384 snd_pcm_sw_params_free(alsa_swparams);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
385
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
386 if ((err = snd_pcm_drain(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
387 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
388 printf("alsa-uninit: pcm drain error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
389 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
390 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
391
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
392 #ifdef start
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
393 if ((err = snd_pcm_reset(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
394 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
395 printf("alsa-uninit: pcm reset error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
396 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
397 }
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
398 #endif
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
399
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
400 if ((err = snd_pcm_close(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
401 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
402 printf("alsa-uninit: pcm close error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
403 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
404 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
405 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
406
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
407 static void audio_pause()
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
408 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
409 int err;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
410
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
411 if ((err = snd_pcm_drain(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
412 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
413 printf("alsa-pause: pcm drain error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
414 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
415 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
416
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
417 #ifdef reset
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
418 if ((err = snd_pcm_reset(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
419 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
420 printf("alsa-pause: pcm reset error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
421 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
422 }
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
423 #endif
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
424 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
425
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
426 static void audio_resume()
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
427 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
428 int err;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
429
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
430 if ((err = snd_pcm_prepare(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
431 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
432 printf("alsa-resume: pcm prepare error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
433 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
434 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
435
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
436 #ifdef start
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
437 if ((err = snd_pcm_start(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
438 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
439 printf("alsa-resume: pcm start error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
440 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
441 }
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
442 #endif
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
443 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
444
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
445 /* stop playing and empty buffers (for seeking/pause) */
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
446 static void reset()
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
447 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
448 int err;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
449
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
450 if ((err = snd_pcm_drain(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
451 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
452 printf("alsa-reset: pcm drain error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
453 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
454 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
455
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
456 #ifdef start
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
457 if ((err = snd_pcm_reset(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
458 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
459 printf("alsa-reset: pcm reset error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
460 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
461 }
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
462 #endif
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
463
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
464 if ((err = snd_pcm_prepare(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
465 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
466 printf("alsa-reset: pcm prepare error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
467 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
468 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
469
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
470 #ifdef start
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
471 if ((err = snd_pcm_start(alsa_handler)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
472 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
473 printf("alsa-reset: pcm start error: %s\n", snd_strerror(err));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
474 return;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
475 }
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
476 #endif
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
477 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
478
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
479 /*
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
480 plays 'len' bytes of 'data'
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
481 returns: number of bytes played
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
482 */
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
483 static int play(void* data, int len, int flags)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
484 {
1115
a16b569f2702 -Wall style cleanups, TEST IT, it can be working by others
al3x
parents: 1058
diff changeset
485 int got_len;
a16b569f2702 -Wall style cleanups, TEST IT, it can be working by others
al3x
parents: 1058
diff changeset
486
2059
3c390543302c alsa9 pecs by joy_ping <joy@pingfm.org>
pontscho
parents: 1207
diff changeset
487 got_len = snd_pcm_writei(alsa_handler, data, len / 4);
3c390543302c alsa9 pecs by joy_ping <joy@pingfm.org>
pontscho
parents: 1207
diff changeset
488
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
489 //if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_data.bps))) != (len/ao_data.bps)) {
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
490 //SHOULD BE FIXED
1115
a16b569f2702 -Wall style cleanups, TEST IT, it can be working by others
al3x
parents: 1058
diff changeset
491 if (got_len == -EPIPE) /* underrun? */
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
492 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
493 printf("alsa-play: alsa underrun, resetting stream\n");
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
494 if ((got_len = snd_pcm_prepare(alsa_handler)) < 0)
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
495 {
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
496 printf("alsa-play: playback prepare error: %s\n", snd_strerror(got_len));
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
497 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
498 }
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
499 if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_data.bps))) != (len/ao_data.bps))
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
500 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
501 printf("alsa-play: write error after reset: %s - giving up\n",
1128
d2dd25dd11bc Hacked it working, still needs fixings!
atmosfear
parents: 1115
diff changeset
502 snd_strerror(got_len));
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
503 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
504 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
505 return(len); /* 2nd write was ok */
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
506 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
507 return(len);
2209
a59f952fad34 applied patch by Joy Winter <joy@pingfm.org>
arpi
parents: 2059
diff changeset
508 //}
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
509 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
510
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
511 /* how many byes are free in the buffer */
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
512 static int get_space()
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
513 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
514 snd_pcm_status_t *status;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
515 int ret;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
516
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
517 if ((ret = snd_pcm_status_malloc(&status)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
518 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
519 printf("alsa-space: memory allocation error: %s\n", snd_strerror(ret));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
520 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
521 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
522
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
523 if ((ret = snd_pcm_status(alsa_handler, status)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
524 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
525 printf("alsa-space: cannot get pcm status: %s\n", snd_strerror(ret));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
526 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
527 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
528
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
529 switch(snd_pcm_status_get_state(status))
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
530 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
531 case SND_PCM_STATE_OPEN:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
532 case SND_PCM_STATE_PREPARED:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
533 case SND_PCM_STATE_RUNNING:
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
534 ret = snd_pcm_status_get_avail(status) * ao_data.bps;
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
535 break;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
536 default:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
537 ret = 0;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
538 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
539
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
540 snd_pcm_status_free(status);
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
541
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
542 if (ret < 0)
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
543 ret = 0;
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
544 return(ret);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
545 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
546
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
547 /* delay in seconds between first and last sample in buffer */
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
548 static float get_delay()
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
549 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
550 snd_pcm_status_t *status;
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
551 float ret;
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
552
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
553 if ((ret = snd_pcm_status_malloc(&status)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
554 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
555 printf("alsa-delay: memory allocation error: %s\n", snd_strerror(ret));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
556 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
557 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
558
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
559 if ((ret = snd_pcm_status(alsa_handler, status)) < 0)
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
560 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
561 printf("alsa-delay: cannot get pcm status: %s\n", snd_strerror(ret));
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
562 return(0);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
563 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
564
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
565 switch(snd_pcm_status_get_state(status))
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
566 {
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
567 case SND_PCM_STATE_OPEN:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
568 case SND_PCM_STATE_PREPARED:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
569 case SND_PCM_STATE_RUNNING:
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2209
diff changeset
570 ret = (float)snd_pcm_status_get_delay(status)/(float)ao_data.samplerate;
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
571 break;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
572 default:
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
573 ret = 0;
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
574 }
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
575
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
576 snd_pcm_status_free(status);
1129
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
577
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
578 if (ret < 0)
705fa4ac4fed hacked to work seek/pause/resume/uninit
al3x
parents: 1128
diff changeset
579 ret = 0;
1050
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
580 return(ret);
87eb4325baf6 first release, meg nem akar menni :(
al3x
parents:
diff changeset
581 }