Con_Printf ("SndSys_Init: suggesting sound width = %hu\n",
suggested->width);
}
-
+
return false;
}
-
+
if (pcm_handle != NULL)
{
Con_Print ("SndSys_Init: WARNING: Init called before Shutdown!\n");
SndSys_Shutdown ();
}
-
+
// Determine the name of the PCM handle we'll use
switch (requested->channels)
{
pcm_name, snd_strerror (err));
return false;
}
-
+
// Allocate the hardware parameters
err = snd_pcm_hw_params_malloc (&hw_params);
if (err != 0)
alsasoundtime = 0;
if (snd_channellayout.integer == SND_CHANNELLAYOUT_AUTO)
Cvar_SetValueQuick (&snd_channellayout, SND_CHANNELLAYOUT_ALSA);
-
+
return true;
// It's not very clean, but it avoids a lot of duplicated code.
init_error:
-
+
if (hw_params != NULL)
snd_pcm_hw_params_free (hw_params);
SndSys_Shutdown ();
// We can only do something on underrun ("broken pipe") errors
if (err_num != -EPIPE)
return false;
-
+
err = snd_pcm_prepare (pcm_handle);
if (err != 0)
{
snd_renderbuffer->startframe += written;
expected_delay += written;
}
-
+
return written;
}
unsigned int startoffset, factor;
snd_pcm_uframes_t limit, nbframes;
snd_pcm_sframes_t written;
-
+
if (pcm_handle == NULL ||
snd_renderbuffer->startframe == snd_renderbuffer->endframe)
return;
written = SndSys_Write (&snd_renderbuffer->ring[startoffset * factor], limit);
if (written < 0 || (snd_pcm_uframes_t)written != limit)
return;
-
+
nbframes -= limit;
startoffset = 0;
}
else
timediff = expected_delay - delay;
expected_delay = delay;
-
+
alsasoundtime += (unsigned int)timediff;
-
+
return alsasoundtime;
}