diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-06-14 20:36:26 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-06-14 20:36:26 +0000 |
commit | 5ed2a3ba745856206c66d8ecb98afb8a1f9ec7b5 (patch) | |
tree | b158176d2c90868417f8611f0491a14ce5726ad2 /audio/pcm_bluetooth.c | |
parent | 9d1a7f6c590fc40315f74e710e88bcda85d7f7ba (diff) |
Initial support for audio control plugin and some code cleanups.
Diffstat (limited to 'audio/pcm_bluetooth.c')
-rw-r--r-- | audio/pcm_bluetooth.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c index d588bcfd..16c99f06 100644 --- a/audio/pcm_bluetooth.c +++ b/audio/pcm_bluetooth.c @@ -84,14 +84,27 @@ static snd_pcm_sframes_t bluetooth_pointer(snd_pcm_ioplug_t *io) return data->hw_ptr; } +static void bluetooth_exit(struct bluetooth_data *data) +{ + if (data == NULL) + return; + + if (data->sock >= 0) + close(data->sock); + + if (data->buffer) + free(data->buffer); + + free(data); +} + static int bluetooth_close(snd_pcm_ioplug_t *io) { struct bluetooth_data *data = io->private_data; DBG("bluetooth_close %p", io); - free(data->buffer); - free(data); + bluetooth_exit(data); return 0; } @@ -517,6 +530,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(bluetooth) stream == SND_PCM_STREAM_PLAYBACK ? "Playback" : "Capture"); data = malloc(sizeof(struct bluetooth_data)); + memset(data, 0, sizeof(struct bluetooth_data)); if (!data) { err = -ENOMEM; goto error; @@ -552,11 +566,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(bluetooth) return 0; error: - if (data) { - if (data->sock >= 0) - close(data->sock); - free(data); - } + bluetooth_exit(data); return err; } |