Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#8267 closed defect (fixed)

bug in alsa use.

Reported by: dengxf@… Owned by: JYA
Priority: minor Milestone: unknown
Component: MythTV - Audio Output Version: head
Severity: low Keywords:
Cc: foobum@… Ticket locked: no

Description

function SetParameters? in audiooutputalsa.cpp, there is a wrong usage of alsa api. snd_pcm_hw_params_get_buffer_size or snd_pcm_hw_params_get_period_size should be called after snd_pcm_hw_params. if it is called before snd_pcm_hw_params, they maybe failed. for example: call snd_pcm_hw_params_set_rate_near with 12000, when call snd_pcm_hw_params_get_buffer_size, it will failed.

here is a patch: --- audiooutputalsa.cpp.orig 2010-04-01 20:09:31.000000000 +0800 +++ audiooutputalsa.cpp 2010-04-01 20:09:59.000000000 +0800 @@ -421,16 +421,6 @@

return err;

}

  • if ((err = snd_pcm_hw_params_get_buffer_size(params, &buffer_size)) < 0)
  • {
  • Error(QString("Unable to get buffer size for playback: %1")
  • .arg(snd_strerror(err)));
  • return err;
  • } else {
  • VERBOSE(VB_AUDIO, QString("get_buffer_size returned %1").arg(buffer_size));
  • }
  • soundcard_buffer_size = buffer_size * audio_bytes_per_sample;

-

/* set the period time */ if ((err = snd_pcm_hw_params_set_period_time_near(

handle, params, &period_time, &dir)) < 0)

@@ -442,20 +432,30 @@

VERBOSE(VB_AUDIO, QString("set_period_time_near returned %1").arg(period_time));

}

  • if ((err = snd_pcm_hw_params_get_period_size(params, &period_size,
  • &dir)) < 0) {
  • Error(QString("Unable to get period size for playback: %1")

+ /* write the parameters to device */ + if ((err = snd_pcm_hw_params(handle, params)) < 0) { + Error(QString("Unable to set hw params for playback: %1") + .arg(snd_strerror(err))); + return err; + } + + if ((err = snd_pcm_hw_params_get_buffer_size(params, &buffer_size)) < 0) + { + Error(QString("Unable to get buffer size for playback: %1")

.arg(snd_strerror(err)));

return err;

} else {

  • VERBOSE(VB_AUDIO, QString("get_period_size returned %1").arg(period_size));

+ VERBOSE(VB_AUDIO, QString("get_buffer_size returned %1").arg(buffer_size));

}

+ soundcard_buffer_size = buffer_size * audio_bytes_per_sample;

  • /* write the parameters to device */
  • if ((err = snd_pcm_hw_params(handle, params)) < 0) {
  • Error(QString("Unable to set hw params for playback: %1")

+ if ((err = snd_pcm_hw_params_get_period_size(params, &period_size, + &dir)) < 0) { + Error(QString("Unable to get period size for playback: %1")

.arg(snd_strerror(err)));

return err;

+ } else { + VERBOSE(VB_AUDIO, QString("get_period_size returned %1").arg(period_size));

}

/* get the current swparams */

Attachments (1)

mythtv-alsa.patch (2.5 KB) - added by tarek-spam@… 14 years ago.
patch

Download all attachments as: .zip

Change History (7)

Changed 14 years ago by tarek-spam@…

Attachment: mythtv-alsa.patch added

patch

comment:1 Changed 14 years ago by tarek-spam@…

I've attached a patch file because the above was mangled

comment:3 Changed 14 years ago by JYA

Cc: foobum@… added

comment:5 Changed 14 years ago by stuartm

Ticket locked: set

comment:6 Changed 14 years ago by JYA

Milestone: 0.23unknown
Severity: mediumlow
Ticket locked: unset
Version: 0.23rc1head

comment:7 Changed 14 years ago by JYA

Resolution: fixed
Status: newclosed

Fixed since merge of hd-audio branch

comment:8 Changed 14 years ago by JYA

Some more information following questions on IRC. The ALSA code this patch was modifying doesn't exist anymore. Most of the code in ALSA was fully rewritten.

The patch attached in the ticket wasn't used.

Note: See TracTickets for help on using tickets.