rockbox/firmware/export/pcm_sink.h
Solomon Peachy 9dce0c3258 Work around a false positive compiler warning in pcm_switch_sink()
CC firmware/pcm.c
firmware/pcm.c: In function ‘pcm_switch_sink’:
firmware/pcm.c:311:38: warning: array subscript 1 is above array bounds of ‘struct pcm_sink *[1]’ [-Warray-bounds]
  311 |     struct pcm_sink* old_sink = sinks[cur_sink];
      |                                 ~~~~~^~~~~~~~~~
firmware/pcm.c:79:25: note: while referencing ‘sinks’
   79 | static struct pcm_sink* sinks[PCM_SINK_NUM] = {
      |

PCM_SINK_NUM is 1, and cur_sink is initialized to 0.  It can never be set
above 0.  cur_sink can never be >= PCM_SINK_NUM, ie 0, but for some reason
the compiler thinks otherwise.... sometimes.

This only shows up on native ARM builds with GCC9.5.0

Change-Id: I1aa731a4ee21c46a264c8b70833e3b43e777e8a7
2026-04-17 21:56:38 -04:00

59 lines
1.8 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2025 by Sho Tanimoto
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#pragma once
#include <stddef.h>
#include <stdint.h>
struct pcm_sink_caps {
const unsigned long* samprs;
uint16_t num_samprs;
uint16_t default_freq;
};
struct pcm_sink_ops {
void (*init)(void);
void (*postinit)(void);
void (*set_freq)(uint16_t freq);
void (*lock)(void);
void (*unlock)(void);
void (*play)(const void* addr, size_t size);
void (*stop)(void);
};
struct pcm_sink {
/* characteristics */
const struct pcm_sink_caps caps;
/* operations */
const struct pcm_sink_ops ops;
/* runtime states */
unsigned long pending_freq;
unsigned long configured_freq;
unsigned long pcm_is_ready;
};
enum pcm_sink_ids {
PCM_SINK_BUILTIN = 0,
PCM_SINK_NUM
};
/* defined in each platform pcm source */
extern struct pcm_sink builtin_pcm_sink;