summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/buffering.c56
-rw-r--r--apps/buffering.h7
-rw-r--r--apps/playback.c3
-rw-r--r--docs/PLUGIN_API15
-rw-r--r--lib/rbcodec/metadata/metadata.c38
-rw-r--r--lib/rbcodec/metadata/metadata.h1
6 files changed, 1 insertions, 119 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index db555d8805..8661a42ab8 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -1436,62 +1436,6 @@ ssize_t bufgetdata(int handle_id, size_t size, void **data)
1436 return size; 1436 return size;
1437} 1437}
1438 1438
1439ssize_t bufgettail(int handle_id, size_t size, void **data)
1440{
1441 if (thread_self() != buffering_thread_id)
1442 return ERR_WRONG_THREAD; /* only from buffering thread */
1443
1444 /* We don't support tail requests of > guardbuf_size, for simplicity */
1445 if (size > GUARD_BUFSIZE)
1446 return ERR_INVALID_VALUE;
1447
1448 const struct memory_handle *h = find_handle(handle_id);
1449 if (!h)
1450 return ERR_HANDLE_NOT_FOUND;
1451
1452 if (h->end >= h->filesize) {
1453 size_t tidx = ringbuf_sub_empty(h->widx, size);
1454
1455 if (tidx + size > buffer_len) {
1456 size_t copy_n = tidx + size - buffer_len;
1457 memcpy(guard_buffer, ringbuf_ptr(0), copy_n);
1458 }
1459
1460 *data = ringbuf_ptr(tidx);
1461 }
1462 else {
1463 size = ERR_HANDLE_NOT_DONE;
1464 }
1465
1466 return size;
1467}
1468
1469ssize_t bufcuttail(int handle_id, size_t size)
1470{
1471 if (thread_self() != buffering_thread_id)
1472 return ERR_WRONG_THREAD; /* only from buffering thread */
1473
1474 struct memory_handle *h = find_handle(handle_id);
1475 if (!h)
1476 return ERR_HANDLE_NOT_FOUND;
1477
1478 if (h->end >= h->filesize) {
1479 /* Cannot trim to before read position */
1480 size_t available = h->end - MAX(h->start, h->pos);
1481 if (available < size)
1482 size = available;
1483
1484 h->widx = ringbuf_sub_empty(h->widx, size);
1485 h->filesize -= size;
1486 h->end -= size;
1487 } else {
1488 size = ERR_HANDLE_NOT_DONE;
1489 }
1490
1491 return size;
1492}
1493
1494
1495/* 1439/*
1496SECONDARY EXPORTED FUNCTIONS 1440SECONDARY EXPORTED FUNCTIONS
1497============================ 1441============================
diff --git a/apps/buffering.h b/apps/buffering.h
index 1a75d865ae..bc47d6b1a1 100644
--- a/apps/buffering.h
+++ b/apps/buffering.h
@@ -46,8 +46,7 @@ enum data_type {
46#define ERR_FILE_ERROR -4 46#define ERR_FILE_ERROR -4
47#define ERR_HANDLE_NOT_DONE -5 47#define ERR_HANDLE_NOT_DONE -5
48#define ERR_UNSUPPORTED_TYPE -6 48#define ERR_UNSUPPORTED_TYPE -6
49#define ERR_WRONG_THREAD -7 49#define ERR_BITMAP_TOO_LARGE -7
50#define ERR_BITMAP_TOO_LARGE -8
51 50
52/* Initialise the buffering subsystem */ 51/* Initialise the buffering subsystem */
53void buffering_init(void) INIT_ATTR; 52void buffering_init(void) INIT_ATTR;
@@ -68,8 +67,6 @@ bool buffering_reset(char *buf, size_t buflen);
68 * bufftell : Return the handle's file read position 67 * bufftell : Return the handle's file read position
69 * bufread : Copy data from a handle to a buffer 68 * bufread : Copy data from a handle to a buffer
70 * bufgetdata: Obtain a pointer for linear access to a "size" amount of data 69 * bufgetdata: Obtain a pointer for linear access to a "size" amount of data
71 * bufgettail: Out-of-band get the last size bytes of a handle.
72 * bufcuttail: Out-of-band remove the trailing 'size' bytes of a handle.
73 * 70 *
74 * NOTE: bufread and bufgetdata will block the caller until the requested 71 * NOTE: bufread and bufgetdata will block the caller until the requested
75 * amount of data is ready (unless EOF is reached). 72 * amount of data is ready (unless EOF is reached).
@@ -85,8 +82,6 @@ int bufadvance(int handle_id, off_t offset);
85off_t bufftell(int handle_id); 82off_t bufftell(int handle_id);
86ssize_t bufread(int handle_id, size_t size, void *dest); 83ssize_t bufread(int handle_id, size_t size, void *dest);
87ssize_t bufgetdata(int handle_id, size_t size, void **data); 84ssize_t bufgetdata(int handle_id, size_t size, void **data);
88ssize_t bufgettail(int handle_id, size_t size, void **data);
89ssize_t bufcuttail(int handle_id, size_t size);
90 85
91/*************************************************************************** 86/***************************************************************************
92 * SECONDARY FUNCTIONS 87 * SECONDARY FUNCTIONS
diff --git a/apps/playback.c b/apps/playback.c
index a56c6d17ec..7fdb302d71 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -3467,9 +3467,6 @@ static void buffer_event_finished_callback(unsigned short id, void *ev_data)
3467 break; 3467 break;
3468 3468
3469 case TYPE_PACKET_AUDIO: 3469 case TYPE_PACKET_AUDIO:
3470 /* Strip any useless trailing tags that are left. */
3471 strip_tags(hid);
3472 /* Fall-through */
3473 case TYPE_ATOMIC_AUDIO: 3470 case TYPE_ATOMIC_AUDIO:
3474 LOGFQUEUE("buffering > audio Q_AUDIO_HANDLE_FINISHED: %d", hid); 3471 LOGFQUEUE("buffering > audio Q_AUDIO_HANDLE_FINISHED: %d", hid);
3475 audio_queue_post(Q_AUDIO_HANDLE_FINISHED, hid); 3472 audio_queue_post(Q_AUDIO_HANDLE_FINISHED, hid);
diff --git a/docs/PLUGIN_API b/docs/PLUGIN_API
index 8814833959..963809a27a 100644
--- a/docs/PLUGIN_API
+++ b/docs/PLUGIN_API
@@ -211,13 +211,6 @@ bool bufclose(int handle_id)
211 \return 211 \return
212 \description 212 \description
213 213
214ssize_t bufcuttail(int handle_id, size_t size)
215 \group buffering API
216 \param handle_id
217 \param size
218 \return
219 \description
220
221ssize_t bufgetdata(int handle_id, size_t size, void **data) 214ssize_t bufgetdata(int handle_id, size_t size, void **data)
222 \group buffering API 215 \group buffering API
223 \param handle_id 216 \param handle_id
@@ -226,14 +219,6 @@ ssize_t bufgetdata(int handle_id, size_t size, void **data)
226 \return 219 \return
227 \description 220 \description
228 221
229ssize_t bufgettail(int handle_id, size_t size, void **data)
230 \group buffering API
231 \param handle_id
232 \param size
233 \param data
234 \return
235 \description
236
237int bufopen(const char *file, size_t offset, enum data_type type) 222int bufopen(const char *file, size_t offset, enum data_type type)
238 \group buffering API 223 \group buffering API
239 \param file 224 \param file
diff --git a/lib/rbcodec/metadata/metadata.c b/lib/rbcodec/metadata/metadata.c
index aec72db97f..19147ccdb3 100644
--- a/lib/rbcodec/metadata/metadata.c
+++ b/lib/rbcodec/metadata/metadata.c
@@ -458,44 +458,6 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname)
458 return true; 458 return true;
459} 459}
460 460
461#ifndef __PCTOOL__
462void strip_tags(int handle_id)
463{
464 static const unsigned char tag[] = "TAG";
465 static const unsigned char apetag[] = "APETAGEX";
466 size_t len, version;
467 void *tail;
468
469 if (bufgettail(handle_id, 128, &tail) != 128)
470 return;
471
472 if (memcmp(tail, tag, 3) == 0)
473 {
474 /* Skip id3v1 tag */
475 logf("Cutting off ID3v1 tag");
476 bufcuttail(handle_id, 128);
477 }
478
479 /* Get a new tail, as the old one may have been cut */
480 if (bufgettail(handle_id, 32, &tail) != 32)
481 return;
482
483 /* Check for APE tag (look for the APE tag footer) */
484 if (memcmp(tail, apetag, 8) != 0)
485 return;
486
487 /* Read the version and length from the footer */
488 version = get_long_le(&((unsigned char *)tail)[8]);
489 len = get_long_le(&((unsigned char *)tail)[12]);
490 if (version == 2000)
491 len += 32; /* APEv2 has a 32 byte header */
492
493 /* Skip APE tag */
494 logf("Cutting off APE tag (%ldB)", len);
495 bufcuttail(handle_id, len);
496}
497#endif /* ! __PCTOOL__ */
498
499#define MOVE_ENTRY(x) if (x) x += offset; 461#define MOVE_ENTRY(x) if (x) x += offset;
500 462
501void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig) 463void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig)
diff --git a/lib/rbcodec/metadata/metadata.h b/lib/rbcodec/metadata/metadata.h
index 50fd5bac86..1a205a08eb 100644
--- a/lib/rbcodec/metadata/metadata.h
+++ b/lib/rbcodec/metadata/metadata.h
@@ -333,7 +333,6 @@ void wipe_mp3entry(struct mp3entry *id3);
333 333
334void fill_metadata_from_path(struct mp3entry *id3, const char *trackname); 334void fill_metadata_from_path(struct mp3entry *id3, const char *trackname);
335int get_audio_base_codec_type(int type); 335int get_audio_base_codec_type(int type);
336void strip_tags(int handle_id);
337bool rbcodec_format_is_atomic(int afmt); 336bool rbcodec_format_is_atomic(int afmt);
338bool format_buffers_with_offset(int afmt); 337bool format_buffers_with_offset(int afmt);
339 338