Skip to contentSkip to conversation

snd_pcm_sw_params_set_xfer_align replacement?

DISCUSSION Aaron J. Grier 3 participants 7 messages Jul 18, 2008 – Jul 31, 2008

lore
Share & tools
lore
#0 lore raw

snd_pcm_sw_params_set_xfer_align() has been deprecated but the docs don't mention what it was replaced with.

I don't ever want or need partial reads and writes -- my app would actually be happiest being completely synchronous to the hardware with fixed-size buffers. any suggestions how to get ALSA to do this?

Signature · 1 line
  Aaron J. Grier | "Not your ordinary poofy goof." | [email protected]
#1 lore raw
Quoted 2 lines · Aaron J. Grier

snd_pcm_sw_params_set_xfer_align() has been deprecated but the docs don't mention what it was replaced with.

There is no replacement; the transfer alignment always is one frame, i.e., there is none.

Quoted 1 line

I don't ever want or need partial reads and writes

You get partial reads/writes only when you ask for it (by using non- blocking mode) or when an error occurs.

HTH
Clemens

#2 lore raw
Quoted 6 lines · Clemens Ladisch
Quoted 2 lines · Aaron J. Grier

snd_pcm_sw_params_set_xfer_align() has been deprecated but the docs don't mention what it was replaced with.

There is no replacement; the transfer alignment always is one frame, i.e., there is none.

would it be possible for a note to be added to the documentation explaining this?

Quoted 4 lines
Quoted 1 line

I don't ever want or need partial reads and writes

You get partial reads/writes only when you ask for it (by using non- blocking mode) or when an error occurs.

I want non-blocking behavior (return immediately if there is no data available), but I don't want to have to deal with partial reads. I figured out a workaround using snd_pcm_avail_update(), but I'm wondering if there isn't a better way.

if I switched to using callbacks, how would I control the amount of data passed to the callbacks now that set_xfer_align() is gone?

Signature · 1 line
  Aaron J. Grier | "Not your ordinary poofy goof." | [email protected]
#3 lore raw
Quoted 8 lines · Aaron J. Grier
Quoted 2 lines · Clemens Ladisch

You get partial reads/writes only when you ask for it (by using non- blocking mode) or when an error occurs.

I want non-blocking behavior (return immediately if there is no data available), but I don't want to have to deal with partial reads. I figured out a workaround using snd_pcm_avail_update(), but I'm wondering if there isn't a better way.

You could write your own read function that calls snd_pcm_read*() repeatedly until you have as much data as you want, but this is probably more complex than just checking for data before doing a blocking read.

Regards,
Clemens

#4 lore raw
In reply to Aaron J. Grier

At Mon, 21 Jul 2008 11:31:35 -0700,

Quoted 11 lines · Aaron J. Grier
Quoted 6 lines · Clemens Ladisch
Quoted 2 lines · Aaron J. Grier

snd_pcm_sw_params_set_xfer_align() has been deprecated but the docs don't mention what it was replaced with.

There is no replacement; the transfer alignment always is one frame, i.e., there is none.

would it be possible for a note to be added to the documentation explaining this?

Patch please :)

Note that the transfer alignment was really buggy, and didn't work at all like what you imagined from its name. This has nothing to do with the period size and wake-up setting.

Takashi

#5 lore raw

[PATCH - snd_pcm_sw_params_set_xfer_align doc update 1add notes regarding snd_pcm_sw_params_set_xfer_align's deprecation and

src/pcm/pcm.c +11 -0
index ee2300e..a937b40 100644
@@ -5694,6 +5694,17 @@ int snd_pcm_sw_params_get_period_event(const snd_pcm_sw_params_t *params, int *v
  * \param params Software configuration container
  * \param val Chunk size (frames are attempted to be transferred in chunks)
  * \return 0 otherwise a negative error code
+ *
+ * "There is no replacement; the transfer alignment always is one
+ * frame[.]" -- Clemens Ladisch <[email protected]>
+ *
+ * "Note that the transfer alignment was really buggy, and didn't work
+ * at all like what you imagined from its name." -- Takashi Iwai
+ * <[email protected]>
+ *
+ * If fixed-size transfers are required, use \ref snd_pcm_avail_update
+ * if to determine the number of frames available before reading or
+ * writing.
  */
 #ifndef DOXYGEN
 int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params ATTRIBUTE_UNUSED, snd_pcm_uframes_t val ATTRIBUTE_UNUSED)
Signature · 1 line
1.5.4.1
#6 lore raw

[PATCH - snd_pcm_sw_params_set_xfer_align doc update 2fix grammatical error

src/pcm/pcm.c +1 -1
index a937b40..ada697a 100644
@@ -5703,7 +5703,7 @@ int snd_pcm_sw_params_get_period_event(const snd_pcm_sw_params_t *params, int *v
  * <[email protected]>
  *
  * If fixed-size transfers are required, use \ref snd_pcm_avail_update
- * if to determine the number of frames available before reading or
+ * to determine the number of frames available before reading or
  * writing.
  */
 #ifndef DOXYGEN
Signature · 1 line
1.5.4.1