mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 15:00:11 +01:00
add seeking, update readme
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@135 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
599b28e497
commit
1e4e66ce3f
@ -6,11 +6,12 @@ line decoder called "test", and a simple Winamp plugin called "in_vgmstream".
|
||||
|
||||
--- test ---
|
||||
Usage: test.exe [-o outfile.wav] [-l loop count]
|
||||
[-f fade time] [-ipcmxeE] infile
|
||||
[-f fade time] [-d fade delay] [-ipPcmxeE] infile
|
||||
Options:
|
||||
-o outfile.wav: name of output .wav file, default is dump.wav
|
||||
-l loop count: loop count, default 2.0
|
||||
-f fade time: fade time (seconds), default 10.0
|
||||
-d fade delay: fade delay (seconds, default 0.0
|
||||
-i: ignore looping information and play the whole stream once
|
||||
-p: output to stdout (for piping into another program)
|
||||
-P: output to stdout even if stdout is a terminal
|
||||
@ -25,8 +26,7 @@ test -o happy.wav happy.adx
|
||||
to decode happy.adx to happy.wav.
|
||||
|
||||
--- in_vgmstream ---
|
||||
Drop the in_vgmstream.dll in your Winamp plugins directory. There is no
|
||||
configuration or seeking yet.
|
||||
Drop the in_vgmstream.dll in your Winamp plugins directory.
|
||||
|
||||
---
|
||||
File types supported by this version of vgmstream:
|
||||
|
@ -60,6 +60,7 @@ VGMSTREAM * vgmstream = NULL;
|
||||
HANDLE decode_thread_handle = INVALID_HANDLE_VALUE;
|
||||
int paused = 0;
|
||||
int decode_abort = 0;
|
||||
int seek_needed_samples = -1;
|
||||
int decode_pos_ms = 0;
|
||||
int decode_pos_samples = 0;
|
||||
int stream_length_samples = 0;
|
||||
@ -172,7 +173,6 @@ int play(char *fn)
|
||||
{
|
||||
int max_latency;
|
||||
|
||||
|
||||
/* don't lose a pointer! */
|
||||
if (vgmstream) {
|
||||
/* TODO: this should either pop up an error box or close the file */
|
||||
@ -214,6 +214,7 @@ int play(char *fn)
|
||||
input_module.VSASetInfo(vgmstream->sample_rate,vgmstream->channels);
|
||||
|
||||
decode_abort = 0;
|
||||
seek_needed_samples = -1;
|
||||
decode_pos_ms = 0;
|
||||
decode_pos_samples = 0;
|
||||
paused = 0;
|
||||
@ -274,7 +275,8 @@ int getoutputtime() {
|
||||
|
||||
/* seek */
|
||||
void setoutputtime(int t) {
|
||||
/* TODO: seeking */
|
||||
if (vgmstream)
|
||||
seek_needed_samples = (long long)t * vgmstream->sample_rate / 1000LL;
|
||||
}
|
||||
|
||||
/* pass these commands through */
|
||||
@ -349,11 +351,34 @@ DWORD WINAPI __stdcall decode(void *arg) {
|
||||
|
||||
int samples_to_do;
|
||||
int l;
|
||||
|
||||
if (decode_pos_samples+576>stream_length_samples && !loop_forever)
|
||||
samples_to_do=stream_length_samples-decode_pos_samples;
|
||||
else
|
||||
samples_to_do=576;
|
||||
|
||||
/* play 'till the end of this seek, or note if we're done seeking */
|
||||
if (seek_needed_samples != -1) {
|
||||
/* reset if we need to seek backwards */
|
||||
if (seek_needed_samples < decode_pos_samples) {
|
||||
VGMSTREAM * temp;
|
||||
temp = vgmstream;
|
||||
vgmstream = NULL;
|
||||
close_vgmstream(temp);
|
||||
|
||||
temp = init_vgmstream(lastfn);
|
||||
vgmstream = temp;
|
||||
|
||||
decode_pos_samples = 0;
|
||||
decode_pos_ms = 0;
|
||||
}
|
||||
if (decode_pos_samples < seek_needed_samples) {
|
||||
samples_to_do=seek_needed_samples-decode_pos_samples;
|
||||
if (samples_to_do>576) samples_to_do=576;
|
||||
} else
|
||||
seek_needed_samples = -1;
|
||||
}
|
||||
|
||||
l = (samples_to_do*vgmstream->channels*2)<<(input_module.dsp_isactive()?1:0);
|
||||
|
||||
if (samples_to_do == 0) {
|
||||
@ -366,6 +391,13 @@ DWORD WINAPI __stdcall decode(void *arg) {
|
||||
}
|
||||
Sleep(10);
|
||||
}
|
||||
else if (seek_needed_samples != -1) {
|
||||
render_vgmstream(sample_buffer,samples_to_do,vgmstream);
|
||||
input_module.outMod->Flush((int)decode_pos_ms);
|
||||
|
||||
decode_pos_samples+=samples_to_do;
|
||||
decode_pos_ms=decode_pos_samples*1000LL/vgmstream->sample_rate;
|
||||
}
|
||||
else if (input_module.outMod->CanWrite() >= l) {
|
||||
/* let vgmstream do its thing */
|
||||
render_vgmstream(sample_buffer,samples_to_do,vgmstream);
|
||||
|
Loading…
Reference in New Issue
Block a user