summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-04-04 12:06:29 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-04-04 12:06:29 +0000
commit8a237a829e0f63b61536f315209a6d0ea1477e31 (patch)
tree1fe54329fe776aa7bc982a37203cb61c13244a48
parentec4e9b8d600c53add3c8bf6eb7fe1975dba141a7 (diff)
downloadrockbox-8a237a829e0f63b61536f315209a6d0ea1477e31.tar.gz
rockbox-8a237a829e0f63b61536f315209a6d0ea1477e31.zip
More audio code restructuring, mostly renaming functions so far
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6246 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/bookmark.c8
-rw-r--r--apps/debug_menu.c12
-rw-r--r--apps/main.c8
-rw-r--r--apps/onplay.c10
-rw-r--r--apps/playlist.c24
-rw-r--r--apps/playlist_viewer.c14
-rw-r--r--apps/plugin.c28
-rw-r--r--apps/plugin.h27
-rw-r--r--apps/plugins/alpine_cdc.c58
-rw-r--r--apps/plugins/favorites.c2
-rw-r--r--apps/plugins/splitedit.c44
-rw-r--r--apps/recorder/recording.c55
-rw-r--r--apps/screens.c16
-rw-r--r--apps/settings.c4
-rw-r--r--apps/settings_menu.c5
-rw-r--r--apps/status.c12
-rw-r--r--apps/talk.c12
-rw-r--r--apps/tree.c12
-rw-r--r--apps/wps-display.c4
-rw-r--r--apps/wps.c62
-rw-r--r--firmware/export/audio.h81
-rw-r--r--firmware/export/mpeg.h56
-rw-r--r--firmware/mpeg.c71
-rw-r--r--firmware/powermgmt.c24
-rw-r--r--firmware/rolo.c4
-rw-r--r--uisimulator/common/stubs.c2
26 files changed, 342 insertions, 313 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index 04de581eb5..4af4b967b9 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -26,7 +26,7 @@
#include "lcd.h"
#include "button.h"
#include "usb.h"
-#include "mpeg.h"
+#include "audio.h"
#include "wps.h"
#include "settings.h"
#include "bookmark.h"
@@ -227,7 +227,7 @@ bool bookmark_autobookmark(void)
if (!system_check())
return false;
- mpeg_pause(); /* first pause playback */
+ audio_pause(); /* first pause playback */
switch (global_settings.autocreatebookmark)
{
case BOOKMARK_YES:
@@ -404,7 +404,7 @@ static char* create_bookmark()
char *file;
/* grab the currently playing track */
- struct mp3entry *id3 = mpeg_current_track();
+ struct mp3entry *id3 = audio_current_track();
if(!id3)
return NULL;
@@ -1144,7 +1144,7 @@ static bool generate_bookmark_file_name(const char *in)
static bool system_check(void)
{
int resume_index = 0;
- struct mp3entry *id3 = mpeg_current_track();
+ struct mp3entry *id3 = audio_current_track();
if (!id3)
{
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index f8d3f36f02..d8ebe9bfb1 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -38,7 +38,7 @@
#include "system.h"
#include "font.h"
#include "disk.h"
-#include "mpeg.h"
+#include "audio.h"
#include "mp3_playback.h"
#include "settings.h"
#include "ata.h"
@@ -335,11 +335,11 @@ bool dbg_os(void)
#endif
#ifdef HAVE_LCD_BITMAP
-bool dbg_mpeg_thread(void)
+bool dbg_audio_thread(void)
{
char buf[32];
int button;
- struct mpeg_debug d;
+ struct audio_debug d;
lcd_setmargins(0, 0);
@@ -352,7 +352,7 @@ bool dbg_mpeg_thread(void)
return false;
}
- mpeg_get_debugdata(&d);
+ audio_get_debugdata(&d);
lcd_clear_display();
@@ -1862,7 +1862,7 @@ static bool dbg_disk_info(void)
case SETTINGS_OK:
if (page == 3) {
- mpeg_stop(); /* stop playback, to avoid disk access */
+ audio_stop(); /* stop playback, to avoid disk access */
lcd_clear_display();
lcd_puts(0,0,"Scanning");
lcd_puts(0,1,"disk...");
@@ -2016,7 +2016,7 @@ bool debug_menu(void)
{ "View disk info", dbg_disk_info },
#endif
#ifdef HAVE_LCD_BITMAP
- { "View mpeg thread", dbg_mpeg_thread },
+ { "View audio thread", dbg_audio_thread },
#ifdef PM_DEBUG
{ "pm histogram", peak_meter_histogram},
#endif /* PM_DEBUG */
diff --git a/apps/main.c b/apps/main.c
index 505022481e..b5c6364080 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -38,7 +38,7 @@
#ifndef DEBUG
#include "serial.h"
#endif
-#include "mpeg.h"
+#include "audio.h"
#include "mp3_playback.h"
#include "main_menu.h"
#include "thread.h"
@@ -114,7 +114,7 @@ void init(void)
global_settings.mdb_shape,
global_settings.mdb_enable,
global_settings.superbass);
- mpeg_init();
+ audio_init();
button_clear_queue(); /* Empty the keyboard buffer */
}
@@ -235,7 +235,7 @@ void init(void)
tree_init();
/* No buffer allocation (see buffer.c) may take place after the call to
- mpeg_init() since the mpeg thread takes the rest of the buffer space */
+ audio_init() since the mpeg thread takes the rest of the buffer space */
mp3_init( global_settings.volume,
global_settings.bass,
global_settings.treble,
@@ -250,7 +250,7 @@ void init(void)
global_settings.mdb_shape,
global_settings.mdb_enable,
global_settings.superbass);
- mpeg_init();
+ audio_init();
talk_init();
#ifdef AUTOROCK
diff --git a/apps/onplay.c b/apps/onplay.c
index 7ebe4e1f45..f761014bbf 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -26,7 +26,7 @@
#include "lcd.h"
#include "dir.h"
#include "file.h"
-#include "mpeg.h"
+#include "audio.h"
#include "menu.h"
#include "lang.h"
#include "playlist.h"
@@ -84,7 +84,7 @@ struct playlist_args {
static bool add_to_playlist(int position, bool queue)
{
- bool new_playlist = !(mpeg_status() & MPEG_STATUS_PLAY);
+ bool new_playlist = !(audio_status() & AUDIO_STATUS_PLAY);
if (new_playlist)
playlist_create(NULL, NULL);
@@ -152,12 +152,12 @@ static bool add_to_playlist(int position, bool queue)
static bool view_playlist(void)
{
- bool was_playing = mpeg_status() & MPEG_STATUS_PLAY;
+ bool was_playing = audio_status() & AUDIO_STATUS_PLAY;
bool result;
result = playlist_viewer_ex(selected_file);
- if (!was_playing && (mpeg_status() & MPEG_STATUS_PLAY) &&
+ if (!was_playing && (audio_status() & AUDIO_STATUS_PLAY) &&
onplay_result == ONPLAY_OK)
/* playlist was started from viewer */
onplay_result = ONPLAY_START_PLAY;
@@ -181,7 +181,7 @@ static bool playlist_options(void)
pstart++;
}
- if (mpeg_status() & MPEG_STATUS_PLAY)
+ if (audio_status() & AUDIO_STATUS_PLAY)
{
items[i].desc = ID2P(LANG_INSERT);
args[i].position = PLAYLIST_INSERT;
diff --git a/apps/playlist.c b/apps/playlist.c
index cb9d2ba3ea..3370937a69 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -73,7 +73,7 @@
#include "dir.h"
#include "sprintf.h"
#include "debug.h"
-#include "mpeg.h"
+#include "audio.h"
#include "lcd.h"
#include "kernel.h"
#include "settings.h"
@@ -348,7 +348,7 @@ static int add_indices_to_playlist(struct playlist_info* playlist,
if (!buffer)
{
/* use mp3 buffer for maximum load speed */
- mpeg_stop();
+ audio_stop();
talk_buffer_steal(); /* we use the mp3 buffer, need to tell */
buffer = mp3buf;
@@ -629,7 +629,7 @@ static int add_directory_to_playlist(struct playlist_info* playlist,
display_playlist_count(*count, count_str);
if (*count == PLAYLIST_DISPLAY_COUNT)
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
}
/* let the other threads work */
@@ -1625,7 +1625,7 @@ int playlist_start(int start_index, int offset)
playlist->index = start_index;
talk_buffer_steal(); /* will use the mp3 buffer */
- mpeg_play(offset);
+ audio_play(offset);
return 0;
}
@@ -1932,7 +1932,7 @@ int playlist_insert_track(struct playlist_info* playlist, const char *filename,
if (result != -1)
{
fsync(playlist->control_fd);
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
}
return result;
@@ -1970,7 +1970,7 @@ int playlist_insert_directory(struct playlist_info* playlist,
fsync(playlist->control_fd);
display_playlist_count(count, count_str);
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
return result;
}
@@ -2063,7 +2063,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
display_playlist_count(count, count_str);
if (count == PLAYLIST_DISPLAY_COUNT)
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
}
}
@@ -2078,7 +2078,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
*temp_ptr = '/';
display_playlist_count(count, count_str);
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
return result;
}
@@ -2106,7 +2106,7 @@ int playlist_delete(struct playlist_info* playlist, int index)
result = remove_track_from_playlist(playlist, index, true);
if (result != -1)
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
return result;
}
@@ -2194,7 +2194,7 @@ int playlist_move(struct playlist_info* playlist, int index, int new_index)
}
fsync(playlist->control_fd);
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
}
}
@@ -2215,7 +2215,7 @@ int playlist_randomise(struct playlist_info* playlist, unsigned int seed,
result = randomise_playlist(playlist, seed, start_current, true);
if (result != -1)
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
return result;
}
@@ -2233,7 +2233,7 @@ int playlist_sort(struct playlist_info* playlist, bool start_current)
result = sort_playlist(playlist, start_current, true);
if (result != -1)
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
return result;
}
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index f1235301cf..64d57d7d2e 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -21,7 +21,7 @@
#include <string.h>
#include <sprintf.h>
#include "playlist.h"
-#include "mpeg.h"
+#include "audio.h"
#include "screens.h"
#include "status.h"
#include "settings.h"
@@ -142,7 +142,7 @@ static bool initialize(char* filename, bool reload)
{
char* buffer;
int buffer_size;
- bool is_playing = mpeg_status() & MPEG_STATUS_PLAY;
+ bool is_playing = audio_status() & AUDIO_STATUS_PLAY;
if (!filename && !is_playing)
/* Nothing is playing, exit */
@@ -702,7 +702,7 @@ static int onplay_menu(int index)
case 0:
/* delete track */
if (current)
- mpeg_stop();
+ audio_stop();
playlist_delete(viewer.playlist, tracks[index].index);
@@ -714,7 +714,7 @@ static int onplay_menu(int index)
global_settings.repeat_mode == REPEAT_ALL)
{
talk_buffer_steal(); /* will use the mp3 buffer */
- mpeg_play(0);
+ audio_play(0);
viewer.current_playing_track = -1;
}
}
@@ -838,7 +838,7 @@ bool playlist_viewer_ex(char* filename)
{
int track;
- if (!viewer.playlist && !(mpeg_status() & MPEG_STATUS_PLAY))
+ if (!viewer.playlist && !(audio_status() & AUDIO_STATUS_PLAY))
{
/* Play has stopped */
#ifdef HAVE_LCD_CHARCELLS
@@ -954,14 +954,14 @@ bool playlist_viewer_ex(char* filename)
else if (!viewer.playlist)
{
/* Stop current track and play new track */
- mpeg_stop();
+ audio_stop();
playlist_start(tracks[INDEX(viewer.cursor_pos)].index, 0);
update_playlist(false);
}
else
{
/* Play track from playlist on disk */
- mpeg_stop();
+ audio_stop();
/* New playlist */
if (playlist_set_current(viewer.playlist) < 0)
diff --git a/apps/plugin.c b/apps/plugin.c
index 2031f0d450..412d86b4c9 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -199,20 +199,20 @@ static const struct plugin_api rockbox_api = {
#endif
/* playback control */
- PREFIX(mpeg_play),
- mpeg_stop,
- mpeg_pause,
- mpeg_resume,
- mpeg_next,
- mpeg_prev,
- mpeg_ff_rewind,
- mpeg_next_track,
+ PREFIX(audio_play),
+ audio_stop,
+ audio_pause,
+ audio_resume,
+ audio_next,
+ audio_prev,
+ audio_ff_rewind,
+ audio_next_track,
playlist_amount,
- mpeg_status,
- mpeg_has_changed_track,
- mpeg_current_track,
- mpeg_flush_and_reload_tracks,
- mpeg_get_file_pos,
+ audio_status,
+ audio_has_changed_track,
+ audio_current_track,
+ audio_flush_and_reload_tracks,
+ audio_get_file_pos,
mpeg_get_last_header,
#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
sound_set_pitch,
@@ -409,7 +409,7 @@ void* plugin_get_buffer(int* buffer_size)
Playback gets stopped, to avoid conflicts. */
void* plugin_get_mp3_buffer(int* buffer_size)
{
- mpeg_stop();
+ audio_stop();
talk_buffer_steal(); /* we use the mp3 buffer, need to tell */
*buffer_size = mp3end - mp3buf;
return mp3buf;
diff --git a/apps/plugin.h b/apps/plugin.h
index 45f03555ec..ff37a7c46d 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -42,6 +42,7 @@
#include "lcd.h"
#include "id3.h"
#include "mpeg.h"
+#include "audio.h"
#include "mp3_playback.h"
#include "pcm_playback.h"
#include "settings.h"
@@ -239,20 +240,20 @@ struct plugin_api {
#endif
/* playback control */
- void (*PREFIX(mpeg_play))(int offset);
- void (*mpeg_stop)(void);
- void (*mpeg_pause)(void);
- void (*mpeg_resume)(void);
- void (*mpeg_next)(void);
- void (*mpeg_prev)(void);
- void (*mpeg_ff_rewind)(int newtime);
- struct mp3entry* (*mpeg_next_track)(void);
+ void (*PREFIX(audio_play))(int offset);
+ void (*audio_stop)(void);
+ void (*audio_pause)(void);
+ void (*audio_resume)(void);
+ void (*audio_next)(void);
+ void (*audio_prev)(void);
+ void (*audio_ff_rewind)(int newtime);
+ struct mp3entry* (*audio_next_track)(void);
int (*playlist_amount)(void);
- int (*mpeg_status)(void);
- bool (*mpeg_has_changed_track)(void);
- struct mp3entry* (*mpeg_current_track)(void);
- void (*mpeg_flush_and_reload_tracks)(void);
- int (*mpeg_get_file_pos)(void);
+ int (*audio_status)(void);
+ bool (*audio_has_changed_track)(void);
+ struct mp3entry* (*audio_current_track)(void);
+ void (*audio_flush_and_reload_tracks)(void);
+ int (*audio_get_file_pos)(void);
unsigned long (*mpeg_get_last_header)(void);
#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
void (*sound_set_pitch)(int pitch);
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c
index d944810b31..d0b3b1d8d1 100644
--- a/apps/plugins/alpine_cdc.c
+++ b/apps/plugins/alpine_cdc.c
@@ -817,7 +817,7 @@ void emu_process_packet(unsigned char* mbus_msg, int msg_size)
if (playmsg_dirty)
{
- rb->yield(); /* give the mpeg thread a chance to process */
+ rb->yield(); /* give the audio thread a chance to process */
get_playmsg(); /* force update */
mbus_send(gEmu.playmsg, sizeof(gEmu.playmsg));
}
@@ -876,10 +876,10 @@ void get_playmsg(void)
if (gEmu.set_state != EMU_FF && gEmu.set_state != EMU_FR)
{
- switch(rb->mpeg_status())
+ switch(rb->audio_status())
{
- case MPEG_STATUS_PLAY:
- print_scroll("MpegStat Play");
+ case AUDIO_STATUS_PLAY:
+ print_scroll("AudioStat Play");
if (gEmu.set_state == EMU_FF || gEmu.set_state == EMU_FR)
gEmu.playmsg[2] = gEmu.set_state; /* set FF/FR */
else
@@ -890,8 +890,8 @@ void get_playmsg(void)
bit_set(gEmu.playmsg, 59, false); /* clear stop */
break;
- case MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE:
- print_scroll("MpegStat Pause");
+ case AUDIO_STATUS_PLAY | AUDIO_STATUS_PAUSE:
+ print_scroll("AudioStat Pause");
gEmu.playmsg[2] = EMU_PAUSED;
bit_set(gEmu.playmsg, 56, false); /* clear play */
bit_set(gEmu.playmsg, 57, true); /* set pause */
@@ -899,7 +899,7 @@ void get_playmsg(void)
break;
default:
- print_scroll("MpegStat 0");
+ print_scroll("AudioStat 0");
gEmu.playmsg[2] = EMU_STOPPED;
bit_set(gEmu.playmsg, 56, false); /* clear play */
bit_set(gEmu.playmsg, 57, false); /* clear pause */
@@ -943,7 +943,7 @@ int get_playtime(void)
{
struct mp3entry* p_mp3entry;
- p_mp3entry = rb->mpeg_current_track();
+ p_mp3entry = rb->audio_current_track();
if (p_mp3entry == NULL)
return 0;
@@ -955,7 +955,7 @@ int get_tracklength(void)
{
struct mp3entry* p_mp3entry;
- p_mp3entry = rb->mpeg_current_track();
+ p_mp3entry = rb->audio_current_track();
if (p_mp3entry == NULL)
return 0;
@@ -967,13 +967,13 @@ void set_track(int selected)
{
if (selected > get_track())
{
- print_scroll("mpeg_next");
- rb->mpeg_next();
+ print_scroll("audio_next");
+ rb->audio_next();
}
else if (selected < get_track())
{
- print_scroll("mpeg_prev");
- rb->mpeg_prev();
+ print_scroll("audio_prev");
+ rb->audio_prev();
}
}
@@ -982,7 +982,7 @@ int get_track(void)
{
struct mp3entry* p_mp3entry;
- p_mp3entry = rb->mpeg_current_track();
+ p_mp3entry = rb->audio_current_track();
if (p_mp3entry == NULL)
return 0;
@@ -992,48 +992,48 @@ int get_track(void)
/* start or resume playback */
void set_play(void)
{
- if (rb->mpeg_status() == MPEG_STATUS_PLAY)
+ if (rb->audio_status() == AUDIO_STATUS_PLAY)
return;
- if (rb->mpeg_status() == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE))
+ if (rb->audio_status() == (AUDIO_STATUS_PLAY | AUDIO_STATUS_PAUSE))
{
- print_scroll("mpeg_resume");
- rb->mpeg_resume();
+ print_scroll("audio_resume");
+ rb->audio_resume();
}
else
{
- print_scroll("mpeg_play(0)");
- rb->mpeg_play(0);
+ print_scroll("audio_play(0)");
+ rb->audio_play(0);
}
}
/* pause playback */
void set_pause(void)
{
- if (rb->mpeg_status() == MPEG_STATUS_PLAY)
+ if (rb->audio_status() == AUDIO_STATUS_PLAY)
{
- print_scroll("mpeg_pause");
- rb->mpeg_pause();
+ print_scroll("audio_pause");
+ rb->audio_pause();
}
}
/* stop playback */
void set_stop(void)
{
- if (rb->mpeg_status() & MPEG_STATUS_PLAY)
+ if (rb->audio_status() & AUDIO_STATUS_PLAY)
{
- print_scroll("mpeg_stop");
- rb->mpeg_stop();
+ print_scroll("audio_stop");
+ rb->audio_stop();
}
}
/* seek */
void set_position(int seconds)
{
- if (rb->mpeg_status() & MPEG_STATUS_PLAY)
+ if (rb->audio_status() & AUDIO_STATUS_PLAY)
{
- print_scroll("mpeg_ff_rewind");
- rb->mpeg_ff_rewind(seconds * 1000);
+ print_scroll("audio_ff_rewind");
+ rb->audio_ff_rewind(seconds * 1000);
}
}
diff --git a/apps/plugins/favorites.c b/apps/plugins/favorites.c
index c4b969f920..68eab43298 100644
--- a/apps/plugins/favorites.c
+++ b/apps/plugins/favorites.c
@@ -21,7 +21,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
if(parameter) {
rb->strncpy(track_path, parameter, MAX_PATH);
} else {
- id3 = rb->mpeg_current_track();
+ id3 = rb->audio_current_track();
if (!id3) {
rb->splash(HZ*2, true, "Nothing To Save");
return PLUGIN_OK;
diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c
index c2cdc8de6e..d38223827b 100644
--- a/apps/plugins/splitedit.c
+++ b/apps/plugins/splitedit.c
@@ -614,11 +614,11 @@ static int save(
}
/* find the file position of the split point */
- rb->mpeg_pause();
- rb->mpeg_ff_rewind(splittime);
+ rb->audio_pause();
+ rb->audio_ff_rewind(splittime);
rb->yield();
rb->yield();
- end = rb->mpeg_get_file_pos();
+ end = rb->audio_get_file_pos();
/* open the source file */
src_file = rb->open(mp3->path, O_RDONLY);
@@ -720,7 +720,7 @@ static int save(
retval = -3;
}
- rb->mpeg_resume();
+ rb->audio_resume();
return retval;
}
@@ -985,27 +985,27 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
case LOOP_MODE_ALL:
case LOOP_MODE_TO:
- rb->mpeg_pause();
- rb->mpeg_ff_rewind(range_start);
+ rb->audio_pause();
+ rb->audio_ff_rewind(range_start);
#ifdef HAVE_MMC
/* MMC is slow - wait some time to allow track reload to finish */
rb->sleep(HZ/20);
if (mp3->elapsed > play_end) /* reload in progress */
rb->splash(10*HZ, true, "Wait - reloading");
#endif
- rb->mpeg_resume();
+ rb->audio_resume();
break;
case LOOP_MODE_FROM:
- rb->mpeg_pause();
- rb->mpeg_ff_rewind(xpos_to_time(split_x));
+ rb->audio_pause();
+ rb->audio_ff_rewind(xpos_to_time(split_x));
#ifdef HAVE_MMC
/* MMC is slow - wait some time to allow track reload to finish */
rb->sleep(HZ/20);
if (mp3->elapsed > play_end) /* reload in progress */
rb->splash(10*HZ, true, "Wait - reloading");
#endif
- rb->mpeg_resume();
+ rb->audio_resume();
break;
case LOOP_MODE_FREE:
@@ -1037,9 +1037,9 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
if (lastbutton != SPLITEDIT_PLAY_PRE)
break;
#endif
- rb->mpeg_pause();
- rb->mpeg_ff_rewind(xpos_to_time(split_x));
- rb->mpeg_resume();
+ rb->audio_pause();
+ rb->audio_ff_rewind(xpos_to_time(split_x));
+ rb->audio_resume();
break;
case BUTTON_UP:
@@ -1159,9 +1159,9 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
}
update_data();
- if (mp3 != rb->mpeg_current_track())
+ if (mp3 != rb->audio_current_track())
{
- struct mp3entry *new_mp3 = rb->mpeg_current_track();
+ struct mp3entry *new_mp3 = rb->audio_current_track();
if (rb->strncasecmp(path_mp3, new_mp3->path,
sizeof (path_mp3)))
{
@@ -1173,10 +1173,10 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
else
{
mp3 = new_mp3;
- rb->mpeg_pause();
- rb->mpeg_flush_and_reload_tracks();
- rb->mpeg_ff_rewind(range_start);
- rb->mpeg_resume();
+ rb->audio_pause();
+ rb->audio_flush_and_reload_tracks();
+ rb->audio_ff_rewind(range_start);
+ rb->audio_resume();
}
}
}
@@ -1192,12 +1192,12 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb = api;
rb->lcd_clear_display();
rb->lcd_update();
- mp3 = rb->mpeg_current_track();
+ mp3 = rb->audio_current_track();
if (mp3 != NULL)
{
- if (rb->mpeg_status() & MPEG_STATUS_PAUSE)
+ if (rb->audio_status() & AUDIO_STATUS_PAUSE)
{
- rb->mpeg_resume();
+ rb->audio_resume();
}
splitedit_editor(mp3, mp3->elapsed, MIN_RANGE_SIZE * 8);
}
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 39e94739b5..9ef6d4a521 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -27,6 +27,7 @@
#include "lcd.h"
#include "led.h"
#include "mpeg.h"
+#include "audio.h"
#include "mp3_playback.h"
#include "mas.h"
#include "button.h"
@@ -256,7 +257,7 @@ static void trigger_listener(int trigger_status)
switch (trigger_status)
{
case TRIG_GO:
- if((mpeg_status() & MPEG_STATUS_RECORD) != MPEG_STATUS_RECORD)
+ if((audio_status() & AUDIO_STATUS_RECORD) != AUDIO_STATUS_RECORD)
{
talk_buffer_steal(); /* we use the mp3 buffer */
mpeg_record(rec_create_filename(path_buffer));
@@ -276,9 +277,9 @@ static void trigger_listener(int trigger_status)
/* A _change_ to TRIG_READY means the current recording has stopped */
case TRIG_READY:
- if(mpeg_status() & MPEG_STATUS_RECORD)
+ if(audio_status() & AUDIO_STATUS_RECORD)
{
- mpeg_stop();
+ audio_stop();
if (global_settings.rec_trigger_mode != TRIG_MODE_REARM)
{
peak_meter_set_trigger_listener(NULL);
@@ -306,7 +307,7 @@ bool recording_screen(void)
int hours, minutes;
char path_buffer[MAX_PATH];
bool been_in_usb_mode = false;
- int last_mpeg_stat = -1;
+ int last_audio_stat = -1;
bool last_led_stat = false;
const unsigned char *byte_units[] = {
@@ -352,15 +353,15 @@ bool recording_screen(void)
while(!done)
{
- int mpeg_stat = mpeg_status();
+ int audio_stat = audio_status();
/*
* Flash the LED while waiting to record. Turn it on while
* recording.
*/
- if(mpeg_stat & MPEG_STATUS_RECORD)
+ if(audio_stat & AUDIO_STATUS_RECORD)
{
- if (mpeg_stat & MPEG_STATUS_PAUSE)
+ if (audio_stat & AUDIO_STATUS_PAUSE)
{
/*
This is supposed to be the same as
@@ -411,24 +412,24 @@ bool recording_screen(void)
/* Wait for a button while drawing the peak meter */
button = peak_meter_draw_get_btn(0, 8 + h*2, LCD_WIDTH, h);
- if (last_mpeg_stat != mpeg_stat)
+ if (last_audio_stat != audio_stat)
{
- if (mpeg_stat == MPEG_STATUS_RECORD)
+ if (audio_stat == AUDIO_STATUS_RECORD)
{
have_recorded = true;
}
- last_mpeg_stat = mpeg_stat;
+ last_audio_stat = audio_stat;
}
switch(button)
{
case REC_STOPEXIT:
- if(mpeg_stat & MPEG_STATUS_RECORD)
+ if(audio_stat & AUDIO_STATUS_RECORD)
{
/* turn off the trigger */
peak_meter_trigger(false);
peak_meter_set_trigger_listener(NULL);
- mpeg_stop();
+ audio_stop();
}
else
{
@@ -444,7 +445,7 @@ bool recording_screen(void)
case REC_RECPAUSE:
/* Only act if the mpeg is stopped */
- if(!(mpeg_stat & MPEG_STATUS_RECORD))
+ if(!(audio_stat & AUDIO_STATUS_RECORD))
{
/* is this manual or triggered recording? */
if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
@@ -458,7 +459,7 @@ bool recording_screen(void)
last_seconds = 0;
if (global_settings.talk_menu)
{ /* no voice possible here, but a beep */
- mpeg_beep(HZ/2); /* longer beep on start */
+ audio_beep(HZ/2); /* longer beep on start */
}
}
@@ -476,12 +477,12 @@ bool recording_screen(void)
}
else
{
- if(mpeg_stat & MPEG_STATUS_PAUSE)
+ if(audio_stat & AUDIO_STATUS_PAUSE)
{
mpeg_resume_recording();
if (global_settings.talk_menu)
{ /* no voice possible here, but a beep */
- mpeg_beep(HZ/4); /* short beep on resume */
+ audio_beep(HZ/4); /* short beep on resume */
}
}
else
@@ -594,7 +595,7 @@ bool recording_screen(void)
#ifdef REC_SETTINGS
case REC_SETTINGS:
- if(mpeg_stat != MPEG_STATUS_RECORD)
+ if(audio_stat != AUDIO_STATUS_RECORD)
{
/* led is restored at begin of loop / end of function */
led(false);
@@ -625,7 +626,7 @@ bool recording_screen(void)
#ifdef REC_F2
case REC_F2:
- if(mpeg_stat != MPEG_STATUS_RECORD)
+ if(audio_stat != AUDIO_STATUS_RECORD)
{
/* led is restored at begin of loop / end of function */
led(false);
@@ -642,14 +643,14 @@ bool recording_screen(void)
#ifdef REC_F3
case REC_F3:
- if(mpeg_stat & MPEG_STATUS_RECORD)
+ if(audio_stat & AUDIO_STATUS_RECORD)
{
mpeg_new_file(rec_create_filename(path_buffer));
last_seconds = 0;
}
else
{
- if(mpeg_stat != MPEG_STATUS_RECORD)
+ if(audio_stat != AUDIO_STATUS_RECORD)
{
/* led is restored at begin of loop / end of function */
led(false);
@@ -667,7 +668,7 @@ bool recording_screen(void)
case SYS_USB_CONNECTED:
/* Only accept USB connection when not recording */
- if(mpeg_stat != MPEG_STATUS_RECORD)
+ if(audio_stat != AUDIO_STATUS_RECORD)
{
default_event_handler(SYS_USB_CONNECTED);
done = true;
@@ -708,7 +709,7 @@ bool recording_screen(void)
dseconds = rec_timesplit_seconds();
- if(mpeg_stat & MPEG_STATUS_PRERECORD)
+ if(audio_stat & AUDIO_STATUS_PRERECORD)
{
snprintf(buf, 32, "%s...", str(LANG_RECORD_PRERECORD));
}
@@ -741,7 +742,7 @@ bool recording_screen(void)
/* We will do file splitting regardless, since the OFF
setting really means 24 hours. This is to make sure
that the recorded files don't get too big. */
- if (mpeg_stat && (seconds >= dseconds))
+ if (audio_stat && (seconds >= dseconds))
{
mpeg_new_file(rec_create_filename(path_buffer));
update_countdown = 1;
@@ -822,7 +823,7 @@ bool recording_screen(void)
}
}
- if(mpeg_stat & MPEG_STATUS_ERROR)
+ if(audio_stat & AUDIO_STATUS_ERROR)
{
done = true;
}
@@ -830,12 +831,12 @@ bool recording_screen(void)
invert_led(false);
- if(mpeg_status() & MPEG_STATUS_ERROR)
+ if(audio_status() & AUDIO_STATUS_ERROR)
{
splash(0, true, str(LANG_DISK_FULL));
status_draw(true);
lcd_update();
- mpeg_error_clear();
+ audio_error_clear();
while(1)
{
@@ -845,7 +846,7 @@ bool recording_screen(void)
}
}
- mpeg_init_playback();
+ audio_init_playback();
/* make sure the trigger is really turned off */
peak_meter_trigger(false);
diff --git a/apps/screens.c b/apps/screens.c
index f56c28a165..1d11fdbb5e 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -25,7 +25,7 @@
#include "lang.h"
#include "icons.h"
#include "font.h"
-#include "mpeg.h"
+#include "audio.h"
#include "mp3_playback.h"
#include "usb.h"
#include "settings.h"
@@ -452,17 +452,17 @@ int pitch_screen(void)
break;
case BUTTON_ON | BUTTON_PLAY:
- mpeg_pause();
+ audio_pause();
used = true;
break;
case BUTTON_PLAY | BUTTON_REL:
- mpeg_resume();
+ audio_resume();
used = true;
break;
case BUTTON_ON | BUTTON_PLAY | BUTTON_REL:
- mpeg_resume();
+ audio_resume();
exit = true;
break;
@@ -651,7 +651,7 @@ bool quick_screen(int context, int button)
global_settings.playlist_shuffle =
!global_settings.playlist_shuffle;
- if(mpeg_status() & MPEG_STATUS_PLAY)
+ if(audio_status() & AUDIO_STATUS_PLAY)
{
if (global_settings.playlist_shuffle)
playlist_randomise(NULL, current_tick, true);
@@ -727,7 +727,7 @@ bool quick_screen(int context, int button)
case BUTTON_F2:
if ( oldrepeat != global_settings.repeat_mode )
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
break;
case BUTTON_F3:
@@ -1254,14 +1254,14 @@ bool shutdown_screen(void)
bool browse_id3(void)
{
- struct mp3entry* id3 = mpeg_current_track();
+ struct mp3entry* id3 = audio_current_track();
int button;
int menu_pos = 0;
int menu_max = 8;
bool exit = false;
char scroll_text[MAX_PATH];
- if (!(mpeg_status() & MPEG_STATUS_PLAY))
+ if (!(audio_status() & AUDIO_STATUS_PLAY))
return false;
while (!exit)
diff --git a/apps/settings.c b/apps/settings.c
index bad8fa29ab..39bb9b4d26 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -31,7 +31,7 @@
#include "usb.h"
#include "backlight.h"
#include "lcd.h"
-#include "mpeg.h"
+#include "audio.h"
#include "mp3_playback.h"
#include "talk.h"
#include "string.h"
@@ -757,7 +757,7 @@ void settings_apply(void)
sound_settings_apply();
- mpeg_set_buffer_margin(global_settings.buffer_margin);
+ audio_set_buffer_margin(global_settings.buffer_margin);
lcd_set_contrast(global_settings.contrast);
lcd_scroll_speed(global_settings.scroll_speed);
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index bc87ec141d..9590e15476 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -26,6 +26,7 @@
#include "lcd.h"
#include "menu.h"
#include "mpeg.h"
+#include "audio.h"
#include "button.h"
#include "kernel.h"
#include "thread.h"
@@ -452,7 +453,7 @@ static bool repeat_mode(void)
INT, names, 3, NULL );
if (old_repeat != global_settings.repeat_mode)
- mpeg_flush_and_reload_tracks();
+ audio_flush_and_reload_tracks();
return result;
}
@@ -817,7 +818,7 @@ static bool buffer_margin(void)
{
return set_int(str(LANG_MP3BUFFER_MARGIN), "s", UNIT_SEC,
&global_settings.buffer_margin,
- mpeg_set_buffer_margin, 1, 0, 7 );
+ audio_set_buffer_margin, 1, 0, 7 );
}
static bool ff_rewind_min_step(void)
diff --git a/apps/status.c b/apps/status.c
index d4736f3773..62eb03465c 100644
--- a/apps/status.c
+++ b/apps/status.c
@@ -25,7 +25,7 @@
#include "settings.h"
#include "status.h"
#include "mp3_playback.h"
-#include "mpeg.h"
+#include "audio.h"
#include "wps.h"
#ifdef HAVE_RTC
#include "timefuncs.h"
@@ -75,16 +75,16 @@ void status_set_ffmode(enum playmode mode)
int current_playmode(void)
{
- int mpeg_stat = mpeg_status();
+ int audio_stat = audio_status();
/* ff_mode can be either STATUS_FASTFORWARD or STATUS_FASTBACKWARD
and that supercedes the other modes */
if(ff_mode)
return ff_mode;
- if(mpeg_stat & MPEG_STATUS_PLAY)
+ if(audio_stat & AUDIO_STATUS_PLAY)
{
- if(mpeg_stat & MPEG_STATUS_PAUSE)
+ if(audio_stat & AUDIO_STATUS_PAUSE)
return STATUS_PAUSE;
else
return STATUS_PLAY;
@@ -92,9 +92,9 @@ int current_playmode(void)
#if CONFIG_HWCODEC == MAS3587F
else
{
- if(mpeg_stat & MPEG_STATUS_RECORD)
+ if(audio_stat & AUDIO_STATUS_RECORD)
{
- if(mpeg_stat & MPEG_STATUS_PAUSE)
+ if(audio_stat & AUDIO_STATUS_PAUSE)
return STATUS_RECORD_PAUSE;
else
return STATUS_RECORD;
diff --git a/apps/talk.c b/apps/talk.c
index 6fb75c2601..2b97629d55 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -28,7 +28,7 @@
#include "system.h"
#include "settings.h"
#include "mp3_playback.h"
-#include "mpeg.h"
+#include "audio.h"
#include "lang.h"
#include "talk.h"
#include "id3.h"
@@ -432,7 +432,7 @@ int talk_id(long id, bool enqueue)
unsigned char* clipbuf;
int unit;
- if (mpeg_status()) /* busy, buffer in use */
+ if (audio_status()) /* busy, buffer in use */
return -1;
if (p_voicefile == NULL && has_voicefile)
@@ -471,7 +471,7 @@ int talk_file(const char* filename, bool enqueue)
int size;
struct mp3entry info;
- if (mpeg_status()) /* busy, buffer in use */
+ if (audio_status()) /* busy, buffer in use */
return -1;
if (p_thumbnail == NULL || size_for_thumbnail <= 0)
@@ -512,7 +512,7 @@ int talk_number(long n, bool enqueue)
int level = 0; /* mille count */
long mil = 1000000000; /* highest possible "-illion" */
- if (mpeg_status()) /* busy, buffer in use */
+ if (audio_status()) /* busy, buffer in use */
return -1;
if (!enqueue)
@@ -591,7 +591,7 @@ int talk_value(long n, int unit, bool enqueue)
VOICE_HERTZ,
};
- if (mpeg_status()) /* busy, buffer in use */
+ if (audio_status()) /* busy, buffer in use */
return -1;
if (unit < 0 || unit >= UNIT_LAST)
@@ -623,7 +623,7 @@ int talk_spell(const char* spell, bool enqueue)
{
char c; /* currently processed char */
- if (mpeg_status()) /* busy, buffer in use */
+ if (audio_status()) /* busy, buffer in use */
return -1;
if (!enqueue)
diff --git a/apps/tree.c b/apps/tree.c
index d2b78f9872..139043ab04 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -33,7 +33,7 @@
#include "tree.h"
#include "main_menu.h"
#include "sprintf.h"
-#include "mpeg.h"
+#include "audio.h"
#include "playlist.h"
#include "menu.h"
#include "wps.h"
@@ -799,8 +799,8 @@ static bool dirbrowse(void)
{
/* Stop the music if it is playing, else show the shutdown
screen */
- if(mpeg_status())
- mpeg_stop();
+ if(audio_status())
+ audio_stop();
else {
if (!charger_inserted()) {
shutdown_screen();
@@ -998,7 +998,7 @@ static bool dirbrowse(void)
/* don't enter wps from plugin browser etc */
if (*tc.dirfilter < NUM_FILTER_MODES)
{
- if (mpeg_status() & MPEG_STATUS_PLAY)
+ if (audio_status() & AUDIO_STATUS_PLAY)
{
start_wps=true;
}
@@ -1539,7 +1539,7 @@ int ft_play_dirname(int start_index)
char dirname_mp3_filename[MAX_PATH+1];
struct entry *dircache = tc.dircache;
- if (mpeg_status() & MPEG_STATUS_PLAY)
+ if (audio_status() & AUDIO_STATUS_PLAY)
return 0;
snprintf(dirname_mp3_filename, sizeof(dirname_mp3_filename), "%s/%s/%s",
@@ -1566,7 +1566,7 @@ void ft_play_filename(char *dir, char *file)
{
char name_mp3_filename[MAX_PATH+1];
- if (mpeg_status() & MPEG_STATUS_PLAY)
+ if (audio_status() & AUDIO_STATUS_PLAY)
return;
if (strcasecmp(&file[strlen(file) - strlen(file_thumbnail_ext)],
diff --git a/apps/wps-display.c b/apps/wps-display.c
index 9c8619fa66..1ed70541dc 100644
--- a/apps/wps-display.c
+++ b/apps/wps-display.c
@@ -29,7 +29,7 @@
#include "lcd.h"
#include "hwcompat.h"
#include "font.h"
-#include "mpeg.h"
+#include "audio.h"
#include "id3.h"
#include "settings.h"
#include "playlist.h"
@@ -1011,7 +1011,7 @@ bool wps_display(struct mp3entry* id3,
{
lcd_clear_display();
- if (!id3 && !(mpeg_status() & MPEG_STATUS_PLAY))
+ if (!id3 && !(audio_status() & AUDIO_STATUS_PLAY))
{
#ifdef HAVE_LCD_CHARCELLS
lcd_puts(0, 0, str(LANG_END_PLAYLIST_PLAYER));
diff --git a/apps/wps.c b/apps/wps.c
index d5f921c350..e281131836 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -33,7 +33,7 @@
#include "settings.h"
#include "wps.h"
#include "wps-display.h"
-#include "mpeg.h"
+#include "audio.h"
#include "mp3_playback.h"
#include "usb.h"
#include "status.h"
@@ -262,11 +262,11 @@ static bool ffwd_rew(int button)
}
else
{
- if ( (mpeg_status() & MPEG_STATUS_PLAY) &&
+ if ( (audio_status() & AUDIO_STATUS_PLAY) &&
id3 && id3->length )
{
if (!paused)
- mpeg_pause();
+ audio_pause();
#if CONFIG_KEYPAD == PLAYER_PAD
lcd_stop_scroll();
#endif
@@ -308,12 +308,12 @@ static bool ffwd_rew(int button)
case WPS_PREV:
case WPS_NEXT:
- mpeg_ff_rewind(id3->elapsed+ff_rewind_count);
+ audio_ff_rewind(id3->elapsed+ff_rewind_count);
ff_rewind_count = 0;
ff_rewind = false;
status_set_ffmode(0);
if (!paused)
- mpeg_resume();
+ audio_resume();
#ifdef HAVE_LCD_CHARCELLS
wps_display(id3, nid3);
#endif
@@ -332,7 +332,7 @@ static bool ffwd_rew(int button)
button = button_get(true);
}
- /* let mpeg thread update id3->elapsed before calling wps_refresh */
+ /* let audio thread update id3->elapsed before calling wps_refresh */
yield();
wps_refresh(id3, nid3, 0, WPS_REFRESH_ALL);
return usb;
@@ -340,14 +340,14 @@ static bool ffwd_rew(int button)
static bool update(void)
{
- bool track_changed = mpeg_has_changed_track();
+ bool track_changed = audio_has_changed_track();
bool retcode = false;
- nid3 = mpeg_next_track();
+ nid3 = audio_next_track();
if (track_changed)
{
lcd_stop_scroll();
- id3 = mpeg_current_track();
+ id3 = audio_current_track();
if (wps_display(id3, nid3))
retcode = true;
else
@@ -391,8 +391,8 @@ static void fade(bool fade_in)
/* zero out the sound */
sound_set(SOUND_VOLUME, current_volume);
- sleep(HZ/10); /* let mpeg thread run */
- mpeg_resume();
+ sleep(HZ/10); /* let audio thread run */
+ audio_resume();
while (current_volume < global_settings.volume) {
current_volume += 2;
@@ -410,8 +410,8 @@ static void fade(bool fade_in)
sleep(1);
sound_set(SOUND_VOLUME, current_volume);
}
- mpeg_pause();
- sleep(HZ/5); /* let mpeg thread run */
+ audio_pause();
+ sleep(HZ/5); /* let audio thread run */
/* reset volume to what it was before the fade */
sound_set(SOUND_VOLUME, global_settings.volume);
@@ -451,10 +451,10 @@ long wps_show(void)
ff_rewind = false;
- if(mpeg_status() & MPEG_STATUS_PLAY)
+ if(audio_status() & AUDIO_STATUS_PLAY)
{
- id3 = mpeg_current_track();
- nid3 = mpeg_next_track();
+ id3 = audio_current_track();
+ nid3 = audio_next_track();
if (id3) {
if (wps_display(id3, nid3))
return 0;
@@ -468,13 +468,13 @@ long wps_show(void)
while ( 1 )
{
- bool mpeg_paused = (mpeg_status() & MPEG_STATUS_PAUSE)?true:false;
+ bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false;
- /* did someone else (i.e power thread) change mpeg pause mode? */
- if (paused != mpeg_paused) {
- paused = mpeg_paused;
+ /* did someone else (i.e power thread) change audio pause mode? */
+ if (paused != audio_paused) {
+ paused = audio_paused;
- /* if another thread paused mpeg, we are probably in car mode,
+ /* if another thread paused audio, we are probably in car mode,
about to shut down. lets save the settings. */
if (paused && global_settings.resume) {
settings_save();
@@ -560,10 +560,10 @@ long wps_show(void)
}
#endif
- /* Exit if mpeg has stopped playing. This can happen if using the
+ /* Exit if audio has stopped playing. This can happen if using the
sleep timer with the charger plugged or if starting a recording
from F1 */
- if (!mpeg_status())
+ if (!audio_status())
exit = true;
switch(button)
@@ -598,7 +598,7 @@ long wps_show(void)
if ( global_settings.fade_on_stop )
fade(1);
else
- mpeg_resume();
+ audio_resume();
}
else
{
@@ -606,7 +606,7 @@ long wps_show(void)
if ( global_settings.fade_on_stop )
fade(0);
else
- mpeg_pause();
+ audio_pause();
if (global_settings.resume) {
settings_save();
#ifndef HAVE_RTC
@@ -662,16 +662,16 @@ long wps_show(void)
case WPS_RC_PREV:
#endif
if (!id3 || (id3->elapsed < 3*1000)) {
- mpeg_prev();
+ audio_prev();
}
else {
if (!paused)
- mpeg_pause();
+ audio_pause();
- mpeg_ff_rewind(0);
+ audio_ff_rewind(0);
if (!paused)
- mpeg_resume();
+ audio_resume();
}
break;
@@ -684,7 +684,7 @@ long wps_show(void)
#ifdef WPS_RC_NEXT
case WPS_RC_NEXT:
#endif
- mpeg_next();
+ audio_next();
break;
/* menu key functions */
@@ -789,7 +789,7 @@ long wps_show(void)
lcd_stop_scroll();
bookmark_autobookmark();
- mpeg_stop();
+ audio_stop();
/* Keys can be locked when exiting, so either unlock here
or implement key locking in tree.c too */
diff --git a/firmware/export/audio.h b/firmware/export/audio.h
new file mode 100644
index 0000000000..b276490ab3
--- /dev/null
+++ b/firmware/export/audio.h
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2005 by Linus Nielsen Feltzing
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef AUDIO_H
+#define AUDIO_H
+
+#include <stdbool.h>
+
+#ifdef SIMULATOR
+#define audio_play(x) sim_audio_play(x)
+#endif
+
+#define AUDIO_STATUS_PLAY 1
+#define AUDIO_STATUS_PAUSE 2
+#define AUDIO_STATUS_RECORD 4
+#define AUDIO_STATUS_PRERECORD 8
+#define AUDIO_STATUS_ERROR 16
+
+#define AUDIOERR_DISK_FULL 1
+
+struct audio_debug
+{
+ int mp3buflen;
+ int mp3buf_write;
+ int mp3buf_swapwrite;
+ int mp3buf_read;
+
+ int last_dma_chunk_size;
+
+ bool dma_on;
+ bool playing;
+ bool play_pending;
+ bool is_playing;
+ bool filling;
+ bool dma_underrun;
+
+ int unplayed_space;
+ int playable_space;
+ int unswapped_space;
+
+ int low_watermark_level;
+ int lowest_watermark_level;
+};
+
+void audio_init(void);
+void audio_play(int 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(int newtime);
+void audio_flush_and_reload_tracks(void);
+struct mp3entry* audio_current_track(void);
+struct mp3entry* audio_next_track(void);
+bool audio_has_changed_track(void);
+void audio_get_debugdata(struct audio_debug *dbgdata);
+void audio_set_buffer_margin(int seconds);
+unsigned int audio_error(void);
+void audio_error_clear(void);
+int audio_get_file_pos(void);
+void audio_beep(int duration);
+void audio_init_playback(void);
+
+#endif
diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h
index 479c5f2317..ca0de1f823 100644
--- a/firmware/export/mpeg.h
+++ b/firmware/export/mpeg.h
@@ -42,50 +42,8 @@
/* For ID3 info and VBR header */
#define MPEG_RESERVED_HEADER_SPACE (4096 + 1500)
-#ifdef SIMULATOR
-#define mpeg_play(x) sim_mpeg_play(x)
-#endif
-
-struct mpeg_debug
-{
- int mp3buflen;
- int mp3buf_write;
- int mp3buf_swapwrite;
- int mp3buf_read;
-
- int last_dma_chunk_size;
-
- bool dma_on;
- bool playing;
- bool play_pending;
- bool is_playing;
- bool filling;
- bool dma_underrun;
-
- int unplayed_space;
- int playable_space;
- int unswapped_space;
-
- int low_watermark_level;
- int lowest_watermark_level;
-};
-
-void mpeg_init(void);
-void mpeg_play(int offset);
-void mpeg_stop(void);
-void mpeg_pause(void);
-void mpeg_resume(void);
-void mpeg_next(void);
-void mpeg_prev(void);
-void mpeg_ff_rewind(int newtime);
-void mpeg_flush_and_reload_tracks(void);
-struct mp3entry* mpeg_current_track(void);
-struct mp3entry* mpeg_next_track(void);
-bool mpeg_has_changed_track(void);
-int mpeg_status(void);
#if (CONFIG_HWCODEC == MAS3587F) || defined(SIMULATOR)
void mpeg_init_recording(void);
-void mpeg_init_playback(void);
void mpeg_record(const char *filename);
void mpeg_new_file(const char *filename);
void mpeg_set_recording_options(int frequency, int quality,
@@ -97,25 +55,11 @@ unsigned long mpeg_num_recorded_bytes(void);
void mpeg_pause_recording(void);
void mpeg_resume_recording(void);
#endif
-void mpeg_get_debugdata(struct mpeg_debug *dbgdata);
-void mpeg_set_buffer_margin(int seconds);
-unsigned int mpeg_error(void);
-void mpeg_error_clear(void);
-int mpeg_get_file_pos(void);
unsigned long mpeg_get_last_header(void);
-void mpeg_beep(int duration);
/* in order to keep the recording here, I have to expose this */
void rec_tick(void);
void playback_tick(void); /* FixMe: get rid of this, use mp3_get_playtime() */
void mpeg_id3_options(bool _v1first);
-#define MPEG_STATUS_PLAY 1
-#define MPEG_STATUS_PAUSE 2
-#define MPEG_STATUS_RECORD 4
-#define MPEG_STATUS_PRERECORD 8
-#define MPEG_STATUS_ERROR 16
-
-#define MPEGERR_DISK_FULL 1
-
#endif
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index d8de1a37b4..79265e4452 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -23,6 +23,7 @@
#include "panic.h"
#include "id3.h"
#include "mpeg.h"
+#include "audio.h"
#include "ata.h"
#include "string.h"
#include <kernel.h>
@@ -220,10 +221,10 @@ static void set_elapsed(struct mp3entry* id3)
id3->elapsed = id3->offset / id3->bpf * id3->tpf;
}
-int mpeg_get_file_pos(void)
+int audio_get_file_pos(void)
{
int pos = -1;
- struct mp3entry *id3 = mpeg_current_track();
+ struct mp3entry *id3 = audio_current_track();
if (id3->vbr)
{
@@ -402,12 +403,12 @@ static void recalculate_watermark(int bitrate)
}
}
-void mpeg_set_buffer_margin(int seconds)
+void audio_set_buffer_margin(int seconds)
{
low_watermark_margin = seconds;
}
-void mpeg_get_debugdata(struct mpeg_debug *dbgdata)
+void audio_get_debugdata(struct audio_debug *dbgdata)
{
dbgdata->mp3buflen = mp3buflen;
dbgdata->mp3buf_write = mp3buf_write;
@@ -1264,7 +1265,7 @@ static void mpeg_thread(void)
}
case MPEG_FF_REWIND: {
- struct mp3entry *id3 = mpeg_current_track();
+ struct mp3entry *id3 = audio_current_track();
unsigned int oldtime = id3->elapsed;
unsigned int newtime = (unsigned int)ev.data;
int curpos, newpos, diffpos;
@@ -1272,7 +1273,7 @@ static void mpeg_thread(void)
id3->elapsed = newtime;
- newpos = mpeg_get_file_pos();
+ newpos = audio_get_file_pos();
if(newpos < 0)
{
id3->elapsed = oldtime;
@@ -1808,7 +1809,7 @@ static void mpeg_thread(void)
{
if(errno == ENOSPC)
{
- mpeg_errno = MPEGERR_DISK_FULL;
+ mpeg_errno = AUDIOERR_DISK_FULL;
demand_irq_enable(false);
stop_recording();
queue_post(&mpeg_queue, MPEG_STOP_DONE, 0);
@@ -1830,7 +1831,7 @@ static void mpeg_thread(void)
{
if(errno == ENOSPC)
{
- mpeg_errno = MPEGERR_DISK_FULL;
+ mpeg_errno = AUDIOERR_DISK_FULL;
demand_irq_enable(false);
stop_recording();
queue_post(&mpeg_queue, MPEG_STOP_DONE, 0);
@@ -1902,7 +1903,7 @@ static void mpeg_thread(void)
{
if(errno == ENOSPC)
{
- mpeg_errno = MPEGERR_DISK_FULL;
+ mpeg_errno = AUDIOERR_DISK_FULL;
stop_recording();
queue_post(&mpeg_queue, MPEG_STOP_DONE, 0);
break;
@@ -2013,7 +2014,7 @@ void mpeg_id3_options(bool _v1first)
v1first = _v1first;
}
-struct mp3entry* mpeg_current_track()
+struct mp3entry* audio_current_track()
{
#ifdef SIMULATOR
return &taginfo;
@@ -2025,7 +2026,7 @@ struct mp3entry* mpeg_current_track()
#endif /* #ifdef SIMULATOR */
}
-struct mp3entry* mpeg_next_track()
+struct mp3entry* audio_next_track()
{
#ifdef SIMULATOR
return &taginfo;
@@ -2037,7 +2038,7 @@ struct mp3entry* mpeg_next_track()
#endif /* #ifdef SIMULATOR */
}
-bool mpeg_has_changed_track(void)
+bool audio_has_changed_track(void)
{
if(last_track_counter != current_track_counter)
{
@@ -2048,7 +2049,7 @@ bool mpeg_has_changed_track(void)
}
#if CONFIG_HWCODEC == MAS3587F
-void mpeg_init_playback(void)
+void audio_init_playback(void)
{
init_playback_done = false;
queue_post(&mpeg_queue, MPEG_INIT_PLAYBACK, NULL);
@@ -2407,7 +2408,7 @@ void mpeg_set_recording_gain(int left, int right, bool use_mic)
}
/* try to make some kind of beep, also in recording mode */
-void mpeg_beep(int duration)
+void audio_beep(int duration)
{
long starttick = current_tick;
do
@@ -2495,7 +2496,7 @@ void bitswap(unsigned char *data, int length)
(void)length;
}
-void mpeg_init_playback(void)
+void audio_init_playback(void)
{
/* a dummy */
}
@@ -2504,7 +2505,7 @@ unsigned long mpeg_recorded_time(void)
/* a dummy */
return 0;
}
-void mpeg_beep(int duration)
+void audio_beep(int duration)
{
/* a dummy */
(void)duration;
@@ -2558,7 +2559,7 @@ void mpeg_set_recording_options(int frequency, int quality,
}
#endif
-void mpeg_play(int offset)
+void audio_play(int offset)
{
#ifdef SIMULATOR
char* trackname;
@@ -2595,7 +2596,7 @@ void mpeg_play(int offset)
mpeg_errno = 0;
}
-void mpeg_stop(void)
+void audio_stop(void)
{
#ifndef SIMULATOR
mpeg_stop_done = false;
@@ -2610,7 +2611,7 @@ void mpeg_stop(void)
}
-void mpeg_pause(void)
+void audio_pause(void)
{
#ifndef SIMULATOR
queue_post(&mpeg_queue, MPEG_PAUSE, NULL);
@@ -2621,7 +2622,7 @@ void mpeg_pause(void)
#endif /* #ifndef SIMULATOR */
}
-void mpeg_resume(void)
+void audio_resume(void)
{
#ifndef SIMULATOR
queue_post(&mpeg_queue, MPEG_RESUME, NULL);
@@ -2632,7 +2633,7 @@ void mpeg_resume(void)
#endif /* #ifndef SIMULATOR */
}
-void mpeg_next(void)
+void audio_next(void)
{
#ifndef SIMULATOR
queue_post(&mpeg_queue, MPEG_NEXT, NULL);
@@ -2660,7 +2661,7 @@ void mpeg_next(void)
#endif /* #ifndef SIMULATOR */
}
-void mpeg_prev(void)
+void audio_prev(void)
{
#ifndef SIMULATOR
queue_post(&mpeg_queue, MPEG_PREV, NULL);
@@ -2687,7 +2688,7 @@ void mpeg_prev(void)
#endif /* #ifndef SIMULATOR */
}
-void mpeg_ff_rewind(int newtime)
+void audio_ff_rewind(int newtime)
{
#ifndef SIMULATOR
queue_post(&mpeg_queue, MPEG_FF_REWIND, (void *)newtime);
@@ -2696,43 +2697,43 @@ void mpeg_ff_rewind(int newtime)
#endif /* #ifndef SIMULATOR */
}
-void mpeg_flush_and_reload_tracks(void)
+void audio_flush_and_reload_tracks(void)
{
#ifndef SIMULATOR
queue_post(&mpeg_queue, MPEG_FLUSH_RELOAD, NULL);
#endif /* #ifndef SIMULATOR*/
}
-int mpeg_status(void)
+int audio_status(void)
{
int ret = 0;
if(is_playing)
- ret |= MPEG_STATUS_PLAY;
+ ret |= AUDIO_STATUS_PLAY;
if(paused)
- ret |= MPEG_STATUS_PAUSE;
+ ret |= AUDIO_STATUS_PAUSE;
#if CONFIG_HWCODEC == MAS3587F
if(is_recording && !is_prerecording)
- ret |= MPEG_STATUS_RECORD;
+ ret |= AUDIO_STATUS_RECORD;
if(is_prerecording)
- ret |= MPEG_STATUS_PRERECORD;
+ ret |= AUDIO_STATUS_PRERECORD;
#endif /* #if CONFIG_HWCODEC == MAS3587F */
if(mpeg_errno)
- ret |= MPEG_STATUS_ERROR;
+ ret |= AUDIO_STATUS_ERROR;
return ret;
}
-unsigned int mpeg_error(void)
+unsigned int audio_error(void)
{
return mpeg_errno;
}
-void mpeg_error_clear(void)
+void audio_error_clear(void)
{
mpeg_errno = 0;
}
@@ -2745,21 +2746,21 @@ static void mpeg_thread(void)
struct mp3entry* id3;
while ( 1 ) {
if (is_playing) {
- id3 = mpeg_current_track();
+ id3 = audio_current_track();
if (!paused)
{
id3->elapsed+=1000;
id3->offset+=1000;
}
if (id3->elapsed>=id3->length)
- mpeg_next();
+ audio_next();
}
sleep(HZ);
}
}
#endif /* #ifdef SIMULATOR */
-void mpeg_init(void)
+void audio_init(void)
{
mpeg_errno = 0;
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 71b0f08fff..9cfacad9b0 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -31,7 +31,7 @@
#include "power.h"
#include "button.h"
#include "ata.h"
-#include "mpeg.h"
+#include "audio.h"
#include "mp3_playback.h"
#include "usb.h"
#include "powermgmt.h"
@@ -343,7 +343,7 @@ static void battery_level_update(void)
static void handle_auto_poweroff(void)
{
long timeout = poweroff_idle_timeout_value[poweroff_timeout]*60*HZ;
- int mpeg_stat = mpeg_status();
+ int audio_stat = audio_status();
#ifdef HAVE_CHARGING
/*
@@ -360,8 +360,8 @@ static void handle_auto_poweroff(void)
(radio_get_status() != FMRADIO_PLAYING) &&
#endif
!usb_inserted() &&
- ((mpeg_stat == 0) ||
- ((mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE)) &&
+ ((audio_stat == 0) ||
+ ((audio_stat == (AUDIO_STATUS_PLAY | AUDIO_STATUS_PAUSE)) &&
!sleeptimer_active)))
{
if(TIME_AFTER(current_tick, last_event_tick + timeout) &&
@@ -377,7 +377,7 @@ static void handle_auto_poweroff(void)
{
if(TIME_AFTER(current_tick, sleeptimer_endtick))
{
- mpeg_stop();
+ audio_stop();
#ifdef HAVE_CHARGING
if((charger_input_state == CHARGER) ||
(charger_input_state == CHARGER_PLUGGED))
@@ -413,8 +413,8 @@ static void car_adapter_mode_processing(void)
if (waiting_to_resume_play) {
if (TIME_AFTER(current_tick, play_resume_time)) {
- if (mpeg_status() & MPEG_STATUS_PAUSE) {
- mpeg_resume();
+ if (audio_status() & AUDIO_STATUS_PAUSE) {
+ audio_resume();
}
waiting_to_resume_play = false;
}
@@ -423,15 +423,15 @@ static void car_adapter_mode_processing(void)
/*
* Just got unplugged, pause if playing
*/
- if ((mpeg_status() & MPEG_STATUS_PLAY) &&
- !(mpeg_status() & MPEG_STATUS_PAUSE)) {
- mpeg_pause();
+ if ((audio_status() & AUDIO_STATUS_PLAY) &&
+ !(audio_status() & AUDIO_STATUS_PAUSE)) {
+ audio_pause();
}
} else if(charger_input_state == CHARGER_PLUGGED) {
/*
* Just got plugged in, delay & resume if we were playing
*/
- if (mpeg_status() & MPEG_STATUS_PAUSE) {
+ if (audio_status() & AUDIO_STATUS_PAUSE) {
/* delay resume a bit while the engine is cranking */
play_resume_time = current_tick + HZ*5;
waiting_to_resume_play = true;
@@ -920,7 +920,7 @@ void shutdown_hw(void)
fd = -1;
}
#endif
- mpeg_stop();
+ audio_stop();
ata_flush();
ata_spindown(1);
while(ata_disk_is_active())
diff --git a/firmware/rolo.c b/firmware/rolo.c
index ceb70791cf..e2ef26b3aa 100644
--- a/firmware/rolo.c
+++ b/firmware/rolo.c
@@ -23,7 +23,7 @@
#include "sprintf.h"
#include "button.h"
#include "file.h"
-#include "mpeg.h"
+#include "audio.h"
#include "system.h"
#include "i2c.h"
#include "string.h"
@@ -101,7 +101,7 @@ int rolo_load(const char* filename)
lcd_puts(0, 1, "Loading");
lcd_update();
- mpeg_stop();
+ audio_stop();
fd = open(filename, O_RDONLY);
if(-1 == fd) {
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index 3ed16e8e34..043744388c 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -183,7 +183,7 @@ void mpeg_set_pitch(int pitch)
(void)pitch;
}
-void mpeg_set_buffer_margin(int seconds)
+void audio_set_buffer_margin(int seconds)
{
(void)seconds;
}