[pulseaudio-tickets] [PulseAudio] #133: ALSA's SND_PCM_FORMAT_U16_BE (and LE) not supported, Allegro fails to initialize sound
PulseAudio
trac-noreply at tango.0pointer.de
Sat Oct 6 00:48:58 PDT 2007
#133: ALSA's SND_PCM_FORMAT_U16_BE (and LE) not supported, Allegro fails to
initialize sound
----------------------------+-----------------------------------------------
Reporter: izm | Owner: lennart
Type: defect | Status: new
Priority: normal | Milestone:
Component: module-alsa-* | Severity: normal
Resolution: | Keywords: allegro alsa format snd_pcm_format
----------------------------+-----------------------------------------------
Changes (by izm):
* keywords: allegro alsa => allegro alsa format snd_pcm_format
* summary: Allegro fails to initialize sound => ALSA's
SND_PCM_FORMAT_U16_BE (and LE) not supported,
Allegro fails to initialize sound
Comment:
After some (a lot of) poking, I've discovered that Allegro uses
SND_PCM_FORMAT_U16_BE and SND_PCM_FORMAT_U16_LE to set the format, and
these are '''NOT DEFINED''' in PA's alsa-util.c. alsa-util.c only defines
translations for SND_PCM_FORMAT_S16_LE and SND_PCM_FORMAT_S16_BE, but not
the unsigned equivalents, so Allegro's sound format gets assigned
PA_SAMPLE_INVALID, which of course would make the "Invalid argument"
message make sense.
Tanuk, in IRC, suggested that either more formats could be added to the
alsa plugin which would perform the translation, or more formats could be
supported in pulseaudio.
The ALSA driver for Allegro can be seen here:
[https://alleg.svn.sourceforge.net/svnroot/alleg/allegro/branches/4.3.10plus/src/unix/alsa9.c
alsa9.c]
Here's a snip of the code that handles the format, from the alsa_init()
function:
{{{
format = ((alsa_bits == 16) ? SND_PCM_FORMAT_U16_NE : SND_PCM_FORMAT_U8);
switch (format) {
case SND_PCM_FORMAT_U8:
alsa_bits = 8;
break;
case SND_PCM_FORMAT_U16_NE:
if (sizeof(short) != 2) {
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
get_config_text("Unsupported sample format"));
goto Error;
}
break;
default:
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
get_config_text("Unsupported sample format"));
goto Error;
}
alsa_sample_size = (alsa_bits / 8) * (alsa_stereo ? 2 : 1);
if (fragsize == 0) {
unsigned int size = alsa_rate * ALSA_DEFAULT_BUFFER_MS / 1000 /
numfrags;
fragsize = 1;
while (fragsize < size)
fragsize <<= 1;
}
snd_pcm_hw_params_malloc(&hwparams);
snd_pcm_sw_params_malloc(&swparams);
ALSA9_CHECK(snd_pcm_hw_params_any(pcm_handle, hwparams));
ALSA9_CHECK(snd_pcm_hw_params_set_access(pcm_handle, hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED));
ALSA9_CHECK(snd_pcm_hw_params_set_format(pcm_handle, hwparams,
format));
}}}
where the macros of importance are:
{{{
#ifndef SND_PCM_FORMAT_S16_NE
#ifdef ALLEGRO_BIG_ENDIAN
#define SND_PCM_FORMAT_S16_NE SND_PCM_FORMAT_S16_BE
#else
#define SND_PCM_FORMAT_S16_NE SND_PCM_FORMAT_S16_LE
#endif
#endif
#ifndef SND_PCM_FORMAT_U16_NE
#ifdef ALLEGRO_BIG_ENDIAN
#define SND_PCM_FORMAT_U16_NE SND_PCM_FORMAT_U16_BE
#else
#define SND_PCM_FORMAT_U16_NE SND_PCM_FORMAT_U16_LE
#endif
#endif
#define ALSA9_CHECK(a) do { \
int err = (a); \
if (err<0) { \
uszprintf(allegro_error, ALLEGRO_ERROR_SIZE, "ALSA: %s : %s", #a,
get_config_text(snd_strerror(err))); \
goto Error; \
} \
} while(0)
}}}
--
Ticket URL: <http://www.pulseaudio.org/ticket/133#comment:3>
PulseAudio <http://pulseaudio.org/>
The PulseAudio Sound Server
More information about the pulseaudio-bugs
mailing list