@ -43,7 +43,7 @@ using namespace aaudio; // TODO just import names needed
AAudioServiceStreamBase : : AAudioServiceStreamBase ( AAudioService & audioService )
: mUpMessageQueue ( nullptr )
, mTimestampThread ( " AATime " )
, mAtomic Timestamp( )
, mAtomic Stream Timestamp( )
, mAudioService ( audioService ) {
mMmapClient . clientUid = - 1 ;
mMmapClient . clientPid = - 1 ;
@ -182,7 +182,7 @@ aaudio_result_t AAudioServiceStreamBase::start() {
setSuspended ( false ) ;
// Start with fresh presentation timestamps.
mAtomic Timestamp. clear ( ) ;
mAtomic Stream Timestamp. clear ( ) ;
mClientHandle = AUDIO_PORT_HANDLE_NONE ;
result = startDevice ( ) ;
@ -291,16 +291,20 @@ aaudio_result_t AAudioServiceStreamBase::flush() {
}
// implement Runnable, periodically send timestamps to client
__attribute__ ( ( no_sanitize ( " integer " ) ) )
void AAudioServiceStreamBase : : run ( ) {
ALOGD ( " %s() %s entering >>>>>>>>>>>>>> TIMESTAMPS " , __func__ , getTypeText ( ) ) ;
TimestampScheduler timestampScheduler ;
timestampScheduler . setBurstPeriod ( mFramesPerBurst , getSampleRate ( ) ) ;
timestampScheduler . start ( AudioClock : : getNanoseconds ( ) ) ;
int64_t nextTime = timestampScheduler . nextAbsoluteTime ( ) ;
int32_t loopCount = 0 ;
while ( mThreadEnabled . load ( ) ) {
loopCount + + ;
if ( AudioClock : : getNanoseconds ( ) > = nextTime ) {
aaudio_result_t result = sendCurrentTimestamp ( ) ;
if ( result ! = AAUDIO_OK ) {
ALOGE ( " %s() timestamp thread got result = %d " , __func__ , result ) ;
break ;
}
nextTime = timestampScheduler . nextAbsoluteTime ( ) ;
@ -310,7 +314,8 @@ void AAudioServiceStreamBase::run() {
AudioClock : : sleepUntilNanoTime ( nextTime ) ;
}
}
ALOGD ( " %s() %s exiting <<<<<<<<<<<<<< TIMESTAMPS " , __func__ , getTypeText ( ) ) ;
ALOGD ( " %s() %s exiting after %d loops <<<<<<<<<<<<<< TIMESTAMPS " ,
__func__ , getTypeText ( ) , loopCount ) ;
}
void AAudioServiceStreamBase : : disconnect ( ) {