static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) { struct astream_out *out = (struct astream_out *)stream; struct str_parms *parms; char *str; char value[32]; int ret; parms = str_parms_create_str(kvpairs); pthread_mutex_lock(&out->lock); ret = str_parms_get_str(parms, OUT_SINK_ADDR_PARM, value, sizeof(value)); if (ret >= 0) { /* strlen(00:00:00:00:00:00) == 17 */ if (strlen(value) == 17) { strlcpy(out->a2dp_addr, value, sizeof(out->a2dp_addr)); if (out->data) a2dp_set_sink(out->data, out->a2dp_addr); } else ret = -EINVAL; } pthread_mutex_unlock(&out->lock); str_parms_destroy(parms); return ret; }
status_t A2dpAudioInterface::A2dpAudioStreamOut::setAddress(const char* address) { Mutex::Autolock lock(mLock); if (strlen(address) != strlen("00:00:00:00:00:00")) return -EINVAL; strcpy(mA2dpAddress, address); if (mData) a2dp_set_sink(mData, mA2dpAddress); return NO_ERROR; }
status_t A2dpAudioInterface::A2dpAudioStreamOut::init() { if (!mData) { status_t status = a2dp_init(44100, 2, &mData); if (status < 0) { LOGE("a2dp_init failed err: %d\n", status); mData = NULL; return status; } a2dp_set_sink(mData, mA2dpAddress); } return 0; }
static int _out_init_locked(struct astream_out *out, const char *addr) { int ret; if (out->data) return 0; /* XXX: shouldn't this use the sample_rate/channel_count from 'out'? */ ret = a2dp_init(44100, 2, &out->data); if (ret < 0) { LOGE("a2dp_init failed err: %d\n", ret); out->data = NULL; return ret; } /* XXX: is this even necessary? */ if (addr) strlcpy(out->a2dp_addr, addr, sizeof(out->a2dp_addr)); a2dp_set_sink(out->data, out->a2dp_addr); return 0; }