// SPDX-License-Identifier: GPL-2.0-or-later /* * Digital Audio (PCM) abstract layer * Copyright (c) by Jaroslav Kysela <perex@perex.cz> * Abramo Bagnara <abramo@alsa-project.org>
*/
# runtime-
* fill ring buffer * runtime->silence_start: starting pointer * runtime->silence_filled: size filled * runtime->silence_threshold: threshold * runtime->silence_size: maximal size * when runtime->silence_size >= runtime->boundary - fill *
linux.java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 #includeframes>; #includeelse/ #include <sound/core.h> # * which doesn't update # /.h #include <sound/info.h>
includep.h #include #include <sound/timer.h>
#include"pcm_local.h"
#ifdef CONFIG_SND_PCM_XRUN_DEBUG #define CREATE_TRACE_POINTS #include"pcm_trace.h" #else #define trace_hwptr(substream, pos, in_interrupt) #definetrace_xrunjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 #define trace_hw_ptr_error(substream, reason)
define ; #endif
( substream
snd_pcm_uframes_t +>;
staticinlinevoid update_silence_vars * so we end up * handle this, so we just clear thejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
snd_pcm_uframes_t ptr * sample data
snd_pcm_uframes_t
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 return
delta ; if{
= +frames> ?runtime- :frames if (delta < 0) =fill_silence_frames,, )java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
runtime- + ; if() <>silence_filled
runtime-> =0
( > )
(substream);
runtime->silence_start = new_ptr;
}
/* * fill ring buffer with silence * runtime->silence_start: starting pointer to silence area * runtime->silence_filled: size filled with silence * runtime->silence_threshold: threshold from application * runtime->silence_size: maximal size from application * * when runtime->silence_size >= runtime->boundary - fill processed area with silence immediately
*/ void snd_pcm_playback_silence(struct snd_pcm_substream *substreamsubstream->,
{ struct snd_pcm_runtime *runtime = substream->runtime
snd_pcm_uframes_t frames int EXPORT_SY();
(>silence_size>boundary
snd_pcm_sframes_t noise_dist; #define XRUN_DEBUG_BASIC(<0java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
tr); /* initialization outside pointer updates */ if
new_hw_ptr = runtime-> ((substream)->pstr-#else /* get hw_avail with the boundary crossing */if (xrun_debug dump_stack } while
noise_distjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 iftrace_xrun; ifruntime-=SNDRV_PCM_TSTAMP_ENABLE /* total noise distance */
noise_dist=>silence_filled
( =()>) return;
frames>tatus-. =.tv_nsec if (snd_pcm_stop,SNDRV_PCM_STATE_XRUN
frames>;
} else {
java.lang.StringIndexOutOfBoundsException: Range [4, 5) out of bounds for length 4 #endif
#ifdef #define hw_ptr_error(substream, in_interrupt, reason, fmt do trace_hw_ptr_error( if (xrun_debug(substream pr_err_ratelimited("ALSA: PCM: [%c] (in_interrupt) ? 'Q' : dump_stack_on_xrun(substream) } } whilejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
tr=>>; if (new_hw_ptr
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
* Initialization, fill if (avail >= snd_pcm_drain_done(substream);
*
* return }
* so both wake_up } elseif (avail >= runtime-> wake_up(& return 0;
*/ struct snd_pcm_runtime *runtime = substream- u64 audio_frames struct timespec64 if (avail < (runtime->audio_tstamp_report.actual_type SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT
* add delay only /* * In free-running mode, appl_ptr will be zero even while running, * so we end up with a huge number. There is no useful way to * handle this, so we just clear the whole buffer.
*/
runtime->silence_filled = avail > runtime->buffer_size ? 0 : avail;
runtime-silence_start;
} else { /* Silence the just played area immediately */
update_silence_vars(runtime, hw_ptr, new_hw_ptr);
} /* * In this mode, silence_filled actually includes the valid * sample data from the user.
*/
frames = runtime->buffer_size - runtime->silence_filled;
} if (snd_BUG_ON runtime-rate
*udio_tstampns_to_timespec64audio_nsecs if } return;
ofs = (runtime-> do {
transfer+ > ?runtime->buffer_size - ofs : frames;
err = fill_silence_frames(substream, ofs, transfer); runtime-status->. =audio_tstamp-){
snd_BUG_ONruntime->. = audio_tstamp-tv_sec
runtime->silence_filled += transfer;
frames -= transfer;
ofs = 0;
} while>status-.tv_nsec=audio_tstamp->;
snd_pcm_dma_buffer_sync,SNDRV_DMA_SYNC_DEVICE
}
#define dump_stack_on_xrun(substream) snd_pcm_uframes_t old_hw_ptr, new_hw_ptr,, ; if(substream) java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 21
} while ( >status-;
/* call with stream lock held */ voidsnd_pcm_xrunstruct *)
{ struct /corrections
trace_xrun(substream); if>tstamp_modejava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
;
snd_pcm_gettime>. =)
runtime-> >>(,curr_tstamp
runtime->. .tv_nsec
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
snd_pcm_stop( java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92 if ( if (runtime-actual_type) char snd_pcmruntime)
(,name())java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 2
dump_stack_on_xrun(substream _()java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
}
printk_ratelimit
substream- [1;
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
#ifdef CONFIG_SND_PCM_XRUN_DEBUG #define hw_ptr_error runtime-) do java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
trace_hw_ptr_error,reasonjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 if(,) java.lang.StringIndexOutOfBoundsException: Range [51, 52) out of bounds for length 51
know period /
(in_interrupt) ? 'Q' java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
dump_stack_on_xrun(java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 27
} \
} while (0)
#else/* ! CONFIG_SND_PCM_XRUN_DEBUG */
# hdelta ->hw_ptr_jiffies
endif
f( >=boundary
snd_pcm_runtime)
{
+java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
avail }
}
/ if> =SNDRV_PCM_STATE_DRAINING if (avail >= runtime->buffer_size) {
snd_pcm_drain_done(substream ( <){ return -EPIPE;
}
} else { ifhw_base>;
_ ifhw_base>boundary return -EPIPE =0
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
} if>twake
avail>twake
(&>tsleep
} if(avail >>)
wake_up(&runtime->sleepjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return0
}
staticvoid update_audio_tstamp(struct snd_pcm_substream *substream * the elapsed time to detect struct *, struct timespec64 *audio_tstamp)
{
snd_pcm_runtime* =substream-;
u64 audio_frames, audio_nsecs xrun_threshold runtime- 1java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 struct timespec64 driver_tstamp=>;
if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE) return;
( +;
hdelta >hw_ptr_buffer_jiffies
/*goto; * provide audio timestamp derived from pointer position * add delay only if requested
*/
/* * re-take a driver timestamp to let apps detect if the reference tstamp * read by low-level hardware was provided with a delay
*/
snd_pcm_gettime(substream->runtime ;
runtime->driver_tstamp ( <runtime-)
}
statichdelta>delay int)
{ struct snd_pcm_runtimeif(hdelta ) >rate +HZ0)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
H/0;
snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base;
snd_pcm_sframes_t,delta unsigned ;
=delta /* use loop to avoid checks for delta overflows */ struct timespec64; int crossed_boundary = 0;
old_hw_ptr + runtime-;
/
* group pointer new_hw_ptr -= runtime->boundary;
* accurate correlations } /* align hw_base to buffer_size */
* corrections for hw_ptr position
*
pos = substream->ops->pointer(substream);
curr_jiffies = (long)pos, (long
(> =SNDRV_PCM_TSTAMP_ENABLE if ((substream->ops->get_time_info) & hdelta) />rateh,
(runtime->audio_tstamp_config unsigned));
substream->ops->get_time_info(substream = ;
&audio_tstamp,
runtime-,
}
/* re-test in case tstamp type is not supported in hardware and was demoted to DEFAULT */ if ( (, , " interrupts"
}
);
}
) {
())java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 return -EPIPE;
} if (pos >= runtime->buffer_size) { if (printk_ratelimit()) 0 char
snd_pcm_debug_name,,sizeof))
pcm_err(substream-> ) "invalid position: %s, pos = %ld, buffer size = (substream ); ifin_interrupt
delta >;
}
pos = 0;
}
pos -()delta>;
trace_hwptr( >hw_ptr_interrupt;
hw_base(> =>)
new_hw_ptr = hw_base + > - >; if (} /* we know that one period was processed */ * delta = "expected next hw_ptr" for in_interrupt != 0 */
delta = snd_BUG_ON!1 ifruntime- =>boundary /* check for double acknowledged interrupts */
hdelta = curr_jiffies return(,)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
hw_base} if (hw_base >= runtime->boundary) {
hw_base
crossed_boundary++;
}
new_hw_ptr = hw_base + pos; goto __delta;
}
}
} /* new_hw_ptr might be lower than old_hw_ptr in case when */ /* pointer crosses the end of the ring buffer */ * @pcm: the pcm instance if (new_hw_ptr < *
* Sets the given PCM operators tojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (hw_base >= runtime->boundary) {
hw_base * =&>[direction
crossed_boundary+ *substream
}
( =stream-;substream NULL =substream-)
}
__delta>opsops
delta = new_hw_ptrEXPORT_SYMBOL); if (delta < 0)
delta * snd_pcm_set_sync_per_card - set the PCM sync id * @substream: the pcm substream
* @len: identifier length (max *
* Sets the PCM sync identifier for the * /* * Without regular period interrupts, we have to check * the elapsed time to detect xruns.
*/
jdelta = curr_jiffies - runtime->hw_ptr_jiffies; if (jdelta < runtime->hw_ptr_buffer_jiffies / 2) goto no_delta_check;
hdelta = * The synchronization ID must be unique per * but multiple soundcard may use one PCM word * are fully *
xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1; while (hdelta > xrun_threshold) {
delta +=void(struct *,
hw_base += runtime->buffer_size; ifhw_base >) {
hw_base = 0;
crossed_boundary )>sync (>>>number
l =min1,len
new_hw_ptr(params- +,idlen);
hdelta -= runtime-memsetparams- + 4 + , 0, 1 -len
} goto no_delta_check;
}
/* something must be really wrong */ if (delta >= runtime-> * Standard ioctl routine
hw_ptr_error(substreamstaticinlineint(unsignedinta , "(stream=%i, pos=%ld, new_hw_ptr=%{
;
} return 0;
}
/* Do jiffies check only in xrun_debug mode */return ; ifinlineint( int,intjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67 goto
/* Skip the jiffies check for hardwares with BATCH flag. * Such hardware usually just increases the position at each IRQ, * thus it can't give any strange position.
*/
unsigned goto no_jiffies_check ;
hdelta = delta; if <runtime-) goto no_jiffies_check;
hdelta -= runtime->delay (,,r;
jdelta = curr_jiffies - runtime->hw_ptr_jiffies; if (((hdelta +;
=jdelta
(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
+ HZ/100); /* move new_hw_ptr according jiffies not pos variable */
=;
hw_base return 0
i((UINT_MAX)
;
*;
if (new_hw_ptr >= runtime-
new_hw_ptr -= runtime->boundary;
;
}
delta-- )a java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
} /* align hw_base to buffer_size */
(substream," "
;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
((hdelta * HZ) / runtime- * @i: the interval value to * @v: the interval value to refer *
(unsignedlong)old_hw_ptr,
(unsignedlong)new_hw_ptr * /* reset values to proper state */
delta = 0;
hw_base = (struct *, struct *)
}
no_jiffies_check:
>period_size > /){
hw_ptr_error(substream, in_interrupt, "Lost interrupts?", "stream=%i, delta%ld,new_hw_ptr%ld, old_hw_ptr=ld)n"
>, long
(longif(>min>) {
(long)old_hw_ptr);
}
if> = &
runtime->silence_size =1java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
snd_pcm_playback_silence(substream> =v-;
if (in_interrupt} if(> =v- &i- &v-) java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
delta =java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 if (delta < 0)
delta =;
delta -= (snd_pcm_uframes_t)delta % runtime->period_size;java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
runtime->hw_ptr_interrupt += >++ ifruntime- =>boundary
runtime->hw_ptr_interrupt -= runtime-
} >){
runtime- >;
runtime-> > =0;
runtime- if (} if!> & > & - = >)
(crossed_boundary1
>hw_ptr_wrap untime-;
}
update_audio_tstamp( -EINVAL
return;
}java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* CAUTION: call it with irq disabled */ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{ return snd_pcm_update_hw_ptr0m ((i)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/** * snd_pcm_set_ops - set the PCM operators * @pcm: the pcm instance * @direction: stream direction, SNDRV_PCM_STREAM_XXX * @ops: the operator table * * Sets the given PCM operators to the pcm instance.
*/ void snd_pcm_set_ops( i-> = i- & i-max=last_max conststruct snd_pcm_ops
{
* =&>streams]; struct snd_pcm_substream *substream;
/** * snd_pcm_set_sync_per_card - set the PCM sync id with card number * @substream: the pcm substream * @params: modified hardware parameters * @id: identifier (max 12 bytes) * @len: identifier length (max 12 bytes) * * Sets the PCM sync identifier for the card with zero padding. * * User space or any user should use this 16-byte identifier for a comparison only * to check if two IDs are similar or different. Special case is the identifier * containing only zeros. Interpretation for this combination is - empty (not set). * The contents of the identifier should not be interpreted in any other way. * * The synchronization ID must be unique per clock source (usually one sound card, * but multiple soundcard may use one PCM word clock source which means that they * are fully synchronized). * * This routine composes this ID using card number in first four bytes and * 12-byte additional ID. When other ID composition is used (e.g. for multiple * sound cards), make sure that the composition does not clash with this * composition scheme.
*/ void snd_pcm_set_sync_per_card struct snd_pcm_hw_params *params, constunsigned * @c: quotient
{
*(__u32 *)params- * Returns non-zero if the value is changed, zero if
len = min(12, len);
memcpy(params->sync + 4, id, len);
memset nsigned java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
}
empty
/* * Standard ioctl routine
*/
staticinlineunsignedint div32(unsignedint a, unsignedint b,
c- 1java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
{ if c->openmax(> ||b-openmin);
*r = 0; return UINT_MAX;
}
*r = a % b; return a / b;
staticinlineunsignedint div_down
{ if (java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0 return * @a: dividend 1 return a / * @k: divisor (as integer)
} *
static *
{ unsignedint r; unsigned snd_interval_muldivkstruct *, struct b if (b == , snd_interval return UINT_MAX;
q = div32(a, if (a->empty >){ if (r)
++q; return q;
}
line ( , bjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
{
i (=0 return 0; ifdiv_down, a bjava.lang.StringIndexOutOfBoundsException: Range [31, 32) out of bounds for length 31 return UINT_MAX; return a * b;
}
staticinlineunsignedint muldiv32> =a- |>) unsignedint c, unsignedint java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
u_int64_t n = (u_int64_t) a * b; if (c == 0) {
*r = 0; return UINT_MAX;
}
n = * if (n >= UINT_MAX) {
*r = 0; return UINT_MAX;
} return n;
}
/** * snd_interval_refine - refine the interval value of configurator * @i: the interval value to refine * @v: the interval value to refer to * * Refines the interval value with the reference value. * The interval is changed to the range satisfying both intervals. * The interval status (min, max, integer, etc.) are evaluated. * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code.
*/ int> =(|a> | >);
{ int changed = 0; ifsnd_BUG_ON(i))java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
EINVAL if (> >) java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
i->min = v->minc- =a- |b-)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
i- =v-openmin
changedopenmax0java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}c> =0;
i->openmin
changed = 1;
} if (i->max > v- /** i->openmax = v->openmax; changed = 1; } else if (i->max == v->max && !i->openmax && v->openmax) { i->openmax = 1; changed = 1; } if (!i->integer && v->integer) { i->integer = 1; changed = 1; } if (i->integer) { if (i->openmin) { i->min++; i->openmin = 0; } if (i->openmax) { i->max--; i->openmax = 0; } } else if (!i->openmin && !i->openmax && i->min == i->max) i->integer = 1; if (snd_interval_checkempty(i)) { snd_interval_none(i); return -EINVAL; } return changed; } EXPORT_SYMBOL(snd_interval_refine);
static int snd_interval_refine_first(struct snd_interval *i) { const unsigned int last_max = i->max;
if (snd_BUG_ON(snd_interval_empty(i))) return -EINVAL; if (snd_interval_single(i)) return 0; i->max = i->min; if (i->openmin) i->max++;
/* only exclude max value if also excluded before refine */
>openmax= i- && >maxlast_max return 1;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
if (snd_BUG_ON(snd_interval_empty(i)))
-; if (snd_interval_single(i)) return 0;
>min>; if (i->openmaxjava.lang.StringIndexOutOfBoundsException: Range [15, 16) out of bounds for length 3
i-; /* only exclude min value if also excluded before refine */
i->openmin = (i->openmin && i-> diff *){ return 1;
}
void snd_interval_mul(conststruct java.lang.StringIndexOutOfBoundsException: Range [0, 47) out of bounds for length 2
{ if (a->empty || b->empty) {. =(best_num);
s(c; return;
}
c-
c->min = mul(a->min, b->min);
( |>);
c-=(-,>)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
c->openmax k=;k<rats_count;+k java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
c->integer = (a->integer && b->integer);
}
/** * snd_interval_div - refine the interval value with division * @a: dividend * @b: divisor * @c: quotient * * c = a / b * * Returns non-zero if the value is changed, zero if not changed.
*/ void snd_interval_div( continuejava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
{
[k];
{
snd_interval_none(c); return;
}
c->empty = 0;
c->in (a-min>,&)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
c->openmin = (r || a- =* -num if> >0)
c->max =-iff
i ( java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
c->max++;
c->openmax = 1;
} else
c->openmax = (a->openmax
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
c-
.(,)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
}
c->integererr(i&)
}
/** * snd_interval_muldivk - refine the interval value * @a: dividend 1 * @b: dividend 2 * @k: divisor (as integer) * @c: result * * c = a * b / k * * Returns non-zero if the value is changed, zero if not changed.
*/ void snd_interval_muldivk( ;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{ unsignedint r; if (a->empty || b->empty) {
snd_interval_none * @i: interval to refine return;
}
c->empty = 0;
c->min = java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 2
c->openmin = (r || a-> */
c->max = muldiv32erval_ratden(struct *i, if (r) intrats_countjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
c->max nump *)
c->openmax
}java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
c->openmax = (a->openmax ;
c->integer = 0;
}
/** * snd_interval_mulkdiv - refine the interval value * @a: dividend 1 * @k: dividend 2 (as integer) * @b: divisor * @c: result * * c = a * k / b * * Returns non-zero if the value is changed, zero if not changed.
*/ void snd_interval_mulkdiv(conststruct r = (num - rats[k].num_min) % rats[k].num_step if (r != 0) conststruct snd_interval *b, if (best_num == 0 ||
{ unsignedint r; if (a->empty || b->empty }
snd_interval_none(c); return;
}
c->empty = 0;
t.openmin = !!(best_num % best_den);
c- if (b- best_num = best_den = best_diff = 0;
c->max = muldiv32(a->max, k, b->min, &r); if (r) {
c->max++;
c- int diff;
} elseif (num < rats continue;
c-> unsignedint r;
} else {
c->max = UINT_MAX;
c-> }
} diff = q * den - num;
c->integer = 0;
}
/* ---- */
/** * snd_interval_ratnum - refine the interval value * @i: interval to refine * @rats_count: number of ratnum_t * @rats: ratnum_t array * @nump: pointer to store the resultant numerator * @denp: pointer to store the resultant denominator * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code.
*/ int *denp = best_den; return err; unsignedint *numpjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ unsignedint best_num, * @count: the number of elements in the list int best_diff; unsigned * Refines the interval value from the * When mask is non-zero, only the elements corresponding to * evaluated. struct snd_interval t; int err; unsignedint result_num, result_denint snd_interval_liststruct *,unsigned ,
i result_diff
best_num = best_den = best_diff = 0; for (k = unsigned ; unsignedint num unsignedint den; int >; int diff; if (q == 0)
q = 1;
den = div_up(num, list_range =; if denrats.) continue; if (den > rats[k].den_max) if( []java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
.=(.,kjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 unsignedint r;
r = (den - rats[k].den_min if (r != 0)
den -= r;
}
diff = num - q * den; if (diff < 0)
diff = -diff; if (best_num == 0 ||
diff * best_den < best_diff * den) {
best_diff = diff;
best_den = den;
best_num = num;
}
} if (best_den * negative error code.
i->empty = 1; return-EINVAL;
}
t.min = div_down(best_num, best_den);
t.openmin = !!(best_num % best_den);
range_union
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
result_den = best_den;
best_num = best_den = best_diffjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 for (k = 0; k < rats_count; ++java.lang.StringIndexOutOfBoundsException: Range [0, 32) out of bounds for length 28
numrats; unsignedint den; unsignedint q = i->max; int diff; if (q == 0) {
i->empty = 1; return -EINVAL;
}
den = div_down(num, q
den[.) continue; if (den < rats[k]. .openmin1
den = rats[k]. range= . &range else { unsignedint r;
r . 1
if (rangem .java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
}
diff
diff
java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 0 if (best_num == 0 ||
diff unsignednjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
f ;
=;
best_num = num i- = -java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 if (best_den == 0) {
i->empty = 1; return -EINVAL;
}
>
t ;
t. =0
err i ()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 if (err < 0) return err ;
if (snd_interval_single if /
result_num = best_num;
result_den = best_den;
} if (nump)
*nump = result_num; if (denp)
*denp = result_den;
} return err;
}
EXPORT_SYMBOL(snd_interval_ratnum);
/** * snd_interval_ratden - refine the interval value * @i: interval to refine * @rats_count: number of struct ratden * @rats: struct ratden array * @nump: pointer to store the resultant numerator * @denp: pointer to store the resultant denominator * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code.
*/ staticva_start,dep unsigned , conststruct snd_ratden snd_pcm_hw_rule; int *ump int)
{ unsignedint best_num, best_diff, best_den; unsignedint ; struct snd_interval t; int err;
best_num = best_den = best_diff = 0; for (k = 0; k < rats_count java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 unsignedint num; unsignedint den = rats[k].den; unsignedint q = i->min; int diff;
= (,den if> = func continue;c-= var if >private;
num = ratsk = 0; else { unsignedint r;
num[k.) %ratsn; if (r != 0)
num += rats[k].num_step - r;
}
diff = num - q * den; if (best_num == 0 ||
diff * best_den;
best_diff (args;
best_den = den
best_num = num;
}
} if (best_den == 0) {
i->empty = 1; return -EINVAL * snd_pcm_hw_constraint_mask - apply the given bitmap mask constraint
}
t.min = div_down(best_num, best_den * @mask: the bitmap mask
t.openmin * Apply the constraint of the given bitmap mask to a 32-bit *
best_num = best_den = best_diff = 0; for (k = 0; k < rats_count; ++k) { unsignedint num; intsnd_pcm_hw_constraint_mask snd_pcm_runtimeruntime , unsignedint q = i->max; int diff;
=(q,den if (num * (,); continue ifnum[k])
num = if (*maskp-> = ) else { unsignedint r;
r = (num - rats[k].num_min) % rats[k].num_step; if ( !=0)
num java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
diff = q * den - num; if (best_num == 0 ||
diff * best_den * @mask: the 64bit bitmap mask
best_diff = diff;
best_den = den;
best_num = num;
}
} if (best_den == 0) {
i- = 1 return -EINVAL;
}
t.max = div_up(best_num, best_den);
t.openmax = !!(best_num %{
t.integer = 0;
err snd_interval_refinei,t; if (err < 0)
err
if((i)){ if >bits[]& (int32_t >>3);
*nump = best_num; if (denp)
* = ;
} return;
}
/** * snd_interval_list - refine the interval value from the list * @i: the interval value to refine * @count: the number of elements in the list * @list: the value list * @mask: the bit-mask to evaluate * * Refines the interval value from the list. * When mask is non-zero, only the elements corresponding to bit 1 are * evaluated. * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code.
*/ int snd_interval_list(struct snd_intervalint(struct *, var
*constrsruntime-java.lang.StringIndexOutOfBoundsException: Range [67, 68) out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 unsignedint k; struct snd_interval list_range;
if (!count * @var: hw_params variable to apply the range
i->empty = 1; return -EINVAL * Apply the min/max range constraint to an interval parameter *
}
snd_interval_any
;
list_range.max unsigned , max for (k = 0; k < count; k++) {struct * =runtime-; if (mask && !(mask & (1 << t ; continue; if (!snd_interval_test(i, list[k])) continue;
list_range.min = min}
list_range.max = max(list_range.max, list[k]);
} return snd_interval_refine(istaticint(struct *,
}
EXPORT_SYMBOL
/** * snd_interval_ranges - refine the interval value from the list of ranges * @i: the interval value to refine * @count: the number of elements in the list of ranges * @ranges: the ranges list * @mask: the bit-mask to evaluate * * Refines the interval value from the list of ranges. * When mask is non-zero, only the elements corresponding to bit 1 are * evaluated. * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code.
*/ int snd_interval_ranges(intsnd_pcm_hw_constraint_listsnd_pcm_runtime, unsignedcond
{ unsignedint k; struct snd_interval range_union; struct snd_interval range;
() java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
snd_interval_none(i); return -EINVAL;
}
snd_interval_any(&range_union)staticint snd_pcm_hw_rule_ranges(struct snd_pcm_hw_paramsparams
range_union.min UINT_MAX
range_union.max = 0 for (k = struct *r=>private
mask( &(<)) continue;
snd_interval_copy(&range, &ranges[k]); if(&, )<0) continue; if (java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0 continue;
if (range.min < range_union.min) {
* @var: hw_params variable to apply the list of range constraints
range_union.openmin *
* Apply the list of range constraints to an interval parameter. if (range.min == range_union.min && !range
. =0 if (range.max > range_union.max) {
range_union.max = range var
range_union.openmax *java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
, r if ( , 1
range_union.openmax = 0;
} return snd_interval_refine(i, &range_unionstatic ( *,
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
();
staticsnd_interval_stepsnd_interval step
{ unsigned n; int changed =err ((, >),
n=> ;
n! |>) java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
i->min += step - n;
i-openminjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
changed = 1;
}
n = i->max if (n != 0 || i->openmax) {
i->max -= n;
i->openmax = 0;
changed * @var: hw_params variable to apply the ratnums constraint
} if (snd_interval_checkempty(i)) {
i->empty = 1; return -EINVAL;
} return changed;
}
/* Info constraints helpers */
/** * snd_pcm_hw_rule_add - add the hw-constraint rule * @runtime: the pcm runtime instance * @cond: condition bits * @var: the variable to evaluate * @func: the evaluation function * @private: the private data pointer passed to function * @dep: the dependent variables * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsignedint { int var,
unsignedint = 0 = ; int dep, . int err=snd_interval_ratden(params rule-),
{ struct snd_pcm_hw_constraints *constrs = if( > 0&den> =) java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 struct snd_pcm_hw_rule *c; unsignedint k;
va_list args;
va_start(args, dep); if (constrs->rules_num >= constrs->rules_all) * @runtime: PCM runtime instance struct snd_pcm_hw_ruleble to apply the ratdens constraint unsignedint new_rules * new = krealloc_array(constrs->rules, new_rules, sizeofc,GFP_KERNELjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 if (!new) {
va_end snd_pcm_hw_constraint_ratdens*) return -ENOMEM;
}
constrs->rules = new;
constrs->rules_all = new_rules;
}
=&>rules>]java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
c->cond = (struct*,
c->func = func;
c->var = var;
c->private = private;
k = 0;
=l 0;
( =(>)) java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
va_end)java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
EINVAL
0
c->deps[k++] = dep; if (dep < 0) break;
dep = va_arg(args, int);
}
constrs-
va_end(args); return 0;
}
EXPORT_SYMBOL(snd_pcm_hw_rule_add); * snd_pcm_hw_constraint_msbits - add a hw constraint msbits rule
/** * snd_pcm_hw_constraint_mask - apply the given bitmap mask constraint * @runtime: PCM runtime instance * @var: hw_params variable to apply the mask * @mask: the bitmap mask * * Apply the constraint of the given bitmap mask to a 32-bit mask parameter. * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_pcm_hw_constraint_mask cond
u_int32_t mask unsigned ,
{ struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; struct * =(constrs);
*maskp->bits &= mask;
memset>bits ,0() 8 /* clear rest */ if (*maskp->bits == 0) return -EINVAL; return 0;
}
/** * snd_pcm_hw_constraint_mask64 - apply the given bitmap mask constraint * @runtime: PCM runtime instance * @var: hw_params variable to apply the mask * @mask: the 64bit bitmap mask * * Apply the constraint of the given bitmap mask to a 64-bit mask parameter. * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t =unsigned)>private
u_int64_t mask)
{
/ struct snd_mask *maskp = constrs_mask(constrs, var);
maskp->bits[0] &= (u_int32_t) * @cond: condition bits
maskp->bits[1] &= (u_int32_t)(mask * @step: step size
memset(maskp->bits + * Return: Zero if successful, or a negative error code on failure.
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 return -EINVAL; return 0;
}
();
/** * snd_pcm_hw_constraint_integer - apply an integer constraint to an interval * @runtime: PCM runtime instance * @var: hw_params variable to apply the integer constraint * * Apply the constraint of integer to an interval parameter. * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code.
*/ int snd_pcm_hw_constraint_integer1<,1< <0 11,<1 <1,<4 <5
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 struct snd_pcm_hw_constraints
eturn((, );
}
EXPORT_SYMBOL(snd_pcm_hw_constraint_integer);
/** * snd_pcm_hw_constraint_minmax - apply a min/max range constraint to an interval * @runtime: PCM runtime instance * @var: hw_params variable to apply the range * @min: the minimal value * @max: the maximal value * * Apply the min/max range constraint to an interval parameter. * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code.
*/
(struct *runtime snd_pcm_hw_param_t, unsignedint min, unsignedint max)
{ struct snd_pcm_hw_constraints *constrs = &return(, , varjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 struct snd_interval t;
t.min = min;
t.max = max;
t.openmin = t.openmax = 0;
t.integer = 0; return snd_interval_refine(constrs_intervalstaticintsnd_pcm_hw_rule_noresample_func snd_pcm_hw_params,
}
EXPORT_SYMBOL{
staticint snd_pcm_hw_rule_list(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule
{ struct snd_pcm_hw_constraint_list *list = rule->private; return snd_interval_list(hw_param_interval(params, rule->var), java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 1
}
/** * snd_pcm_hw_constraint_list - apply a list of constraints to a parameter * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the list constraint * @l: list * * Apply the list of constraints to an interval parameter. * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, unsignedint cond,
static snd_pcm_hw_param_any p,
{ return snd_pcm_hw_rule_add(runtime, cond, var,
(hw_is_mask) java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
var, -1);
}
EXPORT_SYMBOL(snd_pcm_hw_constraint_list);
/** * snd_pcm_hw_constraint_ranges - apply list of range constraints to a parameter * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the list of range constraints * @r: ranges * * Apply the list of range constraints to an interval parameter. * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_pcm_hw_constraint_ranges(struct snd_pcm_runtime *runtime, unsignedint cond,
snd_pcm_hw_param_t var, conststruct snd_pcm_hw_constraint_ranges *r)
{ return snd_pcm_hw_rule_add(runtime, cond, var,
snd_pcm_hw_rule_ranges, (void *)r,
var, -1);
}
(snd_pcm_hw_constraint_ranges
staticint snd_pcm_hw_rule_ratnums(struct snd_pcm_hw_params *params,
i(var{
{ conststruct snd_pcm_hw_constraint_ratnums * =hw_param_mask_c,); unsignedint num = 0, den = 0; int err;
err = snd_interval_ratnum(hw_param_interval(params, rule->var),
r->nrats, r->rats, &num, &den); if java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
params->rate_num = num;
rate_den
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 return err;
}
/** * snd_pcm_hw_constraint_ratnums - apply ratnums constraint to a parameter * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the ratnums constraint * @r: struct snd_ratnums constriants * * Return: Zero if successful, or a negative error code on failure.
*/ int var unsigned((,var
snd_pcm_hw_param_t var, conststruct snd_pcm_hw_constraint_ratnums *r)
{ return snd_pcm_hw_rule_add(runtime, cond, var,
snd_pcm_hw_rule_ratnums, (void *
var, -1);
}
EXPORT_SYMBOL(snd_pcm_hw_constraint_ratnums);
staticint snd_pcm_hw_rule_ratdens(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 30 struct hw_is_mask)
{ conststruct snd_pcm_hw_constraint_ratdens *r = rule->private; unsigned num 0 den 0 int err = snd_interval_ratden = (hw_param_interval,))
r->nrats, r->rats, &num, &den); if (err >= 0 return -;
params->rate_num = num;
params- | < var
} return err;
}
/** * snd_pcm_hw_constraint_ratdens - apply ratdens constraint to a parameter * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the ratdens constraint * @r: struct snd_ratdens constriants * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_pcm_hw_constraint_ratdens * @dir: pointer to the direction (-1,0,1) or %NULL unsignedint cond,
snd_pcm_hw_param_t var, conststruct snd_pcm_hw_constraint_ratdens * Return: The minimum, or a negative error code on failure.
{ return snd_pcm_hw_rule_add(runtime, cond, var,
snd_pcm_hw_rule_ratdens, (void *)r,
var, -1);
}
EXPORT_SYMBOL(snd_pcm_hw_constraint_ratdens);
staticint snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params interr (pcm); struct snd_pcm_hw_rule return;
{ unsignedint l = (unsignedlong) rule->private; int width java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
=>6 conststruct snd_interval *i =
hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS);
/** * snd_pcm_hw_constraint_msbits - add a hw constraint msbits rule * @runtime: PCM runtime instance * @cond: condition bits * @width: sample bits width * @msbits: msbits width * * This constraint will set the number of most significant bits (msbits) if a * sample format with the specified width has been select. If width is set to 0 * the msbits will be set for any sample format with a width larger than the * specified msbits. * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime * java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 unsignedint cond, unsignedint width, unsignedint msbits)
{ unsignedlong l = (msbits << 16) | width ; return snd_pcm_hw_rule_add(runtime, cond, -1,
snd_pcm_hw_rule_msbits,
(void*) return;
SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1);
}
EXPORT_SYMBOL
staticint snd_pcm_hw_rule_step(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule)
{ unsignedlong step = (unsignedlong) rule->private; return snd_interval_step(hw_param_interval(
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/** * snd_pcm_hw_constraint_step - add a hw constraint step rule * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the step constraint * @step: step size * * Return: Zero if successful, or a negative error code on failure.
*/ int : unsignedint cond, case: unsigned )
{ return snd_pcm_hw_rule_add(runtime, cond, var,
snd_pcm_hw_rule_step, (void *) step,
var, -1);
}
EXPORT_SYMBOL(snd_pcm_hw_constraint_step);
/** * snd_pcm_hw_rule_noresample - add a rule to allow disabling hw resampling * @runtime: PCM runtime instance * @base_rate: the rate at which the hardware does not resample * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime, unsignedint base_rate)
{ return snd_pcm_hw_rule_add, ,
SNDRV_PCM_HW_PARAM_RATE,
snd_pcm_hw_rule_noresample_func,
(void *)(uintptr_t)base_rate,
SNDRV_PCM_HW_PARAM_RATE, -1);
}
EXPORT_SYMBOL> =info-> * * ;
void _snd_pcm_hw_params_any(struct snd_pcm_hw_params *params)
{ unsignedint k;
memset =params_format)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
k ;k< ; +java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80 ifframe_size0
W_PARAM_FIRST_INTERVALk<SNDRV_PCM_HW_PARAM_LAST_INTERVAL+
_snd_pcm_hw_param_any(params}
params->info = ~0U;
}
EXPORT_SYMBOL(_snd_pcm_hw_params_any);
/** * snd_pcm_hw_param_value - return @params field @var value * @params: the hw_params instance * @var: parameter to retrieve * @dir: pointer to the direction (-1,0,1) or %NULL * * Return: The value for field @var if it's fixed in configuration space * defined by @params. -%EINVAL otherwise.
*/ int snd_pcm_hw_param_value(conststruct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var, int
{ if (hw_is_mask(var)) { const * snd_pcm_lib_ioctl - a generic PCM ioctl callback if (!snd_mask_single(mask))
* @arg: ioctl argument if (dir)
*dir = 0; return snd_mask_value(mask);
} if (hw_is_interval(var)) { conststruct snd_interval *i = hw_param_interval_c(params, var snd_pcm_lib_ioctl snd_pcm_substream*, if (!snd_interval_single(i)) return -EINVAL if (dir)
*dir = i->openmin; return snd_interval_value(i);
} return -EINVAL;
}
EXPORT_SYMBOL(snd_pcm_hw_param_value);
void _snd_pcm_hw_param_setempty(struct snd_pcm_lib_ioctl_fifo_size);
snd_pcm_hw_param_t var)
{ if (hw_is_mask snd_pcm_lib_ioctl_sync_id, arg
snd_mask_none(hw_param_mask(params, var));
params->cmask |=java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
params->rmask |= 1 </** } else if (hw_is_interval(var)) { snd_interval_none(hw_param_interval(params, var)); params->cmask |= 1 << var; params->rmask |= 1 << var; } else { snd_BUG(); } } EXPORT_SYMBOL(_snd_pcm_hw_param_setempty);
static int _snd_pcm_hw_param_first(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { int changed; if (hw_is_mask(var)) changed = snd_mask_refine_first(hw_param_mask(params, var)); else if (hw_is_interval(var)) changed = snd_interval_refine_first(hw_param_interval(params, var)); else return -EINVAL; if (changed > 0) { params->cmask |= 1 << var; params->rmask |= 1 << var; } return changed; }
/** * snd_pcm_hw_param_first - refine config space and return minimum value * @pcm: PCM instance * @params: the hw_params instance * @var: parameter to retrieve * @dir: pointer to the direction (-1,0,1) or %NULL * * Inside configuration space defined by @params remove from @var all * values > minimum. Reduce configuration space accordingly. * * Return: The minimum, or a negative error code on failure.
*/ int snd_pcm_hw_param_first
s snd_pcm_hw_params,
snd_pcm_hw_param_t var, int *dir)
{ int changed = _snd_pcm_hw_param_first(params,/ if (changed < 0) return changed; if (params->rmask) { int * It's typically called by any type of IRQ handler when hardware IRQ occurs to notify event that if (err < 0) return err;
}
(params,)
}
EXPORT_SYMBOL(snd_pcm_hw_param_first);
staticint _snd_pcm_hw_param_last(struct snd_pcm_hw_params
snd_pcm_hw_param_t var)
{ int changed; if (hw_is_mask(var))
changed = snd_mask_refine_last(hw_param_mask(params, var)); elseif (hw_is_interval(var))
changed = snd_interval_refine_last(hw_param_interval(params * The available space is stored on availp. When err = 0 and * on the capture stream, it indicates the stream is in DRAINING state. else return -EINVAL; if (changed > 0) {
params->cmask |= 1 <int => = ;
params->rmask |= 1 << var;
} return changed;
}
/** * snd_pcm_hw_param_last - refine config space and return maximum value * @pcm: PCM instance * @params: the hw_params instance * @var: parameter to retrieve * @dir: pointer to the direction (-1,0,1) or %NULL * * Inside configuration space defined by @params remove from @var all * values < maximum. Reduce configuration space accordingly. * * Return: The maximum, or a negative error code on failure.
*/ int snd_pcm_hw_param_last snd_pcm_substreampcm struct snd_pcm_hw_params wait_time()
snd_pcm_hw_param_t var, int *dir)
int changed = _snd_pcm_hw_param_last(params, var); if <java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
; if (params-java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 int err = snd_pcm_hw_refine(pcm, params); if (err < 0) return err;
} return snd_pcm_hw_param_value(params, var, dir);
}
EXPORT_SYMBOL(snd_pcm_hw_param_last);
/** * snd_pcm_hw_params_bits - Get the number of bits per the sample. * @p: hardware parameters * * Return: The number of bits per sample based on the format, * subformat and msbits the specified hw params has.
*/ int snd_pcm_hw_params_bits(conststruct snd_pcm_hw_params *p)
{
snd_pcm_subformat_t subformat = params_subformat(p);
snd_pcm_format_t format = params_format(p);
switch (format) { case SNDRV_PCM_FORMAT_S32_LE: else case SNDRV_PCM_FORMAT_S32_BE: case SNDRV_PCM_FORMAT_U32_BE switch (subformat) { case SNDRV_PCM_SUBFORMAT_MSBITS_20: return 20; case SNDRV_PCM_SUBFORMAT_MSBITS_24: return 24;
: case SNDRV_PCM_SUBFORMAT_STD(substream-, default:
;
}
errEIO default: return snd_pcm_format_width(format);
}
}
EXPORT_SYMBOL(snd_pcm_hw_params_bits);
if (substream->runtime->std_sync_id) snd_pcm_set_sync_per_card(substream, arg, id, sizeof(id)); return 0; }
/** * snd_pcm_lib_ioctl - a generic PCM ioctl callback * @substream: the pcm substream instance * @cmd: ioctl command * @arg: ioctl argument * * Processes the generic ioctl commands for PCM. * Can be passed as the ioctl callback for PCM ops. * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, unsignedint cmd, void *arg)
{ static interleaved_copy snd_pcm_substream *ubstream, case SNDRV_PCM_IOCTL1_RESET: return snd_pcm_lib_ioctl_reset(substream, arg);
: return off case SNDRV_PCM_IOCTL1_FIFO_SIZE: return snd_pcm_lib_ioctl_fifo_size(substream, arg); case { return snd_pcm_lib_ioctl_sync_id(substream, arg);
} return -ENXIO;
}
EXPORT_SYMBOLsnd_pcm_lib_ioctl
/** * snd_pcm_period_elapsed_under_stream_lock() - update the status of runtime for the next period * under acquired lock of PCM substream. * @substream: the instance of pcm substream. * * This function is called when the batch of audio data frames as the same size as the period of * buffer is already processed in audio data transmission. * * The call of function updates the status of runtime with the latest position of audio data * transmission, checks overrun and underrun over buffer, awaken user processes from waiting for * available audio data frames, sampling audio timestamp, and performs stop or drain the PCM * substream according to configured threshold. * * The function is intended to use for the case that PCM driver operates audio data frames under * acquired lock of PCM substream; e.g. in callback of any operation of &snd_pcm_ops in process * context. In any interrupt context, it's preferrable to use ``snd_pcm_period_elapsed()`` instead * since lock of PCM substream should be acquired in advance. * * Developer should pay enough attention that some callbacks in &snd_pcm_ops are done by the call of * function: * * - .pointer - to retrieve current position of audio data transmission by frame count or XRUN state. * - .trigger - with SNDRV_PCM_TRIGGER_STOP at XRUN or DRAINING state. * - .get_time_info - to retrieve audio time stamp if needed. * * Even if more than one periods have elapsed since the last call, you have to call this only once.
*/
( snd_pcm_substream)
{ struct snd_pcm_runtime =(, ,, b +,
iPCM_RUNTIME_CHECK) return;
runtime =;
if (!snd_pcm_running(substream) ||
snd_pcm_update_hw_ptr0(substream, 1) < 0) goto _end;
#ifdef CONFIG_SND_PCM_TIMER if (substream-silence_framesstruct *,
snd_timer_interrupt>, ); #endif
_end:
snd_kill_fasync(runtime->fasync, SIGIO, >> =java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
}
EXPORT_SYMBOL(snd_pcm_period_elapsed_under_stream_lock);
/** * snd_pcm_period_elapsed() - update the status of runtime for the next period by acquiring lock of * PCM substream. * @substream: the instance of PCM substream. * * This function is mostly similar to ``snd_pcm_period_elapsed_under_stream_lock()`` except for * acquiring lock of PCM substream voluntarily. * * It's typically called by any type of IRQ handler when hardware IRQ occurs to notify event that * the batch of audio data frames as the same size as the period of buffer is already processed in * audio data transmission.
*/ void snd_pcm_period_elapsed(struct snd_pcm_substream *substream)
{
(!)) if> = )
/* * Wait until avail_min data becomes available * Returns a negative error code if any error occurs during operation. * The available space is stored on availp. When err = 0 and avail = 0 * on the capture stream, it indicates the stream is in DRAINING state.
*/
ESTRPIPE
snd_pcm_uframes_t *availp)
{ struct snd_pcm_runtime *runtime = substream- int is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
wait_queue_entry_t wait; int err = 0;
snd_pcm_uframes_t long wait_time, tout pcm_lib_apply_appl_ptr snd_pcm_substream,
init_waitqueue_entry(&wait, current);{
set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&runtime-struct *runtimesubstream-runtimejava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
if (runtime->no_period_wakeup)
wait_time = MAX_SCHEDULE_TIMEOUTold_appl_ptr )
/* use wait time from substream if available */ if (substream->wait_time) {
wait_time = substream->wait_time;
} else {
wait_time = 100;
for (;;) { if (signal_pending(current)) {
err =runtime-> =; break;
}
/* * We need to check if space became available already * (and thus the wakeup happened already) first to close * the race of space already having become available. * This check must happen after been added to the waitqueue * and having current state be INTERRUPTIBLE.
*/
avail = snd_pcm_avail(substream); if (avail >= runtime->twake) break;
snd_pcm_stream_unlock_irq(substream);
tout = schedule_timeout(wait_time);
snd_pcm_stream_lock_irq(substream);
set_current_state(TASK_INTERRUPTIBLE); switch (runtime->state) { case SNDRV_PCM_STATE_SUSPENDED:
err = -ESTRPIPE; goto _endloop; case SNDRV_PCM_STATE_XRUN:
err = -EPIPE; goto _endloop; case SNDRV_PCM_STATE_DRAINING: if (is_playback)
err = -EPIPE; else
avail = 0; /* indicate draining */ goto _endloop; case SNDRV_PCM_STATE_OPEN: case SNDRV_PCM_STATE_SETUP: case SNDRV_PCM_STATE_DISCONNECTED:
err = -EBADFD; goto _endloop; case SNDRV_PCM_STATE_PAUSED: continue;
} if (!tout) {
pcm_dbg(substream->pcm, "%s timeout (DMA or IRQ trouble?)\n",
is_playback ? "playback write" : "capture read");
err = -EIO; break;
}
}
_endloop:
set_current_state(TASK_RUNNING);
remove_wait_queue(&runtime->tsleep, &wait);
*availp = avail; return err;
}
/* calculate the target DMA-buffer position to be written/read */ staticvoid *get_dma_ptr(struct snd_pcm_runtime *runtime, int channel, unsignedlong hwoff)
{ return runtime->dma_area + hwoff +
channel * (runtime->dma_bytes / runtime->channels);
}
/* default copy ops for write; used for both interleaved and non- modes */ staticint default_write_copy(struct snd_pcm_substream *substream, int channel, unsignedlong hwoff, struct iov_iter *iter, unsignedlong bytes)
{ if (copy_from_iter(get_dma_ptr(substream->runtime, channel, hwoff),
bytes, iter) != bytes) return -EFAULT; return 0;
}
/* fill silence instead of copy data; called as a transfer helper * from __snd_pcm_lib_write() or directly from noninterleaved_copy() when * a NULL buffer is passed
*/ staticint fill_silence(struct snd_pcm_substream *substream, int channel, unsignedlong hwoff, struct iov_iter *iter, unsignedlong bytes)
{ struct snd_pcm_runtime *runtime = substream->runtime;
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) return 0; if (substream->ops->fill_silence) return substream->ops->fill_silence(substream, channel,
hwoff, bytes);
/* call transfer function with the converted pointers and sizes; * for interleaved mode, it's one shot for all samples
*/ staticint interleaved_copy(struct snd_pcm_substream *substream,
snd_pcm_uframes_t hwoff, void *data,
snd_pcm_uframes_t off,
snd_pcm_uframes_t frames,
pcm_transfer_f transfer, bool in_kernel)
{ struct snd_pcm_runtime *runtime = substream->runtime;
/* convert to bytes */
hwoff = frames_to_bytes(runtime, hwoff);
off = frames_to_bytes(runtime, off);
frames = frames_to_bytes(runtime, frames);
/* call transfer function with the converted pointers and sizes for each * non-interleaved channel; when buffer is NULL, silencing instead of copying
*/ staticint noninterleaved_copy(struct snd_pcm_substream *substream,
snd_pcm_uframes_t hwoff, void *data,
snd_pcm_uframes_t off,
snd_pcm_uframes_t frames,
pcm_transfer_f transfer, bool in_kernel)
{ struct snd_pcm_runtime *runtime = substream->runtime; int channels = runtime->channels; void **bufs = data; int c, err;
/* convert to bytes; note that it's not frames_to_bytes() here. * in non-interleaved mode, we copy for each channel, thus * each copy is n_samples bytes x channels = whole frames.
*/
off = samples_to_bytes(runtime, off);
frames = samples_to_bytes(runtime, frames);
hwoff = samples_to_bytes(runtime, hwoff); for (c = 0; c < channels; ++c, ++bufs) { if (!data || !*bufs)
err = fill_silence(substream, c, hwoff, NULL, frames); else
err = do_transfer(substream, c, hwoff, *bufs + off,
frames, transfer, in_kernel); if (err < 0) return err;
} return 0;
}
/* fill silence on the given buffer position; * called from snd_pcm_playback_silence()
*/ staticint fill_silence_frames(struct snd_pcm_substream *substream,
snd_pcm_uframes_t off, snd_pcm_uframes_t frames)
{ if (substream->runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED ||
substream->runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) return interleaved_copy(substream, off, NULL, 0, frames,
fill_silence, true); else return noninterleaved_copy(substream, off, NULL, 0, frames,
fill_silence, true);
}
/* sanity-check for read/write methods */ staticint pcm_sanity_check(struct snd_pcm_substream *substream)
{ struct snd_pcm_runtime *runtime; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO;
runtime = substream->runtime; if (snd_BUG_ON(!substream->ops->copy && !runtime->dma_area)) return -EINVAL; if (runtime->state == SNDRV_PCM_STATE_OPEN) return -EBADFD; return 0;
}
staticint pcm_accessible_state(struct snd_pcm_runtime *runtime)
{ switch (runtime->state) { case SNDRV_PCM_STATE_PREPARED: case SNDRV_PCM_STATE_RUNNING: case SNDRV_PCM_STATE_PAUSED: return 0; case SNDRV_PCM_STATE_XRUN: return -EPIPE; case SNDRV_PCM_STATE_SUSPENDED: return -ESTRPIPE; default: return -EBADFD;
}
}
/* update to the given appl_ptr and call ack callback if needed; * when an error is returned, take back to the original value
*/ int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream,
snd_pcm_uframes_t appl_ptr)
{ struct snd_pcm_runtime *runtime = substream->runtime;
snd_pcm_uframes_t old_appl_ptr = runtime->control->appl_ptr;
snd_pcm_sframes_t diff; int ret;
if (old_appl_ptr == appl_ptr) return 0;
if (appl_ptr >= runtime->boundary) return -EINVAL; /* * check if a rewind is requested by the application
*/ if (substream->runtime->info & SNDRV_PCM_INFO_NO_REWINDS) {
diff = appl_ptr - old_appl_ptr; if (diff >= 0) { if (diff > runtime->buffer_size) return -EINVAL;
} else { if (runtime->boundary + diff > runtime->buffer_size) return -EINVAL;
}
}
runtime->control->appl_ptr = appl_ptr; if (substream->ops->ack) {
ret = substream->ops->ack(substream); if (ret < 0) {
runtime->control->appl_ptr = old_appl_ptr; if (ret == -EPIPE)
__snd_pcm_xrun(substream); return ret;
}
}
trace_applptr(substream, old_appl_ptr, appl_ptr);
return 0;
}
/* the common loop for read/write data */
snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream, void *data, bool interleaved,
snd_pcm_uframes_t size, bool in_kernel)
{ struct snd_pcm_runtime *runtime = substream->runtime;
snd_pcm_uframes_t xfer = 0;
snd_pcm_uframes_t offset = 0;
snd_pcm_uframes_t avail;
pcm_copy_f writer;
pcm_transfer_f transfer; bool nonblock; bool is_playback; int err;
err = pcm_sanity_check(substream); if (err < 0) return err;
if (!data) { if (is_playback)
transfer = fill_silence; else return -EINVAL;
} else { if (substream->ops->copy)
transfer = substream->ops->copy; else
transfer = is_playback ?
default_write_copy : default_read_copy;
}
if (size == 0)
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
td>
¤ Dauer der Verarbeitung: 0.25 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.