summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/action.c4
-rw-r--r--apps/gui/wps.c3
-rw-r--r--apps/misc.c48
-rw-r--r--apps/misc.h22
-rw-r--r--apps/playback.c6
-rw-r--r--apps/plugin.c7
-rw-r--r--apps/plugin.h12
-rw-r--r--apps/plugins/mpegplayer/mpeg_misc.c4
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c26
-rw-r--r--apps/plugins/mpegplayer/pcm_output.c65
10 files changed, 149 insertions, 48 deletions
diff --git a/apps/action.c b/apps/action.c
index aa19403703..15b2d8a4c8 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -203,9 +203,7 @@ static int get_action_worker(int context, int timeout,
203 203
204#if CONFIG_CODEC == SWCODEC 204#if CONFIG_CODEC == SWCODEC
205 /* Produce keyclick */ 205 /* Produce keyclick */
206 if (global_settings.keyclick && !(button & BUTTON_REL)) 206 keyclick_click(button);
207 if (!(button & BUTTON_REPEAT) || global_settings.keyclick_repeats)
208 beep_play(4000, KEYCLICK_DURATION, 2500*global_settings.keyclick);
209#endif 207#endif
210 208
211 if ((context != last_context) && ((last_button & BUTTON_REL) == 0) 209 if ((context != last_context) && ((last_button & BUTTON_REL) == 0)
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index cbf003adbd..80522d04bd 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -577,8 +577,7 @@ static void play_hop(int direction)
577 else if (direction == 1 && step >= remaining) 577 else if (direction == 1 && step >= remaining)
578 { 578 {
579#if CONFIG_CODEC == SWCODEC 579#if CONFIG_CODEC == SWCODEC
580 if(global_settings.beep) 580 system_sound_play(SOUND_TRACK_NO_MORE);
581 beep_play(1000, 150, 1500*global_settings.beep);
582#endif 581#endif
583 return; 582 return;
584 } 583 }
diff --git a/apps/misc.c b/apps/misc.c
index dfee05fb5a..1800342a50 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -1037,3 +1037,51 @@ enum current_activity get_current_activity(void)
1037 return current_activity[current_activity_top?current_activity_top-1:0]; 1037 return current_activity[current_activity_top?current_activity_top-1:0];
1038} 1038}
1039 1039
1040#if CONFIG_CODEC == SWCODEC
1041/* Play a standard sound */
1042void system_sound_play(enum system_sound sound)
1043{
1044 static const struct beep_params
1045 {
1046 int *setting;
1047 unsigned short frequency;
1048 unsigned short duration;
1049 unsigned short amplitude;
1050 } beep_params[] =
1051 {
1052 [SOUND_KEYCLICK] =
1053 { &global_settings.keyclick,
1054 4000, KEYCLICK_DURATION, 2500 },
1055 [SOUND_TRACK_SKIP] =
1056 { &global_settings.beep,
1057 2000, 100, 2500 },
1058 [SOUND_TRACK_NO_MORE] =
1059 { &global_settings.beep,
1060 1000, 100, 1500 },
1061 };
1062
1063 const struct beep_params *params = &beep_params[sound];
1064
1065 if (*params->setting)
1066 {
1067 beep_play(params->frequency, params->duration,
1068 params->amplitude * *params->setting);
1069 }
1070}
1071
1072/* Produce keyclick based upon button and global settings */
1073void keyclick_click(int button)
1074{
1075 /* Settings filters */
1076 if (global_settings.keyclick &&
1077 (global_settings.keyclick_repeats || !(button & BUTTON_REPEAT)))
1078 {
1079 /* Button filters */
1080 if (button != BUTTON_NONE && !(button & BUTTON_REL)
1081 && !(button & (SYS_EVENT|BUTTON_MULTIMEDIA)) )
1082 {
1083 system_sound_play(SOUND_KEYCLICK);
1084 }
1085 }
1086}
1087#endif /* CONFIG_CODEC == SWCODEC */
diff --git a/apps/misc.h b/apps/misc.h
index c3c52d13e0..7ea5360db5 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -100,9 +100,6 @@ int clamp_value_wrap(int value, int max, int min);
100#endif 100#endif
101#endif 101#endif
102 102
103void beep_play(unsigned int frequency, unsigned int duration,
104 unsigned int amplitude);
105
106enum current_activity { 103enum current_activity {
107 ACTIVITY_UNKNOWN = 0, 104 ACTIVITY_UNKNOWN = 0,
108 ACTIVITY_MAINMENU, 105 ACTIVITY_MAINMENU,
@@ -118,6 +115,25 @@ enum current_activity {
118 ACTIVITY_PITCHSCREEN, 115 ACTIVITY_PITCHSCREEN,
119 ACTIVITY_OPTIONSELECT 116 ACTIVITY_OPTIONSELECT
120}; 117};
118
119#if CONFIG_CODEC == SWCODEC
120void beep_play(unsigned int frequency, unsigned int duration,
121 unsigned int amplitude);
122
123enum system_sound
124{
125 SOUND_KEYCLICK = 0,
126 SOUND_TRACK_SKIP,
127 SOUND_TRACK_NO_MORE,
128};
129
130/* Play a standard sound */
131void system_sound_play(enum system_sound sound);
132
133/* Produce keyclick based upon button and global settings */
134void keyclick_click(int button);
135#endif /* CONFIG_CODEC == SWCODEC */
136
121void push_current_activity(enum current_activity screen); 137void push_current_activity(enum current_activity screen);
122void pop_current_activity(void); 138void pop_current_activity(void);
123enum current_activity get_current_activity(void); 139enum current_activity get_current_activity(void);
diff --git a/apps/playback.c b/apps/playback.c
index cbb94a9d22..c74c606016 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -3352,8 +3352,7 @@ void audio_skip(int offset)
3352 processed one */ 3352 processed one */
3353 skip_offset = accum; 3353 skip_offset = accum;
3354 3354
3355 if (global_settings.beep) 3355 system_sound_play(SOUND_TRACK_SKIP);
3356 beep_play(2000, 100, 2500*global_settings.beep);
3357 3356
3358 LOGFQUEUE("audio > audio Q_AUDIO_SKIP %d", offset); 3357 LOGFQUEUE("audio > audio Q_AUDIO_SKIP %d", offset);
3359 3358
@@ -3373,8 +3372,7 @@ void audio_skip(int offset)
3373 else 3372 else
3374 { 3373 {
3375 /* No more tracks */ 3374 /* No more tracks */
3376 if (global_settings.beep) 3375 system_sound_play(SOUND_TRACK_NO_MORE);
3377 beep_play(1000, 100, 1500*global_settings.beep);
3378 } 3376 }
3379 3377
3380 id3_mutex_unlock(); 3378 id3_mutex_unlock();
diff --git a/apps/plugin.c b/apps/plugin.c
index 6b3d39973f..b47dd951ea 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -782,6 +782,13 @@ static const struct plugin_api rockbox_api = {
782 mixer_channel_status, 782 mixer_channel_status,
783 mixer_channel_get_buffer, 783 mixer_channel_get_buffer,
784 mixer_channel_calculate_peaks, 784 mixer_channel_calculate_peaks,
785 mixer_channel_play_data,
786 mixer_channel_play_pause,
787 mixer_channel_stop,
788 mixer_channel_set_amplitude,
789 mixer_channel_get_bytes_waiting,
790 system_sound_play,
791 keyclick_click,
785#endif 792#endif
786}; 793};
787 794
diff --git a/apps/plugin.h b/apps/plugin.h
index 77c8e831d4..e9c0c64a00 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -146,7 +146,7 @@ void* plugin_get_buffer(size_t *buffer_size);
146#define PLUGIN_MAGIC 0x526F634B /* RocK */ 146#define PLUGIN_MAGIC 0x526F634B /* RocK */
147 147
148/* increase this every time the api struct changes */ 148/* increase this every time the api struct changes */
149#define PLUGIN_API_VERSION 207 149#define PLUGIN_API_VERSION 208
150 150
151/* update this to latest version if a change to the api struct breaks 151/* update this to latest version if a change to the api struct breaks
152 backwards compatibility (and please take the opportunity to sort in any 152 backwards compatibility (and please take the opportunity to sort in any
@@ -913,6 +913,16 @@ struct plugin_api {
913 void * (*mixer_channel_get_buffer)(enum pcm_mixer_channel channel, int *count); 913 void * (*mixer_channel_get_buffer)(enum pcm_mixer_channel channel, int *count);
914 void (*mixer_channel_calculate_peaks)(enum pcm_mixer_channel channel, 914 void (*mixer_channel_calculate_peaks)(enum pcm_mixer_channel channel,
915 int *left, int *right); 915 int *left, int *right);
916 void (*mixer_channel_play_data)(enum pcm_mixer_channel channel,
917 pcm_play_callback_type get_more,
918 unsigned char *start, size_t size);
919 void (*mixer_channel_play_pause)(enum pcm_mixer_channel channel, bool play);
920 void (*mixer_channel_stop)(enum pcm_mixer_channel channel);
921 void (*mixer_channel_set_amplitude)(enum pcm_mixer_channel channel,
922 unsigned int amplitude);
923 size_t (*mixer_channel_get_bytes_waiting)(enum pcm_mixer_channel channel);
924 void (*system_sound_play)(enum system_sound sound);
925 void (*keyclick_click)(int button);
916#endif 926#endif
917}; 927};
918 928
diff --git a/apps/plugins/mpegplayer/mpeg_misc.c b/apps/plugins/mpegplayer/mpeg_misc.c
index d9e033322e..895fbe04a9 100644
--- a/apps/plugins/mpegplayer/mpeg_misc.c
+++ b/apps/plugins/mpegplayer/mpeg_misc.c
@@ -214,6 +214,10 @@ int mpeg_button_get(int timeout)
214 mpeg_sysevent_clear(); 214 mpeg_sysevent_clear();
215 button = timeout == TIMEOUT_BLOCK ? rb->button_get(true) : 215 button = timeout == TIMEOUT_BLOCK ? rb->button_get(true) :
216 rb->button_get_w_tmo(timeout); 216 rb->button_get_w_tmo(timeout);
217
218 /* Produce keyclick */
219 rb->keyclick_click(button);
220
217 return mpeg_sysevent_callback(button, NULL); 221 return mpeg_sysevent_callback(button, NULL);
218} 222}
219 223
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 41f6b2e868..c6e1f4dded 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -386,6 +386,7 @@ enum video_action
386 VIDEO_STOP = 0, 386 VIDEO_STOP = 0,
387 VIDEO_PREV, 387 VIDEO_PREV,
388 VIDEO_NEXT, 388 VIDEO_NEXT,
389 VIDEO_ACTION_MANUAL = 0x8000, /* Flag that says user did it */
389}; 390};
390 391
391/* OSD status - same order as icon array */ 392/* OSD status - same order as icon array */
@@ -2139,7 +2140,7 @@ static int button_loop(void)
2139 /* Release within 3 seconds of start: skip to previous 2140 /* Release within 3 seconds of start: skip to previous
2140 * file */ 2141 * file */
2141 osd_stop(); 2142 osd_stop();
2142 next_action = VIDEO_PREV; 2143 next_action = VIDEO_PREV | VIDEO_ACTION_MANUAL;
2143 } 2144 }
2144 } 2145 }
2145 else if ((button & ~BUTTON_REPEAT) == old_button) { 2146 else if ((button & ~BUTTON_REPEAT) == old_button) {
@@ -2169,7 +2170,7 @@ static int button_loop(void)
2169 if ((old_button | BUTTON_REL) == button) { 2170 if ((old_button | BUTTON_REL) == button) {
2170 /* If button has been released: skip to next file */ 2171 /* If button has been released: skip to next file */
2171 osd_stop(); 2172 osd_stop();
2172 next_action = VIDEO_NEXT; 2173 next_action = VIDEO_NEXT | VIDEO_ACTION_MANUAL;
2173 } 2174 }
2174 else if ((button & ~BUTTON_REPEAT) == old_button) { 2175 else if ((button & ~BUTTON_REPEAT) == old_button) {
2175 button = osd_seek_btn(old_button); 2176 button = osd_seek_btn(old_button);
@@ -2251,11 +2252,10 @@ enum plugin_status plugin_start(const void* parameter)
2251 2252
2252 while (!quit) 2253 while (!quit)
2253 { 2254 {
2254 int result;
2255
2256 init_settings(videofile); 2255 init_settings(videofile);
2257 2256
2258 result = stream_open(videofile); 2257 int result = stream_open(videofile);
2258 bool manual_skip = false;
2259 2259
2260 if (result >= STREAM_OK) { 2260 if (result >= STREAM_OK) {
2261 /* start menu */ 2261 /* start menu */
@@ -2267,6 +2267,8 @@ enum plugin_status plugin_start(const void* parameter)
2267 if (result != MPEG_START_QUIT) { 2267 if (result != MPEG_START_QUIT) {
2268 /* Enter button loop and process UI */ 2268 /* Enter button loop and process UI */
2269 next_action = button_loop(); 2269 next_action = button_loop();
2270 manual_skip = next_action & VIDEO_ACTION_MANUAL;
2271 next_action &= ~VIDEO_ACTION_MANUAL;
2270 } 2272 }
2271 2273
2272 stream_close(); 2274 stream_close();
@@ -2341,6 +2343,13 @@ enum plugin_status plugin_start(const void* parameter)
2341 sizeof(videofile)); 2343 sizeof(videofile));
2342 /* quit after finished the last videofile */ 2344 /* quit after finished the last videofile */
2343 quit = !get_videofile_says; 2345 quit = !get_videofile_says;
2346
2347 if (manual_skip)
2348 {
2349 rb->system_sound_play(get_videofile_says ?
2350 SOUND_TRACK_SKIP : SOUND_TRACK_NO_MORE);
2351 }
2352
2344 break; 2353 break;
2345 } 2354 }
2346 case VIDEO_PREV: 2355 case VIDEO_PREV:
@@ -2348,6 +2357,13 @@ enum plugin_status plugin_start(const void* parameter)
2348 get_videofile_says = get_videofile(VIDEO_PREV, videofile, 2357 get_videofile_says = get_videofile(VIDEO_PREV, videofile,
2349 sizeof(videofile)); 2358 sizeof(videofile));
2350 /* if there is no previous file, play the same videofile */ 2359 /* if there is no previous file, play the same videofile */
2360
2361 if (manual_skip)
2362 {
2363 rb->system_sound_play(get_videofile_says ?
2364 SOUND_TRACK_SKIP : SOUND_TRACK_NO_MORE);
2365 }
2366
2351 break; 2367 break;
2352 } 2368 }
2353 case VIDEO_STOP: 2369 case VIDEO_STOP:
diff --git a/apps/plugins/mpegplayer/pcm_output.c b/apps/plugins/mpegplayer/pcm_output.c
index fb7ff434aa..8db9531049 100644
--- a/apps/plugins/mpegplayer/pcm_output.c
+++ b/apps/plugins/mpegplayer/pcm_output.c
@@ -23,6 +23,9 @@
23#include "plugin.h" 23#include "plugin.h"
24#include "mpegplayer.h" 24#include "mpegplayer.h"
25 25
26/* PCM channel we're using */
27#define MPEG_PCM_CHANNEL PCM_MIXER_CHAN_PLAYBACK
28
26/* Pointers */ 29/* Pointers */
27 30
28/* Start of buffer */ 31/* Start of buffer */
@@ -217,24 +220,22 @@ bool pcm_output_empty(void)
217/* Flushes the buffer - clock keeps counting */ 220/* Flushes the buffer - clock keeps counting */
218void pcm_output_flush(void) 221void pcm_output_flush(void)
219{ 222{
220 bool playing, paused;
221
222 rb->pcm_play_lock(); 223 rb->pcm_play_lock();
223 224
224 playing = rb->pcm_is_playing(); 225 enum channel_status status = rb->mixer_channel_status(MPEG_PCM_CHANNEL);
225 paused = rb->pcm_is_paused();
226 226
227 /* Stop PCM to clear current buffer */ 227 /* Stop PCM to clear current buffer */
228 if (playing) 228 if (status != CHANNEL_STOPPED)
229 rb->pcm_play_stop(); 229 rb->mixer_channel_stop(MPEG_PCM_CHANNEL);
230
231 rb->pcm_play_unlock();
230 232
231 pcm_reset_buffer(); 233 pcm_reset_buffer();
232 234
233 /* Restart if playing state was current */ 235 /* Restart if playing state was current */
234 if (playing && !paused) 236 if (status == CHANNEL_PLAYING)
235 rb->pcm_play_data(get_more, NULL, 0); 237 rb->mixer_channel_play_data(MPEG_PCM_CHANNEL,
236 238 get_more, NULL, 0);
237 rb->pcm_play_unlock();
238} 239}
239 240
240/* Seek the reference clock to the specified time - next audio data ready to 241/* Seek the reference clock to the specified time - next audio data ready to
@@ -264,10 +265,12 @@ uint32_t pcm_output_get_clock(void)
264 do 265 do
265 { 266 {
266 time = clock_time; 267 time = clock_time;
267 rem = rb->pcm_get_bytes_waiting() >> 2; 268 rem = rb->mixer_channel_get_bytes_waiting(MPEG_PCM_CHANNEL) >> 2;
268 } 269 }
269 while (UNLIKELY(time != clock_time || 270 while (UNLIKELY(time != clock_time ||
270 (rem == 0 && rb->pcm_is_playing() && !rb->pcm_is_paused()))); 271 (rem == 0 &&
272 rb->mixer_channel_status(MPEG_PCM_CHANNEL) == CHANNEL_PLAYING))
273 );
271 274
272 return time - rem; 275 return time - rem;
273 276
@@ -283,10 +286,12 @@ uint32_t pcm_output_get_ticks(uint32_t *start)
283 do 286 do
284 { 287 {
285 tick = clock_tick; 288 tick = clock_tick;
286 rem = rb->pcm_get_bytes_waiting() >> 2; 289 rem = rb->mixer_channel_get_bytes_waiting(MPEG_PCM_CHANNEL) >> 2;
287 } 290 }
288 while (UNLIKELY(tick != clock_tick || 291 while (UNLIKELY(tick != clock_tick ||
289 (rem == 0 && rb->pcm_is_playing() && !rb->pcm_is_paused()))); 292 (rem == 0 &&
293 rb->mixer_channel_status(MPEG_PCM_CHANNEL) == CHANNEL_PLAYING))
294 );
290 295
291 if (start) 296 if (start)
292 *start = clock_start; 297 *start = clock_start;
@@ -299,16 +304,22 @@ void pcm_output_play_pause(bool play)
299{ 304{
300 rb->pcm_play_lock(); 305 rb->pcm_play_lock();
301 306
302 if (rb->pcm_is_playing()) 307 if (rb->mixer_channel_status(MPEG_PCM_CHANNEL) != CHANNEL_STOPPED)
303 { 308 {
304 rb->pcm_play_pause(play); 309 rb->mixer_channel_play_pause(MPEG_PCM_CHANNEL, play);
310 rb->pcm_play_unlock();
305 } 311 }
306 else if (play) 312 else
307 { 313 {
308 rb->pcm_play_data(get_more, NULL, 0); 314 rb->pcm_play_unlock();
309 }
310 315
311 rb->pcm_play_unlock(); 316 if (play)
317 {
318 rb->mixer_channel_set_amplitude(MPEG_PCM_CHANNEL, MIX_AMP_UNITY);
319 rb->mixer_channel_play_data(MPEG_PCM_CHANNEL,
320 get_more, NULL, 0);
321 }
322 }
312} 323}
313 324
314/* Stops all playback and resets the clock */ 325/* Stops all playback and resets the clock */
@@ -316,13 +327,13 @@ void pcm_output_stop(void)
316{ 327{
317 rb->pcm_play_lock(); 328 rb->pcm_play_lock();
318 329
319 if (rb->pcm_is_playing()) 330 if (rb->mixer_channel_status(MPEG_PCM_CHANNEL) != CHANNEL_STOPPED)
320 rb->pcm_play_stop(); 331 rb->mixer_channel_stop(MPEG_PCM_CHANNEL);
332
333 rb->pcm_play_unlock();
321 334
322 pcm_output_flush(); 335 pcm_output_flush();
323 pcm_output_set_clock(0); 336 pcm_output_set_clock(0);
324
325 rb->pcm_play_unlock();
326} 337}
327 338
328/* Drains any data if the start threshold hasn't been reached */ 339/* Drains any data if the start threshold hasn't been reached */
@@ -343,11 +354,6 @@ bool pcm_output_init(void)
343 354
344 pcm_reset_buffer(); 355 pcm_reset_buffer();
345 356
346 /* Some targets could play at the movie frequency without resampling but
347 * as of now DSP assumes a certain frequency (always 44100Hz) so
348 * resampling will be needed for other movie audio rates. */
349 rb->pcm_set_frequency(NATIVE_FREQUENCY);
350
351#if INPUT_SRC_CAPS != 0 357#if INPUT_SRC_CAPS != 0
352 /* Select playback */ 358 /* Select playback */
353 rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); 359 rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
@@ -379,5 +385,4 @@ bool pcm_output_init(void)
379 385
380void pcm_output_exit(void) 386void pcm_output_exit(void)
381{ 387{
382 rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
383} 388}