summaryrefslogtreecommitdiff
path: root/plugins/wma/libasf
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2013-01-25 22:07:00 +0100
committerGravatar waker <wakeroid@gmail.com>2013-01-25 22:07:00 +0100
commit2b2ab15d0022b302e651318ad45aa6a85889a864 (patch)
treef410dceccf9b94af42441a5ead937adc6a025a56 /plugins/wma/libasf
parent1bceb2657b2e2e426c3fc1c96e668e8612fec490 (diff)
wma: seeking WIP
Diffstat (limited to 'plugins/wma/libasf')
-rw-r--r--plugins/wma/libasf/asf.c12
-rw-r--r--plugins/wma/libasf/asf.h2
2 files changed, 8 insertions, 6 deletions
diff --git a/plugins/wma/libasf/asf.c b/plugins/wma/libasf/asf.c
index 90c8974f..595a27ac 100644
--- a/plugins/wma/libasf/asf.c
+++ b/plugins/wma/libasf/asf.c
@@ -404,7 +404,7 @@ int asf_get_timestamp(int *duration, DB_FILE *fp)
}
/*entry point for seeks*/
-int asf_seek(int ms, asf_waveformatex_t* wfx, DB_FILE *fp, int64_t first_frame_offset)
+int asf_seek(int ms, asf_waveformatex_t* wfx, DB_FILE *fp, int64_t first_frame_offset, int *skip_ms)
{
int time, duration, delta, temp, count=0;
@@ -437,22 +437,24 @@ int asf_seek(int ms, asf_waveformatex_t* wfx, DB_FILE *fp, int64_t first_frame_o
/*check the time stamp of our packet*/
time = asf_get_timestamp(&duration, fp);
- DEBUGF("time %d ms with duration %d\n", time, duration);
+// DEBUGF("time %d ms with duration %d\n", time, duration);
if (time < 0) {
/*unknown error, try to recover*/
DEBUGF("UKNOWN SEEK ERROR\n");
deadbeef->fseek (fp, first_frame_offset+initial_packet*wfx->packet_size, SEEK_SET);
+ *skip_ms = 0;
/*seek failed so return time stamp of the initial packet*/
- return asf_get_timestamp(&duration, fp);
+ return -1;//asf_get_timestamp(&duration, fp);
}
+ DEBUGF("time: %d, duration: %d (ms: %d)\n", time, duration, ms);
if ((time+duration>=ms && time<=ms) || count > 10) {
- DEBUGF("Found our packet! Now at %d packet\n", packet_num);
+ DEBUGF("Found our packet! Now at %d packet, time %d, requested %d\n", packet_num, time, ms);
deadbeef->fseek (fp, pos, SEEK_SET);
+ *skip_ms = ms - time;
return time;
} else {
- DEBUGF("Seek again\n", packet_num);
/*seek again*/
delta = ms-time;
/*estimate new packet number from bitrate and our current position*/
diff --git a/plugins/wma/libasf/asf.h b/plugins/wma/libasf/asf.h
index cb96fed2..f49d38d1 100644
--- a/plugins/wma/libasf/asf.h
+++ b/plugins/wma/libasf/asf.h
@@ -49,6 +49,6 @@ int asf_read_packet(uint8_t** audiobuf, int* audiobufsize, int* packetlength,
int asf_get_timestamp(int *duration, DB_FILE *fp);
-int asf_seek(int ms, asf_waveformatex_t* wfx, DB_FILE *fp, int64_t first_frame_offset);
+int asf_seek(int ms, asf_waveformatex_t* wfx, DB_FILE *fp, int64_t first_frame_offset, int *skip_ms);
#endif /* _ASF_H */