chromium/chromecast/media/audio/BUILD.gn

# Copyright 2015 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//chromecast/chromecast.gni")
import("//media/media_options.gni")
import("//testing/test.gni")

cast_source_set("audio_log") {
  sources = [
    "audio_log.cc",
    "audio_log.h",
  ]

  deps = [ "//base" ]
}

cast_source_set("audio_io_thread") {
  sources = [
    "audio_io_thread.cc",
    "audio_io_thread.h",
  ]

  deps = [ "//base" ]
}

cast_source_set("wav_header") {
  sources = [ "wav_header.h" ]
}

cast_source_set("processing") {
  sources = [
    "audio_fader.cc",
    "audio_fader.h",
    "cast_audio_bus.cc",
    "cast_audio_bus.h",
  ]

  deps = [
    "//base",
    "//chromecast/media/api",
  ]

  # Use fastest possible float math.
  configs -= [ "//build/config/compiler:default_optimization" ]
  configs += [ "//build/config/compiler:optimize_speed" ]
  cflags = [
    "-ffast-math",
    "-Wno-nan-infinity-disabled",
  ]
}

cast_source_set("playback_rate_shifter") {
  sources = [
    "playback_rate_shifter.cc",
    "playback_rate_shifter.h",
  ]

  deps = [
    "//base",
    "//chromecast/media/api",
    "//media",
  ]
}

cast_source_set("interleaved_channel_mixer") {
  sources = [
    "interleaved_channel_mixer.cc",
    "interleaved_channel_mixer.h",
  ]

  deps = [
    "//base",
    "//media",
  ]
}

cast_source_set("cma_audio_output") {
  sources = [
    "cma_audio_output.cc",
    "cma_audio_output.h",
  ]

  deps = [
    "//base",
    "//chromecast/base",
    "//chromecast/media/base",
    "//chromecast/media/cma/backend",
    "//chromecast/media/cma/base",
    "//chromecast/public/media",
    "//media",
  ]
}

cast_source_set("resampler") {
  sources = [ "cast_audio_resampler_impl.cc" ]

  deps = [
    "//base",
    "//chromecast/media/api",
    "//media",
  ]
}

cast_source_set("channel_mixer") {
  sources = [ "cast_channel_mixer_impl.cc" ]
  deps = [
    "//base",
    "//chromecast/media/api",
    "//chromecast/media/cma/base",
    "//media",
  ]
}

cast_source_set("audio_renderer") {
  sources = [
    "cast_audio_renderer.cc",
    "cast_audio_renderer.h",
  ]

  public_deps = [ "//chromecast/media/audio/audio_output_service:proto" ]

  deps = [
    ":audio_io_thread",
    "//base",
    "//chromecast/common/mojom",
    "//chromecast/media/audio/audio_output_service:output_connection",
    "//chromecast/media/audio/net:common",
    "//chromecast/media/cma/base",
    "//chromecast/public/media",
    "//media",
    "//media/mojo/mojom",
    "//mojo/public/cpp/bindings",
    "//net",
    "//third_party/blink/public:blink_headers",
  ]
}

cast_source_set("audio") {
  sources = [
    "audio_clock_simulator_impl.cc",
    "cast_audio_input_stream.cc",
    "cast_audio_input_stream.h",
    "cast_audio_manager.cc",
    "cast_audio_manager.h",
    "cast_audio_manager_helper.cc",
    "cast_audio_manager_helper.h",
    "cast_audio_mixer.cc",
    "cast_audio_mixer.h",
    "cast_audio_output_stream.cc",
    "cast_audio_output_stream.h",
    "cast_audio_output_utils.cc",
    "cast_audio_output_utils.h",
    "cma_audio_output_stream.cc",
    "cma_audio_output_stream.h",
  ]

  deps = [
    ":audio_buildflags",
    ":cma_audio_output",
    "//base",
    "//chromecast/base",
    "//chromecast/media/api",
    "//chromecast/media/audio/capture_service:common",
    "//chromecast/media/audio/capture_service:receiver",
    "//chromecast/media/audio/capture_service:utils",
    "//chromecast/media/audio/mixer_service:common",
    "//chromecast/media/audio/mixer_service:output_stream_connection",
    "//chromecast/media/audio/mixer_service:proto",
    "//chromecast/media/audio/net:proto",
    "//chromecast/media/base",
    "//chromecast/media/base:monotonic_clock",
    "//chromecast/media/cma/backend",
    "//chromecast/media/cma/base",
    "//chromecast/public/media",
    "//media",
    "//media:shared_memory_support",
  ]

  if (use_alsa) {
    sources += [
      "cast_audio_manager_alsa.cc",
      "cast_audio_manager_alsa.h",
    ]
    deps += [ ":audio_buildflags" ]
  }

  if (is_android) {
    sources += [
      "cast_audio_manager_android.cc",
      "cast_audio_manager_android.h",
    ]
  }

  configs += [ "//media/audio:platform_config" ]
}

