summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2006-11-29 14:23:24 +0000
committerMichael Sevakis <jethead71@rockbox.org>2006-11-29 14:23:24 +0000
commit7d00f97460823a3ddf80d4cab14fecf605ba3690 (patch)
treeec76a76253f6857e3ad571b385dadef2c43dc8d1 /firmware
parent077ed4925ef6954eb7f4626e153f89dda5df0731 (diff)
PCM: A few tiny changes. 1) Recording a) Flush all pending files if filename queue is full or else perpetual flushing of 1 will occur at low bitrates and short split times. b) #ifdef out currently unused bits and save little less than 1/2K 2) Cleanup some declarations.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11623 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/pcm_playback.h13
-rw-r--r--firmware/export/pcm_record.h12
-rw-r--r--firmware/pcm_record.c34
-rw-r--r--firmware/target/coldfire/pcm-coldfire.c11
4 files changed, 54 insertions, 16 deletions
diff --git a/firmware/export/pcm_playback.h b/firmware/export/pcm_playback.h
index 9c3e96ba63..e7c00edeed 100644
--- a/firmware/export/pcm_playback.h
+++ b/firmware/export/pcm_playback.h
@@ -47,4 +47,17 @@ void pcm_play_pause(bool play);
bool pcm_is_paused(void);
bool pcm_is_playing(void);
+/** The following are for internal use between pcm_playback.c and target-
+ specific portion **/
+
+/* the registered callback function to ask for more mp3 data */
+extern volatile pcm_more_callback_type pcm_callback_for_more;
+extern volatile bool pcm_playing;
+extern volatile bool pcm_paused;
+
+extern void pcm_play_dma_start(const void *addr, size_t size);
+extern void pcm_play_dma_stop(void);
+extern void pcm_play_pause_pause(void);
+extern void pcm_play_pause_unpause(void);
+
#endif /* PCM_PLAYBACK_H */
diff --git a/firmware/export/pcm_record.h b/firmware/export/pcm_record.h
index 38ec202cdc..30d2dc7e6f 100644
--- a/firmware/export/pcm_record.h
+++ b/firmware/export/pcm_record.h
@@ -60,4 +60,16 @@ int pcm_get_num_unprocessed(void);
/* audio.h contains audio_* recording functions */
+
+/** The following are for internal use between pcm_record.c and target-
+ specific portion **/
+/* the registered callback function for when more data is available */
+extern volatile pcm_more_callback_type pcm_callback_more_ready;
+/* DMA transfer in is currently active */
+extern volatile bool pcm_recording;
+
+/* APIs implemented in the target-specific portion */
+extern void pcm_rec_dma_start(const void *addr, size_t size);
+extern void pcm_rec_dma_stop(void);
+
#endif /* PCM_RECORD_H */
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c
index f7059dc40b..bc39c8979a 100644
--- a/firmware/pcm_record.c
+++ b/firmware/pcm_record.c
@@ -74,8 +74,10 @@ static size_t num_rec_bytes; /* Num bytes recorded */
static unsigned long num_rec_samples; /* Number of PCM samples recorded */
/** Stats on encoded data for all files from start to stop **/
+#if 0
static unsigned long long accum_rec_bytes; /* total size written to chunks */
static unsigned long long accum_pcm_samples; /* total pcm count processed */
+#endif
/* Keeps data about current file and is sent as event data for codec */
static struct enc_file_event_data rec_fdata IDATA_ATTR =
@@ -272,6 +274,7 @@ unsigned long pcm_rec_status(void)
return ret;
} /* pcm_rec_status */
+#if 0
int pcm_rec_current_bitrate(void)
{
if (accum_pcm_samples == 0)
@@ -279,17 +282,23 @@ int pcm_rec_current_bitrate(void)
return (int)(8*accum_rec_bytes*enc_sample_rate / (1000*accum_pcm_samples));
} /* pcm_rec_current_bitrate */
+#endif
+#if 0
int pcm_rec_encoder_afmt(void)
{
return enc_config.afmt;
} /* pcm_rec_encoder_afmt */
+#endif
+#if 0
int pcm_rec_rec_format(void)
- {
+{
return afmt_rec_format[enc_config.afmt];
} /* pcm_rec_rec_format */
+#endif
+#ifdef HAVE_SPDIF_IN
unsigned long pcm_rec_sample_rate(void)
{
/* Which is better ?? */
@@ -298,6 +307,7 @@ unsigned long pcm_rec_sample_rate(void)
#endif
return sample_rate;
} /* audio_get_sample_rate */
+#endif
/**
* Creates pcmrec_thread
@@ -332,7 +342,7 @@ void audio_close_recording(void)
unsigned long audio_recorded_time(void)
{
if (!is_recording || enc_sample_rate == 0)
- return 0;
+ return 0;
/* return actual recorded time a la encoded data even if encoder rate
doesn't match the pcm rate */
@@ -589,14 +599,18 @@ static inline void pcmrec_update_sizes_inl(size_t prev_enc_size,
{
ssize_t size_diff = rec_fdata.new_enc_size - prev_enc_size;
num_rec_bytes += size_diff;
+#if 0
accum_rec_bytes += size_diff;
+#endif
}
if (rec_fdata.new_num_pcm != prev_num_pcm)
{
unsigned long pcm_diff = rec_fdata.new_num_pcm - prev_num_pcm;
num_rec_samples += pcm_diff;
+#if 0
accum_pcm_samples += pcm_diff;
+#endif
}
} /* pcmrec_update_sizes_inl */
@@ -980,11 +994,11 @@ static void pcmrec_new_stream(const char *filename, /* next file name */
start->flags |= CHUNKF_START_FILE;
- /* flush one file out if full and adding */
+ /* flush all pending files out if full and adding */
if (fnq_add_fn == pcmrec_fnq_add_filename && pcmrec_fnq_is_full())
{
- logf("fnq full: flushing 1");
- pcmrec_flush(1);
+ logf("fnq full");
+ pcmrec_flush(-1);
}
fnq_add_fn(filename);
@@ -1014,8 +1028,10 @@ static void pcmrec_init(void)
/* stats */
num_rec_bytes = 0;
num_rec_samples = 0;
+#if 0
accum_rec_bytes = 0;
accum_pcm_samples = 0;
+#endif
pcm_thread_unsignal_event(PCMREC_CLOSE);
is_recording = false;
@@ -1059,8 +1075,10 @@ static void pcmrec_start(const char *filename)
/* reset stats */
num_rec_bytes = 0;
num_rec_samples = 0;
+#if 0
accum_rec_bytes = 0;
accum_pcm_samples = 0;
+#endif
spinup_time = -1;
rd_start = enc_wr_index;
@@ -1103,8 +1121,10 @@ static void pcmrec_start(const char *filename)
break;
}
+#if 0
accum_rec_bytes = num_rec_bytes;
accum_pcm_samples = num_rec_samples;
+#endif
}
enc_rd_index = rd_start;
@@ -1513,9 +1533,13 @@ void enc_finish_chunk(void)
if (enc_rd_index != enc_wr_index)
{
num_rec_bytes += chunk->enc_size;
+#if 0
accum_rec_bytes += chunk->enc_size;
+#endif
num_rec_samples += chunk->num_pcm;
+#if 0
accum_pcm_samples += chunk->num_pcm;
+#endif
}
else if (is_recording) /* buffer full */
{
diff --git a/firmware/target/coldfire/pcm-coldfire.c b/firmware/target/coldfire/pcm-coldfire.c
index 2936cf5621..917800d0b8 100644
--- a/firmware/target/coldfire/pcm-coldfire.c
+++ b/firmware/target/coldfire/pcm-coldfire.c
@@ -41,17 +41,6 @@
#define ac_set_frequency tlv320_set_frequency
#endif
-/** Semi-private shared symbols **/
-
-/* the registered callback function to ask for more pcm data */
-extern volatile pcm_more_callback_type pcm_callback_for_more;
-extern volatile bool pcm_playing;
-extern volatile bool pcm_paused;
-
-/* the registered callback function for when more data is available */
-extern volatile pcm_more_callback_type pcm_callback_more_ready;
-extern volatile bool pcm_recording;
-
/* peaks */
static int play_peak_left, play_peak_right;
static unsigned long *rec_peak_addr;