chromium/services/audio/device_listener_output_stream.h

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_AUDIO_DEVICE_LISTENER_OUTPUT_STREAM_H_
#define SERVICES_AUDIO_DEVICE_LISTENER_OUTPUT_STREAM_H_

#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_manager.h"

namespace audio {

// Simple wrapper class, which forwards all AudioOutputStream calls to the
// wrapped |stream_|. It also listens for device change events (via
// the AudioDeviceListener interface, or via errors reporting device changes),
// and forwards them via the |on_device_change_callback_|, on the owning
// (AudioManager) thread. |on_device_change_callback_| must synchronously close
// the DeviceListenerOutputStream.
class DeviceListenerOutputStream final
    : public media::AudioOutputStream,
      public media::AudioOutputStream::AudioSourceCallback,
      public media::AudioManager::AudioDeviceListener {};

}  // namespace audio

#endif  // SERVICES_AUDIO_DEVICE_LISTENER_OUTPUT_STREAM_H_