assert(ctl);
- if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ if (!ctl->p)
return -EBADFD;
+ err = pulse_check_connection(ctl->p);
+ if (err < 0)
+ return err;
+
o = pa_context_get_sink_info_by_name(ctl->p->context, ctl->sink,
sink_info_cb, ctl);
if (o) {
static int pulse_elem_count(snd_ctl_ext_t * ext)
{
snd_ctl_pulse_t *ctl = ext->private_data;
- int count = 0;
+ int count = 0, err;
assert(ctl);
+ if (!ctl->p || !ctl->p->mainloop)
+ return -EBADFD;
+
pa_threaded_mainloop_lock(ctl->p->mainloop);
+ err = pulse_check_connection(ctl->p);
+ if (err < 0) {
+ count = err;
+ goto finish;
+ }
+
if (ctl->source)
count += 2;
if (ctl->sink)
count += 2;
+finish:
pa_threaded_mainloop_unlock(ctl->p->mainloop);
return count;
snd_ctl_elem_id_t * id)
{
snd_ctl_pulse_t *ctl = ext->private_data;
+ int err;
assert(ctl);
- if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ if (!ctl->p || !ctl->p->mainloop)
return -EBADFD;
snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);
pa_threaded_mainloop_lock(ctl->p->mainloop);
+ err = pulse_check_connection(ctl->p);
+ if (err < 0)
+ goto finish;
+
if (ctl->source) {
if (offset == 0)
snd_ctl_elem_id_set_name(id, SOURCE_VOL_NAME);
} else
offset += 2;
+ err = 0;
+
+finish:
pa_threaded_mainloop_unlock(ctl->p->mainloop);
- if (offset == 2)
- snd_ctl_elem_id_set_name(id, SINK_VOL_NAME);
- else if (offset == 3)
- snd_ctl_elem_id_set_name(id, SINK_MUTE_NAME);
+ if (err >= 0) {
+ if (offset == 2)
+ snd_ctl_elem_id_set_name(id, SINK_VOL_NAME);
+ else if (offset == 3)
+ snd_ctl_elem_id_set_name(id, SINK_MUTE_NAME);
+ }
- return 0;
+ return err;
}
static snd_ctl_ext_key_t pulse_find_elem(snd_ctl_ext_t * ext,
assert(ctl);
- if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ if (!ctl->p || !ctl->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(ctl->p->mainloop);
assert(ctl);
- if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ if (!ctl->p || !ctl->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(ctl->p->mainloop);
assert(ctl);
- if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ if (!ctl->p || !ctl->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(ctl->p->mainloop);
assert(ctl);
- if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ if (!ctl->p || !ctl->p->mainloop)
return;
pa_threaded_mainloop_lock(ctl->p->mainloop);
{
snd_ctl_pulse_t *ctl = ext->private_data;
int offset;
- int err = -EAGAIN;
+ int err;
assert(ctl);
- if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ if (!ctl->p || !ctl->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(ctl->p->mainloop);
- if (!ctl->updated || !ctl->subscribed)
+ err = pulse_check_connection(ctl->p);
+ if (err < 0)
+ goto finish;
+
+ if (!ctl->updated || !ctl->subscribed) {
+ err = -EAGAIN;
goto finish;
+ }
if (ctl->source)
offset = 2;
unsigned short *revents)
{
snd_ctl_pulse_t *ctl = ext->private_data;
- int err = 0;
+ int err;
assert(ctl);
- if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ if (!ctl->p || !ctl->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(ctl->p->mainloop);
+ err = pulse_check_connection(ctl->p);
+ if (err < 0)
+ goto finish;
+
if (ctl->updated)
*revents = POLLIN;
else
*revents = 0;
+ err = 0;
+
+finish:
+
pa_threaded_mainloop_unlock(ctl->p->mainloop);
return err;
if (!pcm->p)
return -EBADFD;
- ret = check_active(pcm);
+ ret = check_stream(pcm);
if (ret < 0)
- return ret;
+ goto finish;
+
+ ret = check_active(pcm);
- if (ret > 0)
+finish:
+
+ if (ret != 0) /* On error signal the caller, too */
pulse_poll_activate(pcm->p);
else
pulse_poll_deactivate(pcm->p);
assert(pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(pcm->p->mainloop);
- err = pulse_check_connection(pcm->p);
+ err = check_stream(pcm);
if (err < 0)
goto finish;
assert(pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(pcm->p->mainloop);
- err = pulse_check_connection(pcm->p);
+ err = check_stream(pcm);
if (err < 0)
goto finish;
assert(pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(pcm->p->mainloop);
- err = pulse_check_connection(pcm->p);
+ err = check_stream(pcm);
if (err < 0)
goto finish;
assert(pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
if (io->state == SND_PCM_STATE_XRUN)
pa_threaded_mainloop_lock(pcm->p->mainloop);
- if (!pcm->stream) {
- ret = -EBADFD;
- goto finish;
- }
-
- ret = pulse_check_connection(pcm->p);
+ ret = check_stream(pcm);
if (ret < 0)
goto finish;
assert(pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(pcm->p->mainloop);
- if (!pcm->stream) {
- err = -EBADFD;
- goto finish;
- }
-
for (;;) {
- err = pulse_check_connection(pcm->p);
+ err = check_stream(pcm);
if (err < 0)
goto finish;
assert(pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(pcm->p->mainloop);
- if (!pcm->stream) {
- ret = -EBADFD;
- goto finish;
- }
-
- ret = pulse_check_connection(pcm->p);
+ ret = check_stream(pcm);
if (ret < 0)
goto finish;
assert(pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(pcm->p->mainloop);
- if (!pcm->stream) {
- ret = -EBADFD;
- goto finish;
- }
-
- ret = pulse_check_connection(pcm->p);
+ ret = check_stream(pcm);
if (ret < 0)
goto finish;
assert(pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(pcm->p->mainloop);
- err = check_active(pcm);
+ err = check_stream(pcm);
+ if (err < 0)
+ goto finish;
+ err = check_active(pcm);
if (err < 0)
goto finish;
assert(pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(pcm->p->mainloop);
assert(pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(pcm->p->mainloop);
{
snd_pcm_pulse_t *pcm = io->private_data;
int err = 0;
+ pa_operation *o;
assert (pcm);
- if (!pcm->p)
+ if (!pcm->p || !pcm->p->mainloop)
return -EBADFD;
pa_threaded_mainloop_lock(pcm->p->mainloop);
- if (pcm->stream) {
- pa_operation *o;
- o = pa_stream_cork(pcm->stream, enable, NULL, NULL);
- if (o)
- pa_operation_unref(o);
- else
- err = -EIO;
- }
+ err = check_stream(pcm);
+ if (err < 0)
+ goto finish;
+
+ o = pa_stream_cork(pcm->stream, enable, NULL, NULL);
+ if (o)
+ pa_operation_unref(o);
+ else
+ err = -EIO;
+finish:
pa_threaded_mainloop_unlock(pcm->p->mainloop);
return err;