summaryrefslogtreecommitdiffstats
path: root/pulse
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-08-22 01:11:10 +0200
committerLennart Poettering <lennart@poettering.net>2008-09-03 20:25:36 +0200
commit31adc7c069b3b73a44e00e681d16330ed993c51f (patch)
tree056449e5f2bed5f0c619f3f82bc7f04fa194e783 /pulse
parentf5d1f3be98d95bec41f64d0568accddce8c2f212 (diff)
Add more error checking
Add a bit more error checking where necessary
Diffstat (limited to 'pulse')
-rw-r--r--pulse/pcm_pulse.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c
index 8d823b5..13cdd00 100644
--- a/pulse/pcm_pulse.c
+++ b/pulse/pcm_pulse.c
@@ -484,7 +484,7 @@ static int pulse_prepare(snd_pcm_ioplug_t * io)
{
pa_channel_map map;
snd_pcm_pulse_t *pcm = io->private_data;
- int err = 0;
+ int err = 0, r;
assert(pcm);
assert(pcm->p);
@@ -521,7 +521,11 @@ static int pulse_prepare(snd_pcm_ioplug_t * io)
ss.
channels,
PA_CHANNEL_MAP_ALSA));
- assert(pcm->stream);
+
+ if (!pcm->stream) {
+ err = -ENOMEM;
+ goto finish;
+ }
pa_stream_set_state_callback(pcm->stream, pulse_stream_state_cb,
pcm->p);
@@ -531,18 +535,26 @@ static int pulse_prepare(snd_pcm_ioplug_t * io)
stream_request_cb, pcm);
pa_stream_set_underflow_callback(pcm->stream,
stream_underrun_cb, pcm);
- pa_stream_connect_playback(pcm->stream, pcm->device,
- &pcm->buffer_attr,
- PA_STREAM_AUTO_TIMING_UPDATE |
- PA_STREAM_INTERPOLATE_TIMING,
- NULL, NULL);
+ r = pa_stream_connect_playback(pcm->stream, pcm->device,
+ &pcm->buffer_attr,
+ PA_STREAM_AUTO_TIMING_UPDATE |
+ PA_STREAM_INTERPOLATE_TIMING,
+ NULL, NULL);
} else {
pa_stream_set_read_callback(pcm->stream, stream_request_cb,
pcm);
- pa_stream_connect_record(pcm->stream, pcm->device,
- &pcm->buffer_attr,
- PA_STREAM_AUTO_TIMING_UPDATE |
- PA_STREAM_INTERPOLATE_TIMING);
+ r = pa_stream_connect_record(pcm->stream, pcm->device,
+ &pcm->buffer_attr,
+ PA_STREAM_AUTO_TIMING_UPDATE |
+ PA_STREAM_INTERPOLATE_TIMING);
+ }
+
+ if (r < 0) {
+ SNDERR("PulseAudio: Unable to create stream: %s\n", pa_strerror(pa_context_errno(pcm->p->context)));
+ pa_stream_unref(pcm->stream);
+ pcm->stream = NULL;
+ r = -EIO;
+ goto finish;
}
err =
@@ -804,10 +816,18 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pulse)
}
pcm = calloc(1, sizeof(*pcm));
+ if (!pcm)
+ return -ENOMEM;
- if (device)
+ if (device) {
pcm->device = strdup(device);
+ if (!pcm->device) {
+ err = -ENOMEM;
+ goto error;
+ }
+ }
+
pcm->p = pulse_new();
if (!pcm->p) {
err = -EIO;