diff options
-rw-r--r-- | apps/mpeg.c | 16 | ||||
-rw-r--r-- | apps/pcmbuf.c | 2 | ||||
-rw-r--r-- | apps/playback.c | 26 | ||||
-rw-r--r-- | apps/playback.h | 1 | ||||
-rw-r--r-- | firmware/export/audio.h | 61 |
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) | |||
533 | } | 533 | } |
534 | 534 | ||
535 | #ifdef HAVE_DISK_STORAGE | 535 | #ifdef HAVE_DISK_STORAGE |
536 | void audio_set_buffer_margin(int seconds) | 536 | void audio_set_buffer_margin(int setting) |
537 | { | 537 | { |
538 | low_watermark_margin = seconds; | 538 | low_watermark_margin = setting; /* in seconds */ |
539 | } | 539 | } |
540 | #endif | 540 | #endif |
541 | 541 | ||
@@ -2040,7 +2040,7 @@ static void mpeg_thread(void) | |||
2040 | } | 2040 | } |
2041 | #endif /* !SIMULATOR */ | 2041 | #endif /* !SIMULATOR */ |
2042 | 2042 | ||
2043 | struct mp3entry* audio_current_track() | 2043 | struct mp3entry* audio_current_track(void) |
2044 | { | 2044 | { |
2045 | #ifdef SIMULATOR | 2045 | #ifdef SIMULATOR |
2046 | struct mp3entry *id3 = &taginfo; | 2046 | struct mp3entry *id3 = &taginfo; |
@@ -2069,7 +2069,7 @@ struct mp3entry* audio_current_track() | |||
2069 | #endif /* !SIMULATOR */ | 2069 | #endif /* !SIMULATOR */ |
2070 | } | 2070 | } |
2071 | 2071 | ||
2072 | struct mp3entry* audio_next_track() | 2072 | struct mp3entry* audio_next_track(void) |
2073 | { | 2073 | { |
2074 | #ifdef SIMULATOR | 2074 | #ifdef SIMULATOR |
2075 | return &taginfo; | 2075 | return &taginfo; |
@@ -2771,12 +2771,12 @@ void audio_prev(void) | |||
2771 | #endif /* SIMULATOR */ | 2771 | #endif /* SIMULATOR */ |
2772 | } | 2772 | } |
2773 | 2773 | ||
2774 | void audio_ff_rewind(long newtime) | 2774 | void audio_ff_rewind(long newpos) |
2775 | { | 2775 | { |
2776 | #ifndef SIMULATOR | 2776 | #ifndef SIMULATOR |
2777 | queue_post(&mpeg_queue, MPEG_FF_REWIND, newtime); | 2777 | queue_post(&mpeg_queue, MPEG_FF_REWIND, newpos); |
2778 | #else /* SIMULATOR */ | 2778 | #else /* SIMULATOR */ |
2779 | (void)newtime; | 2779 | (void)newpos; |
2780 | #endif /* SIMULATOR */ | 2780 | #endif /* SIMULATOR */ |
2781 | } | 2781 | } |
2782 | 2782 | ||
@@ -2811,10 +2811,12 @@ int audio_status(void) | |||
2811 | return ret; | 2811 | return ret; |
2812 | } | 2812 | } |
2813 | 2813 | ||
2814 | /* Unused function | ||
2814 | unsigned int audio_error(void) | 2815 | unsigned int audio_error(void) |
2815 | { | 2816 | { |
2816 | return mpeg_errno; | 2817 | return mpeg_errno; |
2817 | } | 2818 | } |
2819 | */ | ||
2818 | 2820 | ||
2819 | void audio_error_clear(void) | 2821 | void audio_error_clear(void) |
2820 | { | 2822 | { |
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) | |||
1196 | bufstart = minibuf; | 1196 | bufstart = minibuf; |
1197 | bufend = SKIPBYTES(bufstart, MINIBUF_SIZE); | 1197 | bufend = SKIPBYTES(bufstart, MINIBUF_SIZE); |
1198 | } | 1198 | } |
1199 | else if (audio_buffer_state() != AUDIOBUF_STATE_TRASHED) | 1199 | else if (!audio_buffer_state_trashed()) |
1200 | { | 1200 | { |
1201 | /* Use pcmbuffer */ | 1201 | /* Use pcmbuffer */ |
1202 | bufstart = (int16_t *)pcmbuffer; | 1202 | 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-) */ | |||
116 | /* FIXME: make buf_ridx (C/A-) */ | 116 | /* FIXME: make buf_ridx (C/A-) */ |
117 | 117 | ||
118 | /* Possible arrangements of the buffer */ | 118 | /* Possible arrangements of the buffer */ |
119 | enum audio_buffer_state | ||
120 | { | ||
121 | AUDIOBUF_STATE_TRASHED = -1, /* trashed; must be reset */ | ||
122 | AUDIOBUF_STATE_INITIALIZED = 0, /* voice+audio OR audio-only */ | ||
123 | AUDIOBUF_STATE_VOICED_ONLY = 1, /* voice-only */ | ||
124 | }; | ||
119 | static int buffer_state = AUDIOBUF_STATE_TRASHED; /* Buffer state */ | 125 | static int buffer_state = AUDIOBUF_STATE_TRASHED; /* Buffer state */ |
120 | 126 | ||
121 | /* These are used to store the current and next (or prev if the current is the last) | 127 | /* 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); | |||
224 | 230 | ||
225 | /**************************************/ | 231 | /**************************************/ |
226 | 232 | ||
233 | |||
234 | /** Pcmbuf callbacks */ | ||
235 | |||
227 | /* Between the codec and PCM track change, we need to keep updating the | 236 | /* Between the codec and PCM track change, we need to keep updating the |
228 | "elapsed" value of the previous (to the codec, but current to the | 237 | * "elapsed" value of the previous (to the codec, but current to the |
229 | user/PCM/WPS) track, so that the progressbar reaches the end. | 238 | * user/PCM/WPS) track, so that the progressbar reaches the end. |
230 | During that transition, the WPS will display othertrack_id3. */ | 239 | * During that transition, the WPS will display othertrack_id3. */ |
231 | void audio_pcmbuf_position_callback(unsigned int time) | 240 | void audio_pcmbuf_position_callback(unsigned int time) |
232 | { | 241 | { |
233 | time += othertrack_id3->elapsed; | 242 | time += othertrack_id3->elapsed; |
@@ -258,9 +267,7 @@ void audio_post_track_change(bool pcmbuf) | |||
258 | } | 267 | } |
259 | } | 268 | } |
260 | 269 | ||
261 | /* Scan the pcmbuf queue and return true if a message pulled. | 270 | /* Scan the pcmbuf queue and return true if a message pulled */ |
262 | * Permissible Context(s): Thread | ||
263 | */ | ||
264 | static bool pcmbuf_queue_scan(struct queue_event *ev) | 271 | static bool pcmbuf_queue_scan(struct queue_event *ev) |
265 | { | 272 | { |
266 | if (!queue_empty(&pcmbuf_queue)) | 273 | if (!queue_empty(&pcmbuf_queue)) |
@@ -276,7 +283,8 @@ static bool pcmbuf_queue_scan(struct queue_event *ev) | |||
276 | return false; | 283 | return false; |
277 | } | 284 | } |
278 | 285 | ||
279 | /* --- Helper functions --- */ | 286 | |
287 | /** Helper functions */ | ||
280 | 288 | ||
281 | static struct mp3entry *bufgetid3(int handle_id) | 289 | static struct mp3entry *bufgetid3(int handle_id) |
282 | { | 290 | { |
@@ -439,9 +447,9 @@ unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size) | |||
439 | return buf; | 447 | return buf; |
440 | } | 448 | } |
441 | 449 | ||
442 | int audio_buffer_state(void) | 450 | bool audio_buffer_state_trashed(void) |
443 | { | 451 | { |
444 | return buffer_state; | 452 | return buffer_state == AUDIOBUF_STATE_TRASHED; |
445 | } | 453 | } |
446 | 454 | ||
447 | #ifdef HAVE_RECORDING | 455 | #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); | |||
76 | int get_audio_hid(void); | 76 | int get_audio_hid(void); |
77 | int *get_codec_hid(void); | 77 | int *get_codec_hid(void); |
78 | void audio_set_prev_elapsed(unsigned long setting); | 78 | void audio_set_prev_elapsed(unsigned long setting); |
79 | bool audio_buffer_state_trashed(void); | ||
79 | 80 | ||
80 | /* Define one constant that includes recording related functionality */ | 81 | /* Define one constant that includes recording related functionality */ |
81 | #if defined(HAVE_RECORDING) && !defined(SIMULATOR) | 82 | #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 @@ | |||
53 | #define AUDIO_GAIN_MIC 1 | 53 | #define AUDIO_GAIN_MIC 1 |
54 | 54 | ||
55 | 55 | ||
56 | void audio_init(void); | ||
57 | void audio_play(long offset); | ||
58 | void audio_stop(void); | ||
59 | void audio_pause(void); | ||
60 | void audio_resume(void); | ||
61 | void audio_next(void); | ||
62 | void audio_prev(void); | ||
63 | int audio_status(void); | ||
64 | void audio_ff_rewind(long newpos); | ||
65 | void audio_flush_and_reload_tracks(void); | ||
66 | struct mp3entry* audio_current_track(void); | ||
67 | struct mp3entry* audio_next_track(void); | ||
68 | #ifdef HAVE_DISK_STORAGE | ||
69 | void audio_set_buffer_margin(int setting); | ||
70 | #endif | ||
71 | void audio_error_clear(void); | ||
72 | int audio_get_file_pos(void); | ||
73 | void audio_beep(int duration); | ||
74 | |||
75 | #if CONFIG_CODEC == SWCODEC | ||
76 | /* Required call when audio buffer is required for some other purpose */ | ||
77 | unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size); | ||
78 | /* only implemented in playback.c, but called from firmware */ | ||
79 | |||
80 | #else /* hwcodec only */ | ||
56 | struct audio_debug | 81 | struct audio_debug |
57 | { | 82 | { |
58 | int audiobuflen; | 83 | int audiobuflen; |
@@ -77,40 +102,9 @@ struct audio_debug | |||
77 | int lowest_watermark_level; | 102 | int lowest_watermark_level; |
78 | }; | 103 | }; |
79 | 104 | ||
80 | void audio_init(void); | ||
81 | void audio_play(long offset); | ||
82 | void audio_stop(void); | ||
83 | void audio_pause(void); | ||
84 | void audio_resume(void); | ||
85 | void audio_next(void); | ||
86 | void audio_prev(void); | ||
87 | int audio_status(void); | ||
88 | void audio_ff_rewind(long newtime); | ||
89 | void audio_flush_and_reload_tracks(void); | ||
90 | struct mp3entry* audio_current_track(void); | ||
91 | struct mp3entry* audio_next_track(void); | ||
92 | void audio_get_debugdata(struct audio_debug *dbgdata); | 105 | void audio_get_debugdata(struct audio_debug *dbgdata); |
93 | #ifdef HAVE_DISK_STORAGE | 106 | /* unsigned int audio_error(void); - unused function */ |
94 | void audio_set_buffer_margin(int seconds); | ||
95 | #endif | ||
96 | unsigned int audio_error(void); | ||
97 | void audio_error_clear(void); | ||
98 | int audio_get_file_pos(void); | ||
99 | void audio_beep(int duration); | ||
100 | void audio_init_playback(void); | 107 | void audio_init_playback(void); |
101 | |||
102 | /* Required call when audio buffer is required for some other purpose */ | ||
103 | unsigned char *audio_get_buffer(bool talk_buf, size_t *buffer_size); | ||
104 | /* only implemented in playback.c, but called from firmware */ | ||
105 | |||
106 | #if CONFIG_CODEC == SWCODEC | ||
107 | enum audio_buffer_state | ||
108 | { | ||
109 | AUDIOBUF_STATE_TRASHED = -1, /* trashed; must be reset */ | ||
110 | AUDIOBUF_STATE_INITIALIZED = 0, /* voice+audio OR audio-only */ | ||
111 | AUDIOBUF_STATE_VOICED_ONLY = 1, /* voice-only */ | ||
112 | }; | ||
113 | int audio_buffer_state(void); | ||
114 | #endif | 108 | #endif |
115 | 109 | ||
116 | /* channel modes */ | 110 | /* channel modes */ |
@@ -237,7 +231,7 @@ void audio_spdif_set_monitor(int monitor_spdif); | |||
237 | 231 | ||
238 | unsigned long audio_prev_elapsed(void); | 232 | unsigned long audio_prev_elapsed(void); |
239 | 233 | ||
240 | 234 | #if CONFIG_CODEC != SWCODEC | |
241 | /***********************************************************************/ | 235 | /***********************************************************************/ |
242 | /* audio event handling */ | 236 | /* audio event handling */ |
243 | 237 | ||
@@ -279,3 +273,4 @@ void audio_register_event_handler(AUDIO_EVENT_HANDLER handler, unsigned short ma | |||
279 | processing */ | 273 | processing */ |
280 | 274 | ||
281 | #endif | 275 | #endif |
276 | #endif | ||