Merge branch 'v0.18.x'
This commit is contained in:
commit
913064d6cc
4
NEWS
4
NEWS
@ -49,6 +49,10 @@ ver 0.18.12 (not yet released)
|
|||||||
* database
|
* database
|
||||||
- proxy: fix build failure with libmpdclient 2.2
|
- proxy: fix build failure with libmpdclient 2.2
|
||||||
- proxy: fix add/search and other commands with libmpdclient < 2.9
|
- proxy: fix add/search and other commands with libmpdclient < 2.9
|
||||||
|
* decoder
|
||||||
|
- audiofile: improve responsiveness
|
||||||
|
- audiofile: fix WAV stream playback
|
||||||
|
- dsdiff, dsf: fix stream playback
|
||||||
|
|
||||||
ver 0.18.11 (2014/05/12)
|
ver 0.18.11 (2014/05/12)
|
||||||
* decoder
|
* decoder
|
||||||
|
@ -32,12 +32,27 @@
|
|||||||
#include <af_vfs.h>
|
#include <af_vfs.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
|
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
|
||||||
#define CHUNK_SIZE 1020
|
#define CHUNK_SIZE 1020
|
||||||
|
|
||||||
static constexpr Domain audiofile_domain("audiofile");
|
static constexpr Domain audiofile_domain("audiofile");
|
||||||
|
|
||||||
|
struct AudioFileInputStream {
|
||||||
|
Decoder *const decoder;
|
||||||
|
InputStream &is;
|
||||||
|
|
||||||
|
size_t Read(void *buffer, size_t size) {
|
||||||
|
/* libaudiofile does not like partial reads at all,
|
||||||
|
and wil abort playback; therefore always force full
|
||||||
|
reads */
|
||||||
|
return decoder_read_full(decoder, is, buffer, size)
|
||||||
|
? size
|
||||||
|
: 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
static int
|
static int
|
||||||
audiofile_get_duration(Path path_fs)
|
audiofile_get_duration(Path path_fs)
|
||||||
@ -57,29 +72,26 @@ audiofile_get_duration(Path path_fs)
|
|||||||
static ssize_t
|
static ssize_t
|
||||||
audiofile_file_read(AFvirtualfile *vfile, void *data, size_t length)
|
audiofile_file_read(AFvirtualfile *vfile, void *data, size_t length)
|
||||||
{
|
{
|
||||||
InputStream &is = *(InputStream *)vfile->closure;
|
AudioFileInputStream &afis = *(AudioFileInputStream *)vfile->closure;
|
||||||
|
|
||||||
Error error;
|
return afis.Read(data, length);
|
||||||
size_t nbytes = is.LockRead(data, length, error);
|
|
||||||
if (nbytes == 0 && error.IsDefined()) {
|
|
||||||
LogError(error);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nbytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static AFfileoffset
|
static AFfileoffset
|
||||||
audiofile_file_length(AFvirtualfile *vfile)
|
audiofile_file_length(AFvirtualfile *vfile)
|
||||||
{
|
{
|
||||||
InputStream &is = *(InputStream *)vfile->closure;
|
AudioFileInputStream &afis = *(AudioFileInputStream *)vfile->closure;
|
||||||
|
InputStream &is = afis.is;
|
||||||
|
|
||||||
return is.GetSize();
|
return is.GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static AFfileoffset
|
static AFfileoffset
|
||||||
audiofile_file_tell(AFvirtualfile *vfile)
|
audiofile_file_tell(AFvirtualfile *vfile)
|
||||||
{
|
{
|
||||||
InputStream &is = *(InputStream *)vfile->closure;
|
AudioFileInputStream &afis = *(AudioFileInputStream *)vfile->closure;
|
||||||
|
InputStream &is = afis.is;
|
||||||
|
|
||||||
return is.GetOffset();
|
return is.GetOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +107,8 @@ static AFfileoffset
|
|||||||
audiofile_file_seek(AFvirtualfile *vfile, AFfileoffset _offset,
|
audiofile_file_seek(AFvirtualfile *vfile, AFfileoffset _offset,
|
||||||
int is_relative)
|
int is_relative)
|
||||||
{
|
{
|
||||||
InputStream &is = *(InputStream *)vfile->closure;
|
AudioFileInputStream &afis = *(AudioFileInputStream *)vfile->closure;
|
||||||
|
InputStream &is = afis.is;
|
||||||
|
|
||||||
InputStream::offset_type offset = _offset;
|
InputStream::offset_type offset = _offset;
|
||||||
if (is_relative)
|
if (is_relative)
|
||||||
@ -110,10 +123,10 @@ audiofile_file_seek(AFvirtualfile *vfile, AFfileoffset _offset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static AFvirtualfile *
|
static AFvirtualfile *
|
||||||
setup_virtual_fops(InputStream &stream)
|
setup_virtual_fops(AudioFileInputStream &afis)
|
||||||
{
|
{
|
||||||
AFvirtualfile *vf = new AFvirtualfile();
|
AFvirtualfile *vf = new AFvirtualfile();
|
||||||
vf->closure = &stream;
|
vf->closure = &afis;
|
||||||
vf->write = nullptr;
|
vf->write = nullptr;
|
||||||
vf->read = audiofile_file_read;
|
vf->read = audiofile_file_read;
|
||||||
vf->length = audiofile_file_length;
|
vf->length = audiofile_file_length;
|
||||||
@ -180,7 +193,8 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vf = setup_virtual_fops(is);
|
AudioFileInputStream afis{&decoder, is};
|
||||||
|
vf = setup_virtual_fops(afis);
|
||||||
|
|
||||||
af_fp = afOpenVirtualFile(vf, "r", nullptr);
|
af_fp = afOpenVirtualFile(vf, "r", nullptr);
|
||||||
if (af_fp == AF_NULL_FILEHANDLE) {
|
if (af_fp == AF_NULL_FILEHANDLE) {
|
||||||
|
@ -45,14 +45,6 @@ DsdId::Equals(const char *s) const
|
|||||||
return memcmp(value, s, sizeof(value)) == 0;
|
return memcmp(value, s, sizeof(value)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
dsdlib_read(Decoder *decoder, InputStream &is,
|
|
||||||
void *data, size_t length)
|
|
||||||
{
|
|
||||||
size_t nbytes = decoder_read(decoder, is, data, length);
|
|
||||||
return nbytes == length;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skip the #input_stream to the specified offset.
|
* Skip the #input_stream to the specified offset.
|
||||||
*/
|
*/
|
||||||
@ -123,7 +115,7 @@ dsdlib_tag_id3(InputStream &is,
|
|||||||
id3_byte_t *dsdid3data;
|
id3_byte_t *dsdid3data;
|
||||||
dsdid3data = dsdid3;
|
dsdid3data = dsdid3;
|
||||||
|
|
||||||
if (!dsdlib_read(nullptr, is, dsdid3data, count))
|
if (!decoder_read_full(nullptr, is, dsdid3data, count))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
id3_tag = id3_tag_parse(dsdid3data, count);
|
id3_tag = id3_tag_parse(dsdid3data, count);
|
||||||
|
@ -58,10 +58,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
|
||||||
dsdlib_read(Decoder *decoder, InputStream &is,
|
|
||||||
void *data, size_t length);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
dsdlib_skip_to(Decoder *decoder, InputStream &is,
|
dsdlib_skip_to(Decoder *decoder, InputStream &is,
|
||||||
uint64_t offset);
|
uint64_t offset);
|
||||||
|
@ -90,14 +90,14 @@ static bool
|
|||||||
dsdiff_read_id(Decoder *decoder, InputStream &is,
|
dsdiff_read_id(Decoder *decoder, InputStream &is,
|
||||||
DsdId *id)
|
DsdId *id)
|
||||||
{
|
{
|
||||||
return dsdlib_read(decoder, is, id, sizeof(*id));
|
return decoder_read_full(decoder, is, id, sizeof(*id));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
dsdiff_read_chunk_header(Decoder *decoder, InputStream &is,
|
dsdiff_read_chunk_header(Decoder *decoder, InputStream &is,
|
||||||
DsdiffChunkHeader *header)
|
DsdiffChunkHeader *header)
|
||||||
{
|
{
|
||||||
return dsdlib_read(decoder, is, header, sizeof(*header));
|
return decoder_read_full(decoder, is, header, sizeof(*header));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -109,8 +109,7 @@ dsdiff_read_payload(Decoder *decoder, InputStream &is,
|
|||||||
if (size != (uint64_t)length)
|
if (size != (uint64_t)length)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size_t nbytes = decoder_read(decoder, is, data, length);
|
return decoder_read_full(decoder, is, data, length);
|
||||||
return nbytes == length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,8 +141,8 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
|
|||||||
} else if (header.id.Equals("CHNL")) {
|
} else if (header.id.Equals("CHNL")) {
|
||||||
uint16_t channels;
|
uint16_t channels;
|
||||||
if (header.GetSize() < sizeof(channels) ||
|
if (header.GetSize() < sizeof(channels) ||
|
||||||
!dsdlib_read(decoder, is,
|
!decoder_read_full(decoder, is,
|
||||||
&channels, sizeof(channels)) ||
|
&channels, sizeof(channels)) ||
|
||||||
!dsdlib_skip_to(decoder, is, chunk_end_offset))
|
!dsdlib_skip_to(decoder, is, chunk_end_offset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -151,8 +150,8 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
|
|||||||
} else if (header.id.Equals("CMPR")) {
|
} else if (header.id.Equals("CMPR")) {
|
||||||
DsdId type;
|
DsdId type;
|
||||||
if (header.GetSize() < sizeof(type) ||
|
if (header.GetSize() < sizeof(type) ||
|
||||||
!dsdlib_read(decoder, is,
|
!decoder_read_full(decoder, is,
|
||||||
&type, sizeof(type)) ||
|
&type, sizeof(type)) ||
|
||||||
!dsdlib_skip_to(decoder, is, chunk_end_offset))
|
!dsdlib_skip_to(decoder, is, chunk_end_offset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -205,7 +204,7 @@ dsdiff_handle_native_tag(InputStream &is,
|
|||||||
|
|
||||||
struct dsdiff_native_tag metatag;
|
struct dsdiff_native_tag metatag;
|
||||||
|
|
||||||
if (!dsdlib_read(nullptr, is, &metatag, sizeof(metatag)))
|
if (!decoder_read_full(nullptr, is, &metatag, sizeof(metatag)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t length = FromBE32(metatag.size);
|
uint32_t length = FromBE32(metatag.size);
|
||||||
@ -218,7 +217,7 @@ dsdiff_handle_native_tag(InputStream &is,
|
|||||||
char *label;
|
char *label;
|
||||||
label = string;
|
label = string;
|
||||||
|
|
||||||
if (!dsdlib_read(nullptr, is, label, (size_t)length))
|
if (!decoder_read_full(nullptr, is, label, (size_t)length))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string[length] = '\0';
|
string[length] = '\0';
|
||||||
@ -325,7 +324,7 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
|
|||||||
DsdiffChunkHeader *chunk_header)
|
DsdiffChunkHeader *chunk_header)
|
||||||
{
|
{
|
||||||
DsdiffHeader header;
|
DsdiffHeader header;
|
||||||
if (!dsdlib_read(decoder, is, &header, sizeof(header)) ||
|
if (!decoder_read_full(decoder, is, &header, sizeof(header)) ||
|
||||||
!header.id.Equals("FRM8") ||
|
!header.id.Equals("FRM8") ||
|
||||||
!header.format.Equals("DSD "))
|
!header.format.Equals("DSD "))
|
||||||
return false;
|
return false;
|
||||||
@ -388,10 +387,10 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
|
|||||||
now_size = now_frames * frame_size;
|
now_size = now_frames * frame_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t nbytes = decoder_read(decoder, is, buffer, now_size);
|
if (!decoder_read_full(&decoder, is, buffer, now_size))
|
||||||
if (nbytes != now_size)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const size_t nbytes = now_size;
|
||||||
chunk_size -= nbytes;
|
chunk_size -= nbytes;
|
||||||
|
|
||||||
if (lsbitfirst)
|
if (lsbitfirst)
|
||||||
|
@ -100,7 +100,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
|
|||||||
DsfMetaData *metadata)
|
DsfMetaData *metadata)
|
||||||
{
|
{
|
||||||
DsfHeader dsf_header;
|
DsfHeader dsf_header;
|
||||||
if (!dsdlib_read(decoder, is, &dsf_header, sizeof(dsf_header)) ||
|
if (!decoder_read_full(decoder, is, &dsf_header, sizeof(dsf_header)) ||
|
||||||
!dsf_header.id.Equals("DSD "))
|
!dsf_header.id.Equals("DSD "))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -114,7 +114,8 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
|
|||||||
|
|
||||||
/* read the 'fmt ' chunk of the DSF file */
|
/* read the 'fmt ' chunk of the DSF file */
|
||||||
DsfFmtChunk dsf_fmt_chunk;
|
DsfFmtChunk dsf_fmt_chunk;
|
||||||
if (!dsdlib_read(decoder, is, &dsf_fmt_chunk, sizeof(dsf_fmt_chunk)) ||
|
if (!decoder_read_full(decoder, is,
|
||||||
|
&dsf_fmt_chunk, sizeof(dsf_fmt_chunk)) ||
|
||||||
!dsf_fmt_chunk.id.Equals("fmt "))
|
!dsf_fmt_chunk.id.Equals("fmt "))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -140,7 +141,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
|
|||||||
|
|
||||||
/* read the 'data' chunk of the DSF file */
|
/* read the 'data' chunk of the DSF file */
|
||||||
DsfDataChunk data_chunk;
|
DsfDataChunk data_chunk;
|
||||||
if (!dsdlib_read(decoder, is, &data_chunk, sizeof(data_chunk)) ||
|
if (!decoder_read_full(decoder, is, &data_chunk, sizeof(data_chunk)) ||
|
||||||
!data_chunk.id.Equals("data"))
|
!data_chunk.id.Equals("data"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -244,10 +245,10 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
|
|||||||
now_size = now_frames * frame_size;
|
now_size = now_frames * frame_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t nbytes = decoder_read(&decoder, is, buffer, now_size);
|
if (!decoder_read_full(&decoder, is, buffer, now_size))
|
||||||
if (nbytes != now_size)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const size_t nbytes = now_size;
|
||||||
chunk_size -= nbytes;
|
chunk_size -= nbytes;
|
||||||
|
|
||||||
if (bitreverse)
|
if (bitreverse)
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <ogg/ogg.h>
|
#include <ogg/ogg.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
static constexpr opus_int32 opus_sample_rate = 48000;
|
static constexpr opus_int32 opus_sample_rate = 48000;
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user