Changeset 1059

Show
Ignore:
Timestamp:
11/11/07 15:34:25 (14 months ago)
Author:
stephen_booth
Message:

Removed duration from database

Location:
trunk
Files:
17 modified

Legend:

Unmodified
Added
Removed
  • trunk/Audio/Properties/CoreAudioPropertiesReader.m

    r868 r1059  
    110110        [propertiesDictionary setValue:[NSNumber numberWithDouble:asbd.mSampleRate] forKey:PropertiesSampleRateKey]; 
    111111         
    112         // Save sample rate for duration calcuation 
    113         Float64 sampleRate = asbd.mSampleRate; 
    114          
    115112        // Zero out part of the asbd so we only get the format's name 
    116113        asbd.mSampleRate                = 0; 
     
    143140 
    144141        [propertiesDictionary setValue:[NSNumber numberWithLongLong:totalFrames] forKey:PropertiesTotalFramesKey]; 
    145          
    146         [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)totalFrames / sampleRate] forKey:PropertiesDurationKey]; 
    147          
     142                 
    148143        [self setValue:propertiesDictionary forKey:@"properties"]; 
    149144         
  • trunk/Audio/Properties/FLACPropertiesReader.m

    r1030 r1059  
    9494                                [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:block->data.stream_info.channels] forKey:PropertiesChannelsPerFrameKey]; 
    9595                                [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:block->data.stream_info.sample_rate] forKey:PropertiesSampleRateKey];                             
    96                                 [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)block->data.stream_info.total_samples / block->data.stream_info.sample_rate] forKey:PropertiesDurationKey]; 
    9796                                break; 
    9897                                 
     
    140139                                                [trackDictionary setValue:[NSNumber numberWithUnsignedLongLong:block->data.cue_sheet.tracks[i].offset] forKey:StreamStartingFrameKey]; 
    141140                                                 
    142                                                 // Fill in frame counts and duration 
     141                                                // Fill in frame counts 
    143142                                                if(0 < i) { 
    144143                                                        unsigned frameCount = (block->data.cue_sheet.tracks[i].offset - 1) - block->data.cue_sheet.tracks[i - 1].offset; 
    145144                                                         
    146145                                                        [[cueSheetTracks objectAtIndex:(i - 1)] setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:StreamFrameCountKey]; 
    147                                                         [[cueSheetTracks objectAtIndex:(i - 1)] setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:PropertiesTotalFramesKey]; 
    148                                                         [[cueSheetTracks objectAtIndex:(i - 1)] setValue:[NSNumber numberWithDouble:(double)frameCount / [[propertiesDictionary valueForKey:PropertiesSampleRateKey] floatValue]] forKey:PropertiesDurationKey]; 
    149146                                                } 
    150147                                                 
     
    155152 
    156153                                                        [trackDictionary setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:StreamFrameCountKey]; 
    157                                                         [trackDictionary setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:PropertiesTotalFramesKey]; 
    158                                                         [trackDictionary setValue:[NSNumber numberWithDouble:(double)frameCount / [[propertiesDictionary valueForKey:PropertiesSampleRateKey] floatValue]] forKey:PropertiesDurationKey]; 
    159154                                                } 
    160155 
  • trunk/Audio/Properties/MonkeysAudioPropertiesReader.mm

    r1024 r1059  
    6363        [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:decompressor->GetInfo(APE_INFO_CHANNELS)] forKey:PropertiesChannelsPerFrameKey]; 
    6464        [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:decompressor->GetInfo(APE_INFO_SAMPLE_RATE)] forKey:PropertiesSampleRateKey]; 
    65         [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)decompressor->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS) / decompressor->GetInfo(APE_INFO_SAMPLE_RATE)] forKey:PropertiesDurationKey]; 
    6665                 
    6766        [self setValue:propertiesDictionary forKey:@"properties"]; 
  • trunk/Audio/Properties/MPEGPropertiesReader.m

    r1053 r1059  
    221221 
    222222                                        [propertiesDictionary setValue:[NSNumber numberWithUnsignedLong:xingTotalFrames] forKey:PropertiesTotalFramesKey]; 
    223                                         [propertiesDictionary setValue:[NSNumber numberWithFloat:(xingTotalFrames / frame.header.samplerate)] forKey:PropertiesDurationKey]; 
    224223                                } 
    225224                                 
     
    342341 
    343342                        [propertiesDictionary setValue:[NSNumber numberWithUnsignedLong:totalFrames] forKey:PropertiesTotalFramesKey]; 
    344                         [propertiesDictionary setValue:[NSNumber numberWithFloat:(totalFrames / frame.header.samplerate)] forKey:PropertiesDurationKey]; 
    345343 
    346344                        // For now, quit after second frame 
  • trunk/Audio/Properties/MusepackPropertiesReader.m

    r868 r1059  
    9393        [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:streaminfo.channels] forKey:PropertiesChannelsPerFrameKey]; 
    9494        [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:streaminfo.sample_freq] forKey:PropertiesSampleRateKey]; 
    95         [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)mpc_streaminfo_get_length_samples(&streaminfo) / streaminfo.sample_freq] forKey:PropertiesDurationKey]; 
    9695 
    9796        if(0 != streaminfo.gain_title) 
  • trunk/Audio/Properties/OggFLACPropertiesReader.m

    r1053 r1059  
    4646                         
    4747                        [source setValue:[NSNumber numberWithLongLong:metadata->data.stream_info.total_samples] forKeyPath:@"localProperties.totalFrames"]; 
    48  
    49                         [source setValue:[NSNumber numberWithDouble:(double)metadata->data.stream_info.total_samples / metadata->data.stream_info.sample_rate] forKeyPath:@"localProperties.duration"]; 
    5048                        break; 
    5149                         
  • trunk/Audio/Properties/OggVorbisPropertiesReader.m

    r1022 r1059  
    9090        [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:ovInfo->channels] forKey:PropertiesChannelsPerFrameKey]; 
    9191        [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:ovInfo->rate] forKey:PropertiesSampleRateKey]; 
    92         [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)totalFrames / ovInfo->rate] forKey:PropertiesDurationKey]; 
    9392         
    9493        [self setValue:propertiesDictionary forKey:@"properties"]; 
  • trunk/Audio/Properties/WavPackPropertiesReader.m

    r1023 r1059  
    5656        [propertiesDictionary setValue:[NSNumber numberWithInt:WavpackGetNumChannels(wpc)] forKey:PropertiesChannelsPerFrameKey]; 
    5757        [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:WavpackGetSampleRate(wpc)] forKey:PropertiesSampleRateKey]; 
    58         [propertiesDictionary setValue:[NSNumber numberWithDouble:WavpackGetAverageBitrate(wpc, YES)] forKey:PropertiesBitrateKey]; 
    59         [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)WavpackGetNumSamples(wpc) / WavpackGetSampleRate(wpc)] forKey:PropertiesDurationKey]; 
    60          
     58        [propertiesDictionary setValue:[NSNumber numberWithDouble:WavpackGetAverageBitrate(wpc, YES)] forKey:PropertiesBitrateKey];      
    6159         
    6260        [self setValue:propertiesDictionary forKey:@"properties"]; 
  • trunk/AudioLibrary/AudioStreamTableView.m

    r963 r1059  
    620620        [searchSheet setArtist:[stream valueForKey:MetadataArtistKey]]; 
    621621        [searchSheet setAlbumTitle:[stream valueForKey:MetadataAlbumTitleKey]]; 
    622         [searchSheet setDuration:[stream valueForKey:PropertiesDurationKey]]; 
     622        [searchSheet setDuration:[stream duration]]; 
    623623 
    624624        [[NSApplication sharedApplication] beginSheet:[searchSheet sheet]  
  • trunk/AudioLibrary/SmartPlaylistCriterion.m

    r953 r1059  
    289289                PropertiesFileTypeKey, PropertiesDataFormatKey, PropertiesFormatDescriptionKey,  
    290290                PropertiesBitsPerChannelKey, PropertiesChannelsPerFrameKey, PropertiesSampleRateKey,  
    291                 PropertiesTotalFramesKey, PropertiesDurationKey, PropertiesBitrateKey, 
     291                PropertiesTotalFramesKey, @"duration", PropertiesBitrateKey, 
    292292                @"-", 
    293293                StatisticsDateAddedKey, StatisticsFirstPlayedDateKey, StatisticsLastPlayedDateKey, StatisticsLastSkippedDateKey, 
     
    548548                attributeType   = NSInteger64AttributeType; 
    549549        } 
    550         else if([keyPath isEqualToString:PropertiesDurationKey]) { 
     550        else if([keyPath isEqualToString:@"duration"]) { 
    551551                displayName             = NSLocalizedStringFromTable(@"Duration", @"AudioStream", @""); 
    552552                attributeType   = NSDoubleAttributeType; 
  • trunk/AudioScrobbler/AudioScrobbler.m

    r935 r1059  
    111111                escapeForLastFM([stream valueForKey:MetadataAlbumTitleKey]),  
    112112                escapeForLastFM([stream valueForKey:MetadataMusicBrainzIDKey]),  
    113                 [[stream valueForKey:PropertiesDurationKey] intValue],  
     113                [[stream duration] intValue],  
    114114                escapeForLastFM([[stream valueForKey:StreamURLKey] path]) 
    115115                ]];      
  • trunk/Database/AudioStream.h

    r1043 r1059  
    7070extern NSString * const         PropertiesSampleRateKey; 
    7171extern NSString * const         PropertiesTotalFramesKey; 
    72 extern NSString * const         PropertiesDurationKey; 
    7372extern NSString * const         PropertiesBitrateKey; 
    7473 
     
    9796- (NSString *) pathname; 
    9897 
     98- (NSNumber *) duration; 
     99- (NSNumber *) totalDuration; 
     100 
    99101- (BOOL) isPlaying; 
    100102- (void) setPlaying:(BOOL)playing; 
  • trunk/Database/AudioStream.m

    r1053 r1059  
    7272NSString * const        PropertiesSampleRateKey                                 = @"sampleRate"; 
    7373NSString * const        PropertiesTotalFramesKey                                = @"totalFrames"; 
    74 NSString * const        PropertiesDurationKey                                   = @"duration"; 
    7574NSString * const        PropertiesBitrateKey                                    = @"bitrate"; 
    7675 
     
    255254{ 
    256255        return [[self valueForKey:StreamURLKey] path]; 
     256} 
     257 
     258- (NSNumber *) duration 
     259{ 
     260        if([self isPartOfCueSheet]) 
     261                return [NSNumber numberWithDouble:[[self valueForKey:StreamFrameCountKey] longLongValue] / [[self valueForKey:PropertiesSampleRateKey] floatValue]]; 
     262        else 
     263                return [self totalDuration]; 
     264} 
     265 
     266- (NSNumber *) totalDuration 
     267{ 
     268        return [NSNumber numberWithDouble:[[self valueForKey:PropertiesTotalFramesKey] longLongValue] / [[self valueForKey:PropertiesSampleRateKey] floatValue]]; 
    257269} 
    258270 
     
    357369                        PropertiesSampleRateKey, 
    358370                        PropertiesTotalFramesKey, 
    359                         PropertiesDurationKey, 
    360371                        PropertiesBitrateKey, 
    361372                         
  • trunk/Database/AudioStreamManager.m

    r1055 r1059  
    791791        getColumnValue(statement, 39, stream, PropertiesSampleRateKey, eObjectTypeDouble); 
    792792        getColumnValue(statement, 40, stream, PropertiesTotalFramesKey, eObjectTypeLongLong); 
    793         getColumnValue(statement, 41, stream, PropertiesDurationKey, eObjectTypeDouble); 
    794         getColumnValue(statement, 42, stream, PropertiesBitrateKey, eObjectTypeDouble); 
     793        getColumnValue(statement, 41, stream, PropertiesBitrateKey, eObjectTypeDouble); 
    795794                 
    796795        // Register the object   
     
    868867                bindParameter(statement, 39, stream, PropertiesSampleRateKey, eObjectTypeDouble); 
    869868                bindParameter(statement, 40, stream, PropertiesTotalFramesKey, eObjectTypeLongLong); 
    870                 bindParameter(statement, 41, stream, PropertiesDurationKey, eObjectTypeDouble); 
    871                 bindParameter(statement, 42, stream, PropertiesBitrateKey, eObjectTypeDouble); 
     869                bindParameter(statement, 41, stream, PropertiesBitrateKey, eObjectTypeDouble); 
    872870                 
    873871                result = sqlite3_step(statement); 
     
    971969        bindNamedParameter(statement, ":sample_rate", stream, PropertiesSampleRateKey, eObjectTypeDouble); 
    972970        bindNamedParameter(statement, ":total_frames", stream, PropertiesTotalFramesKey, eObjectTypeLongLong); 
    973         bindNamedParameter(statement, ":duration", stream, PropertiesDurationKey, eObjectTypeDouble); 
    974971        bindNamedParameter(statement, ":bitrate", stream, PropertiesBitrateKey, eObjectTypeDouble); 
    975972         
     
    10821079                                PropertiesSampleRateKey, 
    10831080                                PropertiesTotalFramesKey, 
    1084                                 PropertiesDurationKey, 
    10851081                                PropertiesBitrateKey, 
    10861082                                                                 
  • trunk/SQL/create_stream_table.sql

    r1025 r1059  
    4747        'sample_rate'                           REAL, 
    4848        'total_frames'                          INTEGER, 
    49         'duration'                                      REAL, 
    5049        'bitrate'                                       REAL, 
    5150         
  • trunk/SQL/insert_stream.sql

    r1025 r1059  
    4646                sample_rate, 
    4747                total_frames, 
    48                 duration, 
    4948                bitrate 
    5049 
     
    9897                ?,  
    9998                ?,  
    100                 ?,  
    10199                ? 
    102100                                 
  • trunk/Utilities/CueSheetParser.m

    r1053 r1059  
    330330                        previousTrack = [cueSheetTracks objectAtIndex:(i - 1)]; 
    331331 
    332                 // Fill in frame counts and duration 
     332                // Fill in frame counts 
    333333                if(nil != previousTrack && [[previousTrack valueForKey:StreamURLKey] isEqual:[thisTrack valueForKey:StreamURLKey]]) { 
    334334                        unsigned frameCount = ([[thisTrack valueForKey:StreamStartingFrameKey] longLongValue] - 1) - [[previousTrack valueForKey:StreamStartingFrameKey] longLongValue]; 
    335335                         
    336336                        [previousTrack setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:StreamFrameCountKey]; 
    337                         [previousTrack setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:PropertiesTotalFramesKey]; 
    338                         [previousTrack setValue:[NSNumber numberWithDouble:(double)frameCount / [[thisTrack valueForKey:PropertiesSampleRateKey] floatValue]] forKey:PropertiesDurationKey]; 
    339337                } 
    340338                 
     
    344342                         
    345343                        [thisTrack setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:StreamFrameCountKey]; 
    346                         [thisTrack setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:PropertiesTotalFramesKey]; 
    347                         [thisTrack setValue:[NSNumber numberWithDouble:(double)frameCount / [[thisTrack valueForKey:PropertiesSampleRateKey] floatValue]] forKey:PropertiesDurationKey]; 
    348344                } 
    349345        }