Skip to content

Commit

Permalink
Merge remote-tracking branch 'deadbeef/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba160 committed May 2, 2020
2 parents 4aa5330 + fb7048c commit 8314fb8
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 59 deletions.
8 changes: 0 additions & 8 deletions plugins/artwork/artwork.c
Original file line number Diff line number Diff line change
Expand Up @@ -1251,14 +1251,6 @@ local_image_file (const char *local_path, const char *uri, DB_vfs_t *vfsplug, dd
return 0;
}
}
if (!scan_local_path ("*.jpg", path, uri, vfsplug, cover)
|| !scan_local_path ("*.jpeg", path, uri, vfsplug, cover)
|| !scan_local_path ("*.png", path, uri, vfsplug, cover)) {
free (filemask);
free (folders);
free (path);
return 0;
}
free (path);
}

Expand Down
3 changes: 3 additions & 0 deletions plugins/cocoaui/Utility/tftintutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ calculate_tint_ranges_from_string (const char *inputString, int *tintRanges, uns
p += len;
remaining -= len;
}
if (remaining == 0) {
break;
}
uint32_t i = 0;
u8_nextchar(p, &i);
memcpy (out, p, i);
Expand Down
1 change: 1 addition & 0 deletions plugins/libmp4ff/mp4ff.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ int32_t mp4ff_get_decoder_config(const mp4ff_t *f, const int32_t track,
{
*ppBuf = NULL;
*pBufSize = 0;
return 1;
} else {
*ppBuf = malloc(f->track[track]->decoderConfigLen);
if (*ppBuf == NULL)
Expand Down
122 changes: 73 additions & 49 deletions plugins/mp3/mp3parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,112 +207,136 @@ _parse_packet (mp3packet_t * restrict packet, uint8_t * restrict fb) {
return packet->packetlength;
}

static uint32_t
extract_i32 (unsigned char *buf)
{
uint32_t x;
// big endian extract

x = buf[0];
x <<= 8;
x |= buf[1];
x <<= 8;
x |= buf[2];
x <<= 8;
x |= buf[3];

return x;
}
#define READ_UINT8() ({if (buffer_size < 1) return -1; uint8_t _temp8 = *buffer; buffer++; buffer_size--; _temp8;})
#define READ_UINT32() ({if (buffer_size < 4) return -1; uint32_t _temp32 = (uint32_t)buffer[3] | ((uint32_t)buffer[2]<<8) | ((uint32_t)buffer[1]<<16) | ((uint32_t)buffer[0]<<24); buffer+=4; buffer_size-=4; _temp32;})

static int
_check_xing_header (mp3info_t *info, mp3packet_t *packet, uint8_t *data, int datasize) {
_check_xing_header (mp3info_t *info, mp3packet_t *packet, uint8_t *buffer, int buffer_size) {
const char cookieXing[] = "Xing";
const char cookieInfo[] = "Info";

// ignore mpeg version, and try both 17 and 32 byte offsets
uint8_t *magic = data + 17;
buffer += 17;
buffer_size -= 17;
if (buffer_size < 4) {
return -1;
}

int havecookie = !memcmp (cookieXing, magic, 4) || !memcmp (cookieInfo, magic, 4);
int havecookie = !memcmp (cookieXing, buffer, 4) || !memcmp (cookieInfo, buffer, 4);

if (!havecookie) {
magic = data + 32;
havecookie = !memcmp (cookieXing, magic, 4) || !memcmp (cookieInfo, magic, 4);;
buffer += 15;
buffer_size -= 15;
if (buffer_size < 4) {
return -1;
}

havecookie = !memcmp (cookieXing, buffer, 4) || !memcmp (cookieInfo, buffer, 4);;
}

if (!havecookie) {
return -1;
}

data = magic + 4;
buffer += 4;
buffer_size -= 4;

info->packet_offs = packet->offs+packet->packetlength;

// read flags
uint32_t flags;
flags = extract_i32 (data);
data += 4;
uint32_t flags = READ_UINT32();

if (flags & FRAMES_FLAG) {
if (buffer_size < 4) {
return -1;
}
// read number of frames
uint32_t nframes = extract_i32 (data);
uint32_t nframes = READ_UINT32();
info->totalsamples = nframes * packet->samples_per_frame;
info->have_duration = 1;
data += 4;
}
if (flags & BYTES_FLAG) {
data += 4;
READ_UINT32();
}
if (flags & TOC_FLAG) {
data += 100;
if (buffer_size < 100) {
return -1;
}
buffer += 100;
buffer_size -= 100;
}
if (flags & VBR_SCALE_FLAG) {
data += 4;
READ_UINT32();
}
if (buffer_size < 4) {
return -1;
}
// lame header
int lame_header = 0;
if (!memcmp (data, "LAME", 4)) {
if (!memcmp (buffer, "LAME", 4)) {
lame_header = 1;
}
data += 4;
buffer += 4;
buffer_size -= 4;

data += 5; // what is this?
if (buffer_size < 5) {
return -1;
}

uint8_t rev = *data++;
buffer += 5; // what is this?
buffer_size -= 5;

if (buffer_size < 1) {
return -1;
}
uint8_t rev = READ_UINT8();

switch (rev & 0x0f) {
case XING_CBR ... XING_ABR2:
info->vbr_type = rev & 0x0f;
break;
}
if (lame_header) {
data++; //uint8_t lpf = *data++;
if (buffer_size < 22) {
return -1;
}
buffer += 1; //uint8_t lpf = *data++;
buffer_size -= 1;

//3 floats: replay gain

data += 4; // float rg_peaksignalamp = extract_f32 (buf);
buffer += 4; // float rg_peaksignalamp = extract_f32 (buf);
buffer_size -= 4;

data += 2; // uint16_t rg_radio = extract_i16 (buf);
buffer += 2; // uint16_t rg_radio = extract_i16 (buf);
buffer_size -= 2;

data += 2; // uint16_t rg_audiophile = extract_i16 (buf);
buffer += 2; // uint16_t rg_audiophile = extract_i16 (buf);
buffer_size -= 2;

// skip
data += 2;
buffer += 2;
buffer_size -= 2;

info->delay = (((uint32_t)data[0]) << 4) | ((((uint32_t)data[1]) & 0xf0)>>4);
info->padding = ((((uint32_t)data[1])&0x0f)<<8) | ((uint32_t)data[2]);
data += 3;
info->delay = (((uint32_t)buffer[0]) << 4) | ((((uint32_t)buffer[1]) & 0xf0)>>4);
info->padding = ((((uint32_t)buffer[1])&0x0f)<<8) | ((uint32_t)buffer[2]);
buffer += 3;
buffer_size -= 3;

// skip
data++;
buffer++;
buffer_size -= 1;

data++; // uint8_t mp3gain = *data++;
buffer++; // uint8_t mp3gain = *data++;
buffer_size -= 1;

// lame preset nr
info->lamepreset = data[1] | (data[0]<<8);
data += 2;
info->lamepreset = buffer[1] | (buffer[0]<<8);
buffer += 2;
buffer_size -= 2;

// musiclen
info->lame_musiclength = extract_i32 (data);
info->lame_musiclength = READ_UINT32();
}

return 0;
Expand Down Expand Up @@ -553,7 +577,7 @@ mp3_parse_file (mp3info_t *info, uint32_t flags, DB_FILE *fp, int64_t fsize, int
goto end;
}
// Calculate CBR duration from file size
else if (!vbr && !info->have_xing_header && !(flags & MP3_PARSE_FULLSCAN) && info->npackets >= 200) {
else if (!vbr && !info->have_xing_header && seek_to_sample < 0 && !(flags & MP3_PARSE_FULLSCAN) && info->npackets >= 200) {
// calculate total number of packets from file size
// 8876 - 9485
int64_t npackets = ceil(datasize/(float)info->ref_packet.packetlength);
Expand Down Expand Up @@ -630,7 +654,7 @@ mp3_parse_file (mp3info_t *info, uint32_t flags, DB_FILE *fp, int64_t fsize, int
#if PERFORMANCE_STATS
gettimeofday (&end_tv, NULL);
float elapsed = (end_tv.tv_sec-start_tv.tv_sec) + (end_tv.tv_usec - start_tv.tv_usec) / 1000000.f;
printf ("mp3 stats:\nSeeks: %llu\nReads: %llu\nBytes: %llu\nTime: %f sec", info->num_seeks, info->num_reads, info->bytes_read, elapsed);
printf ("mp3 stats:\nSeeks: %llu\nReads: %llu\nBytes: %llu\nTime: %f sec\n", info->num_seeks, info->num_reads, info->bytes_read, elapsed);
#endif
return err;
}
21 changes: 19 additions & 2 deletions plugins/pulse/pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
static DB_output_t plugin;
DB_functions_t * deadbeef;

#define CONFSTR_PULSE_SERVERADDR "pulse.serveraddr"
// serveraddr2 is a version bump, since the handling has changed, and "default"
// value has different meaning.
#define CONFSTR_PULSE_SERVERADDR "pulse.serveraddr2"
#define CONFSTR_PULSE_BUFFERSIZE "pulse.buffersize"
#define PULSE_DEFAULT_BUFFERSIZE 4096

Expand Down Expand Up @@ -129,7 +131,22 @@ static int pulse_set_spec(ddb_waveformat_t *fmt)

// Read serveraddr from config
char server[1000];
deadbeef->conf_get_str (CONFSTR_PULSE_SERVERADDR, "", server, sizeof (server));

// migrate from 0.7.x
deadbeef->conf_lock ();
int has_server2 = deadbeef->conf_get_str_fast (CONFSTR_PULSE_SERVERADDR, NULL) != NULL;
deadbeef->conf_unlock ();

if (!has_server2) {
deadbeef->conf_get_str ("pulse.serveraddr", "", server, sizeof (server));
// convert default
if (!strcasecmp (server, "default")) {
*server = 0;
}
}
else {
deadbeef->conf_get_str (CONFSTR_PULSE_SERVERADDR, "", server, sizeof (server));
}

s = pa_simple_new(*server ? server : NULL, "Deadbeef", PA_STREAM_PLAYBACK, dev, "Music", &ss, &channel_map, attr, &error);

Expand Down
3 changes: 3 additions & 0 deletions plugins/vfs_zip/vfs_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ vfs_zip_open (const char *fname) {
}
memset (&st, 0, sizeof (st));

while (*colon == '/') {
colon++;
}
int res = zip_stat(z, colon, 0, &st);
if (res != 0) {
zip_close (z);
Expand Down
1 change: 1 addition & 0 deletions scriptable/scriptable_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ valueForKeyOrDefault (scriptableItem_t *item, const char *key, const char *def)

void
scriptableEncoderPresetToConverterEncoderPreset (scriptableItem_t *item, ddb_encoder_preset_t *encoder_preset) {
memset (encoder_preset, 0, sizeof (ddb_encoder_preset_t));
encoder_preset->ext = strdup (valueForKeyOrDefault(item, "ext", ""));
encoder_preset->encoder = strdup (valueForKeyOrDefault(item, "encoder", ""));
encoder_preset->method = atoi (valueForKeyOrDefault(item, "method", "0"));
Expand Down

0 comments on commit 8314fb8

Please sign in to comment.