Fixed bug where unseekable songs still allowed the user to move the slider and updated the time.

CQTexperiment
vspader 2007-05-27 15:11:30 +00:00
parent 04c2fe383c
commit 78a908274b
14 changed files with 34 additions and 45 deletions

View File

@ -36,7 +36,6 @@
- (NSDictionary *)properties; - (NSDictionary *)properties;
- (BOOL)open:(id<CogSource>)source; - (BOOL)open:(id<CogSource>)source;
- (BOOL)seekable;
- (double)seekToTime:(double)time; //time is in milleseconds, should return the time actually seeked to. - (double)seekToTime:(double)time; //time is in milleseconds, should return the time actually seeked to.
- (int)fillBuffer:(void *)buf ofSize:(UInt32)size; - (int)fillBuffer:(void *)buf ofSize:(UInt32)size;
- (void)close; - (void)close;

View File

@ -9,7 +9,7 @@
<key>1063</key> <key>1063</key>
<string>650 960 136 68 0 0 1680 1028 </string> <string>650 960 136 68 0 0 1680 1028 </string>
<key>1156</key> <key>1156</key>
<string>866 232 241 366 0 0 1680 1028 </string> <string>719 529 241 366 0 0 1680 1028 </string>
<key>1324</key> <key>1324</key>
<string>787 658 137 182 0 0 1680 1028 </string> <string>787 658 137 182 0 0 1680 1028 </string>
<key>29</key> <key>29</key>
@ -36,9 +36,9 @@
<array> <array>
<integer>513</integer> <integer>513</integer>
<integer>21</integer> <integer>21</integer>
<integer>1156</integer>
<integer>463</integer> <integer>463</integer>
<integer>1063</integer> <integer>1063</integer>
<integer>1156</integer>
<integer>29</integer> <integer>29</integer>
<integer>1324</integer> <integer>1324</integer>
</array> </array>

Binary file not shown.

View File

@ -29,6 +29,8 @@
NSNumber *idx; NSNumber *idx;
NSNumber *shuffleIndex; NSNumber *shuffleIndex;
NSNumber *seekable;
} }
- (void)setIndex:(NSNumber *)i; - (void)setIndex:(NSNumber *)i;
@ -69,6 +71,9 @@
- (void)setSampleRate:(NSNumber *)s; - (void)setSampleRate:(NSNumber *)s;
- (NSNumber *)sampleRate; - (NSNumber *)sampleRate;
- (void)setSeekable:(NSNumber *)s;
- (NSNumber *)seekable;
- (void)setMetadata: (NSDictionary *)m; - (void)setMetadata: (NSDictionary *)m;
- (void)readMetadataThread; - (void)readMetadataThread;
- (void)setProperties: (NSDictionary *)p; - (void)setProperties: (NSDictionary *)p;

View File

@ -202,6 +202,7 @@
[self setChannels: [dict objectForKey:@"channels" ]]; [self setChannels: [dict objectForKey:@"channels" ]];
[self setBitsPerSample: [dict objectForKey:@"bitsPerSample" ]]; [self setBitsPerSample: [dict objectForKey:@"bitsPerSample" ]];
[self setSampleRate: [dict objectForKey:@"sampleRate" ]]; [self setSampleRate: [dict objectForKey:@"sampleRate" ]];
[self setSeekable: [dict objectForKey:@"seekable" ]];
} }
- (void)readPropertiesThread - (void)readPropertiesThread
@ -271,6 +272,19 @@
return sampleRate; return sampleRate;
} }
- (void)setSeekable:(NSNumber *)s
{
[s retain];
[seekable release];
seekable = s;
}
- (NSNumber *)seekable
{
return seekable;
}
- (void)setMetadata: (NSDictionary *)m - (void)setMetadata: (NSDictionary *)m
{ {
NSString *ti = [m objectForKey:@"title"]; NSString *ti = [m objectForKey:@"title"];

View File

@ -186,14 +186,10 @@
[NSNumber numberWithInt:bitrate],@"bitrate", [NSNumber numberWithInt:bitrate],@"bitrate",
[NSNumber numberWithFloat:frequency],@"sampleRate", [NSNumber numberWithFloat:frequency],@"sampleRate",
[NSNumber numberWithDouble:length],@"length", [NSNumber numberWithDouble:length],@"length",
[NSNumber numberWithBool:YES], @"seekable",
@"big", @"endian", @"big", @"endian",
nil]; nil];
} }
- (BOOL)seekable
{
return YES; //Are you kidding me? it HAS to be seekable. The AudioFile API is 100% impossible to stream in any way. Even using callbacks gives problems. Sigh.
}
@end @end

