A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <string.h>
22#include <stdbool.h>
23#include "config.h"
24#include "status.h"
25#include "audio.h"
26#if CONFIG_TUNER
27#include "radio.h"
28#endif
29
30static enum playmode ff_mode = 0;
31
32void status_set_ffmode(enum playmode mode)
33{
34 ff_mode = mode; /* Either STATUS_FASTFORWARD or STATUS_FASTBACKWARD */
35}
36
37enum playmode status_get_ffmode(void)
38{
39 /* only use this function for STATUS_FASTFORWARD or STATUS_FASTBACKWARD */
40 /* use audio_status() for other modes */
41 return ff_mode;
42}
43
44int current_playmode(void)
45{
46 int audio_stat = audio_status();
47
48 /* ff_mode can be either STATUS_FASTFORWARD or STATUS_FASTBACKWARD
49 and that supercedes the other modes */
50 if(ff_mode)
51 return ff_mode;
52
53 if(audio_stat & AUDIO_STATUS_PLAY)
54 {
55 if(audio_stat & AUDIO_STATUS_PAUSE)
56 return STATUS_PAUSE;
57 else
58 return STATUS_PLAY;
59 }
60
61#ifdef HAVE_RECORDING
62 if(audio_stat & AUDIO_STATUS_RECORD)
63 {
64 if(audio_stat & AUDIO_STATUS_PAUSE)
65 return STATUS_RECORD_PAUSE;
66 else
67 return STATUS_RECORD;
68 }
69#endif
70
71#if CONFIG_TUNER
72 audio_stat = get_radio_status();
73 if(audio_stat & FMRADIO_PLAYING)
74 return STATUS_RADIO;
75
76 if(audio_stat & FMRADIO_PAUSED)
77 return STATUS_RADIO_PAUSE;
78#endif
79
80 return STATUS_STOP;
81}