From 5214bf9aea7278b8bc6a2a3cf0cedb833d461d11 Mon Sep 17 00:00:00 2001 From: Lars Bisballe Jensen Date: Thu, 2 Oct 2014 10:25:32 +0200 Subject: Moved error to top of function --- src/audiobackend-pulse.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/audiobackend-pulse.cc') diff --git a/src/audiobackend-pulse.cc b/src/audiobackend-pulse.cc index ba7c561..580f429 100644 --- a/src/audiobackend-pulse.cc +++ b/src/audiobackend-pulse.cc @@ -73,6 +73,8 @@ AudioBackendPulse::~AudioBackendPulse() void AudioBackendPulse::run() { + int error; + if(!sIn) { sIn = pa_simple_new(NULL, "Anything", PA_STREAM_RECORD, NULL, "record", &ss, NULL, NULL, &error); @@ -85,7 +87,6 @@ void AudioBackendPulse::run() char buf[1024]; while(running) { - int error; pa_simple_read(sIn, buf, sizeof(buf), &error); (void)error; for(int i = 0; i < sizeof(buf); i++) { @@ -111,6 +112,8 @@ int AudioBackendPulse::read(char *pcm, size_t maxsize) int AudioBackendPulse::write(const char *pcm, size_t size) { + int error; + if(!sOut) { sOut = pa_simple_new(NULL, "Anything", PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &error); @@ -121,8 +124,6 @@ int AudioBackendPulse::write(const char *pcm, size_t size) } } - int error; - if (pa_simple_write(sOut, pcm, size, &error) < 0) { fprintf(stderr, __FILE__": pa_simple_write() failed: %s\n", pa_strerror(error)); -- cgit v1.2.3