#include "audio/liba2dp.h"
#include <hardware_legacy/power.h>
-namespace android {
+
+namespace android_audio_legacy {
static const char *sA2dpWakeLock = "A2dpOutputStream";
#define MAX_WRITE_RETRIES 5
// AudioHardwareInterface* hw = 0;
//
// hw = AudioHardwareInterface::create();
-// LOGD("new A2dpAudioInterface(hw: %p)", hw);
+// ALOGD("new A2dpAudioInterface(hw: %p)", hw);
// hw = new A2dpAudioInterface(hw);
// return hw;
//}
AudioStreamOut* A2dpAudioInterface::openOutputStream(
uint32_t devices, int *format, uint32_t *channels, uint32_t *sampleRate, status_t *status)
{
- if (!AudioSystem::isA2dpDevice((AudioSystem::audio_devices)devices)) {
- LOGV("A2dpAudioInterface::openOutputStream() open HW device: %x", devices);
+ if (!audio_is_a2dp_out_device(devices)) {
+ ALOGV("A2dpAudioInterface::openOutputStream() open HW device: %x", devices);
return mHardwareInterface->openOutputStream(devices, format, channels, sampleRate, status);
}
String8 key;
status_t status = NO_ERROR;
- LOGV("setParameters() %s", keyValuePairs.string());
+ ALOGV("setParameters() %s", keyValuePairs.string());
key = "bluetooth_enabled";
if (param.get(key, value) == NO_ERROR) {
keyValuePairs += mHardwareInterface->getParameters(param.toString());
}
- LOGV("getParameters() %s", keyValuePairs.string());
+ ALOGV("getParameters() %s", keyValuePairs.string());
return keyValuePairs;
}
uint32_t lChannels = pChannels ? *pChannels : 0;
uint32_t lRate = pRate ? *pRate : 0;
- LOGD("A2dpAudioStreamOut::set %x, %d, %d, %d\n", device, lFormat, lChannels, lRate);
+ ALOGD("A2dpAudioStreamOut::set %x, %d, %d, %d\n", device, lFormat, lChannels, lRate);
// fix up defaults
if (lFormat == 0) lFormat = format();
A2dpAudioInterface::A2dpAudioStreamOut::~A2dpAudioStreamOut()
{
- LOGV("A2dpAudioStreamOut destructor");
+ ALOGV("A2dpAudioStreamOut destructor");
close();
- LOGV("A2dpAudioStreamOut destructor returning from close()");
+ ALOGV("A2dpAudioStreamOut destructor returning from close()");
}
ssize_t A2dpAudioInterface::A2dpAudioStreamOut::write(const void* buffer, size_t bytes)
size_t remaining = bytes;
if (!mBluetoothEnabled || mClosing || mSuspended) {
- LOGV("A2dpAudioStreamOut::write(), but bluetooth disabled \
+ ALOGV("A2dpAudioStreamOut::write(), but bluetooth disabled \
mBluetoothEnabled %d, mClosing %d, mSuspended %d",
mBluetoothEnabled, mClosing, mSuspended);
goto Error;
while (remaining > 0 && retries) {
status = a2dp_write(mData, buffer, remaining);
if (status < 0) {
- LOGE("a2dp_write failed err: %d\n", status);
+ ALOGE("a2dp_write failed err: %d\n", status);
goto Error;
}
if (status == 0) {
// NOTE: It is likely that the A2DP headset is being disconnected
nsecs_t now = systemTime();
if ((uint32_t)ns2us(now - mLastWriteTime) < (mBufferDurationUs >> 2)) {
- LOGV("A2DP sink runs too fast");
+ ALOGV("A2DP sink runs too fast");
usleep(mBufferDurationUs - (uint32_t)ns2us(now - mLastWriteTime));
}
mLastWriteTime = now;
if (!mData) {
status_t status = a2dp_init(44100, 2, &mData);
if (status < 0) {
- LOGE("a2dp_init failed err: %d\n", status);
+ ALOGE("a2dp_init failed err: %d\n", status);
mData = NULL;
return status;
}
int result = NO_ERROR;
if (!mStandby) {
- LOGV_IF(mClosing || !mBluetoothEnabled, "Standby skip stop: closing %d enabled %d",
+ ALOGV_IF(mClosing || !mBluetoothEnabled, "Standby skip stop: closing %d enabled %d",
mClosing, mBluetoothEnabled);
if (!mClosing && mBluetoothEnabled) {
result = a2dp_stop(mData);
String8 key = String8("a2dp_sink_address");
status_t status = NO_ERROR;
int device;
- LOGV("A2dpAudioStreamOut::setParameters() %s", keyValuePairs.string());
+ ALOGV("A2dpAudioStreamOut::setParameters() %s", keyValuePairs.string());
if (param.get(key, value) == NO_ERROR) {
if (value.length() != strlen("00:00:00:00:00:00")) {
}
key = AudioParameter::keyRouting;
if (param.getInt(key, device) == NO_ERROR) {
- if (AudioSystem::isA2dpDevice((AudioSystem::audio_devices)device)) {
+ if (audio_is_a2dp_out_device(device)) {
mDevice = device;
status = NO_ERROR;
} else {
param.addInt(key, (int)mDevice);
}
- LOGV("A2dpAudioStreamOut::getParameters() %s", param.toString().string());
+ ALOGV("A2dpAudioStreamOut::getParameters() %s", param.toString().string());
return param.toString();
}
status_t A2dpAudioInterface::A2dpAudioStreamOut::setBluetoothEnabled(bool enabled)
{
- LOGD("setBluetoothEnabled %d", enabled);
+ ALOGD("setBluetoothEnabled %d", enabled);
Mutex::Autolock lock(mLock);
status_t A2dpAudioInterface::A2dpAudioStreamOut::setSuspended(bool onOff)
{
- LOGV("setSuspended %d", onOff);
+ ALOGV("setSuspended %d", onOff);
mSuspended = onOff;
standby();
return NO_ERROR;
status_t A2dpAudioInterface::A2dpAudioStreamOut::close()
{
Mutex::Autolock lock(mLock);
- LOGV("A2dpAudioStreamOut::close() calling close_l()");
+ ALOGV("A2dpAudioStreamOut::close() calling close_l()");
return close_l();
}
{
standby_l();
if (mData) {
- LOGV("A2dpAudioStreamOut::close_l() calling a2dp_cleanup(mData)");
+ ALOGV("A2dpAudioStreamOut::close_l() calling a2dp_cleanup(mData)");
a2dp_cleanup(mData);
mData = NULL;
}