2005-04-04 12:06:29 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 by Linus Nielsen Feltzing
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* 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.
|
2005-04-04 12:06:29 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2020-07-17 04:01:32 +00:00
|
|
|
#ifndef __AUDIO_H
|
|
|
|
#define __AUDIO_H
|
2005-04-04 12:06:29 +00:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
2010-05-06 21:04:40 +00:00
|
|
|
#include <string.h> /* size_t */
|
2008-12-09 20:48:04 +00:00
|
|
|
#include "config.h"
|
2006-11-06 18:07:30 +00:00
|
|
|
/* These must always be included with audio.h for this to compile under
|
|
|
|
cetain conditions. Do it here or else spread the complication around to
|
|
|
|
many files. */
|
|
|
|
#include "pcm_sampr.h"
|
2007-10-06 22:27:27 +00:00
|
|
|
#include "pcm.h"
|
2006-11-06 18:07:30 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
#include "enc_base.h"
|
|
|
|
#endif /* HAVE_RECORDING */
|
|
|
|
|
2006-12-10 14:21:31 +00:00
|
|
|
#define AUDIO_STATUS_PLAY 0x0001
|
|
|
|
#define AUDIO_STATUS_PAUSE 0x0002
|
|
|
|
#define AUDIO_STATUS_RECORD 0x0004
|
|
|
|
#define AUDIO_STATUS_PRERECORD 0x0008
|
|
|
|
#define AUDIO_STATUS_ERROR 0x0010
|
|
|
|
#define AUDIO_STATUS_WARNING 0x0020
|
2005-04-04 12:06:29 +00:00
|
|
|
|
2006-12-10 14:21:31 +00:00
|
|
|
#define AUDIOERR_DISK_FULL 1
|
2005-04-04 12:06:29 +00:00
|
|
|
|
2006-12-10 14:21:31 +00:00
|
|
|
#define AUDIO_GAIN_LINEIN 0
|
|
|
|
#define AUDIO_GAIN_MIC 1
|
2005-11-12 04:00:56 +00:00
|
|
|
|
|
|
|
|
2010-03-03 23:20:32 +00:00
|
|
|
void audio_init(void) INIT_ATTR;
|
2013-07-14 11:59:39 +00:00
|
|
|
void audio_play(unsigned long elapsed, unsigned long offset);
|
2009-11-16 20:09:46 +00:00
|
|
|
void audio_stop(void);
|
2011-08-14 15:13:00 +00:00
|
|
|
/* Stops audio from serving playback and frees resources*/
|
|
|
|
void audio_hard_stop(void);
|
2009-11-16 20:09:46 +00:00
|
|
|
void audio_pause(void);
|
|
|
|
void audio_resume(void);
|
|
|
|
void audio_next(void);
|
|
|
|
void audio_prev(void);
|
|
|
|
int audio_status(void);
|
2011-11-17 17:55:02 +00:00
|
|
|
/* size of the audio buffer */
|
|
|
|
size_t audio_buffer_size(void);
|
|
|
|
/* size of the buffer available for allocating memory from the audio buffer using core_*()
|
|
|
|
* returns core_available() if audio buffer is not allocated yet */
|
2011-08-30 14:01:33 +00:00
|
|
|
size_t audio_buffer_available(void);
|
2009-11-16 20:09:46 +00:00
|
|
|
void audio_ff_rewind(long newpos);
|
|
|
|
void audio_flush_and_reload_tracks(void);
|
|
|
|
struct mp3entry* audio_current_track(void);
|
|
|
|
struct mp3entry* audio_next_track(void);
|
2011-02-10 10:26:07 +00:00
|
|
|
bool audio_peek_track(struct mp3entry* id3, int offset);
|
2009-11-16 20:09:46 +00:00
|
|
|
#ifdef HAVE_DISK_STORAGE
|
Auto-Ranging Time Formatting For Menus (hh:mm:ss:mss)
Unifies time formatting in settings_list.c allows time format to
display as HH:MM:SS.MSS or any consecutive combination thereof
(hh:mm:ss, mm:ss, mm:ss.mss, ss.mss, hh, mm, ss ,mss)
works in INT and TABLE settings with the addition of flag 'F_TIME_SETTING'
Time is auto-ranged dependent on value
Adds talk_time_intervals to allow time values to be spoken similar to
display format: x Hours, x Minutes, x Seconds, x Milliseconds
Table lookups merged or removed from recording, clip meter and lcd timeout
-String_Choice replaced with TABLE_SETTING or INT_SETTING for these
functions as well, cleaned-up cfg_vals that get saved to cfgfile
RTL Languages ARE supported
Negative values ARE supported
Backlight on/off are now Always and Never to share formatter with LCD
Timeout
Added flag to allow ranged units to be locked to a minimum index
Added flag to allow leading zero to be supressed from the largest unit
merged talk_time_unit() and talk_time_intervals()
optimized time_split()
optimized format_time_auto()
Backlight time-out list same as original
Change-Id: I59027c62d3f2956bd16fdcc1a48b2ac32c084abd
2018-12-18 04:27:55 +00:00
|
|
|
void audio_set_buffer_margin(int seconds);
|
2009-11-16 20:09:46 +00:00
|
|
|
#endif
|
|
|
|
void audio_error_clear(void);
|
|
|
|
int audio_get_file_pos(void);
|
|
|
|
void audio_beep(int duration);
|
|
|
|
|
2009-11-16 22:02:06 +00:00
|
|
|
void audio_next_dir(void);
|
|
|
|
void audio_prev_dir(void);
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
/* channel modes */
|
|
|
|
enum rec_channel_modes
|
|
|
|
{
|
|
|
|
__CHN_MODE_START_INDEX = -1,
|
|
|
|
|
|
|
|
CHN_MODE_STEREO,
|
|
|
|
CHN_MODE_MONO,
|
|
|
|
|
|
|
|
CHN_NUM_MODES
|
|
|
|
};
|
|
|
|
|
|
|
|
/* channel mode capability bits */
|
|
|
|
#define CHN_CAP_STEREO (1 << CHN_MODE_STEREO)
|
|
|
|
#define CHN_CAP_MONO (1 << CHN_MODE_MONO)
|
|
|
|
#define CHN_CAP_ALL (CHN_CAP_STEREO | CHN_CAP_MONO)
|
2006-08-28 22:38:41 +00:00
|
|
|
|
2007-08-02 18:45:38 +00:00
|
|
|
/* the enums below must match prestr[] in recording.c */
|
2006-11-06 18:07:30 +00:00
|
|
|
enum audio_sources
|
2006-08-28 22:38:41 +00:00
|
|
|
{
|
2007-05-20 20:26:36 +00:00
|
|
|
AUDIO_SRC_PLAYBACK = -1, /* Virtual source */
|
|
|
|
HAVE_MIC_IN_(AUDIO_SRC_MIC,)
|
|
|
|
HAVE_LINE_IN_(AUDIO_SRC_LINEIN,)
|
|
|
|
HAVE_SPDIF_IN_(AUDIO_SRC_SPDIF,)
|
|
|
|
HAVE_FMRADIO_IN_(AUDIO_SRC_FMRADIO,)
|
|
|
|
AUDIO_NUM_SOURCES,
|
|
|
|
AUDIO_SRC_MAX = AUDIO_NUM_SOURCES-1,
|
|
|
|
AUDIO_SRC_DEFAULT = AUDIO_SRC_PLAYBACK
|
|
|
|
};
|
|
|
|
|
2007-06-05 07:03:30 +00:00
|
|
|
extern int audio_channels;
|
|
|
|
extern int audio_output_source;
|
|
|
|
|
2007-05-20 20:26:36 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
/* Recordable source implies it has the input as well */
|
|
|
|
|
|
|
|
/* For now there's no restrictions on any targets with which inputs
|
|
|
|
are recordable so define them as equivalent - if they do differ,
|
|
|
|
special handling is needed right now. */
|
|
|
|
enum rec_sources
|
|
|
|
{
|
|
|
|
__REC_SRC_FIRST = -1,
|
|
|
|
HAVE_MIC_REC_(REC_SRC_MIC,)
|
|
|
|
HAVE_LINE_REC_(REC_SRC_LINEIN,)
|
|
|
|
HAVE_SPDIF_REC_(REC_SRC_SPDIF,)
|
|
|
|
HAVE_FMRADIO_REC_(REC_SRC_FMRADIO,)
|
|
|
|
REC_NUM_SOURCES
|
2006-08-28 22:38:41 +00:00
|
|
|
};
|
2007-05-20 20:26:36 +00:00
|
|
|
#endif /* HAVE_RECORDING */
|
2006-08-28 22:38:41 +00:00
|
|
|
|
2007-05-20 20:26:36 +00:00
|
|
|
/* selects a source to monitor for recording or playback */
|
2006-11-23 19:21:15 +00:00
|
|
|
#define SRCF_PLAYBACK 0x0000 /* default */
|
|
|
|
#define SRCF_RECORDING 0x1000
|
2007-02-18 08:46:12 +00:00
|
|
|
#if CONFIG_TUNER
|
2006-11-23 19:21:15 +00:00
|
|
|
/* for AUDIO_SRC_FMRADIO */
|
|
|
|
#define SRCF_FMRADIO_PLAYING 0x0000 /* default */
|
|
|
|
#define SRCF_FMRADIO_PAUSED 0x2000
|
|
|
|
#endif
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
/* parameters for audio_set_recording_options */
|
|
|
|
struct audio_recording_options
|
2006-08-28 22:38:41 +00:00
|
|
|
{
|
2006-11-06 18:07:30 +00:00
|
|
|
int rec_source;
|
|
|
|
int rec_frequency;
|
|
|
|
int rec_channels;
|
|
|
|
int rec_prerecord_time;
|
2008-10-08 22:18:16 +00:00
|
|
|
int rec_mono_mode;
|
2006-11-06 18:07:30 +00:00
|
|
|
int rec_source_flags; /* for rec_set_source */
|
|
|
|
struct encoder_config enc_config;
|
2006-08-28 22:38:41 +00:00
|
|
|
};
|
2006-11-06 18:07:30 +00:00
|
|
|
|
|
|
|
/* audio recording functions */
|
2011-08-14 15:37:05 +00:00
|
|
|
void audio_init_recording(void);
|
2006-11-06 18:07:30 +00:00
|
|
|
void audio_close_recording(void);
|
|
|
|
void audio_record(const char *filename);
|
|
|
|
void audio_stop_recording(void);
|
|
|
|
void audio_pause_recording(void);
|
|
|
|
void audio_resume_recording(void);
|
|
|
|
void audio_new_file(const char *filename);
|
|
|
|
void audio_set_recording_options(struct audio_recording_options *options);
|
2005-11-12 04:00:56 +00:00
|
|
|
void audio_set_recording_gain(int left, int right, int type);
|
|
|
|
unsigned long audio_recorded_time(void);
|
|
|
|
unsigned long audio_num_recorded_bytes(void);
|
2006-11-06 18:07:30 +00:00
|
|
|
|
2013-06-22 20:41:16 +00:00
|
|
|
unsigned long audio_prerecorded_time(void);
|
2007-06-08 23:42:04 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif /* HAVE_RECORDING */
|
2006-08-28 22:38:41 +00:00
|
|
|
|
2007-06-08 23:42:04 +00:00
|
|
|
#if INPUT_SRC_CAPS != 0
|
|
|
|
/* audio.c */
|
|
|
|
void audio_set_input_source(int source, unsigned flags);
|
|
|
|
/* audio_input_mux: target-specific implementation used by audio_set_source
|
|
|
|
to set hardware inputs and audio paths */
|
|
|
|
void audio_input_mux(int source, unsigned flags);
|
|
|
|
void audio_set_output_source(int source);
|
|
|
|
#endif /* INPUT_SRC_CAPS */
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#ifdef HAVE_SPDIF_IN
|
|
|
|
/* returns index into rec_master_sampr_list */
|
|
|
|
int audio_get_spdif_sample_rate(void);
|
|
|
|
/* > 0: monitor EBUin, 0: Monitor IISrecv, <0: reset only */
|
|
|
|
void audio_spdif_set_monitor(int monitor_spdif);
|
|
|
|
#endif /* HAVE_SPDIF_IN */
|
2005-11-12 04:00:56 +00:00
|
|
|
|
2017-01-14 00:40:12 +00:00
|
|
|
#ifdef HAVE_SPEAKER
|
|
|
|
/* enable/disable the speaker: 0=off, 1=on, 2=on if jack unpluged, off otherwise
|
|
|
|
* NOTE this is a one time thing, this function doesn't implement the logic to
|
|
|
|
* check for jack events, it merely changes the speaker state to the expected
|
|
|
|
* state based on the requested mode.
|
|
|
|
*/
|
|
|
|
void audio_enable_speaker(int mode);
|
|
|
|
#endif
|
|
|
|
|
2005-08-21 23:01:12 +00:00
|
|
|
/***********************************************************************/
|
|
|
|
/* audio event handling */
|
2013-07-12 16:06:38 +00:00
|
|
|
enum track_event_flags
|
|
|
|
{
|
|
|
|
TEF_NONE = 0x0, /* no flags are set */
|
|
|
|
TEF_CURRENT = 0x1, /* event is for the current track */
|
|
|
|
TEF_AUTO_SKIP = 0x2, /* event is sent in context of auto skip */
|
|
|
|
TEF_REWIND = 0x4, /* interpret as rewind, id3->elapsed is the
|
|
|
|
position before the seek back to 0 */
|
|
|
|
};
|
2005-08-21 23:01:12 +00:00
|
|
|
|
2013-07-12 16:06:38 +00:00
|
|
|
struct track_event
|
|
|
|
{
|
|
|
|
unsigned int flags; /* combo of enum track_event_flags values */
|
|
|
|
struct mp3entry *id3; /* pointer to mp3entry describing track */
|
|
|
|
};
|
|
|
|
|
2020-07-17 04:01:32 +00:00
|
|
|
#endif /* __AUDIO_H */
|