{
LOG_VERBOSE(LOG_TAG, "%s Track.cpp: btCreateTrack freq %d channel %d ",
__func__, trackFreq, channelType);
- int ret = -1;
sp<android::AudioTrack> track =
new android::AudioTrack(AUDIO_STREAM_MUSIC, trackFreq, AUDIO_FORMAT_PCM_16_BIT,
- channelType, (int)0, (audio_output_flags_t)AUDIO_OUTPUT_FLAG_FAST,
- NULL, NULL, 0, 0, android::AudioTrack::TRANSFER_SYNC);
+ channelType, (size_t) 0 /*frameCount*/,
+ (audio_output_flags_t)AUDIO_OUTPUT_FLAG_FAST,
+ NULL /*callback_t*/, NULL /*void* user*/, 0 /*notificationFrames*/,
+ AUDIO_SESSION_ALLOCATE, android::AudioTrack::TRANSFER_SYNC);
assert(track != NULL);
BtifAvrcpAudioTrack *trackHolder = new BtifAvrcpAudioTrack;
- assert(trackHolder);
+ assert(trackHolder != NULL);
trackHolder->track = track;
if (trackHolder->track->initCheck() != 0)
void BtifAvrcpAudioTrackStart(void *handle)
{
+ assert(handle != NULL);
BtifAvrcpAudioTrack *trackHolder = static_cast<BtifAvrcpAudioTrack*>(handle);
- assert(trackHolder);
+ assert(trackHolder != NULL);
assert(trackHolder->track != NULL);
LOG_VERBOSE(LOG_TAG, "%s Track.cpp: btStartTrack", __func__);
trackHolder->track->start();
void BtifAvrcpAudioTrackStop(void *handle)
{
+ if (handle == NULL) {
+ LOG_DEBUG(LOG_TAG, "%s handle is null.", __func__);
+ return;
+ }
BtifAvrcpAudioTrack *trackHolder = static_cast<BtifAvrcpAudioTrack*>(handle);
if (trackHolder != NULL && trackHolder->track != NULL) {
LOG_VERBOSE(LOG_TAG, "%s Track.cpp: btStartTrack", __func__);
void BtifAvrcpAudioTrackDelete(void *handle)
{
+ if (handle == NULL) {
+ LOG_DEBUG(LOG_TAG, "%s handle is null.", __func__);
+ return;
+ }
BtifAvrcpAudioTrack *trackHolder = static_cast<BtifAvrcpAudioTrack*>(handle);
if (trackHolder != NULL && trackHolder->track != NULL) {
LOG_VERBOSE(LOG_TAG, "%s Track.cpp: btStartTrack", __func__);
void BtifAvrcpAudioTrackPause(void *handle)
{
+ if (handle == NULL) {
+ LOG_DEBUG(LOG_TAG, "%s handle is null.", __func__);
+ return;
+ }
BtifAvrcpAudioTrack *trackHolder = static_cast<BtifAvrcpAudioTrack*>(handle);
if (trackHolder != NULL && trackHolder->track != NULL) {
LOG_VERBOSE(LOG_TAG, "%s Track.cpp: btStartTrack", __func__);
}
}
+void BtifAvrcpSetAudioTrackGain(void *handle, float gain)
+{
+ if (handle == NULL) {
+ LOG_DEBUG(LOG_TAG, "%s handle is null.", __func__);
+ return;
+ }
+ BtifAvrcpAudioTrack *trackHolder = static_cast<BtifAvrcpAudioTrack*>(handle);
+ if (trackHolder != NULL && trackHolder->track != NULL) {
+ LOG_VERBOSE(LOG_TAG, "%s set gain %f", __func__, gain);
+ trackHolder->track->setVolume(gain);
+ }
+}
+
int BtifAvrcpAudioTrackWriteData(void *handle, void *audioBuffer, int bufferlen)
{
BtifAvrcpAudioTrack *trackHolder = static_cast<BtifAvrcpAudioTrack*>(handle);
- assert(trackHolder);
+ assert(trackHolder != NULL);
assert(trackHolder->track != NULL);
int retval = -1;
#if (defined(DUMP_PCM_DATA) && (DUMP_PCM_DATA == TRUE))