alsa/oss: Remove fd transfer handlers before closing oss/alsa fd/handle
Signed-off-by: malc <av1474@comtv.ru>
This commit is contained in:
parent
9332f6a2e2
commit
6ebfda13a6
@ -123,7 +123,23 @@ static void GCC_FMT_ATTR (3, 4) alsa_logerr2 (
|
|||||||
AUD_log (AUDIO_CAP, "Reason: %s\n", snd_strerror (err));
|
AUD_log (AUDIO_CAP, "Reason: %s\n", snd_strerror (err));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alsa_anal_close (snd_pcm_t **handlep)
|
static void alsa_fini_poll (struct pollhlp *hlp)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct pollfd *pfds = hlp->pfds;
|
||||||
|
|
||||||
|
if (pfds) {
|
||||||
|
for (i = 0; i < hlp->count; ++i) {
|
||||||
|
qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
qemu_free (pfds);
|
||||||
|
}
|
||||||
|
hlp->pfds = NULL;
|
||||||
|
hlp->count = 0;
|
||||||
|
hlp->handle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void alsa_anal_close1 (snd_pcm_t **handlep)
|
||||||
{
|
{
|
||||||
int err = snd_pcm_close (*handlep);
|
int err = snd_pcm_close (*handlep);
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -132,6 +148,12 @@ static void alsa_anal_close (snd_pcm_t **handlep)
|
|||||||
*handlep = NULL;
|
*handlep = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void alsa_anal_close (snd_pcm_t **handlep, struct pollhlp *hlp)
|
||||||
|
{
|
||||||
|
alsa_fini_poll (hlp);
|
||||||
|
alsa_anal_close1 (handlep);
|
||||||
|
}
|
||||||
|
|
||||||
static int alsa_recover (snd_pcm_t *handle)
|
static int alsa_recover (snd_pcm_t *handle)
|
||||||
{
|
{
|
||||||
int err = snd_pcm_prepare (handle);
|
int err = snd_pcm_prepare (handle);
|
||||||
@ -648,7 +670,7 @@ static int alsa_open (int in, struct alsa_params_req *req,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
alsa_anal_close (&handle);
|
alsa_anal_close1 (&handle);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,35 +787,17 @@ static int alsa_run_out (HWVoiceOut *hw)
|
|||||||
return decr;
|
return decr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alsa_fini_poll (struct pollhlp *hlp)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
struct pollfd *pfds = hlp->pfds;
|
|
||||||
|
|
||||||
if (pfds) {
|
|
||||||
for (i = 0; i < hlp->count; ++i) {
|
|
||||||
qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL);
|
|
||||||
}
|
|
||||||
qemu_free (pfds);
|
|
||||||
}
|
|
||||||
hlp->pfds = NULL;
|
|
||||||
hlp->count = 0;
|
|
||||||
hlp->handle = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void alsa_fini_out (HWVoiceOut *hw)
|
static void alsa_fini_out (HWVoiceOut *hw)
|
||||||
{
|
{
|
||||||
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
|
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
|
||||||
|
|
||||||
ldebug ("alsa_fini\n");
|
ldebug ("alsa_fini\n");
|
||||||
alsa_anal_close (&alsa->handle);
|
alsa_anal_close (&alsa->handle, &alsa->pollhlp);
|
||||||
|
|
||||||
if (alsa->pcm_buf) {
|
if (alsa->pcm_buf) {
|
||||||
qemu_free (alsa->pcm_buf);
|
qemu_free (alsa->pcm_buf);
|
||||||
alsa->pcm_buf = NULL;
|
alsa->pcm_buf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
alsa_fini_poll (&alsa->pollhlp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as)
|
static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as)
|
||||||
@ -830,7 +834,7 @@ static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as)
|
|||||||
if (!alsa->pcm_buf) {
|
if (!alsa->pcm_buf) {
|
||||||
dolog ("Could not allocate DAC buffer (%d samples, each %d bytes)\n",
|
dolog ("Could not allocate DAC buffer (%d samples, each %d bytes)\n",
|
||||||
hw->samples, 1 << hw->info.shift);
|
hw->samples, 1 << hw->info.shift);
|
||||||
alsa_anal_close (&handle);
|
alsa_anal_close1 (&handle);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,7 +925,7 @@ static int alsa_init_in (HWVoiceIn *hw, struct audsettings *as)
|
|||||||
if (!alsa->pcm_buf) {
|
if (!alsa->pcm_buf) {
|
||||||
dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
|
dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n",
|
||||||
hw->samples, 1 << hw->info.shift);
|
hw->samples, 1 << hw->info.shift);
|
||||||
alsa_anal_close (&handle);
|
alsa_anal_close1 (&handle);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -933,13 +937,12 @@ static void alsa_fini_in (HWVoiceIn *hw)
|
|||||||
{
|
{
|
||||||
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
|
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
|
||||||
|
|
||||||
alsa_anal_close (&alsa->handle);
|
alsa_anal_close (&alsa->handle, &alsa->pollhlp);
|
||||||
|
|
||||||
if (alsa->pcm_buf) {
|
if (alsa->pcm_buf) {
|
||||||
qemu_free (alsa->pcm_buf);
|
qemu_free (alsa->pcm_buf);
|
||||||
alsa->pcm_buf = NULL;
|
alsa->pcm_buf = NULL;
|
||||||
}
|
}
|
||||||
alsa_fini_poll (&alsa->pollhlp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int alsa_run_in (HWVoiceIn *hw)
|
static int alsa_run_in (HWVoiceIn *hw)
|
||||||
|
@ -114,11 +114,13 @@ static void GCC_FMT_ATTR (3, 4) oss_logerr2 (
|
|||||||
|
|
||||||
static void oss_anal_close (int *fdp)
|
static void oss_anal_close (int *fdp)
|
||||||
{
|
{
|
||||||
int err = close (*fdp);
|
int err;
|
||||||
|
|
||||||
|
qemu_set_fd_handler (*fdp, NULL, NULL, NULL);
|
||||||
|
err = close (*fdp);
|
||||||
if (err) {
|
if (err) {
|
||||||
oss_logerr (errno, "Failed to close file(fd=%d)\n", *fdp);
|
oss_logerr (errno, "Failed to close file(fd=%d)\n", *fdp);
|
||||||
}
|
}
|
||||||
qemu_set_fd_handler (*fdp, NULL, NULL, NULL);
|
|
||||||
*fdp = -1;
|
*fdp = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user