4888131972
Basically, just give it a good rewrite. Software codec recording can be implemented in a more straightforward and simple manner and made more robust through the better codec control now available. Encoded audio buffer uses a packed format instead of fixed-size chunks and uses smaller data headers leading to more efficient usage. The greatest benefit is with a VBR format like wavpack which needs to request a maximum size but only actually ends up committing part of that request. No guard buffers are used for either PCM or encoded audio. PCM is read into the codec's provided buffer and mono conversion done at that time in the core if required. Any highly-specialized sample conversion is still done within the codec itself, such as 32-bit (wavpack) or interleaved mono (mp3). There is no longer a separate filename array. All metadata goes onto the main encoded audio buffer, eliminating any predermined file limit on the buffer as well as not wasting the space for unused path queue slots. The core and codec interface is less awkward and a bit more sensible. Some less useful interface features were removed. Threads are kept on narrow code paths ie. the audio thread never calls encoding functions and the codec thread never calls file functions as before. Codecs no longer call file functions directly. Writes are buffered in the core and data written to storage in larger chunks to speed up flushing of data. In fact, codecs are no longer aware of the stream being a file at all and have no access to the fd. SPDIF frequency detection no longer requires a restart of recording or plugging the source before entering the screen. It will poll for changes and update when stopped or prerecording (which does discard now-invalid prerecorded data). I've seen to it that writing a proper header on full disk works when the format makes it reasonably practical to do so. Other cases may have incorrect data sizes but sample info will be in tact. File left that way may play anyway. mp3_enc.codec acquires the ability to write 'Info' headers with LAME tags to make it gapless (bonus). Change-Id: I670685166d5eb32ef58ef317f50b8af766ceb653 Reviewed-on: http://gerrit.rockbox.org/493 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested-by: Michael Sevakis <jethead71@rockbox.org>
109 lines
3.1 KiB
C
109 lines
3.1 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
* $Id$
|
|
*
|
|
* Copyright (C) 2005-2007 Miika Pekkarinen
|
|
* Copyright (C) 2007-2008 Nicolas Pennequin
|
|
* Copyright (C) 2011-2013 Michael Sevakis
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
****************************************************************************/
|
|
#ifndef AUDIO_THREAD_H
|
|
#define AUDIO_THREAD_H
|
|
|
|
/* Define one constant that includes recording related functionality */
|
|
#if defined(HAVE_RECORDING) && !defined(SIMULATOR)
|
|
#define AUDIO_HAVE_RECORDING
|
|
#endif
|
|
|
|
enum
|
|
{
|
|
Q_NULL = 0, /* reserved */
|
|
|
|
/* -> audio */
|
|
Q_AUDIO_PLAY,
|
|
Q_AUDIO_STOP,
|
|
Q_AUDIO_PAUSE,
|
|
Q_AUDIO_SKIP,
|
|
Q_AUDIO_PRE_FF_REWIND,
|
|
Q_AUDIO_FF_REWIND,
|
|
Q_AUDIO_FLUSH,
|
|
Q_AUDIO_DIR_SKIP,
|
|
|
|
/* pcmbuf -> audio */
|
|
Q_AUDIO_TRACK_CHANGED,
|
|
|
|
/* audio -> audio */
|
|
Q_AUDIO_FILL_BUFFER, /* continue buffering next track */
|
|
|
|
/* buffering -> audio */
|
|
Q_AUDIO_BUFFERING, /* some buffer event */
|
|
Q_AUDIO_FINISH_LOAD_TRACK, /* metadata is buffered */
|
|
Q_AUDIO_HANDLE_FINISHED, /* some other type is buffered */
|
|
|
|
/* codec -> audio (*) */
|
|
Q_AUDIO_CODEC_SEEK_COMPLETE,
|
|
Q_AUDIO_CODEC_COMPLETE,
|
|
|
|
/* audio -> codec */
|
|
Q_CODEC_LOAD,
|
|
Q_CODEC_RUN,
|
|
Q_CODEC_PAUSE,
|
|
Q_CODEC_SEEK,
|
|
Q_CODEC_STOP,
|
|
Q_CODEC_UNLOAD,
|
|
|
|
/* -> codec */
|
|
Q_CODEC_DO_CALLBACK,
|
|
|
|
/* -> recording */
|
|
#ifdef HAVE_RECORDING
|
|
Q_AUDIO_INIT_RECORDING,
|
|
Q_AUDIO_CLOSE_RECORDING,
|
|
Q_AUDIO_RECORDING_OPTIONS,
|
|
Q_AUDIO_RECORD,
|
|
Q_AUDIO_RECORD_STOP,
|
|
Q_AUDIO_RECORD_PAUSE,
|
|
Q_AUDIO_RECORD_RESUME,
|
|
Q_AUDIO_RECORD_FLUSH,
|
|
#endif
|
|
|
|
/*- settings -*/
|
|
|
|
#ifdef HAVE_DISK_STORAGE
|
|
/* -> audio */
|
|
Q_AUDIO_UPDATE_WATERMARK, /* buffering watermark needs updating */
|
|
#endif
|
|
/* -> audio */
|
|
Q_AUDIO_REMAKE_AUDIO_BUFFER, /* buffer needs to be reinitialized */
|
|
};
|
|
|
|
/* (*) If you change these, you must check audio_clear_track_notifications
|
|
in playback.c for correctness */
|
|
|
|
void audio_init(void);
|
|
void playback_init(void);
|
|
unsigned int playback_status(void);
|
|
|
|
void audio_playback_handler(struct queue_event *ev);
|
|
#ifdef AUDIO_HAVE_RECORDING
|
|
void audio_recording_handler(struct queue_event *ev);
|
|
#endif
|
|
|
|
/** --- audio_queue helpers --- **/
|
|
void audio_queue_post(long id, intptr_t data);
|
|
intptr_t audio_queue_send(long id, intptr_t data);
|
|
|
|
#endif /* AUDIO_THREAD_H */
|