[misc/player] Introduce output ability to announce supported formats

Also introduce default output format and selected device format, should the
user want another format.

As part of this, change enum player_format in player.h to enum media_format in
misc.h so that it is akin to struct media_quality.

Modify json API to support this.
This commit is contained in:
ejurgensen
2024-01-07 23:12:03 +01:00
parent 9f719ca155
commit 62b42ce354
21 changed files with 209 additions and 104 deletions

View File

@@ -272,6 +272,21 @@ timespec_reltoabs(struct timespec relative);
/* ------------------------------- Media quality ---------------------------- */
// Bit flags for the sake of outputs announcing what they support
enum media_format {
MEDIA_FORMAT_UNKNOWN = 0,
MEDIA_FORMAT_PCM = (1 << 0),
MEDIA_FORMAT_WAV = (1 << 1),
MEDIA_FORMAT_MP3 = (1 << 2),
MEDIA_FORMAT_ALAC = (1 << 3),
MEDIA_FORMAT_OPUS = (1 << 4),
};
// For iteration
#define MEDIA_FORMAT_FIRST MEDIA_FORMAT_PCM
#define MEDIA_FORMAT_LAST MEDIA_FORMAT_OPUS
#define MEDIA_FORMAT_NEXT(f) (f << 1)
// Remember to adjust quality_is_equal() if adding elements
struct media_quality {
int sample_rate;
@@ -283,6 +298,12 @@ struct media_quality {
bool
quality_is_equal(struct media_quality *a, struct media_quality *b);
enum media_format
media_format_from_string(const char *s);
const char *
media_format_to_string(enum media_format format);
/* -------------------------- Misc utility functions ------------------------ */