diff options
-rw-r--r-- | apps/buffering.c | 19 | ||||
-rw-r--r-- | apps/codec_thread.c | 33 | ||||
-rw-r--r-- | apps/codecs/libm4a/demux.c | 3 | ||||
-rw-r--r-- | apps/metadata.c | 12 | ||||
-rw-r--r-- | apps/metadata.h | 4 | ||||
-rw-r--r-- | apps/metadata/mp4.c | 11 | ||||
-rw-r--r-- | apps/metadata/mpc.c | 4 |
7 files changed, 72 insertions, 14 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index 8d41324190..4516959cab 100644 --- a/apps/buffering.c +++ b/apps/buffering.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | #include <ctype.h> | 26 | #include <ctype.h> |
27 | #include <inttypes.h> | 27 | #include <inttypes.h> |
28 | #define assert(a) | ||
29 | |||
28 | #include "buffering.h" | 30 | #include "buffering.h" |
29 | 31 | ||
30 | #include "storage.h" | 32 | #include "storage.h" |
@@ -611,6 +613,16 @@ static inline bool buffer_is_low(void) | |||
611 | return data_counters.useful < (conf_watermark / 2); | 613 | return data_counters.useful < (conf_watermark / 2); |
612 | } | 614 | } |
613 | 615 | ||
616 | static uintptr_t beyond_handle(struct memory_handle *h) | ||
617 | { | ||
618 | /* | ||
619 | * the last handle on the chain must leave at least one byte | ||
620 | * between itself and the first handle, to avoid overflowing the | ||
621 | * ring by advancing buf_widx up to buf_ridx | ||
622 | */ | ||
623 | return h->next != 0 ? ringbuf_offset(h->next) : ringbuf_sub(buf_ridx, 1); | ||
624 | } | ||
625 | |||
614 | /* Buffer data for the given handle. | 626 | /* Buffer data for the given handle. |
615 | Return whether or not the buffering should continue explicitly. */ | 627 | Return whether or not the buffering should continue explicitly. */ |
616 | static bool buffer_handle(int handle_id) | 628 | static bool buffer_handle(int handle_id) |
@@ -669,10 +681,10 @@ static bool buffer_handle(int handle_id) | |||
669 | buffer_len - h->widx); | 681 | buffer_len - h->widx); |
670 | 682 | ||
671 | ssize_t overlap; | 683 | ssize_t overlap; |
672 | uintptr_t next_handle = ringbuf_offset(h->next); | 684 | uintptr_t next_handle = beyond_handle(h); |
673 | 685 | ||
674 | /* stop copying if it would overwrite the reading position */ | 686 | /* stop copying if it would overwrite the reading position */ |
675 | if (ringbuf_add_cross(h->widx, copy_n, buf_ridx) >= 0) | 687 | if (h->widx == next_handle || ringbuf_add_cross(h->widx, copy_n, buf_ridx) >= 0) |
676 | return false; | 688 | return false; |
677 | 689 | ||
678 | /* FIXME: This would overwrite the next handle | 690 | /* FIXME: This would overwrite the next handle |
@@ -789,8 +801,7 @@ static void rebuffer_handle(int handle_id, size_t newpos) | |||
789 | LOGFQUEUE("buffering >| Q_RESET_HANDLE %d", handle_id); | 801 | LOGFQUEUE("buffering >| Q_RESET_HANDLE %d", handle_id); |
790 | queue_send(&buffering_queue, Q_RESET_HANDLE, handle_id); | 802 | queue_send(&buffering_queue, Q_RESET_HANDLE, handle_id); |
791 | 803 | ||
792 | uintptr_t next = ringbuf_offset(h->next); | 804 | if (ringbuf_sub(beyond_handle(h), h->data) < h->filesize - newpos) |
793 | if (ringbuf_sub(next, h->data) < h->filesize - newpos) | ||
794 | { | 805 | { |
795 | /* There isn't enough space to rebuffer all of the track from its new | 806 | /* There isn't enough space to rebuffer all of the track from its new |
796 | offset, so we ask the user to free some */ | 807 | offset, so we ask the user to free some */ |
diff --git a/apps/codec_thread.c b/apps/codec_thread.c index 21d55a7779..ef02f70811 100644 --- a/apps/codec_thread.c +++ b/apps/codec_thread.c | |||
@@ -102,16 +102,45 @@ static bool codec_load_next_track(void); | |||
102 | 102 | ||
103 | /** misc external functions */ | 103 | /** misc external functions */ |
104 | 104 | ||
105 | /* Used to check whether a new codec must be loaded. See array audio_formats[] | ||
106 | * in metadata.c */ | ||
105 | int get_codec_base_type(int type) | 107 | int get_codec_base_type(int type) |
106 | { | 108 | { |
109 | int base_type = type; | ||
107 | switch (type) { | 110 | switch (type) { |
108 | case AFMT_MPA_L1: | 111 | case AFMT_MPA_L1: |
109 | case AFMT_MPA_L2: | 112 | case AFMT_MPA_L2: |
110 | case AFMT_MPA_L3: | 113 | case AFMT_MPA_L3: |
111 | return AFMT_MPA_L3; | 114 | base_type = AFMT_MPA_L3; |
115 | break; | ||
116 | case AFMT_MPC_SV7: | ||
117 | case AFMT_MPC_SV8: | ||
118 | base_type = AFMT_MPC_SV7; | ||
119 | break; | ||
120 | case AFMT_MP4_AAC: | ||
121 | case AFMT_MP4_AAC_HE: | ||
122 | base_type = AFMT_MP4_AAC; | ||
123 | break; | ||
124 | case AFMT_SAP: | ||
125 | case AFMT_CMC: | ||
126 | case AFMT_CM3: | ||
127 | case AFMT_CMR: | ||
128 | case AFMT_CMS: | ||
129 | case AFMT_DMC: | ||
130 | case AFMT_DLT: | ||
131 | case AFMT_MPT: | ||
132 | case AFMT_MPD: | ||
133 | case AFMT_RMT: | ||
134 | case AFMT_TMC: | ||
135 | case AFMT_TM8: | ||
136 | case AFMT_TM2: | ||
137 | base_type = AFMT_SAP; | ||
138 | break; | ||
139 | default: | ||
140 | break; | ||
112 | } | 141 | } |
113 | 142 | ||
114 | return type; | 143 | return base_type; |
115 | } | 144 | } |
116 | 145 | ||
117 | const char *get_codec_filename(int cod_spec) | 146 | const char *get_codec_filename(int cod_spec) |
diff --git a/apps/codecs/libm4a/demux.c b/apps/codecs/libm4a/demux.c index 8fc90c8092..e584c37858 100644 --- a/apps/codecs/libm4a/demux.c +++ b/apps/codecs/libm4a/demux.c | |||
@@ -257,7 +257,8 @@ static bool read_chunk_stsd(qtmovie_t *qtmovie, size_t chunk_len) | |||
257 | stream_skip(qtmovie->stream, entry_remaining); | 257 | stream_skip(qtmovie->stream, entry_remaining); |
258 | 258 | ||
259 | } else if (qtmovie->res->format==MAKEFOURCC('m','p','4','a')) { | 259 | } else if (qtmovie->res->format==MAKEFOURCC('m','p','4','a')) { |
260 | if (qtmovie->stream->ci->id3->codectype!=AFMT_MP4_AAC) { | 260 | if (qtmovie->stream->ci->id3->codectype!=AFMT_MP4_AAC && |
261 | qtmovie->stream->ci->id3->codectype!=AFMT_MP4_AAC_HE) { | ||
261 | return false; | 262 | return false; |
262 | } | 263 | } |
263 | 264 | ||
diff --git a/apps/metadata.c b/apps/metadata.c index 79ef7ebcad..8ffd1a6af1 100644 --- a/apps/metadata.c +++ b/apps/metadata.c | |||
@@ -86,9 +86,12 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | |||
86 | /* FLAC */ | 86 | /* FLAC */ |
87 | [AFMT_FLAC] = | 87 | [AFMT_FLAC] = |
88 | AFMT_ENTRY("FLAC", "flac", NULL, get_flac_metadata, "flac\0"), | 88 | AFMT_ENTRY("FLAC", "flac", NULL, get_flac_metadata, "flac\0"), |
89 | /* Musepack */ | 89 | /* Musepack SV7 */ |
90 | [AFMT_MPC] = | 90 | [AFMT_MPC_SV7] = |
91 | AFMT_ENTRY("MPC", "mpc", NULL, get_musepack_metadata,"mpc\0"), | 91 | AFMT_ENTRY("MPCv7", "mpc", NULL, get_musepack_metadata,"mpc\0"), |
92 | /* Musepack SV8 */ | ||
93 | [AFMT_MPC_SV8] = | ||
94 | AFMT_ENTRY("MPCv8", "mpc", NULL, get_musepack_metadata,"mpc\0"), | ||
92 | /* A/52 (aka AC3) audio */ | 95 | /* A/52 (aka AC3) audio */ |
93 | [AFMT_A52] = | 96 | [AFMT_A52] = |
94 | AFMT_ENTRY("AC3", "a52", NULL, get_a52_metadata, "a52\0ac3\0"), | 97 | AFMT_ENTRY("AC3", "a52", NULL, get_a52_metadata, "a52\0ac3\0"), |
@@ -101,6 +104,9 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = | |||
101 | /* Advanced Audio Coding in M4A container */ | 104 | /* Advanced Audio Coding in M4A container */ |
102 | [AFMT_MP4_AAC] = | 105 | [AFMT_MP4_AAC] = |
103 | AFMT_ENTRY("AAC", "aac", NULL, get_mp4_metadata, "mp4\0"), | 106 | AFMT_ENTRY("AAC", "aac", NULL, get_mp4_metadata, "mp4\0"), |
107 | /* Advanced Audio Coding High Efficiency in M4A container */ | ||
108 | [AFMT_MP4_AAC_HE] = | ||
109 | AFMT_ENTRY("AAC-HE","aac", NULL, get_mp4_metadata, "mp4\0"), | ||
104 | /* Shorten */ | 110 | /* Shorten */ |
105 | [AFMT_SHN] = | 111 | [AFMT_SHN] = |
106 | AFMT_ENTRY("SHN","shorten", NULL, get_shn_metadata, "shn\0"), | 112 | AFMT_ENTRY("SHN","shorten", NULL, get_shn_metadata, "shn\0"), |
diff --git a/apps/metadata.h b/apps/metadata.h index 93b9891763..8c350fcca3 100644 --- a/apps/metadata.h +++ b/apps/metadata.h | |||
@@ -46,11 +46,13 @@ enum | |||
46 | AFMT_PCM_WAV, /* Uncompressed PCM in a WAV file */ | 46 | AFMT_PCM_WAV, /* Uncompressed PCM in a WAV file */ |
47 | AFMT_OGG_VORBIS, /* Ogg Vorbis */ | 47 | AFMT_OGG_VORBIS, /* Ogg Vorbis */ |
48 | AFMT_FLAC, /* FLAC */ | 48 | AFMT_FLAC, /* FLAC */ |
49 | AFMT_MPC, /* Musepack */ | 49 | AFMT_MPC_SV7, /* Musepack SV7 */ |
50 | AFMT_MPC_SV8, /* Musepack SV8 */ | ||
50 | AFMT_A52, /* A/52 (aka AC3) audio */ | 51 | AFMT_A52, /* A/52 (aka AC3) audio */ |
51 | AFMT_WAVPACK, /* WavPack */ | 52 | AFMT_WAVPACK, /* WavPack */ |
52 | AFMT_MP4_ALAC, /* Apple Lossless Audio Codec */ | 53 | AFMT_MP4_ALAC, /* Apple Lossless Audio Codec */ |
53 | AFMT_MP4_AAC, /* Advanced Audio Coding (AAC) in M4A container */ | 54 | AFMT_MP4_AAC, /* Advanced Audio Coding (AAC) in M4A container */ |
55 | AFMT_MP4_AAC_HE, /* Advanced Audio Coding (AAC-HE) in M4A container */ | ||
54 | AFMT_SHN, /* Shorten */ | 56 | AFMT_SHN, /* Shorten */ |
55 | AFMT_SID, /* SID File Format */ | 57 | AFMT_SID, /* SID File Format */ |
56 | AFMT_ADX, /* ADX File Format */ | 58 | AFMT_ADX, /* ADX File Format */ |
diff --git a/apps/metadata/mp4.c b/apps/metadata/mp4.c index a3721f0e9a..9ae174af7e 100644 --- a/apps/metadata/mp4.c +++ b/apps/metadata/mp4.c | |||
@@ -300,8 +300,7 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3, uint32_t* size) | |||
300 | /* Skip 13 bits from above, plus 3 bits, then read 11 bits */ | 300 | /* Skip 13 bits from above, plus 3 bits, then read 11 bits */ |
301 | else if ((length >= 4) && (((bits >> 5) & 0x7ff) == 0x2b7)) | 301 | else if ((length >= 4) && (((bits >> 5) & 0x7ff) == 0x2b7)) |
302 | { | 302 | { |
303 | /* extensionAudioObjectType */ | 303 | /* We found an extensionAudioObjectType */ |
304 | DEBUGF("MP4: extensionAudioType\n"); | ||
305 | type = bits & 0x1f; /* Object type - 5 bits*/ | 304 | type = bits & 0x1f; /* Object type - 5 bits*/ |
306 | bits = get_long_be(&buf[4]); | 305 | bits = get_long_be(&buf[4]); |
307 | 306 | ||
@@ -680,7 +679,6 @@ static bool read_mp4_container(int fd, struct mp3entry* id3, | |||
680 | { | 679 | { |
681 | uint32_t frequency; | 680 | uint32_t frequency; |
682 | 681 | ||
683 | id3->codectype = (type == MP4_mp4a) ? AFMT_MP4_AAC : AFMT_MP4_ALAC; | ||
684 | lseek(fd, 22, SEEK_CUR); | 682 | lseek(fd, 22, SEEK_CUR); |
685 | read_uint32be(fd, &frequency); | 683 | read_uint32be(fd, &frequency); |
686 | size -= 26; | 684 | size -= 26; |
@@ -700,11 +698,13 @@ static bool read_mp4_container(int fd, struct mp3entry* id3, | |||
700 | read_mp4_atom(fd, &subsize, &subtype, size); | 698 | read_mp4_atom(fd, &subsize, &subtype, size); |
701 | size -= 10; | 699 | size -= 10; |
702 | 700 | ||
701 | id3->codectype = AFMT_MP4_AAC; | ||
703 | if (subtype == MP4_esds) | 702 | if (subtype == MP4_esds) |
704 | { | 703 | { |
705 | sbr_used = read_mp4_esds(fd, id3, &size); | 704 | sbr_used = read_mp4_esds(fd, id3, &size); |
706 | if (sbr_used) | 705 | if (sbr_used) |
707 | { | 706 | { |
707 | id3->codectype = AFMT_MP4_AAC_HE; | ||
708 | if (SBR_upsampling_used) | 708 | if (SBR_upsampling_used) |
709 | DEBUGF("MP4: AAC-HE, SBR upsampling\n"); | 709 | DEBUGF("MP4: AAC-HE, SBR upsampling\n"); |
710 | else | 710 | else |
@@ -712,6 +712,11 @@ static bool read_mp4_container(int fd, struct mp3entry* id3, | |||
712 | } | 712 | } |
713 | } | 713 | } |
714 | } | 714 | } |
715 | else | ||
716 | { | ||
717 | id3->codectype = AFMT_MP4_ALAC; | ||
718 | } | ||
719 | |||
715 | } | 720 | } |
716 | break; | 721 | break; |
717 | 722 | ||
diff --git a/apps/metadata/mpc.c b/apps/metadata/mpc.c index 0dd76fcc4b..0387dc9f77 100644 --- a/apps/metadata/mpc.c +++ b/apps/metadata/mpc.c | |||
@@ -125,6 +125,8 @@ bool get_musepack_metadata(int fd, struct mp3entry *id3) | |||
125 | 125 | ||
126 | bufused = set_replaygain_sv7(id3, false, header[3], bufused); | 126 | bufused = set_replaygain_sv7(id3, false, header[3], bufused); |
127 | bufused = set_replaygain_sv7(id3, true , header[4], bufused); | 127 | bufused = set_replaygain_sv7(id3, true , header[4], bufused); |
128 | |||
129 | id3->codectype = AFMT_MPC_SV7; | ||
128 | } else { | 130 | } else { |
129 | return false; /* only SV7 is allowed within a "MP+" signature */ | 131 | return false; /* only SV7 is allowed within a "MP+" signature */ |
130 | } | 132 | } |
@@ -191,6 +193,8 @@ bool get_musepack_metadata(int fd, struct mp3entry *id3) | |||
191 | bufused += set_replaygain_sv8(id3, true , gain, peak, bufused); | 193 | bufused += set_replaygain_sv8(id3, true , gain, peak, bufused); |
192 | } | 194 | } |
193 | } | 195 | } |
196 | |||
197 | id3->codectype = AFMT_MPC_SV8; | ||
194 | } else { | 198 | } else { |
195 | /* No sv8 stream header found */ | 199 | /* No sv8 stream header found */ |
196 | return false; | 200 | return false; |