Files
aes67-ESP32-P4/components/spotify/CMakeLists.txt
T
bsncubed c240ac9a3c Step 7.5b2: Spotify Connect zeroconf and login work (PCM counted only)
- Zeroconf on our httpd (GET/POST /spotify_info, form body URL-decoded)
  and _spotify-connect._tcp via our mDNS (VERSION, CPath, Stack TXT).
- Session task: waits for the app's login blob, connects with the
  user's client ID/secret and the configured bitrate (96/160/320 ->
  OGG_VORBIS_*), SpircHandler, events logged; cspot exceptions caught.
  Starts when source.mode is spotify/auto and credentials are set.
- bell::bellGlobalLogger was NULL: every CSPOT_LOG crashed the board
  right after addUser (Load access fault in Session.cpp:67 /
  LoginBlob.cpp:58). cspot/bell logs now go to esp_log (UART + syslog);
  signed CDN URL tokens are cut from the log.
- esp_audio_codec's own Vorbis decoder clashed with bell's Tremor
  symbols: CONFIG_AUDIO_DECODER_VORBIS_SUPPORT / SIMPLE_DEC_OGG off.
- status.spotify_state from the session (waiting / connecting /
  connected / login failed / error / disabled / no client credentials).
- Verified from a Mac: device appears, "connected as <user>", access
  token fetched with the user's client credentials, track info, audio
  key, CDN URL (the step broken upstream), PCM decoded. Without
  backpressure a track decodes in ~26 s (b3 feeds the ring).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 18:26:36 +10:00

50 lines
2.5 KiB
CMake

# Spotify Connect via cspot (philippe44 fork, git submodule external/cspot). GPL-3.0.
# Project component (not part of the reusable aes67_* core).
idf_component_register(SRCS "spotify.cpp"
INCLUDE_DIRS "include"
PRIV_REQUIRES aes67_web espressif__mdns mbedtls json pthread lwip esp_timer esp_http_server)
# bell: only what cspot needs (Tremor Vorbis inside; no codec wrapper, sinks, MQTT, web server).
set(BELL_DISABLE_CODECS ON CACHE BOOL "" FORCE)
set(BELL_DISABLE_SINKS ON CACHE BOOL "" FORCE)
set(BELL_DISABLE_MQTT ON CACHE BOOL "" FORCE)
set(BELL_DISABLE_WEBSERVER ON CACHE BOOL "" FORCE)
set(BELL_DISABLE_FMT ON CACHE BOOL "" FORCE)
set(BELL_DISABLE_REGEX ON CACHE BOOL "" FORCE)
set(BELL_ONLY_CJSON ON CACHE BOOL "" FORCE)
set(BELL_EXTERNAL_CJSON idf::json CACHE STRING "" FORCE)
option(BUILD_TESTING OFF)
# Our fixes to the pinned cspot / bell sources (newer GCC, protobuf, CMake), kept as patch files:
# patches/cspot/*.patch apply in external/cspot, patches/bell/*.patch in external/cspot/cspot/bell.
# Each is applied once (skipped when it already reverse-applies).
function(spotify_apply_patches dir repo)
file(GLOB patches "${CMAKE_CURRENT_LIST_DIR}/patches/${dir}/*.patch")
list(SORT patches)
foreach(p ${patches})
execute_process(COMMAND git apply --reverse --check "${p}" WORKING_DIRECTORY "${repo}"
RESULT_VARIABLE applied OUTPUT_QUIET ERROR_QUIET)
if(NOT applied EQUAL 0)
execute_process(COMMAND git apply "${p}" WORKING_DIRECTORY "${repo}" RESULT_VARIABLE rc)
if(NOT rc EQUAL 0)
message(FATAL_ERROR "spotify: patch does not apply: ${p}")
endif()
message(STATUS "spotify: applied ${p}")
endif()
endforeach()
endfunction()
spotify_apply_patches(cspot "${PROJECT_DIR}/external/cspot")
spotify_apply_patches(bell "${PROJECT_DIR}/external/cspot/cspot/bell")
# cspot/bell declare cmake_minimum_required(2.8.12); CMake 4 rejects < 3.5 unless told otherwise.
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
add_subdirectory(${PROJECT_DIR}/external/cspot/cspot ${CMAKE_CURRENT_BINARY_DIR}/cspot)
# bell adds Xtensa (ESP32) assembly for a DSP biquad; the P4 is RISC-V and cspot does not use it.
get_target_property(BELL_SRCS bell SOURCES)
list(FILTER BELL_SRCS EXCLUDE REGEX "\\.S$")
set_target_properties(bell PROPERTIES SOURCES "${BELL_SRCS}")
target_link_libraries(${COMPONENT_LIB} PRIVATE cspot)
target_compile_options(${COMPONENT_LIB} PRIVATE -std=gnu++20)