summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-06-10 02:10:47 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-06-10 02:10:47 +0000
commit4597ebe24b5300f9e0009ae5a4e08a0527214e94 (patch)
treea1d5c3e6c305b5033efca4827e9e2d116662bda3
parent19cc9d063a22cd5162e164d8f5e2fe98944c3721 (diff)
Plugins that play sound must be sure to set inputs and outputs on audio muxed targets. Add strict adherence to the interface protocols. Make sure playback sets the playback output as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13604 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playback.c1
-rw-r--r--apps/plugins/doom/i_sound.c12
-rw-r--r--apps/plugins/metronome.c20
-rw-r--r--apps/plugins/midiplay.c9
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c10
-rw-r--r--apps/plugins/rockboy/rbsound.c10
-rw-r--r--apps/plugins/zxbox/spsound.c10
7 files changed, 59 insertions, 13 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 9cd82de9b6..ca88b5f5e3 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -3303,6 +3303,7 @@ static void audio_play_start(size_t offset)
{
#if INPUT_SRC_CAPS != 0
audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
+ audio_set_output_source(AUDIO_SRC_PLAYBACK);
#endif
/* Wait for any previously playing audio to flush - TODO: Not necessary? */
diff --git a/apps/plugins/doom/i_sound.c b/apps/plugins/doom/i_sound.c
index d79f7a132b..2f4f594077 100644
--- a/apps/plugins/doom/i_sound.c
+++ b/apps/plugins/doom/i_sound.c
@@ -56,9 +56,9 @@
#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL)
#ifdef HW_HAVE_11
-#define SAMPLERATE 11025 // 44100 22050 11025
+#define SAMPLERATE SAMPR_11 // 44100 22050 11025
#else
-#define SAMPLERATE 44100 // 44100 22050 11025
+#define SAMPLERATE SAMPR_44 // 44100 22050 11025
#endif
#define SAMPLESIZE 2 // 16bit
@@ -481,7 +481,7 @@ void I_SubmitSound(void)
void I_ShutdownSound(void)
{
rb->pcm_play_stop();
- rb->pcm_set_frequency(44100); // 44100
+ rb->pcm_set_frequency(HW_SAMPR_DEFAULT); // 44100
}
void I_InitSound()
@@ -491,6 +491,12 @@ void I_InitSound()
// Initialize external data (all sounds) at start, keep static.
printf( "I_InitSound: ");
rb->pcm_play_stop();
+
+#if INPUT_SRC_CAPS != 0
+ /* Select playback */
+ rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
+ rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
+#endif
rb->pcm_set_frequency(SAMPLERATE);
vol_lookup=malloc(128*256*sizeof(int));
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c
index 712731462a..83af2eb46b 100644
--- a/apps/plugins/metronome.c
+++ b/apps/plugins/metronome.c
@@ -904,6 +904,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
#else
#define PLA_ARRAY_COUNT 2
#endif
+ enum plugin_status status;
(void)parameter;
rb = api;
@@ -915,7 +916,12 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
rb->bitswap(sound, sizeof(sound));
#else
prepare_tock();
- rb->pcm_set_frequency(44100);
+#if INPUT_SRC_CAPS != 0
+ /* Select playback */
+ rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
+ rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
+#endif
+ rb->pcm_set_frequency(SAMPR_44);
#endif
calc_period();
@@ -944,7 +950,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
case METRONOME_QUIT:
/* get out of here */
cleanup(NULL);
- return PLUGIN_OK;
+ status = PLUGIN_OK;
+ goto metronome_exit;
#if CONFIG_KEYPAD == ONDIO_PAD
case METRONOME_PLAY_TAP:
@@ -1013,7 +1020,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
default:
if (rb->default_event_handler_ex(button, cleanup, NULL)
== SYS_USB_CONNECTED)
- return PLUGIN_USB_CONNECTED;
+ {
+ status = PLUGIN_USB_CONNECTED;
+ goto metronome_exit;
+ }
reset_tap = false;
break;
@@ -1022,5 +1032,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
tap_count = 0;
}
}
+
+metronome_exit:
+ rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
+ return status;
}
diff --git a/apps/plugins/midiplay.c b/apps/plugins/midiplay.c
index e586f7b0fe..9dda07482e 100644
--- a/apps/plugins/midiplay.c
+++ b/apps/plugins/midiplay.c
@@ -80,11 +80,11 @@ PLUGIN_IRAM_DECLARE
#define FRACTSIZE 10
#ifndef SIMULATOR
- #define SAMPLE_RATE 22050 // 44100 22050 11025
+ #define SAMPLE_RATE SAMPR_22 // 44100 22050 11025
#define MAX_VOICES 20 // Note: 24 midi channels is the minimum general midi
// spec implementation
#else // Simulator requires 44100, and we can afford to use more voices
- #define SAMPLE_RATE 44100
+ #define SAMPLE_RATE SAMPR_44
#define MAX_VOICES 48
#endif
@@ -232,6 +232,11 @@ int midimain(void * filename)
//#ifndef SIMULATOR
rb->pcm_play_stop();
+#if INPUT_SRC_CAPS != 0
+ /* Select playback */
+ rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
+ rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
+#endif
rb->pcm_set_frequency(SAMPLE_RATE); // 44100 22050 11025
//#endif
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 5b098dd7b4..881baa925e 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -1636,6 +1636,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
audiobuf = rb->plugin_get_audio_buffer(&audiosize);
+#if INPUT_SRC_CAPS != 0
+ /* Select playback */
+ rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
+ rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
+#endif
+
+ rb->pcm_set_frequency(SAMPR_44);
+
/* Set disk pointers to NULL */
disk_buf_end = disk_buf = NULL;
@@ -1847,6 +1855,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
save_settings(); /* Save settings (if they have changed) */
+ rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
+
#ifdef HAVE_BACKLIGHT
/* reset backlight settings */
rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
diff --git a/apps/plugins/rockboy/rbsound.c b/apps/plugins/rockboy/rbsound.c
index 4e61d5590c..e671554e25 100644
--- a/apps/plugins/rockboy/rbsound.c
+++ b/apps/plugins/rockboy/rbsound.c
@@ -45,8 +45,14 @@ void pcm_init(void)
}
rb->pcm_play_stop();
+
+#if INPUT_SRC_CAPS != 0
+ /* Select playback */
+ rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
+ rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
+#endif
- rb->pcm_set_frequency(11025); /* 44100 22050 11025 */
+ rb->pcm_set_frequency(SAMPR_11); /* 44100 22050 11025 */
}
void pcm_close(void)
@@ -54,7 +60,7 @@ void pcm_close(void)
memset(&pcm, 0, sizeof pcm);
newly_started = true;
rb->pcm_play_stop();
- rb->pcm_set_frequency(44100);
+ rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
}
int pcm_submit(void)
diff --git a/apps/plugins/zxbox/spsound.c b/apps/plugins/zxbox/spsound.c
index f9a4c6caa7..aae4ad9c8d 100644
--- a/apps/plugins/zxbox/spsound.c
+++ b/apps/plugins/zxbox/spsound.c
@@ -106,8 +106,12 @@ static void open_snd(void)
sndstate = SPS_OPENED;
sound_avail=1;
rb->pcm_play_stop();
- rb->pcm_set_frequency(44100);
-
+#if INPUT_SRC_CAPS != 0
+ /* Select playback */
+ rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
+ rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
+#endif
+ rb->pcm_set_frequency(SAMPR_44);
}
static void close_snd(int normal)
@@ -115,7 +119,7 @@ static void close_snd(int normal)
(void)normal;
sound_avail = 0;
rb->pcm_play_stop();
- rb->pcm_set_frequency(44100);
+ rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
}