summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugin.c3
-rw-r--r--apps/plugin.h15
-rw-r--r--apps/plugins/imageviewer/imageviewer.c2
-rw-r--r--apps/talk.c66
-rw-r--r--apps/voice_thread.c20
-rw-r--r--apps/voice_thread.h14
6 files changed, 38 insertions, 82 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 749132cde8..7ece50bfd3 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -597,9 +597,6 @@ static const struct plugin_api rockbox_api = {
597#if defined (HAVE_PITCHCONTROL) 597#if defined (HAVE_PITCHCONTROL)
598 sound_set_pitch, 598 sound_set_pitch,
599#endif 599#endif
600#if (CONFIG_PLATFORM & PLATFORM_NATIVE) && defined(HAVE_DISK_STORAGE)
601 mp3_is_playing,
602#endif
603 &audio_master_sampr_list[0], 600 &audio_master_sampr_list[0],
604 &hw_freq_sampr[0], 601 &hw_freq_sampr[0],
605 pcm_apply_settings, 602 pcm_apply_settings,
diff --git a/apps/plugin.h b/apps/plugin.h
index fc3da61c57..38d0ee0fff 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -155,12 +155,12 @@ int plugin_open(char *plugin, char *parameter);
155#define PLUGIN_MAGIC 0x526F634B /* RocK */ 155#define PLUGIN_MAGIC 0x526F634B /* RocK */
156 156
157/* increase this every time the api struct changes */ 157/* increase this every time the api struct changes */
158#define PLUGIN_API_VERSION 240 158#define PLUGIN_API_VERSION 241
159 159
160/* update this to latest version if a change to the api struct breaks 160/* update this to latest version if a change to the api struct breaks
161 backwards compatibility (and please take the opportunity to sort in any 161 backwards compatibility (and please take the opportunity to sort in any
162 new function which are "waiting" at the end of the function table) */ 162 new function which are "waiting" at the end of the function table) */
163#define PLUGIN_MIN_API_VERSION 239 163#define PLUGIN_MIN_API_VERSION 241
164 164
165/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ 165/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
166 166
@@ -669,9 +669,6 @@ struct plugin_api {
669#if defined (HAVE_PITCHCONTROL) 669#if defined (HAVE_PITCHCONTROL)
670 void (*sound_set_pitch)(int32_t pitch); 670 void (*sound_set_pitch)(int32_t pitch);
671#endif 671#endif
672#if (CONFIG_PLATFORM & PLATFORM_NATIVE) && defined(HAVE_DISK_STORAGE)
673 bool (*mp3_is_playing)(void);
674#endif /* PLATFORM_NATIVE */
675 const unsigned long *audio_master_sampr_list; 672 const unsigned long *audio_master_sampr_list;
676 const unsigned long *hw_freq_sampr; 673 const unsigned long *hw_freq_sampr;
677 void (*pcm_apply_settings)(void); 674 void (*pcm_apply_settings)(void);
@@ -765,6 +762,7 @@ struct plugin_api {
765#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) 762#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
766 bool (*tagcache_fill_tags)(struct mp3entry *id3, const char *filename); 763 bool (*tagcache_fill_tags)(struct mp3entry *id3, const char *filename);
767#endif 764#endif
765 struct tagcache_stat* (*tagcache_get_stat)(void);
768#endif /* HAVE_TAGCACHE */ 766#endif /* HAVE_TAGCACHE */
769 767
770#ifdef HAVE_ALBUMART 768#ifdef HAVE_ALBUMART
@@ -920,6 +918,7 @@ struct plugin_api {
920 void (*led)(bool on); 918 void (*led)(bool on);
921 919
922 /*plugin*/ 920 /*plugin*/
921 int (*plugin_open)(char *path, char *parameter);
923 void* (*plugin_get_buffer)(size_t *buffer_size); 922 void* (*plugin_get_buffer)(size_t *buffer_size);
924 void* (*plugin_get_audio_buffer)(size_t *buffer_size); 923 void* (*plugin_get_audio_buffer)(size_t *buffer_size);
925 void (*plugin_release_audio_buffer)(void); 924 void (*plugin_release_audio_buffer)(void);
@@ -929,14 +928,8 @@ struct plugin_api {
929 void (*audio_hard_stop)(void); 928 void (*audio_hard_stop)(void);
930#endif 929#endif
931 930
932
933 /* new stuff at the end, sort into place next time 931 /* new stuff at the end, sort into place next time
934 the API gets incompatible */ 932 the API gets incompatible */
935
936#ifdef HAVE_TAGCACHE
937 struct tagcache_stat* (*tagcache_get_stat)(void);
938#endif
939 int (*plugin_open)(char *path, char *parameter);
940 933
941}; 934};
942 935
diff --git a/apps/plugins/imageviewer/imageviewer.c b/apps/plugins/imageviewer/imageviewer.c
index 4070f4b513..8e23787704 100644
--- a/apps/plugins/imageviewer/imageviewer.c
+++ b/apps/plugins/imageviewer/imageviewer.c
@@ -326,7 +326,7 @@ static int show_menu(void) /* return 1 to quit */
326 /* slideshow times < 10s keep disk spinning */ 326 /* slideshow times < 10s keep disk spinning */
327 rb->storage_spindown(0); 327 rb->storage_spindown(0);
328 } 328 }
329 else if (!rb->mp3_is_playing()) 329 else if (!rb->pcm_is_playing())
330 { 330 {
331 /* slideshow times > 10s and not playing: ata_off after load */ 331 /* slideshow times > 10s and not playing: ata_off after load */
332 iv_api.immediate_ata_off = true; 332 iv_api.immediate_ata_off = true;
diff --git a/apps/talk.c b/apps/talk.c
index 4b65700a5d..5d292b05d1 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -46,25 +46,6 @@
46#include "panic.h" 46#include "panic.h"
47#include "misc.h" /* time_split_units() */ 47#include "misc.h" /* time_split_units() */
48 48
49/* Memory layout varies between targets because the
50 Archos (MASCODEC) devices cannot mix voice and audio playback
51
52 MASCODEC | MASCODEC | SWCODEC
53 (playing) | (stopped) |
54 voicebuf-----------+-----------+------------
55 audio | voice | voice
56 |-----------|------------
57 | thumbnail | thumbnail
58 | |------------
59 | | filebuf
60 | |------------
61 | | audio
62 voicebufend----------+-----------+------------
63
64 SWCODEC allocates dedicated buffers (except voice and thumbnail are together
65 in the talkbuf), MASCODEC reuses audiobuf. */
66
67
68/***************** Constants *****************/ 49/***************** Constants *****************/
69 50
70#define QUEUE_SIZE 64 /* must be a power of two */ 51#define QUEUE_SIZE 64 /* must be a power of two */
@@ -128,7 +109,7 @@ static int queue_write; /* write index of queue, by application */
128static int queue_read; /* read index of queue, by ISR context */ 109static int queue_read; /* read index of queue, by ISR context */
129static enum talk_status talk_status = TALK_STATUS_OK; 110static enum talk_status talk_status = TALK_STATUS_OK;
130/* protects queue_read, queue_write and thumbnail_buf_used */ 111/* protects queue_read, queue_write and thumbnail_buf_used */
131static struct mutex queue_mutex SHAREDBSS_ATTR; 112static struct mutex queue_mutex SHAREDBSS_ATTR;
132#define talk_queue_lock() ({ mutex_lock(&queue_mutex); }) 113#define talk_queue_lock() ({ mutex_lock(&queue_mutex); })
133#define talk_queue_unlock() ({ mutex_unlock(&queue_mutex); }) 114#define talk_queue_unlock() ({ mutex_unlock(&queue_mutex); })
134static int sent; /* how many bytes handed over to playback, owned by ISR */ 115static int sent; /* how many bytes handed over to playback, owned by ISR */
@@ -182,7 +163,7 @@ static inline bool check_audio_status(void)
182 return true; 163 return true;
183} 164}
184 165
185/* ISR (mp3_callback()) must not run during moving of the clip buffer, 166/* ISR (voice_callback()) must not run during moving of the clip buffer,
186 * because the MAS may get out-of-sync */ 167 * because the MAS may get out-of-sync */
187static void sync_callback(int handle, bool sync_on) 168static void sync_callback(int handle, bool sync_on)
188{ 169{
@@ -269,13 +250,13 @@ static int open_voicefile(void)
269 char* p_lang = DEFAULT_VOICE_LANG; /* default */ 250 char* p_lang = DEFAULT_VOICE_LANG; /* default */
270 251
271 if ( global_settings.lang_file[0] && 252 if ( global_settings.lang_file[0] &&
272 global_settings.lang_file[0] != 0xff ) 253 global_settings.lang_file[0] != 0xff )
273 { /* try to open the voice file of the selected language */ 254 { /* try to open the voice file of the selected language */
274 p_lang = (char *)global_settings.lang_file; 255 p_lang = (char *)global_settings.lang_file;
275 } 256 }
276 257
277 snprintf(buf, sizeof(buf), LANG_DIR "/%s.voice", p_lang); 258 snprintf(buf, sizeof(buf), LANG_DIR "/%s.voice", p_lang);
278 259
279 return open(buf, O_RDONLY); 260 return open(buf, O_RDONLY);
280} 261}
281 262
@@ -725,7 +706,7 @@ static void mp3_callback(const void** start, size_t* size)
725 curr_hd[1] = commit_buffer[2]; 706 curr_hd[1] = commit_buffer[2];
726 curr_hd[2] = commit_buffer[3]; 707 curr_hd[2] = commit_buffer[3];
727 } 708 }
728 709
729 talk_queue_unlock(); 710 talk_queue_unlock();
730} 711}
731 712
@@ -735,7 +716,7 @@ static void mp3_callback(const void** start, size_t* size)
735void talk_force_shutup(void) 716void talk_force_shutup(void)
736{ 717{
737 /* Had nothing to do (was frame boundary or not our clip) */ 718 /* Had nothing to do (was frame boundary or not our clip) */
738 mp3_play_stop(); 719 voice_play_stop();
739 talk_queue_lock(); 720 talk_queue_lock();
740 queue_write = queue_read = 0; /* reset the queue */ 721 queue_write = queue_read = 0; /* reset the queue */
741 thumbnail_buf_used = 0; 722 thumbnail_buf_used = 0;
@@ -761,7 +742,7 @@ static void queue_clip(struct queue_entry *clip, bool enqueue)
761 /* Something is being enqueued, force_enqueue_next override is no 742 /* Something is being enqueued, force_enqueue_next override is no
762 longer in effect. */ 743 longer in effect. */
763 force_enqueue_next = false; 744 force_enqueue_next = false;
764 745
765 if (!clip->length) 746 if (!clip->length)
766 return; /* safety check */ 747 return; /* safety check */
767 talk_queue_lock(); 748 talk_queue_lock();
@@ -780,11 +761,10 @@ static void queue_clip(struct queue_entry *clip, bool enqueue)
780 size_t size; 761 size_t size;
781 void *buf = commit_transfer(qe, &size); 762 void *buf = commit_transfer(qe, &size);
782 last_clip = qe; 763 last_clip = qe;
783 mp3_play_data(buf, size, mp3_callback); 764 voice_play_data(buf, size, mp3_callback);
784 curr_hd[0] = commit_buffer[1]; 765 curr_hd[0] = commit_buffer[1];
785 curr_hd[1] = commit_buffer[2]; 766 curr_hd[1] = commit_buffer[2];
786 curr_hd[2] = commit_buffer[3]; 767 curr_hd[2] = commit_buffer[3];
787 mp3_play_pause(true); /* kickoff audio */
788 } 768 }
789 769
790 need_shutup = true; 770 need_shutup = true;
@@ -864,7 +844,7 @@ void talk_init(void)
864 } 844 }
865 avg_size = total_size / non_empty; 845 avg_size = total_size / non_empty;
866 max_clips = MIN((int)(MAX_CLIP_BUFFER_SIZE/avg_size) + 1, non_empty); 846 max_clips = MIN((int)(MAX_CLIP_BUFFER_SIZE/avg_size) + 1, non_empty);
867 /* account for possible thumb clips */ 847 /* account for possible thumb clips */
868 total_size += THUMBNAIL_RESERVE; 848 total_size += THUMBNAIL_RESERVE;
869 max_clips += 16; 849 max_clips += 16;
870 voicefile_size = total_size; 850 voicefile_size = total_size;
@@ -1156,19 +1136,19 @@ int talk_number(long n, bool enqueue)
1156 1136
1157 if (!enqueue) 1137 if (!enqueue)
1158 talk_shutup(); /* cut off all the pending stuff */ 1138 talk_shutup(); /* cut off all the pending stuff */
1159 1139
1160 if (n==0) 1140 if (n==0)
1161 { /* special case */ 1141 { /* special case */
1162 talk_id(VOICE_ZERO, true); 1142 talk_id(VOICE_ZERO, true);
1163 return 0; 1143 return 0;
1164 } 1144 }
1165 1145
1166 if (n<0) 1146 if (n<0)
1167 { 1147 {
1168 talk_id(VOICE_MINUS, true); 1148 talk_id(VOICE_MINUS, true);
1169 n = -n; 1149 n = -n;
1170 } 1150 }
1171 1151
1172 while (n) 1152 while (n)
1173 { 1153 {
1174 int segment = n / mil; /* extract in groups of 3 digits */ 1154 int segment = n / mil; /* extract in groups of 3 digits */
@@ -1197,7 +1177,7 @@ int talk_number(long n, bool enqueue)
1197 /* direct indexing */ 1177 /* direct indexing */
1198 if (ones) 1178 if (ones)
1199 talk_id(VOICE_ZERO + ones, true); 1179 talk_id(VOICE_ZERO + ones, true);
1200 1180
1201 /* add billion, million, thousand */ 1181 /* add billion, million, thousand */
1202 if (mil) 1182 if (mil)
1203 talk_id(VOICE_THOUSAND + level, true); 1183 talk_id(VOICE_THOUSAND + level, true);
@@ -1261,21 +1241,21 @@ int talk_value(long n, int unit, bool enqueue)
1261int talk_value_decimal(long n, int unit, int decimals, bool enqueue) 1241int talk_value_decimal(long n, int unit, int decimals, bool enqueue)
1262{ 1242{
1263 int unit_id; 1243 int unit_id;
1264 static const int unit_voiced[] = 1244 static const int unit_voiced[] =
1265 { /* lookup table for the voice ID of the units */ 1245 { /* lookup table for the voice ID of the units */
1266 [0 ... UNIT_LAST-1] = -1, /* regular ID, int, signed */ 1246 [0 ... UNIT_LAST-1] = -1, /* regular ID, int, signed */
1267 [UNIT_MS] 1247 [UNIT_MS]
1268 = VOICE_MILLISECONDS, /* here come the "real" units */ 1248 = VOICE_MILLISECONDS, /* here come the "real" units */
1269 [UNIT_SEC] 1249 [UNIT_SEC]
1270 = VOICE_SECONDS, 1250 = VOICE_SECONDS,
1271 [UNIT_MIN] 1251 [UNIT_MIN]
1272 = VOICE_MINUTES, 1252 = VOICE_MINUTES,
1273 [UNIT_HOUR] 1253 [UNIT_HOUR]
1274 = VOICE_HOURS, 1254 = VOICE_HOURS,
1275 [UNIT_KHZ] 1255 [UNIT_KHZ]
1276 = VOICE_KHZ, 1256 = VOICE_KHZ,
1277 [UNIT_DB] 1257 [UNIT_DB]
1278 = VOICE_DB, 1258 = VOICE_DB,
1279 [UNIT_PERCENT] 1259 [UNIT_PERCENT]
1280 = VOICE_PERCENT, 1260 = VOICE_PERCENT,
1281 [UNIT_MAH] 1261 [UNIT_MAH]
@@ -1411,7 +1391,7 @@ int talk_time_intervals(long time, int unit_idx, bool enqueue)
1411int talk_spell(const char* spell, bool enqueue) 1391int talk_spell(const char* spell, bool enqueue)
1412{ 1392{
1413 char c; /* currently processed char */ 1393 char c; /* currently processed char */
1414 1394
1415 if (talk_temp_disable_count > 0) 1395 if (talk_temp_disable_count > 0)
1416 return -1; /* talking has been disabled */ 1396 return -1; /* talking has been disabled */
1417 if (!check_audio_status()) 1397 if (!check_audio_status())
@@ -1419,7 +1399,7 @@ int talk_spell(const char* spell, bool enqueue)
1419 1399
1420 if (!enqueue) 1400 if (!enqueue)
1421 talk_shutup(); /* cut off all the pending stuff */ 1401 talk_shutup(); /* cut off all the pending stuff */
1422 1402
1423 while ((c = *spell++) != '\0') 1403 while ((c = *spell++) != '\0')
1424 { 1404 {
1425 /* if this grows into too many cases, I should use a table */ 1405 /* if this grows into too many cases, I should use a table */
@@ -1434,7 +1414,7 @@ int talk_spell(const char* spell, bool enqueue)
1434 else if (c == '+') 1414 else if (c == '+')
1435 talk_id(VOICE_PLUS, true); 1415 talk_id(VOICE_PLUS, true);
1436 else if (c == '.') 1416 else if (c == '.')
1437 talk_id(VOICE_DOT, true); 1417 talk_id(VOICE_DOT, true);
1438 else if (c == ' ') 1418 else if (c == ' ')
1439 talk_id(VOICE_PAUSE, true); 1419 talk_id(VOICE_PAUSE, true);
1440 else if (c == '/') 1420 else if (c == '/')
@@ -1448,7 +1428,7 @@ void talk_disable(bool disable)
1448{ 1428{
1449 if (disable) 1429 if (disable)
1450 talk_temp_disable_count++; 1430 talk_temp_disable_count++;
1451 else 1431 else
1452 talk_temp_disable_count--; 1432 talk_temp_disable_count--;
1453} 1433}
1454 1434
diff --git a/apps/voice_thread.c b/apps/voice_thread.c
index 325860be27..171902d10f 100644
--- a/apps/voice_thread.c
+++ b/apps/voice_thread.c
@@ -121,7 +121,7 @@ enum voice_thread_messages
121struct voice_info 121struct voice_info
122{ 122{
123 /* Callback to get more clips */ 123 /* Callback to get more clips */
124 mp3_play_callback_t get_more; 124 voice_play_callback_t get_more;
125 /* Start of clip */ 125 /* Start of clip */
126 const void *start; 126 const void *start;
127 /* Size of clip */ 127 /* Size of clip */
@@ -276,8 +276,8 @@ static void voice_buf_commit(int count)
276} 276}
277 277
278/* Stop any current clip and start playing a new one */ 278/* Stop any current clip and start playing a new one */
279void mp3_play_data(const void *start, size_t size, 279void voice_play_data(const void *start, size_t size,
280 mp3_play_callback_t get_more) 280 voice_play_callback_t get_more)
281{ 281{
282 if (voice_thread_id && start && size && get_more) 282 if (voice_thread_id && start && size && get_more)
283 { 283 {
@@ -294,7 +294,7 @@ void mp3_play_data(const void *start, size_t size,
294} 294}
295 295
296/* Stop current voice clip from playing */ 296/* Stop current voice clip from playing */
297void mp3_play_stop(void) 297void voice_play_stop(void)
298{ 298{
299 if (voice_thread_id != 0) 299 if (voice_thread_id != 0)
300 { 300 {
@@ -303,18 +303,6 @@ void mp3_play_stop(void)
303 } 303 }
304} 304}
305 305
306void mp3_play_pause(bool play)
307{
308 /* a dummy */
309 (void)play;
310}
311
312/* Tell if voice is still in a playing state */
313bool mp3_is_playing(void)
314{
315 return voice_playing;
316}
317
318/* This function is meant to be used by the buffer request functions to 306/* This function is meant to be used by the buffer request functions to
319 ensure the codec is no longer active */ 307 ensure the codec is no longer active */
320void voice_stop(void) 308void voice_stop(void)
diff --git a/apps/voice_thread.h b/apps/voice_thread.h
index 8a17ee09e3..d662aaee33 100644
--- a/apps/voice_thread.h
+++ b/apps/voice_thread.h
@@ -23,16 +23,14 @@
23 23
24#include "config.h" 24#include "config.h"
25 25
26#ifndef MP3_PLAY_CALLBACK_DEFINED 26#ifndef VOICE_PLAY_CALLBACK_DEFINED
27#define MP3_PLAY_CALLBACK_DEFINED 27#define VOICE_PLAY_CALLBACK_DEFINED
28typedef void (*mp3_play_callback_t)(const void **start, size_t *size); 28typedef void (*voice_play_callback_t)(const void **start, size_t *size);
29#endif 29#endif
30 30
31void mp3_play_data(const void *start, size_t size, 31void voice_play_data(const void *start, size_t size,
32 mp3_play_callback_t get_more); 32 voice_play_callback_t get_more);
33void mp3_play_stop(void); 33void voice_play_stop(void);
34void mp3_play_pause(bool play);
35bool mp3_is_playing(void);
36 34
37void voice_wait(void); 35void voice_wait(void);
38void voice_stop(void); 36void voice_stop(void);