mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
complete largefile support
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
SUBDIRS = include
|
||||
|
||||
EXTRA_DIST = \
|
||||
config.h \
|
||||
config.c \
|
||||
configure.h \
|
||||
configure.c \
|
||||
in_flac.c \
|
||||
in_flac.dsp \
|
||||
infobox.c \
|
||||
|
||||
@@ -16,10 +16,14 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdio.h>
|
||||
#include "config.h"
|
||||
#include "configure.h"
|
||||
#include "tagz.h"
|
||||
#include "resource.h"
|
||||
|
||||
@@ -16,11 +16,16 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <limits.h> /* for INT_MAX */
|
||||
#include <stdio.h>
|
||||
|
||||
#include "winamp2/in2.h"
|
||||
#include "config.h"
|
||||
#include "configure.h"
|
||||
#include "infobox.h"
|
||||
#include "tagz.h"
|
||||
|
||||
@@ -326,33 +331,33 @@ static void getfileinfo(char *filename, char *title, int *length_in_msec)
|
||||
{
|
||||
FLAC__StreamMetadata streaminfo;
|
||||
|
||||
if (!filename || !*filename)
|
||||
{
|
||||
if (!filename || !*filename) {
|
||||
filename = lastfn_;
|
||||
if (length_in_msec)
|
||||
{
|
||||
*length_in_msec = (int)file_info_.length_in_msec;
|
||||
length_in_msec = 0; /* force skip in following code */
|
||||
if (length_in_msec) {
|
||||
*length_in_msec = file_info_.length_in_msec;
|
||||
length_in_msec = 0; /* force skip in following code */
|
||||
}
|
||||
}
|
||||
|
||||
if (!FLAC__metadata_get_streaminfo(filename, &streaminfo))
|
||||
{
|
||||
if (!FLAC__metadata_get_streaminfo(filename, &streaminfo)) {
|
||||
if (length_in_msec)
|
||||
*length_in_msec = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (title)
|
||||
{
|
||||
if (title) {
|
||||
static WCHAR buffer[400];
|
||||
format_title(filename, buffer, 400);
|
||||
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, buffer, -1, title, 400, NULL, NULL);
|
||||
}
|
||||
|
||||
if (length_in_msec)
|
||||
if (length_in_msec) {
|
||||
/* with VC++ you have to spoon feed it the casting from uint64->int64->double */
|
||||
*length_in_msec = (int)((double)(FLAC__int64)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5);
|
||||
FLAC__uint64 l = (FLAC__uint64)((double)(FLAC__int64)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5);
|
||||
if (l > INT_MAX)
|
||||
l = INT_MAX;
|
||||
*length_in_msec = (int)l;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -107,11 +107,11 @@ SOURCE=.\include\winamp2\out.h
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\config.c
|
||||
SOURCE=.\configure.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\config.h
|
||||
SOURCE=.\configure.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -16,12 +16,16 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "FLAC/all.h"
|
||||
#include "plugin_common/all.h"
|
||||
#include "infobox.h"
|
||||
#include "config.h"
|
||||
#include "configure.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h> /* for INT_MAX */
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* for memmove() */
|
||||
#include "playback.h"
|
||||
@@ -60,8 +65,7 @@ static void metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__Stre
|
||||
|
||||
if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO)
|
||||
{
|
||||
FLAC__ASSERT(metadata->data.stream_info.total_samples < 0x100000000); /* this plugin can only handle < 4 gigasamples */
|
||||
file_info->total_samples = (unsigned)(metadata->data.stream_info.total_samples&0xfffffffful);
|
||||
file_info->total_samples = metadata->data.stream_info.total_samples;
|
||||
file_info->bits_per_sample = metadata->data.stream_info.bits_per_sample;
|
||||
file_info->channels = metadata->data.stream_info.channels;
|
||||
file_info->sample_rate = metadata->data.stream_info.sample_rate;
|
||||
@@ -72,7 +76,14 @@ static void metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__Stre
|
||||
file_info->abort_flag = true;
|
||||
return;
|
||||
}
|
||||
file_info->length_in_msec = (unsigned)((double)file_info->total_samples / (double)file_info->sample_rate * 1000.0 + 0.5);
|
||||
|
||||
{
|
||||
/* with VC++ you have to spoon feed it the casting from uint64->int64->double */
|
||||
FLAC__uint64 l = (FLAC__uint64)((double)(FLAC__int64)file_info->total_samples / (double)file_info->sample_rate * 1000.0 + 0.5);
|
||||
if (l > INT_MAX)
|
||||
l = INT_MAX;
|
||||
file_info->length_in_msec = (int)l;
|
||||
}
|
||||
}
|
||||
else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
|
||||
{
|
||||
@@ -143,7 +154,7 @@ FLAC__bool FLAC_plugin__decoder_init(FLAC__FileDecoder *decoder, const char *fil
|
||||
file_info->eof = false;
|
||||
file_info->seek_to = -1;
|
||||
file_info->is_playing = true;
|
||||
file_info->average_bps = (unsigned)(filesize / (125.*file_info->total_samples/file_info->sample_rate));
|
||||
file_info->average_bps = (unsigned)(filesize / (125.*(double)(FLAC__int64)file_info->total_samples/(double)file_info->sample_rate));
|
||||
|
||||
bh_index_last_w = 0;
|
||||
bh_index_last_o = BITRATE_HIST_SIZE;
|
||||
@@ -176,8 +187,7 @@ void FLAC_plugin__decoder_delete(FLAC__FileDecoder *decoder)
|
||||
int FLAC_plugin__seek(FLAC__FileDecoder *decoder, file_info_struct *file_info)
|
||||
{
|
||||
int pos;
|
||||
const FLAC__uint64 target_sample =
|
||||
(FLAC__uint64)file_info->total_samples*file_info->seek_to / file_info->length_in_msec;
|
||||
const FLAC__uint64 target_sample = file_info->total_samples * file_info->seek_to / file_info->length_in_msec;
|
||||
|
||||
if (!FLAC__file_decoder_seek_absolute(decoder, target_sample))
|
||||
return -1;
|
||||
|
||||
@@ -38,12 +38,12 @@ typedef struct {
|
||||
volatile FLAC__bool abort_flag;
|
||||
volatile FLAC__bool eof;
|
||||
volatile int seek_to;
|
||||
unsigned total_samples;
|
||||
FLAC__uint64 total_samples;
|
||||
unsigned bits_per_sample;
|
||||
unsigned output_bits_per_sample;
|
||||
unsigned channels;
|
||||
unsigned sample_rate;
|
||||
unsigned length_in_msec;
|
||||
int length_in_msec; /* int (instead of FLAC__uint64) only because that's what Winamp uses; seeking won't work right if this maxes out */
|
||||
unsigned average_bps;
|
||||
FLAC__bool has_replaygain;
|
||||
double replay_scale;
|
||||
|
||||
Reference in New Issue
Block a user