summaryrefslogtreecommitdiffstats
path: root/libs/audioflinger/A2dpAudioInterface.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:44:00 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:44:00 -0800
commitd24b8183b93e781080b2c16c487e60d51c12da31 (patch)
treefbb89154858984eb8e41556da7e9433040d55cd4 /libs/audioflinger/A2dpAudioInterface.cpp
parentf1e484acb594a726fb57ad0ae4cfe902c7f35858 (diff)
downloadframeworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.zip
frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.gz
frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.bz2
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'libs/audioflinger/A2dpAudioInterface.cpp')
-rw-r--r--libs/audioflinger/A2dpAudioInterface.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/libs/audioflinger/A2dpAudioInterface.cpp b/libs/audioflinger/A2dpAudioInterface.cpp
index c8c8431..3c18036 100644
--- a/libs/audioflinger/A2dpAudioInterface.cpp
+++ b/libs/audioflinger/A2dpAudioInterface.cpp
@@ -99,6 +99,10 @@ status_t A2dpAudioInterface::setParameter(const char *key, const char *value)
if (strcmp(key, "a2dp_sink_address") == 0) {
return mOutput->setAddress(value);
}
+ if (strcmp(key, "bluetooth_enabled") == 0 &&
+ strcmp(value, "false") == 0) {
+ return mOutput->close();
+ }
return 0;
}
@@ -154,8 +158,7 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::set(
A2dpAudioInterface::A2dpAudioStreamOut::~A2dpAudioStreamOut()
{
- if (mData)
- a2dp_cleanup(mData);
+ close();
}
ssize_t A2dpAudioInterface::A2dpAudioStreamOut::write(const void* buffer, size_t bytes)
@@ -186,7 +189,8 @@ ssize_t A2dpAudioInterface::A2dpAudioStreamOut::write(const void* buffer, size_t
return bytes;
-Error:
+Error:
+ close();
// Simulate audio output timing in case of error
usleep(bytes * 1000000 / frameSize() / sampleRate());
@@ -213,17 +217,22 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::setAddress(const char* address)
if (strcmp(address, mA2dpAddress)) {
strcpy(mA2dpAddress, address);
-
- if (mInitialized) {
- a2dp_cleanup(mData);
- mData = NULL;
- mInitialized = false;
- }
+ close();
}
return NO_ERROR;
}
+status_t A2dpAudioInterface::A2dpAudioStreamOut::close()
+{
+ if (mData) {
+ a2dp_cleanup(mData);
+ mData = NULL;
+ mInitialized = false;
+ }
+ return NO_ERROR;
+}
+
status_t A2dpAudioInterface::A2dpAudioStreamOut::dump(int fd, const Vector<String16>& args)
{
return NO_ERROR;