mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-16 16:42:33 -05:00
Cleanup audio.h, related functions
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23651 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0d93a00e37
commit
db82be4390
5 changed files with 56 additions and 50 deletions
16
apps/mpeg.c
16
apps/mpeg.c
|
|
@ -533,9 +533,9 @@ static void recalculate_watermark(int bitrate)
|
|||
}
|
||||
|
||||
#ifdef HAVE_DISK_STORAGE
|
||||
void audio_set_buffer_margin(int seconds)
|
||||
void audio_set_buffer_margin(int setting)
|
||||
{
|
||||
low_watermark_margin = seconds;
|
||||
low_watermark_margin = setting; /* in seconds */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -2040,7 +2040,7 @@ static void mpeg_thread(void)
|
|||
}
|
||||
#endif /* !SIMULATOR */
|
||||
|
||||
struct mp3entry* audio_current_track()
|
||||
struct mp3entry* audio_current_track(void)
|
||||
{
|
||||
#ifdef SIMULATOR
|
||||
struct mp3entry *id3 = &taginfo;
|
||||
|
|
@ -2069,7 +2069,7 @@ struct mp3entry* audio_current_track()
|
|||
#endif /* !SIMULATOR */
|
||||
}
|
||||
|
||||
struct mp3entry* audio_next_track()
|
||||
struct mp3entry* audio_next_track(void)
|
||||
{
|
||||
#ifdef SIMULATOR
|
||||
return &taginfo;
|
||||
|
|
@ -2771,12 +2771,12 @@ void audio_prev(void)
|
|||
#endif /* SIMULATOR */
|
||||
}
|
||||
|
||||
void audio_ff_rewind(long newtime)
|
||||
void audio_ff_rewind(long newpos)
|
||||
{
|
||||
#ifndef SIMULATOR
|
||||
queue_post(&mpeg_queue, MPEG_FF_REWIND, newtime);
|
||||
queue_post(&mpeg_queue, MPEG_FF_REWIND, newpos);
|
||||
#else /* SIMULATOR */
|
||||
(void)newtime;
|
||||
(void)newpos;
|
||||
#endif /* SIMULATOR */
|
||||
}
|
||||
|
||||
|
|
@ -2811,10 +2811,12 @@ int audio_status(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Unused function
|
||||
unsigned int audio_error(void)
|
||||
{
|
||||
return mpeg_errno;
|
||||
}
|
||||
*/
|
||||
|
||||
void audio_error_clear(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1196,7 +1196,7 @@ void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude)
|
|||
bufstart = minibuf;
|
||||
bufend = SKIPBYTES(bufstart, MINIBUF_SIZE);
|
||||
}
|
||||
else if (audio_buffer_state() != AUDIOBUF_STATE_TRASHED)
|
||||
else if (!audio_buffer_state_trashed())
|
||||
{
|
||||
/* Use pcmbuffer */
|
||||
bufstart = (int16_t *)pcmbuffer;
|
||||
|
|
|
|||
|
|
@ -116,6 +116,12 @@ static size_t filebuflen = 0; /* Size of buffer (A/C-) */
|
|||
/* FIXME: make buf_ridx (C/A-) */
|
||||
|
||||
/* Possible arrangements of the buffer */
|
||||
enum audio_buffer_state
|
||||
{
|
||||
AUDIOBUF_STATE_TRASHED = -1, /* trashed; must be reset */
|
||||
AUDIOBUF_STATE_INITIALIZED = 0, /* voice+audio OR audio-only */
|
||||
AUDIOBUF_STATE_VOICED_ONLY = 1, /* voice-only */
|
||||
};
|
||||
static int buffer_state = AUDIOBUF_STATE_TRASHED; /* Buffer state */
|
||||
|
||||
/* These are used to store the current and next (or prev if the current is the last)
|
||||
|
|
@ -224,10 +230,13 @@ static void audio_stop_playback(void);
|
|||
|
||||
/**************************************/
|
||||
|
||||
|
||||
/** Pcmbuf callbacks */
|
||||
|
||||
/* Between the codec and PCM track change, we need to keep updating the
|
||||
"elapsed" value of the previous (to the codec, but current to the
|
||||
user/PCM/WPS) track, so that the progressbar reaches the end.
|
||||
During that transition, the WPS will display othertrack_id3. */
|
||||
* "elapsed" value of the previous (to the codec, but current to the
|
||||
* user/PCM/WPS) track, so that the progressbar reaches the end.
|
||||
* During that transition, the WPS will display othertrack_id3. */
|
||||
void audio_pcmbuf_position_callback(unsigned int time)
|
||||
{
|
||||
time += othertrack_id3->elapsed;
|
||||
|
|
@ -258,9 +267,7 @@ void audio_post_track_change(bool pcmbuf)
|
|||
}
|
||||
}
|
||||
|
||||
/* Scan the pcmbuf queue and return true if a message pulled.
|
||||
* Permissible Context(s): Thread
|
||||
*/
|
||||
/* Scan the pcmbuf queue and return true if a message pulled */
|
||||
static bool pcmbuf_queue_scan(struct queue_event *ev)
|
||||
{
|
||||
if (!queue_empty(&pcmbuf_queue))
|
||||
|
|
@ -276,7 +283,8 @@ static bool pcmbuf_queue_scan(struct queue_event *ev)
|
|||
return false;
|
||||
}
|
||||
|
||||
/* --- Helper functions --- */
|
||||
|
||||
/** Helper functions */
|
||||
|
||||
static struct mp3entry *bufgetid3(int handle_id)
|
||||
{
|
||||
|
|
@ -439,9 +447,9 @@ unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size)
|
|||
return buf;
|
||||
}
|
||||
|
||||
int audio_buffer_state(void)
|
||||
bool audio_buffer_state_trashed(void)
|
||||
{
|
||||
return buffer_state;
|
||||
return buffer_state == AUDIOBUF_STATE_TRASHED;
|
||||
}
|
||||
|
||||
#ifdef HAVE_RECORDING
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ void audio_post_track_change(bool pcmbuf);
|
|||
int get_audio_hid(void);
|
||||
int *get_codec_hid(void);
|
||||
void audio_set_prev_elapsed(unsigned long setting);
|
||||
bool audio_buffer_state_trashed(void);
|
||||
|
||||
/* Define one constant that includes recording related functionality */
|
||||
#if defined(HAVE_RECORDING) && !defined(SIMULATOR)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,31 @@
|
|||
#define AUDIO_GAIN_MIC 1
|
||||
|
||||
|
||||
void audio_init(void);
|
||||
void audio_play(long offset);
|
||||
void audio_stop(void);
|
||||
void audio_pause(void);
|
||||
void audio_resume(void);
|
||||
void audio_next(void);
|
||||
void audio_prev(void);
|
||||
int audio_status(void);
|
||||
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);
|
||||
#ifdef HAVE_DISK_STORAGE
|
||||
void audio_set_buffer_margin(int setting);
|
||||
#endif
|
||||
void audio_error_clear(void);
|
||||
int audio_get_file_pos(void);
|
||||
void audio_beep(int duration);
|
||||
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
/* Required call when audio buffer is required for some other purpose */
|
||||
unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size);
|
||||
/* only implemented in playback.c, but called from firmware */
|
||||
|
||||
#else /* hwcodec only */
|
||||
struct audio_debug
|
||||
{
|
||||
int audiobuflen;
|
||||
|
|
@ -77,40 +102,9 @@ struct audio_debug
|
|||
int lowest_watermark_level;
|
||||
};
|
||||
|
||||
void audio_init(void);
|
||||
void audio_play(long offset);
|
||||
void audio_stop(void);
|
||||
void audio_pause(void);
|
||||
void audio_resume(void);
|
||||
void audio_next(void);
|
||||
void audio_prev(void);
|
||||
int audio_status(void);
|
||||
void audio_ff_rewind(long newtime);
|
||||
void audio_flush_and_reload_tracks(void);
|
||||
struct mp3entry* audio_current_track(void);
|
||||
struct mp3entry* audio_next_track(void);
|
||||
void audio_get_debugdata(struct audio_debug *dbgdata);
|
||||
#ifdef HAVE_DISK_STORAGE
|
||||
void audio_set_buffer_margin(int seconds);
|
||||
#endif
|
||||
unsigned int audio_error(void);
|
||||
void audio_error_clear(void);
|
||||
int audio_get_file_pos(void);
|
||||
void audio_beep(int duration);
|
||||
/* unsigned int audio_error(void); - unused function */
|
||||
void audio_init_playback(void);
|
||||
|
||||
/* Required call when audio buffer is required for some other purpose */
|
||||
unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size);
|
||||
/* only implemented in playback.c, but called from firmware */
|
||||
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
enum audio_buffer_state
|
||||
{
|
||||
AUDIOBUF_STATE_TRASHED = -1, /* trashed; must be reset */
|
||||
AUDIOBUF_STATE_INITIALIZED = 0, /* voice+audio OR audio-only */
|
||||
AUDIOBUF_STATE_VOICED_ONLY = 1, /* voice-only */
|
||||
};
|
||||
int audio_buffer_state(void);
|
||||
#endif
|
||||
|
||||
/* channel modes */
|
||||
|
|
@ -237,7 +231,7 @@ void audio_spdif_set_monitor(int monitor_spdif);
|
|||
|
||||
unsigned long audio_prev_elapsed(void);
|
||||
|
||||
|
||||
#if CONFIG_CODEC != SWCODEC
|
||||
/***********************************************************************/
|
||||
/* audio event handling */
|
||||
|
||||
|
|
@ -279,3 +273,4 @@ void audio_register_event_handler(AUDIO_EVENT_HANDLER handler, unsigned short ma
|
|||
processing */
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue