mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Finally commit Metadata on Buffer!
buffering.c and buffering.h implement the new buffering API. playback.c is translated to that API. For more information about the whole concept, see http://www.rockbox.org/wiki/MetadataOnBuffer. There should be no major visible changes, but most existing bugs remain (though fixing them should be easier now that playback.c is a bit less complex) and there probably will be new ones. Please report any problem! Next step is to adapt cuesheet support, which is partly disabled here, and of course fix as much bugs as possible. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15306 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
ccbe242453
commit
3e3c43c747
7 changed files with 1796 additions and 929 deletions
|
@ -14,6 +14,7 @@ menus/display_menu.c
|
||||||
menus/theme_menu.c
|
menus/theme_menu.c
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
menus/eq_menu.c
|
menus/eq_menu.c
|
||||||
|
buffering.c
|
||||||
#endif
|
#endif
|
||||||
menus/main_menu.c
|
menus/main_menu.c
|
||||||
menus/playback_menu.c
|
menus/playback_menu.c
|
||||||
|
|
1238
apps/buffering.c
Normal file
1238
apps/buffering.c
Normal file
File diff suppressed because it is too large
Load diff
120
apps/buffering.h
Normal file
120
apps/buffering.h
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 Nicolas Pennequin
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _BUFFERING_H_
|
||||||
|
#define _BUFFERING_H_
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
|
enum data_type {
|
||||||
|
TYPE_CODEC,
|
||||||
|
TYPE_AUDIO,
|
||||||
|
TYPE_STREAM,
|
||||||
|
TYPE_ID3,
|
||||||
|
TYPE_CUESHEET,
|
||||||
|
TYPE_IMAGE,
|
||||||
|
TYPE_BUFFER,
|
||||||
|
TYPE_UNKNOWN,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialise the buffering subsystem */
|
||||||
|
bool buffering_init(char *buf, size_t buflen);
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* MAIN BUFFERING API CALLS
|
||||||
|
* ========================
|
||||||
|
*
|
||||||
|
* bufopen : Reserve space in the buffer for a given file
|
||||||
|
* bufalloc : Open a new handle from data that needs to be copied from memory
|
||||||
|
* bufclose : Close an open handle
|
||||||
|
* bufseek : Set handle reading index, relatively to the start of the file
|
||||||
|
* bufadvance: Move handle reading index, relatively to current position
|
||||||
|
* bufread : Copy data from a handle to a buffer
|
||||||
|
* bufgetdata: Obtain a pointer for linear access to a "size" amount of data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int bufopen(const char *file, size_t offset, enum data_type type);
|
||||||
|
int bufalloc(const void *src, size_t size, enum data_type type);
|
||||||
|
bool bufclose(int handle_id);
|
||||||
|
int bufseek(int handle_id, size_t newpos);
|
||||||
|
int bufadvance(int handle_id, off_t offset);
|
||||||
|
ssize_t bufread(int handle_id, size_t size, void *dest);
|
||||||
|
ssize_t bufgetdata(int handle_id, size_t size, void **data);
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* SECONDARY FUNCTIONS
|
||||||
|
* ===================
|
||||||
|
*
|
||||||
|
* buf_get_offset: Get a handle offset from a pointer
|
||||||
|
* buf_handle_offset: Get the offset of the first buffered byte from the file
|
||||||
|
* buf_request_buffer_handle: Request buffering of a handle
|
||||||
|
* buf_set_base_handle: Tell the buffering thread which handle is currently read
|
||||||
|
* buf_used: Total amount of buffer space used (including allocated space)
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
ssize_t buf_get_offset(int handle_id, void *ptr);
|
||||||
|
ssize_t buf_handle_offset(int handle_id);
|
||||||
|
void buf_request_buffer_handle(int handle_id);
|
||||||
|
void buf_set_base_handle(int handle_id);
|
||||||
|
size_t buf_used(void);
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* CALLBACK UTILITIES
|
||||||
|
* ==================
|
||||||
|
*
|
||||||
|
* register_buffer_low_callback, unregister_buffer_low_callback:
|
||||||
|
*
|
||||||
|
* Register/Unregister callback functions that will get executed when the buffer
|
||||||
|
* goes below the low watermark. They are executed once, then forgotten.
|
||||||
|
*
|
||||||
|
* NOTE: The callbacks are called from the buffering thread, so don't make them
|
||||||
|
* do too much. Ideally they should just post an event to a queue and return.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define MAX_BUF_CALLBACKS 4
|
||||||
|
typedef void (*buffer_low_callback)(void);
|
||||||
|
bool register_buffer_low_callback(buffer_low_callback func);
|
||||||
|
void unregister_buffer_low_callback(buffer_low_callback func);
|
||||||
|
|
||||||
|
/* Settings */
|
||||||
|
enum {
|
||||||
|
BUFFERING_SET_WATERMARK = 1,
|
||||||
|
BUFFERING_SET_CHUNKSIZE,
|
||||||
|
BUFFERING_SET_PRESEEK,
|
||||||
|
};
|
||||||
|
void buf_set_conf(int setting, size_t value);
|
||||||
|
|
||||||
|
|
||||||
|
/* Debugging */
|
||||||
|
struct buffering_debug {
|
||||||
|
int num_handles;
|
||||||
|
size_t buffered_data;
|
||||||
|
size_t wasted_space;
|
||||||
|
size_t data_rem;
|
||||||
|
size_t useful_data;
|
||||||
|
};
|
||||||
|
void buffering_get_debugdata(struct buffering_debug *dbgdata);
|
||||||
|
|
||||||
|
#endif
|
|
@ -75,6 +75,7 @@
|
||||||
#include "logfdisp.h"
|
#include "logfdisp.h"
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
#include "pcmbuf.h"
|
#include "pcmbuf.h"
|
||||||
|
#include "buffering.h"
|
||||||
#if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
|
#if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
|
||||||
#include "spdif.h"
|
#include "spdif.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -261,7 +262,7 @@ static void dbg_audio_task(void)
|
||||||
ticks++;
|
ticks++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dbg_audio_thread(void)
|
static bool dbg_buffering_thread(void)
|
||||||
{
|
{
|
||||||
char buf[32];
|
char buf[32];
|
||||||
int button;
|
int button;
|
||||||
|
@ -270,6 +271,7 @@ static bool dbg_audio_thread(void)
|
||||||
size_t bufused;
|
size_t bufused;
|
||||||
size_t bufsize = pcmbuf_get_bufsize();
|
size_t bufsize = pcmbuf_get_bufsize();
|
||||||
int pcmbufdescs = pcmbuf_descs();
|
int pcmbufdescs = pcmbuf_descs();
|
||||||
|
struct buffering_debug d;
|
||||||
|
|
||||||
ticks = boost_ticks = 0;
|
ticks = boost_ticks = 0;
|
||||||
|
|
||||||
|
@ -292,6 +294,9 @@ static bool dbg_audio_thread(void)
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffering_get_debugdata(&d);
|
||||||
|
|
||||||
line = 0;
|
line = 0;
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
|
|
||||||
|
@ -300,19 +305,45 @@ static bool dbg_audio_thread(void)
|
||||||
snprintf(buf, sizeof(buf), "pcm: %7ld/%7ld", (long) bufused, (long) bufsize);
|
snprintf(buf, sizeof(buf), "pcm: %7ld/%7ld", (long) bufused, (long) bufsize);
|
||||||
lcd_puts(0, line++, buf);
|
lcd_puts(0, line++, buf);
|
||||||
|
|
||||||
/* Playable space left */
|
gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6,
|
||||||
gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6, bufsize, 0, bufused, HORIZONTAL);
|
bufsize, 0, bufused, HORIZONTAL);
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "codec: %8ld/%8ld", audio_filebufused(), (long) filebuflen);
|
snprintf(buf, sizeof(buf), "alloc: %8ld/%8ld", audio_filebufused(),
|
||||||
|
(long) filebuflen);
|
||||||
lcd_puts(0, line++, buf);
|
lcd_puts(0, line++, buf);
|
||||||
|
|
||||||
/* Playable space left */
|
#if LCD_HEIGHT > 80
|
||||||
gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6, filebuflen, 0,
|
gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6,
|
||||||
audio_filebufused(), HORIZONTAL);
|
filebuflen, 0, audio_filebufused(), HORIZONTAL);
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "track count: %2d", audio_track_count());
|
snprintf(buf, sizeof(buf), "real: %8ld/%8ld", (long)d.buffered_data,
|
||||||
|
(long)filebuflen);
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
|
||||||
|
gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6,
|
||||||
|
filebuflen, 0, (long)d.buffered_data, HORIZONTAL);
|
||||||
|
line++;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "usefl: %8ld/%8ld", (long)(d.useful_data),
|
||||||
|
(long)filebuflen);
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
|
||||||
|
#if LCD_HEIGHT > 80
|
||||||
|
gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6,
|
||||||
|
filebuflen, 0, d.useful_data, HORIZONTAL);
|
||||||
|
line++;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "data_rem: %ld", (long)d.data_rem);
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "track count: %2d", audio_track_count()-1);
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "handle count: %d", (int)d.num_handles);
|
||||||
lcd_puts(0, line++, buf);
|
lcd_puts(0, line++, buf);
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
@ -2241,7 +2272,9 @@ static const struct the_menu_item menuitems[] = {
|
||||||
{ "View database info", dbg_tagcache_info },
|
{ "View database info", dbg_tagcache_info },
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
#if CONFIG_CODEC == SWCODEC || !defined(SIMULATOR)
|
#if CONFIG_CODEC == SWCODEC
|
||||||
|
{ "View buffering thread", dbg_buffering_thread },
|
||||||
|
#elif !defined(SIMULATOR)
|
||||||
{ "View audio thread", dbg_audio_thread },
|
{ "View audio thread", dbg_audio_thread },
|
||||||
#endif
|
#endif
|
||||||
#ifdef PM_DEBUG
|
#ifdef PM_DEBUG
|
||||||
|
|
1233
apps/playback.c
1233
apps/playback.c
File diff suppressed because it is too large
Load diff
|
@ -32,9 +32,9 @@
|
||||||
#define CODEC_SET_AUDIOBUF_WATERMARK 4
|
#define CODEC_SET_AUDIOBUF_WATERMARK 4
|
||||||
|
|
||||||
#if MEM > 1
|
#if MEM > 1
|
||||||
#define MAX_TRACK 32
|
#define MAX_TRACK 128
|
||||||
#else
|
#else
|
||||||
#define MAX_TRACK 8
|
#define MAX_TRACK 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_TRACK_MASK (MAX_TRACK-1)
|
#define MAX_TRACK_MASK (MAX_TRACK-1)
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
#define PRIORITY_BACKGROUND 8 /* Normal application threads */
|
#define PRIORITY_BACKGROUND 8 /* Normal application threads */
|
||||||
|
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
#define MAXTHREADS 16
|
#define MAXTHREADS 17
|
||||||
#else
|
#else
|
||||||
#define MAXTHREADS 11
|
#define MAXTHREADS 11
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue