Skip to content

Commit 31f2ab5

Browse files
z-s-eperexg
authored andcommitted
pcm: documentation improvement mostly regarding samples and frames
In some places samples and frames are used interchangeably, which may be a little confusing, so update it to say 'frames' where it could matter. Closes: #375 Signed-off-by: Jaroslav Kysela <[email protected]>
1 parent c3fec78 commit 31f2ab5

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/pcm/pcm.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ standard C open function - see 'man 2 open'). In non-blocked behaviour,
9696
these I/O functions never stops, they return -EAGAIN error code, when no
9797
data can be transferred (the ring buffer is full in our case). In blocked
9898
behaviour, these I/O functions stop and wait until there is a room in the
99-
ring buffer (playback) or until there are a new samples (capture). The ALSA
99+
ring buffer (playback) or until there are new samples (capture). The ALSA
100100
implementation can be found in the \ref alsa_pcm_rw section.
101101
102102
\subsection pcm_transfer_event Event waiting routines
@@ -351,9 +351,9 @@ enumeration.
351351
These parameters - #snd_pcm_sw_params_t can be modified at
352352
any time including the running state.
353353
354-
\par Minimum available count of samples
354+
\par Minimum available count of frames
355355
356-
This parameter controls the wakeup point. If the count of available samples
356+
This parameter controls the wakeup point. If the count of available frames
357357
is equal or greater than this value, then application will be activated.
358358
359359
\par Timestamp mode
@@ -372,49 +372,49 @@ is ignored by device. Usually, this value is set to one (no align).
372372
\par Start threshold
373373
374374
The start threshold parameter is used to determine the start point in
375-
stream. For playback, if samples in ring buffer is equal or greater than
376-
the start threshold parameters and the stream is not running, the stream will
377-
be started automatically from the device. For capture, if the application wants
378-
to read count of samples equal or greater then the stream will be started.
379-
If you want to use explicit start (#snd_pcm_start), you can
380-
set this value greater than ring buffer size (in samples), but use the
381-
constant LONG_MAX or the boundary value is not a bad idea.
375+
stream. For playback, if the frame count in the ring buffer is equal or greater
376+
than the start threshold parameter and the stream is not running, the stream
377+
will be started automatically from the device. For capture, if the application
378+
wants to read count of frames equal or greater then the stream will be started.
379+
If you want to use explicit start (#snd_pcm_start), you can set this value
380+
greater than the ring buffer size (in frames). For that simply using a large
381+
constant such as LONG_MAX or the boundary value is not a bad idea.
382382
383383
\par Stop threshold
384384
385385
Similarly, the stop threshold parameter is used to automatically stop
386-
the running stream, when the available samples crosses this boundary.
386+
the running stream, when the available frames crosses this boundary.
387387
It means, for playback, the empty samples in ring buffer and for capture,
388388
the filled (used) samples in ring buffer.
389389
390390
\par Silence threshold
391391
392-
The silence threshold specifies count of samples filled with silence
393-
ahead of the current application pointer for playback. It is usable
394-
for applications when an overrun is possible (like tasks depending on
395-
network I/O etc.). If application wants to manage the ahead samples itself,
396-
the #snd_pcm_rewind() function allows to forget the last
397-
samples in the stream.
392+
The silence threshold specifies the count of frames before an underrun when the
393+
buffer gets filled with frames of silence according to the silence size parameter
394+
ahead of the current application pointer for playback. It is usable for applications
395+
when an underrun is possible (like tasks depending on network I/O etc.). If
396+
application wants to manage the ahead samples itself, the #snd_pcm_rewind() function
397+
allows to forget the last samples in the stream.
398398
399399
\section pcm_status Obtaining stream status
400400
401401
The stream status is stored in #snd_pcm_status_t structure.
402402
These parameters can be obtained: the current stream state -
403403
#snd_pcm_status_get_state(), timestamp of trigger -
404404
#snd_pcm_status_get_trigger_tstamp(), timestamp of last
405-
pointer update #snd_pcm_status_get_tstamp(), delay in samples -
406-
#snd_pcm_status_get_delay(), available count in samples -
407-
#snd_pcm_status_get_avail(), maximum available samples -
405+
pointer update #snd_pcm_status_get_tstamp(), delay in frames -
406+
#snd_pcm_status_get_delay(), available count in frames -
407+
#snd_pcm_status_get_avail(), maximum available frames -
408408
#snd_pcm_status_get_avail_max(), ADC over-range count in
409-
samples - #snd_pcm_status_get_overrange(). The last two
409+
frames - #snd_pcm_status_get_overrange(). The last two
410410
parameters - avail_max and overrange are reset to zero after the status
411411
call.
412412
413413
\subsection pcm_status_fast Obtaining stream state fast and update r/w pointer
414414
415415
<p>
416416
The function #snd_pcm_avail_update() updates the current
417-
available count of samples for writing (playback) or filled samples for
417+
available count of frames for writing (playback) or filled frames for
418418
reading (capture). This call is mandatory for updating actual r/w pointer.
419419
Using standalone, it is a light method to obtain current stream position,
420420
because it does not require the user <-> kernel context switch, but the value
@@ -427,10 +427,10 @@ The function #snd_pcm_avail() reads the current hardware pointer
427427
in the ring buffer from hardware and calls #snd_pcm_avail_update() then.
428428
</p>
429429
<p>
430-
The function #snd_pcm_delay() returns the delay in samples.
431-
For playback, it means count of samples in the ring buffer before
432-
the next sample will be sent to DAC. For capture, it means count of samples
433-
in the ring buffer before the next sample will be captured from ADC. It works
430+
The function #snd_pcm_delay() returns the delay in frames.
431+
For playback, it means count of frames in the ring buffer before
432+
the next frames will be sent to DAC. For capture, it means count of frames
433+
in the ring buffer before the next frames will be captured from ADC. It works
434434
only when the stream is in the running or draining (playback only) state.
435435
Note that this function does not update the current r/w pointer for applications,
436436
so the function #snd_pcm_avail_update() must be called afterwards

0 commit comments

Comments
 (0)