comparison libao2/ao_pulse.c @ 26602:d48e2d7191df

Make ao_pulse fall back to s16le format instead of just failing.
author reimar
date Thu, 01 May 2008 16:47:54 +0000
parents bd46b759fd35
children c07abb5a5bef
comparison
equal deleted inserted replaced
26601:590710d64e84 26602:d48e2d7191df
112 112
113 static const struct format_map_s { 113 static const struct format_map_s {
114 int mp_format; 114 int mp_format;
115 pa_sample_format_t pa_format; 115 pa_sample_format_t pa_format;
116 } format_maps[] = { 116 } format_maps[] = {
117 {AF_FORMAT_U8, PA_SAMPLE_U8},
118 {AF_FORMAT_S16_LE, PA_SAMPLE_S16LE}, 117 {AF_FORMAT_S16_LE, PA_SAMPLE_S16LE},
119 {AF_FORMAT_S16_BE, PA_SAMPLE_S16BE}, 118 {AF_FORMAT_S16_BE, PA_SAMPLE_S16BE},
120 {AF_FORMAT_FLOAT_LE, PA_SAMPLE_FLOAT32LE}, 119 {AF_FORMAT_FLOAT_LE, PA_SAMPLE_FLOAT32LE},
121 {AF_FORMAT_FLOAT_BE, PA_SAMPLE_FLOAT32BE}, 120 {AF_FORMAT_FLOAT_BE, PA_SAMPLE_FLOAT32BE},
121 {AF_FORMAT_U8, PA_SAMPLE_U8},
122 {AF_FORMAT_MU_LAW, PA_SAMPLE_ULAW}, 122 {AF_FORMAT_MU_LAW, PA_SAMPLE_ULAW},
123 {AF_FORMAT_A_LAW, PA_SAMPLE_ALAW}, 123 {AF_FORMAT_A_LAW, PA_SAMPLE_ALAW},
124 {AF_FORMAT_UNKNOWN, 0} 124 {AF_FORMAT_UNKNOWN, 0}
125 }; 125 };
126 126
141 141
142 ss.channels = channels; 142 ss.channels = channels;
143 ss.rate = rate_hz; 143 ss.rate = rate_hz;
144 144
145 ao_data.samplerate = rate_hz; 145 ao_data.samplerate = rate_hz;
146 ao_data.format = format;
147 ao_data.channels = channels; 146 ao_data.channels = channels;
148 147
149 fmt_map = format_maps; 148 fmt_map = format_maps;
150 while (fmt_map->mp_format != format) { 149 while (fmt_map->mp_format != format) {
151 if (fmt_map->mp_format == AF_FORMAT_UNKNOWN) { 150 if (fmt_map->mp_format == AF_FORMAT_UNKNOWN) {
152 mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Unsupported sample spec\n"); 151 mp_msg(MSGT_AO, MSGL_V, "AO: [pulse] Unsupported format, using default\n");
153 goto fail; 152 fmt_map = format_maps;
153 break;
154 } 154 }
155 fmt_map++; 155 fmt_map++;
156 } 156 }
157 ao_data.format = fmt_map->mp_format;
157 ss.format = fmt_map->pa_format; 158 ss.format = fmt_map->pa_format;
158 159
159 if (!pa_sample_spec_valid(&ss)) { 160 if (!pa_sample_spec_valid(&ss)) {
160 mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Invalid sample spec\n"); 161 mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Invalid sample spec\n");
161 goto fail; 162 goto fail;