summaryrefslogtreecommitdiff
path: root/src/audiobackend-pulse.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/audiobackend-pulse.cc')
-rw-r--r--src/audiobackend-pulse.cc7
1 files changed, 4 insertions, 3 deletions
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));