View File

@ -282,11 +282,6 @@ void ErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorS
return source; return source;
} }
- (BOOL)seekable
{
return [source seekable];
}
- (void)setEndOfStream:(BOOL)eos - (void)setEndOfStream:(BOOL)eos
{ {
endOfStream = eos; endOfStream = eos;
@ -304,6 +299,7 @@ void ErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorS
[NSNumber numberWithInt:bitsPerSample],@"bitsPerSample", [NSNumber numberWithInt:bitsPerSample],@"bitsPerSample",
[NSNumber numberWithFloat:frequency],@"sampleRate", [NSNumber numberWithFloat:frequency],@"sampleRate",
[NSNumber numberWithDouble:length],@"length", [NSNumber numberWithDouble:length],@"length",
[NSNumber numberWithBool:[source seekable]], @"seekable",
@"big",@"endian", @"big",@"endian",
nil]; nil];
} }

View File

@ -591,15 +591,11 @@ static inline signed int scale (mad_fixed_t sample)
[NSNumber numberWithFloat:frequency],@"sampleRate", [NSNumber numberWithFloat:frequency],@"sampleRate",
[NSNumber numberWithInt:bitrate],@"bitrate", [NSNumber numberWithInt:bitrate],@"bitrate",
[NSNumber numberWithDouble:length],@"length", [NSNumber numberWithDouble:length],@"length",
[NSNumber numberWithBool:[_source seekable]], @"seekable",
@"big", @"endian", @"big", @"endian",
nil]; nil];
} }
- (BOOL)seekable
{
return [_source seekable];
}
+ (NSArray *)fileTypes + (NSArray *)fileTypes
{ {

View File

@ -90,11 +90,6 @@
return source; return source;
} }
- (BOOL)seekable
{
return [source seekable];
}
- (NSDictionary *)properties - (NSDictionary *)properties
{ {
return [NSDictionary dictionaryWithObjectsAndKeys: return [NSDictionary dictionaryWithObjectsAndKeys:
@ -102,6 +97,7 @@
[NSNumber numberWithInt:bitsPerSample],@"bitsPerSample", [NSNumber numberWithInt:bitsPerSample],@"bitsPerSample",
[NSNumber numberWithFloat:frequency],@"sampleRate", [NSNumber numberWithFloat:frequency],@"sampleRate",
[NSNumber numberWithDouble:length],@"length", [NSNumber numberWithDouble:length],@"length",
[NSNumber numberWithBool:[source seekable]], @"seekable",
@"host",@"endian", @"host",@"endian",
nil]; nil];
} }

View File

@ -208,11 +208,6 @@ mpc_bool_t CanSeekProc(void *data)
return source; return source;
} }
- (BOOL)seekable
{
return [source seekable];
}
- (NSDictionary *)properties - (NSDictionary *)properties
{ {
return [NSDictionary dictionaryWithObjectsAndKeys: return [NSDictionary dictionaryWithObjectsAndKeys:
@ -221,6 +216,7 @@ mpc_bool_t CanSeekProc(void *data)
[NSNumber numberWithDouble:length], @"length", [NSNumber numberWithDouble:length], @"length",
[NSNumber numberWithInt:16], @"bitsPerSample", [NSNumber numberWithInt:16], @"bitsPerSample",
[NSNumber numberWithInt:2], @"channels", [NSNumber numberWithInt:2], @"channels",
[NSNumber numberWithBool:[source seekable]], @"seekable",
@"host",@"endian", @"host",@"endian",
nil]; nil];
} }

