Remote submix: fix sink/source reference count handling
The reference count on the strong pointers to the audio sink and
source should be done on the object retrieved from the device
structure, not by accessing the corresponding fields, as they
can be cleared while reading or writing audio data.
Change-Id: I446a2c7bdcb0758b4013b0ad75450a15203fb9da
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp
index 82bac1a..0f8adab 100755
--- a/modules/audio_remote_submix/audio_hw.cpp
+++ b/modules/audio_remote_submix/audio_hw.cpp
@@ -212,7 +212,7 @@
MonoPipe* sink = out->dev->rsxSink.get();
if (sink != NULL) {
- out->dev->rsxSink->incStrong(buffer);
+ sink->incStrong(buffer);
} else {
pthread_mutex_unlock(&out->dev->lock);
ALOGE("out_write without a pipe!");
@@ -230,7 +230,7 @@
ALOGE("out_write() write to pipe returned NEGOTIATE");
pthread_mutex_lock(&out->dev->lock);
- out->dev->rsxSink->decStrong(buffer);
+ sink->decStrong(buffer);
pthread_mutex_unlock(&out->dev->lock);
written_frames = 0;
@@ -244,7 +244,7 @@
pthread_mutex_lock(&out->dev->lock);
- out->dev->rsxSink->decStrong(buffer);
+ sink->decStrong(buffer);
pthread_mutex_unlock(&out->dev->lock);
@@ -382,7 +382,7 @@
MonoPipeReader* source = in->dev->rsxSource.get();
if (source != NULL) {
- in->dev->rsxSource->incStrong(in);
+ source->incStrong(buffer);
} else {
ALOGE("no audio pipe yet we're trying to read!");
pthread_mutex_unlock(&in->dev->lock);
@@ -414,7 +414,7 @@
// done using the source
pthread_mutex_lock(&in->dev->lock);
- in->dev->rsxSource->decStrong(in);
+ source->decStrong(buffer);
pthread_mutex_unlock(&in->dev->lock);