Skip to content

Commit

Permalink
aplay: fix big-endian
Browse files Browse the repository at this point in the history
  • Loading branch information
borine authored and arkq committed Feb 7, 2025
1 parent b804ba8 commit df4afab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions utils/aplay/aplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,8 @@ static void *io_worker_routine(struct io_worker *w) {
pcm_flags = SND_PCM_NO_AUTO_RESAMPLE | SND_PCM_NO_AUTO_FORMAT;
/* The libsamplerate resampler uses FLOAT internally, so prefer that if
* the ALSA device supports it, to avoid the need to convert;
* otherwise convert to the native endian integer format that is input
* to the resampler. */
* otherwise use the native endian integer format that is output
* from the resampler. */
format_1 = resampler_preferred_format();
format_2 = resampler_native_format(pcm_format);
}
Expand Down
10 changes: 6 additions & 4 deletions utils/aplay/resampler.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ void resampler_format_le_to_native(void *buffer, size_t len, snd_pcm_format_t fo
uint32_t *data = buffer;
/* Convert to S32 */
for (n = 0; n < len; n++) {
if (data[n] & 0x00800000)
data[n] |= 0xff000000;
if (data[n] & 0x00000800)
data[n] |= 0x000000ff;
else
data[n] &= 0x00ffffff;
data[n] &= 0xffffff00;
bswap_32(data[n]);
}
break;
Expand All @@ -299,7 +299,9 @@ snd_pcm_format_t resampler_native_format(snd_pcm_format_t source_format) {
case SND_PCM_FORMAT_S16_LE:
return SND_PCM_FORMAT_S16;
case SND_PCM_FORMAT_S24_LE:
return SND_PCM_FORMAT_S24;
/* 24bit samples must be converted to 32 bit before passing to
* the resampler */
return SND_PCM_FORMAT_S32;
case SND_PCM_FORMAT_S32_LE:
return SND_PCM_FORMAT_S32;
default:
Expand Down

0 comments on commit df4afab

Please sign in to comment.