View File

@ -22,7 +22,7 @@
int bitsPerSample; int bitsPerSample;
float frequency; float frequency;
double length; double length;
bool seekTable; BOOL seekable;
} }
@end @end

View File

@ -29,8 +29,11 @@
bufferSize = decoder->shn_get_buffer_block_size(NUM_DEFAULT_BUFFER_BLOCKS); bufferSize = decoder->shn_get_buffer_block_size(NUM_DEFAULT_BUFFER_BLOCKS);
bool seekTable;
decoder->file_info(NULL, &channels, &frequency, NULL, &bitsPerSample, &seekTable); decoder->file_info(NULL, &channels, &frequency, NULL, &bitsPerSample, &seekTable);
NSLog(@"Seek table: %i", seekTable);
seekable = seekTable == true ? YES : NO;
length = decoder->shn_get_song_length(); length = decoder->shn_get_song_length();
decoder->go(); decoder->go();
@ -100,11 +103,6 @@
shn_unload(handle);*/ shn_unload(handle);*/
} }
- (BOOL)seekable
{
return seekTable ? YES : NO;
}
- (NSDictionary *)properties - (NSDictionary *)properties
{ {
return [NSDictionary dictionaryWithObjectsAndKeys: return [NSDictionary dictionaryWithObjectsAndKeys:
@ -112,6 +110,7 @@
[NSNumber numberWithInt:bitsPerSample],@"bitsPerSample", [NSNumber numberWithInt:bitsPerSample],@"bitsPerSample",
[NSNumber numberWithFloat:frequency],@"sampleRate", [NSNumber numberWithFloat:frequency],@"sampleRate",
[NSNumber numberWithDouble:length],@"length", [NSNumber numberWithDouble:length],@"length",
[NSNumber numberWithBool:seekable ],@"seekable",
@"little",@"endian", @"little",@"endian",
nil]; nil];
} }

View File

@ -125,11 +125,6 @@ long sourceTell(void *datasource)
return milliseconds; return milliseconds;
} }
- (BOOL) seekable
{
return [source seekable];
}
- (NSDictionary *)properties - (NSDictionary *)properties
{ {
return [NSDictionary dictionaryWithObjectsAndKeys: return [NSDictionary dictionaryWithObjectsAndKeys:
@ -138,6 +133,7 @@ long sourceTell(void *datasource)
[NSNumber numberWithFloat:frequency], @"sampleRate", [NSNumber numberWithFloat:frequency], @"sampleRate",
[NSNumber numberWithDouble:length], @"length", [NSNumber numberWithDouble:length], @"length",
[NSNumber numberWithInt:bitrate], @"bitrate", [NSNumber numberWithInt:bitrate], @"bitrate",
[NSNumber numberWithBool:([source seekable] && seekable)], @"seekable",
nil]; nil];
} }

View File

@ -245,11 +245,6 @@ int32_t WriteBytesProc(void *ds, void *data, int32_t bcount)
return source; return source;
} }
- (BOOL)seekable
{
return [source seekable];
}
- (NSDictionary *)properties - (NSDictionary *)properties
{ {
return [NSDictionary dictionaryWithObjectsAndKeys: return [NSDictionary dictionaryWithObjectsAndKeys:
@ -258,6 +253,7 @@ int32_t WriteBytesProc(void *ds, void *data, int32_t bcount)
[NSNumber numberWithInt:bitrate],@"bitrate", [NSNumber numberWithInt:bitrate],@"bitrate",
[NSNumber numberWithFloat:frequency],@"sampleRate", [NSNumber numberWithFloat:frequency],@"sampleRate",
[NSNumber numberWithDouble:length],@"length", [NSNumber numberWithDouble:length],@"length",
[NSNumber numberWithBool:[source seekable]], @"seekable",
@"host",@"endian", @"host",@"endian",
nil]; nil];
} }