Opened 14 years ago

Closed 14 years ago

#10081 closed Bug Report - General (fixed)

ALSA: Distorted 24bit playback

Reported by: mac20xx@… Owned by: JYA
Priority: minor Milestone: 0.25
Component: MythTV - Audio Output Version: 0.24.1
Severity: medium Keywords:
Cc: Ticket locked: no

Description

If the decoded audio-data is stored in upper 24bits of 4 bytes alsa output is distorted.

see http://lkml.indiana.edu/hypermail/linux/kernel/0806.3/0134.html

Changing audiooutputalsa.cpp fixed it at least for flac and wave files on my system.

bool AudioOutputALSA::OpenDevice?() {

...

switch (output_format) {

case FORMAT_U8: format = SND_PCM_FORMAT_U8; break; case FORMAT_S16: format = SND_PCM_FORMAT_S16; break; The data is stored in upper 24bits of 4 bytes case FORMAT_S24: format = SND_PCM_FORMAT_S32; break; case FORMAT_S32: format = SND_PCM_FORMAT_S32; break; case FORMAT_FLT: format = SND_PCM_FORMAT_FLOAT; break; default:

Error(QString("Unknown sample format: %1").arg(output_format)); return false;

}

...

}

If all audio-decoders use the upper 24bits of 4 bytes for their data everything should work

Attachments (2)

mythtv.log---original (12.3 KB) - added by mac20xx@… 14 years ago.
mythtv.log---patched (12.8 KB) - added by mac20xx@… 14 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 14 years ago by JYA

Either provide a path, or a sample to reproduce the problem..

Fwiw, 24bits LSB/MSB conversion is done well before it ever reach alsa and should there be any problems, it's not to be done in the alsa code.

comment:2 Changed 14 years ago by JYA

Status: newinfoneeded_new

comment:3 in reply to:  description ; Changed 14 years ago by mac20xx@…

To me its not a problem of byte conversation but a problem of bit location. When using SND_PCM_FORMAT_S24 alsa fetches data from bits 0-24, when using SND_PCM_FORMAT_S32 from bits 8-31.

For testing create a 24bit wave file: sox input.flac -3 24bit.wav This should play fine with aplay Turn volume to zero, start playback in mythmusic and then slowly increase volume.

On my system I only hear very loud white noise without the changes I suggested.

comment:4 in reply to:  3 Changed 14 years ago by mac20xx@…

Different point of view:

If the audio-decoder gets 24bit data and stores it in bits 8-31 of an integer then he's doing an on-the-fly s24_(3)le to s32_le conversation. Input format is still s24_(3)le but what alsa gets is s32_le.

comment:5 Changed 14 years ago by JYA

still waiting for a log (with -v audio) and a sample exhibiting the problem

Changed 14 years ago by mac20xx@…

Attachment: mythtv.log---original added

Changed 14 years ago by mac20xx@…

Attachment: mythtv.log---patched added

comment:6 in reply to:  5 Changed 14 years ago by mac20xx@…

Replying to jyavenard:

still waiting for a log (with -v audio) and a sample exhibiting the problem

Sorry, got a call from work

mythtv.log---original: everything distorted except the 32bit thing

mythtv.log---patched: everything works for me

Where should I upload the samples (8 and 11Mb)

comment:7 Changed 14 years ago by Github

Milestone: unknown0.25
Resolution: fixed
Status: infoneeded_newclosed

Add ALSA playback support for 24 bits LSB audio.

Fixes #10081

Branch: master Changeset: 3dd7439c498a372718b6d8e449cc75340a724324

Note: See TracTickets for help on using tickets.