Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0070110 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: pcm - A helper function to compose PCM stream name for debug prints



Use a common helper function for the PCM stream name displayed in
XRUN and buffer-pointer debug prints.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ab1863fc
Loading
Loading
Loading
Loading
+17 −6
Original line number Original line Diff line number Diff line
@@ -136,6 +136,16 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram
			dump_stack();			\
			dump_stack();			\
	} while (0)
	} while (0)


static void pcm_debug_name(struct snd_pcm_substream *substream,
			   char *name, size_t len)
{
	snprintf(name, len, "pcmC%dD%d%c:%d",
		 substream->pcm->card->number,
		 substream->pcm->device,
		 substream->stream ? 'c' : 'p',
		 substream->number);
}

static void xrun(struct snd_pcm_substream *substream)
static void xrun(struct snd_pcm_substream *substream)
{
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct snd_pcm_runtime *runtime = substream->runtime;
@@ -144,10 +154,9 @@ static void xrun(struct snd_pcm_substream *substream)
		snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp);
		snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp);
	snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
	snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
	if (xrun_debug(substream, 1)) {
	if (xrun_debug(substream, 1)) {
		snd_printd(KERN_DEBUG "XRUN: pcmC%dD%d%c\n",
		char name[16];
			   substream->pcm->card->number,
		pcm_debug_name(substream, name, sizeof(name));
			   substream->pcm->device,
		snd_printd(KERN_DEBUG "XRUN: %s\n", name);
			   substream->stream ? 'c' : 'p');
		dump_stack_on_xrun(substream);
		dump_stack_on_xrun(substream);
	}
	}
}
}
@@ -163,9 +172,11 @@ snd_pcm_update_hw_ptr_pos(struct snd_pcm_substream *substream,
		return pos; /* XRUN */
		return pos; /* XRUN */
	if (pos >= runtime->buffer_size) {
	if (pos >= runtime->buffer_size) {
		if (printk_ratelimit()) {
		if (printk_ratelimit()) {
			snd_printd(KERN_ERR  "BUG: stream = %i, pos = 0x%lx, "
			char name[16];
			pcm_debug_name(substream, name, sizeof(name));
			snd_printd(KERN_ERR  "BUG: %s, pos = 0x%lx, "
				   "buffer size = 0x%lx, period size = 0x%lx\n",
				   "buffer size = 0x%lx, period size = 0x%lx\n",
				   substream->stream, pos, runtime->buffer_size,
				   name, pos, runtime->buffer_size,
				   runtime->period_size);
				   runtime->period_size);
		}
		}
		pos = 0;
		pos = 0;