output: set audio_output->open=1 in audio_output_task()
Since the output plugin returns a value indicating success or error, we can have the output core code assign the "open" flag.
This commit is contained in:
parent
3cae6856b8
commit
2403d32a50
@ -292,8 +292,6 @@ configure_hw:
|
||||
|
||||
ad->sampleSize = audio_format_sample_size(audioFormat) * audioFormat->channels;
|
||||
|
||||
audioOutput->open = 1;
|
||||
|
||||
DEBUG("ALSA device \"%s\" will be playing %i bit, %i channel audio at "
|
||||
"%i Hz\n", ad->device, (int)audioFormat->bits,
|
||||
channels, sampleRate);
|
||||
@ -312,7 +310,6 @@ fail:
|
||||
if (ad->pcmHandle)
|
||||
snd_pcm_close(ad->pcmHandle);
|
||||
ad->pcmHandle = NULL;
|
||||
audioOutput->open = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -372,8 +369,6 @@ static void alsa_closeDevice(struct audio_output *audioOutput)
|
||||
snd_pcm_close(ad->pcmHandle);
|
||||
ad->pcmHandle = NULL;
|
||||
}
|
||||
|
||||
audioOutput->open = 0;
|
||||
}
|
||||
|
||||
static int alsa_playAudio(struct audio_output *audioOutput,
|
||||
|
@ -171,8 +171,6 @@ static void audioOutputAo_closeDevice(struct audio_output *audioOutput)
|
||||
ao_close(ad->device);
|
||||
ad->device = NULL;
|
||||
}
|
||||
|
||||
audioOutput->open = 0;
|
||||
}
|
||||
|
||||
static int audioOutputAo_openDevice(struct audio_output *audioOutput,
|
||||
@ -195,8 +193,6 @@ static int audioOutputAo_openDevice(struct audio_output *audioOutput,
|
||||
if (ad->device == NULL)
|
||||
return -1;
|
||||
|
||||
audioOutput->open = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -201,8 +201,6 @@ static int fifo_openDevice(struct audio_output *audioOutput,
|
||||
|
||||
fd->timer = timer_new(audio_format);
|
||||
|
||||
audioOutput->open = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -214,8 +212,6 @@ static void fifo_closeDevice(struct audio_output *audioOutput)
|
||||
timer_free(fd->timer);
|
||||
fd->timer = NULL;
|
||||
}
|
||||
|
||||
audioOutput->open = 0;
|
||||
}
|
||||
|
||||
static void fifo_dropBufferedAudio(struct audio_output *audioOutput)
|
||||
|
@ -363,22 +363,19 @@ static int jack_openDevice(struct audio_output *audioOutput,
|
||||
if (jd->client == NULL && connect_jack(audioOutput,
|
||||
audio_format) < 0) {
|
||||
freeJackClient(jd);
|
||||
audioOutput->open = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
set_audioformat(audioOutput, audio_format);
|
||||
audioOutput->open = 1;
|
||||
|
||||
DEBUG("jack_openDevice (pid=%d)!\n", getpid ());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void jack_closeDevice(struct audio_output *audioOutput)
|
||||
static void jack_closeDevice(mpd_unused struct audio_output *audioOutput)
|
||||
{
|
||||
/*jack_finishDriver(audioOutput);*/
|
||||
audioOutput->open = 0;
|
||||
DEBUG("jack_closeDevice (pid=%d)\n", getpid());
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,6 @@ static int mvp_openDevice(struct audio_output *audioOutput,
|
||||
mvp_setPcmParams(md, audioFormat->sampleRate, audioFormat->channels, 1,
|
||||
audioFormat->bits);
|
||||
#endif
|
||||
audioOutput->open = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -218,7 +217,6 @@ static void mvp_closeDevice(struct audio_output *audioOutput)
|
||||
if (md->fd >= 0)
|
||||
close(md->fd);
|
||||
md->fd = -1;
|
||||
audioOutput->open = 0;
|
||||
}
|
||||
|
||||
static void mvp_dropBufferedAudio(struct audio_output *audioOutput)
|
||||
|
@ -31,7 +31,6 @@ static int null_openDevice(struct audio_output *audioOutput,
|
||||
struct audio_format *audio_format)
|
||||
{
|
||||
audioOutput->data = timer_new(audio_format);
|
||||
audioOutput->open = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -41,8 +40,6 @@ static void null_closeDevice(struct audio_output *audioOutput)
|
||||
timer_free(audioOutput->data);
|
||||
audioOutput->data = NULL;
|
||||
}
|
||||
|
||||
audioOutput->open = 0;
|
||||
}
|
||||
|
||||
static int null_playAudio(struct audio_output *audioOutput,
|
||||
|
@ -471,13 +471,10 @@ static int oss_open(struct audio_output *audioOutput)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
audioOutput->open = 1;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
oss_close(od);
|
||||
audioOutput->open = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -509,8 +506,6 @@ static void oss_closeDevice(struct audio_output *audioOutput)
|
||||
OssData *od = audioOutput->data;
|
||||
|
||||
oss_close(od);
|
||||
|
||||
audioOutput->open = 0;
|
||||
}
|
||||
|
||||
static void oss_dropBufferedAudio(struct audio_output *audioOutput)
|
||||
|
@ -132,8 +132,6 @@ static void osx_closeDevice(struct audio_output *audioOutput)
|
||||
|
||||
CloseComponent(od->au);
|
||||
AudioUnitUninitialize(od->au);
|
||||
|
||||
audioOutput->open = 0;
|
||||
}
|
||||
|
||||
static OSStatus osx_render(void *vdata,
|
||||
@ -292,8 +290,6 @@ static int osx_openDevice(struct audio_output *audioOutput,
|
||||
od->pos = 0;
|
||||
od->len = 0;
|
||||
|
||||
audioOutput->open = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,6 @@ static int pulse_openDevice(struct audio_output *audioOutput,
|
||||
}
|
||||
|
||||
pd->connAttempts = 0;
|
||||
audioOutput->open = 1;
|
||||
|
||||
DEBUG("PulseAudio output \"%s\" connected and playing %i bit, %i "
|
||||
"channel audio at %i Hz\n", audioOutput->name, audioFormat->bits,
|
||||
@ -178,8 +177,6 @@ static void pulse_closeDevice(struct audio_output *audioOutput)
|
||||
pa_simple_drain(pd->s, NULL);
|
||||
pa_simple_free(pd->s);
|
||||
}
|
||||
|
||||
audioOutput->open = 0;
|
||||
}
|
||||
|
||||
static int pulse_playAudio(struct audio_output *audioOutput,
|
||||
|
@ -358,8 +358,6 @@ static void my_shout_close_device(struct audio_output *audio_output)
|
||||
timer_free(sd->timer);
|
||||
sd->timer = NULL;
|
||||
}
|
||||
|
||||
audio_output->open = 0;
|
||||
}
|
||||
|
||||
static int shout_connect(struct shout_data *sd)
|
||||
@ -455,8 +453,6 @@ static int my_shout_open_device(struct audio_output *audio_output,
|
||||
|
||||
sd->timer = timer_new(audio_format);
|
||||
|
||||
audio_output->open = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -75,13 +75,19 @@ static void *audio_output_task(void *arg)
|
||||
|
||||
case AO_COMMAND_OPEN:
|
||||
assert(!ao->open);
|
||||
ao->plugin->open(ao, &ao->outAudioFormat);
|
||||
ao->result = ao->plugin->open(ao, &ao->outAudioFormat);
|
||||
|
||||
assert(!ao->open);
|
||||
if (ao->result == 0)
|
||||
ao->open = 1;
|
||||
|
||||
ao_command_finished(ao);
|
||||
break;
|
||||
|
||||
case AO_COMMAND_CLOSE:
|
||||
assert(ao->open);
|
||||
ao->plugin->close(ao);
|
||||
ao->open = 0;
|
||||
ao_command_finished(ao);
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user