src/media/audio/drivers/virtual_audio/virtual_audio_stream.cc
// Timer handler for sending out position notifications: to AudioCore, to VAD clients that do not
// override the notification frequency, and to VAD clients that set it to the same value that
// AudioCore has selected.
Timer handler for sending out position notifications: to AudioCore, to VAD clients that do not
override the notification frequency, and to VAD clients that set it to the same value that
AudioCore has selected.
Timer handler for sending out position notifications : to AudioCore to VAD clients that do not override the notification frequency and to VAD clients that set it to the same value that AudioCore has selected .
void VirtualAudioStream::ProcessRingNotification() {
  audio::ScopedToken t(
      domain_token());  
  ZX_DEBUG_ASSERT(notification_period_.get() > 0);
  auto monotonic_time = target_notification_time_.get();
  ZX_DEBUG_ASSERT(monotonic_time > 0);
  auto running_duration = target_notification_time_ - start_time_;
  uint64_t frames = (running_duration * frame_rate_) / zx::sec(1);
  uint32_t ring_buffer_position = (frames % num_ring_buffer_frames_) * frame_size_;
  audio::audio_proto::RingBufPositionNotify resp = {};
  resp.hdr.cmd = AUDIO_RB_POSITION_NOTIFY;
  resp.monotonic_time = monotonic_time;
  resp.ring_buffer_pos = ring_buffer_position;
  NotifyPosition(resp);
  if (!using_alt_notifications_) {
    parent_->NotifyPosition(monotonic_time, ring_buffer_position);
  }
  target_notification_time_ += notification_period_;
  notify_timer_.PostForTime(dispatcher(), target_notification_time_);
}
void VirtualAudioStream :: ProcessRingNotification ( ) { audio :: ScopedToken t ( domain_token ( ) ) ; ZX_DEBUG_ASSERT ( notification_period_ . get ( ) > 0 ) ; auto monotonic_time = target_notification_time_ . get ( ) ; ZX_DEBUG_ASSERT ( monotonic_time > 0 ) ; auto running_duration = target_notification_time_ - start_time_ ; uint64_t frames = ( running_duration * frame_rate_ ) / zx :: sec ( 1 ) ; uint32_t ring_buffer_position = ( frames % num_ring_buffer_frames_ ) * frame_size_ ; audio :: audio_proto :: RingBufPositionNotify resp = { } ; resp . hdr . cmd = AUDIO_RB_POSITION_NOTIFY ; resp . monotonic_time = monotonic_time ; resp . ring_buffer_pos = ring_buffer_position ; NotifyPosition ( resp ) ; if ( ! using_alt_notifications_ ) { parent_ -> NotifyPosition ( monotonic_time , ring_buffer_position ) ; } target_notification_time_ += notification_period_ ; notify_timer_ . PostForTime ( dispatcher ( ) , target_notification_time_ ) ; }
Timer handler for sending out position notifications: to AudioCore, to VAD clients that do not
override the notification frequency, and to VAD clients that set it to the same value that
AudioCore has selected.
Timer handler for sending out position notifications : to AudioCore to VAD clients that do not override the notification frequency and to VAD clients that set it to the same value that AudioCore has selected .
// This method handles posts to notify_timer_ sent to dispatcher(). // TODO(MTWN-57): use a proper Timeline object here.