summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/mpeg.c16
-rw-r--r--apps/pcmbuf.c2
-rw-r--r--apps/playback.c26
-rw-r--r--apps/playback.h1
-rw-r--r--firmware/export/audio.h61
5 files changed, 56 insertions, 50 deletions
diff --git a/apps/mpeg.c b/apps/mpeg.c
index e28260b6a7..079faac13c 100644
--- a/apps/mpeg.c
+++ b/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)
{
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index 7d5d71413b..a75c110694 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -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;
diff --git a/apps/playback.c b/apps/playback.c
index a9d419b13f..f0794faf87 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -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
diff --git a/apps/playback.h b/apps/playback.h
index 403848418f..760408a02f 100644
--- a/apps/playback.h
+++ b/apps/playback.h
@@ -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)
diff --git a/firmware/export/audio.h b/firmware/export/audio.h
index 6236c6d5d1..1ce023a5e5 100644
--- a/firmware/export/audio.h
+++ b/firmware/export/audio.h
@@ -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