summaryrefslogtreecommitdiffstats
path: root/meta-moblin/packages/pulseaudio/pulseaudio-0.9.15/alsaerror.patch
blob: 2efa3e89b8d232a3196d716a9ada64e24bd857f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
From: Lennart Poettering <lennart@poettering.net>
Date: Sun, 19 Apr 2009 17:22:51 +0000 (+0200)
Subject: alsa: properly convert return values of snd_strerror() to utf8
X-Git-Url: http://git.0pointer.de/?p=pulseaudio.git;a=commitdiff_plain;h=98a25c506e692ab091b4af7e1b37e8432fc08e8f

alsa: properly convert return values of snd_strerror() to utf8
---

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 2fbcd7b..41e8b47 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -281,7 +281,7 @@ static int try_recover(struct userdata *u, const char *call, int err) {
     pa_assert(call);
     pa_assert(err < 0);
 
-    pa_log_debug("%s: %s", call, snd_strerror(err));
+    pa_log_debug("%s: %s", call, pa_alsa_strerror(err));
 
     pa_assert(err != -EAGAIN);
 
@@ -289,7 +289,7 @@ static int try_recover(struct userdata *u, const char *call, int err) {
         pa_log_debug("%s: Buffer underrun!", call);
 
     if ((err = snd_pcm_recover(u->pcm_handle, err, 1)) < 0) {
-        pa_log("%s: %s", call, snd_strerror(err));
+        pa_log("%s: %s", call, pa_alsa_strerror(err));
         return -1;
     }
 
@@ -636,12 +636,12 @@ static void update_smoother(struct userdata *u) {
     /* Let's update the time smoother */
 
     if (PA_UNLIKELY((err = pa_alsa_safe_delay(u->pcm_handle, &delay, u->hwbuf_size, &u->sink->sample_spec)) < 0)) {
-        pa_log_warn("Failed to query DSP status data: %s", snd_strerror(err));
+        pa_log_warn("Failed to query DSP status data: %s", pa_alsa_strerror(err));
         return;
     }
 
     if (PA_UNLIKELY((err = snd_pcm_status(u->pcm_handle, status)) < 0))
-        pa_log_warn("Failed to get timestamp: %s", snd_strerror(err));
+        pa_log_warn("Failed to get timestamp: %s", pa_alsa_strerror(err));
     else {
         snd_htimestamp_t htstamp = { 0, 0 };
         snd_pcm_status_get_htstamp(status, &htstamp);
@@ -764,7 +764,7 @@ static int update_sw_params(struct userdata *u) {
     pa_log_debug("setting avail_min=%lu", (unsigned long) avail_min);
 
     if ((err = pa_alsa_set_sw_params(u->pcm_handle, avail_min)) < 0) {
-        pa_log("Failed to set software parameters: %s", snd_strerror(err));
+        pa_log("Failed to set software parameters: %s", pa_alsa_strerror(err));
         return err;
     }
 
@@ -792,7 +792,7 @@ static int unsuspend(struct userdata *u) {
                             SND_PCM_NO_AUTO_RESAMPLE|
                             SND_PCM_NO_AUTO_CHANNELS|
                             SND_PCM_NO_AUTO_FORMAT)) < 0) {
-        pa_log("Error opening PCM device %s: %s", u->device_name, snd_strerror(err));
+        pa_log("Error opening PCM device %s: %s", u->device_name, pa_alsa_strerror(err));
         goto fail;
     }
 
@@ -803,7 +803,7 @@ static int unsuspend(struct userdata *u) {
     d = u->use_tsched;
 
     if ((err = pa_alsa_set_hw_params(u->pcm_handle, &ss, &nfrags, &period_size, u->hwbuf_size / u->frame_size, &b, &d, TRUE)) < 0) {
-        pa_log("Failed to set hardware parameters: %s", snd_strerror(err));
+        pa_log("Failed to set hardware parameters: %s", pa_alsa_strerror(err));
         goto fail;
     }
 
@@ -1030,7 +1030,7 @@ static void sink_get_volume_cb(pa_sink *s) {
     return;
 
 fail:
-    pa_log_error("Unable to read volume: %s", snd_strerror(err));
+    pa_log_error("Unable to read volume: %s", pa_alsa_strerror(err));
 }
 
 static void sink_set_volume_cb(pa_sink *s) {
@@ -1141,7 +1141,7 @@ static void sink_set_volume_cb(pa_sink *s) {
     return;
 
 fail:
-    pa_log_error("Unable to set volume: %s", snd_strerror(err));
+    pa_log_error("Unable to set volume: %s", pa_alsa_strerror(err));
 }
 
 static void sink_get_mute_cb(pa_sink *s) {
@@ -1152,7 +1152,7 @@ static void sink_get_mute_cb(pa_sink *s) {
     pa_assert(u->mixer_elem);
 
     if ((err = snd_mixer_selem_get_playback_switch(u->mixer_elem, 0, &sw)) < 0) {
-        pa_log_error("Unable to get switch: %s", snd_strerror(err));
+        pa_log_error("Unable to get switch: %s", pa_alsa_strerror(err));
         return;
     }
 
@@ -1167,7 +1167,7 @@ static void sink_set_mute_cb(pa_sink *s) {
     pa_assert(u->mixer_elem);
 
     if ((err = snd_mixer_selem_set_playback_switch_all(u->mixer_elem, !s->muted)) < 0) {
-        pa_log_error("Unable to set switch: %s", snd_strerror(err));
+        pa_log_error("Unable to set switch: %s", pa_alsa_strerror(err));
         return;
     }
 }
@@ -1206,7 +1206,7 @@ static int process_rewind(struct userdata *u) {
     pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) rewind_nbytes);
 
     if (PA_UNLIKELY((unused = pa_alsa_safe_avail(u->pcm_handle, u->hwbuf_size, &u->sink->sample_spec)) < 0)) {
-        pa_log("snd_pcm_avail() failed: %s", snd_strerror((int) unused));
+        pa_log("snd_pcm_avail() failed: %s", pa_alsa_strerror((int) unused));
         return -1;
     }
 
@@ -1228,7 +1228,7 @@ static int process_rewind(struct userdata *u) {
         in_frames = (snd_pcm_sframes_t) (rewind_nbytes / u->frame_size);
         pa_log_debug("before: %lu", (unsigned long) in_frames);
         if ((out_frames = snd_pcm_rewind(u->pcm_handle, (snd_pcm_uframes_t) in_frames)) < 0) {
-            pa_log("snd_pcm_rewind() failed: %s", snd_strerror((int) out_frames));
+            pa_log("snd_pcm_rewind() failed: %s", pa_alsa_strerror((int) out_frames));
             return -1;
         }
         pa_log_debug("after: %lu", (unsigned long) out_frames);
@@ -1359,7 +1359,7 @@ static void thread_func(void *userdata) {
             pollfd = pa_rtpoll_item_get_pollfd(u->alsa_rtpoll_item, &n);
 
             if ((err = snd_pcm_poll_descriptors_revents(u->pcm_handle, pollfd, n, &revents)) < 0) {
-                pa_log("snd_pcm_poll_descriptors_revents() failed: %s", snd_strerror(err));
+                pa_log("snd_pcm_poll_descriptors_revents() failed: %s", pa_alsa_strerror(err));
                 goto fail;
             }
 
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index c59fc75..843f70b 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -278,7 +278,7 @@ static int try_recover(struct userdata *u, const char *call, int err) {
     pa_assert(call);
     pa_assert(err < 0);
 
-    pa_log_debug("%s: %s", call, snd_strerror(err));
+    pa_log_debug("%s: %s", call, pa_alsa_strerror(err));
 
     pa_assert(err != -EAGAIN);
 
@@ -286,7 +286,7 @@ static int try_recover(struct userdata *u, const char *call, int err) {
         pa_log_debug("%s: Buffer overrun!", call);
 
     if ((err = snd_pcm_recover(u->pcm_handle, err, 1)) < 0) {
-        pa_log("%s: %s", call, snd_strerror(err));
+        pa_log("%s: %s", call, pa_alsa_strerror(err));
         return -1;
     }
 
@@ -606,12 +606,12 @@ static void update_smoother(struct userdata *u) {
     /* Let's update the time smoother */
 
     if (PA_UNLIKELY((err = pa_alsa_safe_delay(u->pcm_handle, &delay, u->hwbuf_size, &u->source->sample_spec)) < 0)) {
-        pa_log_warn("Failed to get delay: %s", snd_strerror(err));
+        pa_log_warn("Failed to get delay: %s", pa_alsa_strerror(err));
         return;
     }
 
     if (PA_UNLIKELY((err = snd_pcm_status(u->pcm_handle, status)) < 0))
-        pa_log_warn("Failed to get timestamp: %s", snd_strerror(err));
+        pa_log_warn("Failed to get timestamp: %s", pa_alsa_strerror(err));
     else {
         snd_htimestamp_t htstamp = { 0, 0 };
         snd_pcm_status_get_htstamp(status, &htstamp);
@@ -721,7 +721,7 @@ static int update_sw_params(struct userdata *u) {
     pa_log_debug("setting avail_min=%lu", (unsigned long) avail_min);
 
     if ((err = pa_alsa_set_sw_params(u->pcm_handle, avail_min)) < 0) {
-        pa_log("Failed to set software parameters: %s", snd_strerror(err));
+        pa_log("Failed to set software parameters: %s", pa_alsa_strerror(err));
         return err;
     }
 
@@ -747,7 +747,7 @@ static int unsuspend(struct userdata *u) {
                             SND_PCM_NO_AUTO_RESAMPLE|
                             SND_PCM_NO_AUTO_CHANNELS|
                             SND_PCM_NO_AUTO_FORMAT)) < 0) {
-        pa_log("Error opening PCM device %s: %s", u->device_name, snd_strerror(err));
+        pa_log("Error opening PCM device %s: %s", u->device_name, pa_alsa_strerror(err));
         goto fail;
     }
 
@@ -758,7 +758,7 @@ static int unsuspend(struct userdata *u) {
     d = u->use_tsched;
 
     if ((err = pa_alsa_set_hw_params(u->pcm_handle, &ss, &nfrags, &period_size, u->hwbuf_size / u->frame_size, &b, &d, TRUE)) < 0) {
-        pa_log("Failed to set hardware parameters: %s", snd_strerror(err));
+        pa_log("Failed to set hardware parameters: %s", pa_alsa_strerror(err));
         goto fail;
     }
 
@@ -988,7 +988,7 @@ static void source_get_volume_cb(pa_source *s) {
     return;
 
 fail:
-    pa_log_error("Unable to read volume: %s", snd_strerror(err));
+    pa_log_error("Unable to read volume: %s", pa_alsa_strerror(err));
 }
 
 static void source_set_volume_cb(pa_source *s) {
@@ -1100,7 +1100,7 @@ static void source_set_volume_cb(pa_source *s) {
     return;
 
 fail:
-    pa_log_error("Unable to set volume: %s", snd_strerror(err));
+    pa_log_error("Unable to set volume: %s", pa_alsa_strerror(err));
 }
 
 static void source_get_mute_cb(pa_source *s) {
@@ -1111,7 +1111,7 @@ static void source_get_mute_cb(pa_source *s) {
     pa_assert(u->mixer_elem);
 
     if ((err = snd_mixer_selem_get_capture_switch(u->mixer_elem, 0, &sw)) < 0) {
-        pa_log_error("Unable to get switch: %s", snd_strerror(err));
+        pa_log_error("Unable to get switch: %s", pa_alsa_strerror(err));
         return;
     }
 
@@ -1126,7 +1126,7 @@ static void source_set_mute_cb(pa_source *s) {
     pa_assert(u->mixer_elem);
 
     if ((err = snd_mixer_selem_set_capture_switch_all(u->mixer_elem, !s->muted)) < 0) {
-        pa_log_error("Unable to set switch: %s", snd_strerror(err));
+        pa_log_error("Unable to set switch: %s", pa_alsa_strerror(err));
         return;
     }
 }
@@ -1218,7 +1218,7 @@ static void thread_func(void *userdata) {
             pollfd = pa_rtpoll_item_get_pollfd(u->alsa_rtpoll_item, &n);
 
             if ((err = snd_pcm_poll_descriptors_revents(u->pcm_handle, pollfd, n, &revents)) < 0) {
-                pa_log("snd_pcm_poll_descriptors_revents() failed: %s", snd_strerror(err));
+                pa_log("snd_pcm_poll_descriptors_revents() failed: %s", pa_alsa_strerror(err));
                 goto fail;
             }
 
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index d2dc6e8..ddc3c77 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -33,6 +33,7 @@
 #include <pulse/timeval.h>
 #include <pulse/util.h>
 #include <pulse/i18n.h>
+#include <pulse/utf8.h>
 
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
@@ -40,6 +41,7 @@
 #include <pulsecore/atomic.h>
 #include <pulsecore/core-error.h>
 #include <pulsecore/once.h>
+#include <pulsecore/thread.h>
 
 #include "alsa-util.h"
 
@@ -106,7 +108,7 @@ static void io_cb(pa_mainloop_api*a, pa_io_event* e, int fd, pa_io_event_flags_t
     pa_assert(i != fdl->num_fds);
 
     if ((err = snd_mixer_poll_descriptors_revents(fdl->mixer, fdl->work_fds, fdl->num_fds, &revents)) < 0) {
-        pa_log_error("Unable to get poll revent: %s", snd_strerror(err));
+        pa_log_error("Unable to get poll revent: %s", pa_alsa_strerror(err));
         return;
     }
 
@@ -129,7 +131,7 @@ static void defer_cb(pa_mainloop_api*a, pa_defer_event* e, void *userdata) {
     a->defer_enable(fdl->defer, 0);
 
     if ((n = snd_mixer_poll_descriptors_count(fdl->mixer)) < 0) {
-        pa_log("snd_mixer_poll_descriptors_count() failed: %s", snd_strerror(n));
+        pa_log("snd_mixer_poll_descriptors_count() failed: %s", pa_alsa_strerror(n));
         return;
     }
     num_fds = (unsigned) n;
@@ -146,7 +148,7 @@ static void defer_cb(pa_mainloop_api*a, pa_defer_event* e, void *userdata) {
     memset(fdl->work_fds, 0, sizeof(struct pollfd) * num_fds);
 
     if ((err = snd_mixer_poll_descriptors(fdl->mixer, fdl->work_fds, num_fds)) < 0) {
-        pa_log_error("Unable to get poll descriptors: %s", snd_strerror(err));
+        pa_log_error("Unable to get poll descriptors: %s", pa_alsa_strerror(err));
         return;
     }
 
@@ -482,42 +484,42 @@ int pa_alsa_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_min) {
     snd_pcm_sw_params_alloca(&swparams);
 
     if ((err = snd_pcm_sw_params_current(pcm, swparams) < 0)) {
-        pa_log_warn("Unable to determine current swparams: %s\n", snd_strerror(err));
+        pa_log_warn("Unable to determine current swparams: %s\n", pa_alsa_strerror(err));
         return err;
     }
 
     if ((err = snd_pcm_sw_params_set_period_event(pcm, swparams, 0)) < 0) {
-        pa_log_warn("Unable to disable period event: %s\n", snd_strerror(err));
+        pa_log_warn("Unable to disable period event: %s\n", pa_alsa_strerror(err));
         return err;
     }
 
     if ((err = snd_pcm_sw_params_set_tstamp_mode(pcm, swparams, SND_PCM_TSTAMP_ENABLE)) < 0) {
-        pa_log_warn("Unable to enable time stamping: %s\n", snd_strerror(err));
+        pa_log_warn("Unable to enable time stamping: %s\n", pa_alsa_strerror(err));
         return err;
     }
 
     if ((err = snd_pcm_sw_params_get_boundary(swparams, &boundary)) < 0) {
-        pa_log_warn("Unable to get boundary: %s\n", snd_strerror(err));
+        pa_log_warn("Unable to get boundary: %s\n", pa_alsa_strerror(err));
         return err;
     }
 
     if ((err = snd_pcm_sw_params_set_stop_threshold(pcm, swparams, boundary)) < 0) {
-        pa_log_warn("Unable to set stop threshold: %s\n", snd_strerror(err));
+        pa_log_warn("Unable to set stop threshold: %s\n", pa_alsa_strerror(err));
         return err;
     }
 
     if ((err = snd_pcm_sw_params_set_start_threshold(pcm, swparams, (snd_pcm_uframes_t) -1)) < 0) {
-        pa_log_warn("Unable to set start threshold: %s\n", snd_strerror(err));
+        pa_log_warn("Unable to set start threshold: %s\n", pa_alsa_strerror(err));
         return err;
     }
 
     if ((err = snd_pcm_sw_params_set_avail_min(pcm, swparams, avail_min)) < 0) {
-        pa_log_error("snd_pcm_sw_params_set_avail_min() failed: %s", snd_strerror(err));
+        pa_log_error("snd_pcm_sw_params_set_avail_min() failed: %s", pa_alsa_strerror(err));
         return err;
     }
 
     if ((err = snd_pcm_sw_params(pcm, swparams)) < 0) {
-        pa_log_warn("Unable to set sw params: %s\n", snd_strerror(err));
+        pa_log_warn("Unable to set sw params: %s\n", pa_alsa_strerror(err));
         return err;
     }
 
@@ -854,7 +856,7 @@ snd_pcm_t *pa_alsa_open_by_device_string(
                                 SND_PCM_NO_AUTO_RESAMPLE|
                                 SND_PCM_NO_AUTO_CHANNELS|
                                 (reformat ? 0 : SND_PCM_NO_AUTO_FORMAT))) < 0) {
-            pa_log_info("Error opening PCM device %s: %s", d, snd_strerror(err));
+            pa_log_info("Error opening PCM device %s: %s", d, pa_alsa_strerror(err));
             goto fail;
         }
 
@@ -882,7 +884,7 @@ snd_pcm_t *pa_alsa_open_by_device_string(
                 continue;
             }
 
-            pa_log_info("Failed to set hardware parameters on %s: %s", d, snd_strerror(err));
+            pa_log_info("Failed to set hardware parameters on %s: %s", d, pa_alsa_strerror(err));
             snd_pcm_close(pcm_handle);
 
             goto fail;
@@ -1000,17 +1002,17 @@ int pa_alsa_prepare_mixer(snd_mixer_t *mixer, const char *dev) {
     pa_assert(dev);
 
     if ((err = snd_mixer_attach(mixer, dev)) < 0) {
-        pa_log_info("Unable to attach to mixer %s: %s", dev, snd_strerror(err));
+        pa_log_info("Unable to attach to mixer %s: %s", dev, pa_alsa_strerror(err));
         return -1;
     }
 
     if ((err = snd_mixer_selem_register(mixer, NULL, NULL)) < 0) {
-        pa_log_warn("Unable to register mixer: %s", snd_strerror(err));
+        pa_log_warn("Unable to register mixer: %s", pa_alsa_strerror(err));
         return -1;
     }
 
     if ((err = snd_mixer_load(mixer)) < 0) {
-        pa_log_warn("Unable to load mixer: %s", snd_strerror(err));
+        pa_log_warn("Unable to load mixer: %s", pa_alsa_strerror(err));
         return -1;
     }
 
@@ -1136,7 +1138,7 @@ int pa_alsa_find_mixer_and_elem(
     }
 
     if ((err = snd_mixer_open(&m, 0)) < 0) {
-        pa_log("Error opening mixer: %s", snd_strerror(err));
+        pa_log("Error opening mixer: %s", pa_alsa_strerror(err));
         return -1;
     }
 
@@ -1338,7 +1340,7 @@ void pa_alsa_dump(pa_log_level_t level, snd_pcm_t *pcm) {
     pa_assert_se(snd_output_buffer_open(&out) == 0);
 
     if ((err = snd_pcm_dump(pcm, out)) < 0)
-        pa_logl(level, "snd_pcm_dump(): %s", snd_strerror(err));
+        pa_logl(level, "snd_pcm_dump(): %s", pa_alsa_strerror(err));
     else {
         char *s = NULL;
         snd_output_buffer_string(out, &s);
@@ -1362,7 +1364,7 @@ void pa_alsa_dump_status(snd_pcm_t *pcm) {
     pa_assert_se(snd_pcm_status(pcm, status) == 0);
 
     if ((err = snd_pcm_status_dump(status, out)) < 0)
-        pa_log_debug("snd_pcm_dump(): %s", snd_strerror(err));
+        pa_log_debug("snd_pcm_dump(): %s", pa_alsa_strerror(err));
     else {
         char *s = NULL;
         snd_output_buffer_string(out, &s);
@@ -1524,7 +1526,7 @@ void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm, snd_m
     snd_pcm_info_alloca(&info);
 
     if ((err = snd_pcm_hw_params_current(pcm, hwparams)) < 0)
-        pa_log_warn("Error fetching hardware parameter info: %s", snd_strerror(err));
+        pa_log_warn("Error fetching hardware parameter info: %s", pa_alsa_strerror(err));
     else {
 
         if ((bits = snd_pcm_hw_params_get_sbits(hwparams)) >= 0)
@@ -1535,7 +1537,7 @@ void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm, snd_m
         pa_proplist_sets(p, "alsa.mixer_element", snd_mixer_selem_get_name(elem));
 
     if ((err = snd_pcm_info(pcm, info)) < 0)
-        pa_log_warn("Error fetching PCM info: %s", snd_strerror(err));
+        pa_log_warn("Error fetching PCM info: %s", pa_alsa_strerror(err));
     else
         pa_alsa_init_proplist_pcm_info(c, p, info);
 }
@@ -1568,14 +1570,14 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
 
         case SND_PCM_STATE_XRUN:
             if ((err = snd_pcm_recover(pcm, -EPIPE, 1)) != 0) {
-                pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP and XRUN: %s", snd_strerror(err));
+                pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP and XRUN: %s", pa_alsa_strerror(err));
                 return -1;
             }
             break;
 
         case SND_PCM_STATE_SUSPENDED:
             if ((err = snd_pcm_recover(pcm, -ESTRPIPE, 1)) != 0) {
-                pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP and SUSPENDED: %s", snd_strerror(err));
+                pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP and SUSPENDED: %s", pa_alsa_strerror(err));
                 return -1;
             }
             break;
@@ -1585,7 +1587,7 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
             snd_pcm_drop(pcm);
 
             if ((err = snd_pcm_prepare(pcm)) < 0) {
-                pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP with snd_pcm_prepare(): %s", snd_strerror(err));
+                pa_log_warn("Could not recover from POLLERR|POLLNVAL|POLLHUP with snd_pcm_prepare(): %s", pa_alsa_strerror(err));
                 return -1;
             }
             break;
@@ -1602,7 +1604,7 @@ pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll) {
     pa_assert(pcm);
 
     if ((n = snd_pcm_poll_descriptors_count(pcm)) < 0) {
-        pa_log("snd_pcm_poll_descriptors_count() failed: %s", snd_strerror(n));
+        pa_log("snd_pcm_poll_descriptors_count() failed: %s", pa_alsa_strerror(n));
         return NULL;
     }
 
@@ -1610,7 +1612,7 @@ pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll) {
     pollfd = pa_rtpoll_item_get_pollfd(item, NULL);
 
     if ((err = snd_pcm_poll_descriptors(pcm, pollfd, (unsigned) n)) < 0) {
-        pa_log("snd_pcm_poll_descriptors() failed: %s", snd_strerror(err));
+        pa_log("snd_pcm_poll_descriptors() failed: %s", pa_alsa_strerror(err));
         pa_rtpoll_item_free(item);
         return NULL;
     }
@@ -1819,3 +1821,30 @@ pa_bool_t pa_alsa_pcm_is_modem(snd_pcm_t *pcm) {
 
     return snd_pcm_info_get_class(info) == SND_PCM_CLASS_MODEM;
 }
+
+PA_STATIC_TLS_DECLARE(cstrerror, pa_xfree);
+
+const char* pa_alsa_strerror(int errnum) {
+    const char *original = NULL;
+    char *translated, *t;
+    char errbuf[128];
+
+    if ((t = PA_STATIC_TLS_GET(cstrerror)))
+        pa_xfree(t);
+
+    original = snd_strerror(errnum);
+
+    if (!original) {
+        pa_snprintf(errbuf, sizeof(errbuf), "Unknown error %i", errnum);
+        original = errbuf;
+    }
+
+    if (!(translated = pa_locale_to_utf8(original))) {
+        pa_log_warn("Unable to convert error string to locale, filtering.");
+        translated = pa_utf8_filter(original);
+    }
+
+    PA_STATIC_TLS_SET(cstrerror, translated);
+
+    return translated;
+}
diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h
index c8acc7c..77ac8a7 100644
--- a/src/modules/alsa/alsa-util.h
+++ b/src/modules/alsa/alsa-util.h
@@ -146,4 +146,6 @@ pa_bool_t pa_alsa_pcm_is_hw(snd_pcm_t *pcm);
 
 pa_bool_t pa_alsa_pcm_is_modem(snd_pcm_t *pcm);
 
+const char* pa_alsa_strerror(int errnum);
+
 #endif
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index fdc952d..51d466e 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -304,7 +304,7 @@ int pa__init(pa_module *m) {
     u->modargs = ma;
 
     if ((alsa_card_index = snd_card_get_index(u->device_id)) < 0) {
-        pa_log("Card '%s' doesn't exist: %s", u->device_id, snd_strerror(alsa_card_index));
+        pa_log("Card '%s' doesn't exist: %s", u->device_id, pa_alsa_strerror(alsa_card_index));
         goto fail;
     }