Bug 495558 - Initialize sydneyaudio/ALSA with host endian format (fixes sound on big endian machines). r=chris.double

--HG--
extra : rebase_source : d2635e23f0e65a7e9db397d54f998610fa2348f6
This commit is contained in:
Matthew Gregan 2009-09-07 14:44:39 +12:00
parent 4d45703ece
commit 1ccbfca6b5
4 changed files with 52 additions and 2 deletions

View File

@ -19,6 +19,7 @@ sydney_os2_base.patch: Bug 448918 - add OS/2 support (this patch should
sydney_os2_moz.patch: Bug 448918 - add Mozilla-specific code to
sydney_audio_os2.c
bug495794_closeAudio.patch fixes a crash when destroying the sa_stream_t after
a failed attempt to open the stream.
bug495558_alsa_endian.patch adds support for big endian ALSA platforms.

View File

@ -0,0 +1,44 @@
diff --git a/media/libsydneyaudio/src/sydney_audio_alsa.c b/media/libsydneyaudio/src/sydney_audio_alsa.c
--- a/media/libsydneyaudio/src/sydney_audio_alsa.c
+++ b/media/libsydneyaudio/src/sydney_audio_alsa.c
@@ -93,17 +93,17 @@ sa_stream_create_pcm(
if (_s == NULL) {
return SA_ERROR_INVALID;
}
*_s = NULL;
if (mode != SA_MODE_WRONLY) {
return SA_ERROR_NOT_SUPPORTED;
}
- if (format != SA_PCM_FORMAT_S16_LE) {
+ if (format != SA_PCM_FORMAT_S16_NE) {
return SA_ERROR_NOT_SUPPORTED;
}
/*
* Allocate the instance and required resources.
*/
if ((s = malloc(sizeof(sa_stream_t))) == NULL) {
return SA_ERROR_OOM;
@@ -137,17 +137,21 @@ sa_stream_open(sa_stream_t *s) {
if (snd_pcm_open(&s->output_unit,
"default",
SND_PCM_STREAM_PLAYBACK,
0) < 0) {
return SA_ERROR_NO_DEVICE;
}
if (snd_pcm_set_params(s->output_unit,
+#ifdef SA_LITTLE_ENDIAN
SND_PCM_FORMAT_S16_LE,
+#else
+ SND_PCM_FORMAT_S16_BE,
+#endif
SND_PCM_ACCESS_RW_INTERLEAVED,
s->n_channels,
s->rate,
1,
500000) < 0) {
snd_pcm_close(s->output_unit);
s->output_unit = NULL;
return SA_ERROR_NOT_SUPPORTED;

View File

@ -98,7 +98,7 @@ sa_stream_create_pcm(
if (mode != SA_MODE_WRONLY) {
return SA_ERROR_NOT_SUPPORTED;
}
if (format != SA_PCM_FORMAT_S16_LE) {
if (format != SA_PCM_FORMAT_S16_NE) {
return SA_ERROR_NOT_SUPPORTED;
}
@ -142,7 +142,11 @@ sa_stream_open(sa_stream_t *s) {
}
if (snd_pcm_set_params(s->output_unit,
#ifdef SA_LITTLE_ENDIAN
SND_PCM_FORMAT_S16_LE,
#else
SND_PCM_FORMAT_S16_BE,
#endif
SND_PCM_ACCESS_RW_INTERLEAVED,
s->n_channels,
s->rate,

View File

@ -10,3 +10,4 @@ patch -p4 <include-CoreServices.patch
patch -p4 <sydney_os2_base.patch
patch -p4 <sydney_os2_moz.patch
patch -p3 <bug495794_closeAudio.patch
patch -p3 < bug495558_alsa_endian.patch