1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Michael Sevakis 2007-06-10 02:10:47 +00:00
parent 19cc9d063a
commit 4597ebe24b
7 changed files with 59 additions and 13 deletions

View file

@ -3303,6 +3303,7 @@ static void audio_play_start(size_t offset)
{ {
#if INPUT_SRC_CAPS != 0 #if INPUT_SRC_CAPS != 0
audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
audio_set_output_source(AUDIO_SRC_PLAYBACK);
#endif #endif
/* Wait for any previously playing audio to flush - TODO: Not necessary? */ /* Wait for any previously playing audio to flush - TODO: Not necessary? */

View file

@ -56,9 +56,9 @@
#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL) #define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL)
#ifdef HW_HAVE_11 #ifdef HW_HAVE_11
#define SAMPLERATE 11025 // 44100 22050 11025 #define SAMPLERATE SAMPR_11 // 44100 22050 11025
#else #else
#define SAMPLERATE 44100 // 44100 22050 11025 #define SAMPLERATE SAMPR_44 // 44100 22050 11025
#endif #endif
#define SAMPLESIZE 2 // 16bit #define SAMPLESIZE 2 // 16bit
@ -481,7 +481,7 @@ void I_SubmitSound(void)
void I_ShutdownSound(void) void I_ShutdownSound(void)
{ {
rb->pcm_play_stop(); rb->pcm_play_stop();
rb->pcm_set_frequency(44100); // 44100 rb->pcm_set_frequency(HW_SAMPR_DEFAULT); // 44100
} }
void I_InitSound() void I_InitSound()
@ -491,6 +491,12 @@ void I_InitSound()
// Initialize external data (all sounds) at start, keep static. // Initialize external data (all sounds) at start, keep static.
printf( "I_InitSound: "); printf( "I_InitSound: ");
rb->pcm_play_stop(); 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); rb->pcm_set_frequency(SAMPLERATE);
vol_lookup=malloc(128*256*sizeof(int)); vol_lookup=malloc(128*256*sizeof(int));

View file

@ -904,6 +904,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
#else #else
#define PLA_ARRAY_COUNT 2 #define PLA_ARRAY_COUNT 2
#endif #endif
enum plugin_status status;
(void)parameter; (void)parameter;
rb = api; rb = api;
@ -915,7 +916,12 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
rb->bitswap(sound, sizeof(sound)); rb->bitswap(sound, sizeof(sound));
#else #else
prepare_tock(); 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 #endif
calc_period(); calc_period();
@ -944,7 +950,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
case METRONOME_QUIT: case METRONOME_QUIT:
/* get out of here */ /* get out of here */
cleanup(NULL); cleanup(NULL);
return PLUGIN_OK; status = PLUGIN_OK;
goto metronome_exit;
#if CONFIG_KEYPAD == ONDIO_PAD #if CONFIG_KEYPAD == ONDIO_PAD
case METRONOME_PLAY_TAP: case METRONOME_PLAY_TAP:
@ -1013,7 +1020,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
default: default:
if (rb->default_event_handler_ex(button, cleanup, NULL) if (rb->default_event_handler_ex(button, cleanup, NULL)
== SYS_USB_CONNECTED) == SYS_USB_CONNECTED)
return PLUGIN_USB_CONNECTED; {
status = PLUGIN_USB_CONNECTED;
goto metronome_exit;
}
reset_tap = false; reset_tap = false;
break; break;
@ -1022,5 +1032,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
tap_count = 0; tap_count = 0;
} }
} }
metronome_exit:
rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
return status;
} }

View file

@ -80,11 +80,11 @@ PLUGIN_IRAM_DECLARE
#define FRACTSIZE 10 #define FRACTSIZE 10
#ifndef SIMULATOR #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 #define MAX_VOICES 20 // Note: 24 midi channels is the minimum general midi
// spec implementation // spec implementation
#else // Simulator requires 44100, and we can afford to use more voices #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 #define MAX_VOICES 48
#endif #endif
@ -232,6 +232,11 @@ int midimain(void * filename)
//#ifndef SIMULATOR //#ifndef SIMULATOR
rb->pcm_play_stop(); 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 rb->pcm_set_frequency(SAMPLE_RATE); // 44100 22050 11025
//#endif //#endif

View file

@ -1636,6 +1636,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
audiobuf = rb->plugin_get_audio_buffer(&audiosize); 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 */ /* Set disk pointers to NULL */
disk_buf_end = disk_buf = 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) */ save_settings(); /* Save settings (if they have changed) */
rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
#ifdef HAVE_BACKLIGHT #ifdef HAVE_BACKLIGHT
/* reset backlight settings */ /* reset backlight settings */
rb->backlight_set_timeout(rb->global_settings->backlight_timeout); rb->backlight_set_timeout(rb->global_settings->backlight_timeout);

View file

@ -46,7 +46,13 @@ void pcm_init(void)
rb->pcm_play_stop(); rb->pcm_play_stop();
rb->pcm_set_frequency(11025); /* 44100 22050 11025 */ #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_11); /* 44100 22050 11025 */
} }
void pcm_close(void) void pcm_close(void)
@ -54,7 +60,7 @@ void pcm_close(void)
memset(&pcm, 0, sizeof pcm); memset(&pcm, 0, sizeof pcm);
newly_started = true; newly_started = true;
rb->pcm_play_stop(); rb->pcm_play_stop();
rb->pcm_set_frequency(44100); rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
} }
int pcm_submit(void) int pcm_submit(void)

View file

@ -106,8 +106,12 @@ static void open_snd(void)
sndstate = SPS_OPENED; sndstate = SPS_OPENED;
sound_avail=1; sound_avail=1;
rb->pcm_play_stop(); 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) static void close_snd(int normal)
@ -115,7 +119,7 @@ static void close_snd(int normal)
(void)normal; (void)normal;
sound_avail = 0; sound_avail = 0;
rb->pcm_play_stop(); rb->pcm_play_stop();
rb->pcm_set_frequency(44100); rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
} }