From c9c4e2e9efac93ad5cd6bcabcb4ec53f0a0df70c Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Thu, 13 Aug 2020 12:03:37 -0400 Subject: [PATCH] Componentize SkAudioPlayer Relocate under modules/audioplayer and package as a standalone component. Change-Id: If9dc72bb0abe170049a514c9931186703a3c138a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310058 Commit-Queue: Florin Malita Reviewed-by: Mike Reed --- BUILD.gn | 8 +------- modules/audioplayer/BUILD.gn | 19 +++++++++++++++++++ .../audioplayer}/SkAudioPlayer.cpp | 2 +- .../audioplayer}/SkAudioPlayer.h | 0 .../audioplayer}/SkAudioPlayer_mac.mm | 2 +- .../audioplayer}/SkAudioPlayer_none.cpp | 2 +- modules/skottie/src/layers/AudioLayer.cpp | 3 +++ samplecode/SampleAudio.cpp | 2 +- tools/viewer/SkottieSlide.cpp | 2 +- 9 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 modules/audioplayer/BUILD.gn rename {src/ports => modules/audioplayer}/SkAudioPlayer.cpp (96%) rename {include/ports => modules/audioplayer}/SkAudioPlayer.h (100%) rename {src/ports => modules/audioplayer}/SkAudioPlayer_mac.mm (97%) rename {src/ports => modules/audioplayer}/SkAudioPlayer_none.cpp (85%) diff --git a/BUILD.gn b/BUILD.gn index 12feeff718..2b2e47aa58 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -459,7 +459,6 @@ optional("fontmgr_mac_ct") { # AppKit symbols NSFontWeightXXX may be dlsym'ed. "AppKit.framework", "ApplicationServices.framework", - "AVFoundation.framework", ] } @@ -2505,7 +2504,6 @@ if (skia_enable_tools) { test_app("viewer") { is_shared_library = is_android sources = [ - "src/ports/SkAudioPlayer.cpp", "tools/viewer/AnimTimer.h", "tools/viewer/BisectSlide.cpp", "tools/viewer/GMSlide.cpp", @@ -2539,6 +2537,7 @@ if (skia_enable_tools) { ":tool_utils", ":trace", "experimental/skrive", + "modules/audioplayer", "modules/particles", "modules/skottie", "modules/skottie:utils", @@ -2558,11 +2557,6 @@ if (skia_enable_tools) { "//third_party/spirv-tools:spvtools_val", ] } - if (is_mac) { - sources += [ "src/ports/SkAudioPlayer_mac.mm" ] - } else { - sources += [ "src/ports/SkAudioPlayer_none.cpp" ] - } } } diff --git a/modules/audioplayer/BUILD.gn b/modules/audioplayer/BUILD.gn new file mode 100644 index 0000000000..26311fccca --- /dev/null +++ b/modules/audioplayer/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright 2020 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("../../gn/skia.gni") + +component("audioplayer") { + public = [ "SkAudioPlayer.h" ] + sources = [ "SkAudioPlayer.cpp" ] + deps = [ "../..:skia" ] + + if (is_mac) { + sources += [ "SkAudioPlayer_mac.mm" ] + frameworks = [ "AVFoundation.framework" ] + } else { + sources += [ "SkAudioPlayer_none.cpp" ] + } +} diff --git a/src/ports/SkAudioPlayer.cpp b/modules/audioplayer/SkAudioPlayer.cpp similarity index 96% rename from src/ports/SkAudioPlayer.cpp rename to modules/audioplayer/SkAudioPlayer.cpp index a190521bfb..ea26f4866d 100644 --- a/src/ports/SkAudioPlayer.cpp +++ b/modules/audioplayer/SkAudioPlayer.cpp @@ -5,7 +5,7 @@ * found in the LICENSE file. */ -#include "include/ports/SkAudioPlayer.h" +#include "modules/audioplayer/SkAudioPlayer.h" #include #include diff --git a/include/ports/SkAudioPlayer.h b/modules/audioplayer/SkAudioPlayer.h similarity index 100% rename from include/ports/SkAudioPlayer.h rename to modules/audioplayer/SkAudioPlayer.h diff --git a/src/ports/SkAudioPlayer_mac.mm b/modules/audioplayer/SkAudioPlayer_mac.mm similarity index 97% rename from src/ports/SkAudioPlayer_mac.mm rename to modules/audioplayer/SkAudioPlayer_mac.mm index 8a5ffc3517..e2c1b7449d 100644 --- a/src/ports/SkAudioPlayer_mac.mm +++ b/modules/audioplayer/SkAudioPlayer_mac.mm @@ -6,7 +6,7 @@ */ #include "include/core/SkData.h" -#include "include/ports/SkAudioPlayer.h" +#include "modules/audioplayer/SkAudioPlayer.h" #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) diff --git a/src/ports/SkAudioPlayer_none.cpp b/modules/audioplayer/SkAudioPlayer_none.cpp similarity index 85% rename from src/ports/SkAudioPlayer_none.cpp rename to modules/audioplayer/SkAudioPlayer_none.cpp index 79e0f4d666..c1b300e14a 100644 --- a/src/ports/SkAudioPlayer_none.cpp +++ b/modules/audioplayer/SkAudioPlayer_none.cpp @@ -6,7 +6,7 @@ */ #include "include/core/SkData.h" -#include "include/ports/SkAudioPlayer.h" +#include "modules/audioplayer/SkAudioPlayer.h" std::unique_ptr SkAudioPlayer::Make(sk_sp src) { return nullptr; diff --git a/modules/skottie/src/layers/AudioLayer.cpp b/modules/skottie/src/layers/AudioLayer.cpp index f6ef7a3851..253f12bede 100644 --- a/modules/skottie/src/layers/AudioLayer.cpp +++ b/modules/skottie/src/layers/AudioLayer.cpp @@ -70,6 +70,9 @@ sk_sp AnimationBuilder::attachAudioLayer(const skjson::ObjectV layer_info->fInPoint, layer_info->fOutPoint, fFrameRate)); + } else { + this->log(Logger::Level::kWarning, nullptr, + "Could not load audio asset '%s'.", name->begin()); } } } diff --git a/samplecode/SampleAudio.cpp b/samplecode/SampleAudio.cpp index acc27ec3f2..efd45d6bba 100644 --- a/samplecode/SampleAudio.cpp +++ b/samplecode/SampleAudio.cpp @@ -7,7 +7,7 @@ #include "include/core/SkCanvas.h" #include "include/core/SkData.h" -#include "include/ports/SkAudioPlayer.h" +#include "modules/audioplayer/SkAudioPlayer.h" #include "samplecode/Sample.h" #include "src/core/SkUtils.h" #include "tools/Resources.h" diff --git a/tools/viewer/SkottieSlide.cpp b/tools/viewer/SkottieSlide.cpp index ceb73125f8..8b29936233 100644 --- a/tools/viewer/SkottieSlide.cpp +++ b/tools/viewer/SkottieSlide.cpp @@ -12,7 +12,7 @@ #include "include/core/SkCanvas.h" #include "include/core/SkFont.h" #include "include/core/SkTime.h" -#include "include/ports/SkAudioPlayer.h" +#include "modules/audioplayer/SkAudioPlayer.h" #include "modules/skottie/include/Skottie.h" #include "modules/skottie/utils/SkottieUtils.h" #include "modules/skresources/include/SkResources.h"