cast_source_set("cast_audio_output_device") {
  sources = [
    "cast_audio_output_device.cc",
    "cast_audio_output_device.h",
  ]

  deps = [
    ":audio_io_thread",
    "//base",
    "//chromecast/common/mojom",
    "//chromecast/media/audio/audio_output_service:output_connection",
    "//chromecast/media/audio/audio_output_service:proto",
    "//chromecast/media/base:monotonic_clock",
    "//content/renderer:renderer",
    "//media",
    "//media/mojo/mojom",
    "//net",
  ]
}

if (is_android) {
  cast_source_set("cast_audio_device_factory") {
    sources = [
      "cast_audio_device_factory.cc",
      "cast_audio_device_factory.h",
    ]

    deps = [
      ":cast_audio_output_device",
      "//base",
      "//chromecast/base",
      "//content/public/renderer",
      "//content/renderer:renderer",
      "//media",
      "//third_party/blink/public:blink",
      "//third_party/blink/public/common",
    ]
  }
}

source_set("dummy_external_audio_pipeline") {
  sources = [ "external_audio_pipeline_dummy.cc" ]

  public_deps = [ "//chromecast/public/media" ]
}

cast_shared_library("libcast_external_audio_pipeline_1.0") {
  public_deps = [ ":dummy_external_audio_pipeline" ]
}

source_set("fake_external_audio_pipeline") {
  sources = [
    "fake_external_audio_pipeline.cc",
    "fake_external_audio_pipeline_support.h",
  ]

  deps = [
    "//base",
    "//chromecast/public",
    "//chromecast/public/media",
  ]
}

buildflag_header("audio_buildflags") {
  header = "audio_buildflags.h"

  flags = [ "ENABLE_AUDIO_CAPTURE_SERVICE=$enable_audio_capture_service" ]

  if (use_alsa) {
    # Currently, this flag will only be used in cast_audio_manager_alsa.cc
    flags += [ "AUDIO_INPUT_SAMPLE_RATE=$audio_input_sample_rate" ]
  }
}

cast_source_set("rate_adjuster") {
  sources = [
    "rate_adjuster.cc",
    "rate_adjuster.h",
  ]

  deps = [
    "//base",
    "//chromecast/base",
  ]
}

cast_source_set("test_support") {
  testonly = true

  sources = [
    "mock_audio_input_callback.h",
    "mock_cast_audio_manager_helper_delegate.h",
  ]

  public_deps = [ "//testing/gmock" ]

  deps = [
    ":audio",
    "//media",
  ]
}

cast_source_set("unittests") {
  testonly = true
  sources = [
    "audio_clock_simulator_unittest.cc",
    "audio_fader_unittest.cc",
    "interleaved_channel_mixer_unittest.cc",
    "playback_rate_shifter_unittest.cc",
    "rate_adjuster_unittest.cc",
  ]

  deps = [
    ":audio",
    ":interleaved_channel_mixer",
    ":playback_rate_shifter",
    ":processing",
    ":rate_adjuster",
    "//base",
    "//chromecast/media/api",
    "//media",
    "//testing/gmock",
    "//testing/gtest",
  ]
}