r1006: configure: Use libx264_pic instead of libx264 if available.
[cinelerra_cv/mob.git] / cinelerra / wavecache.C
blobbd629de9b3f065cd2adf6fddc49df007fb768f6d
1 #include "asset.h"
2 #include "mutex.h"
3 #include "wavecache.h"
5 #include <string.h>
7 WaveCacheItem::WaveCacheItem()
8  : CacheItemBase()
12 WaveCacheItem::~WaveCacheItem()
16 int WaveCacheItem::get_size()
18         return sizeof(WaveCacheItem) + (path ? strlen(path) : 0);
23 WaveCache::WaveCache()
24  : CacheBase()
28 WaveCache::~WaveCache()
33 WaveCacheItem* WaveCache::get_wave(int asset_id,
34         int channel,
35         int64_t start,
36         int64_t end)
38         lock->lock("WaveCache::get_wave");
39         int item_number = -1;
40         WaveCacheItem *result = 0;
41         
42         result = (WaveCacheItem*)get_item(start);
43         while(result && result->position == start)
44         {
45                 if(result->asset_id == asset_id && 
46                         result->channel == channel &&
47                         result->end == end)
48                 {
49                         result->age = get_age();
50                         return result;
51                 }
52                 else
53                         result = (WaveCacheItem*)result->next;
54         }
55         
56         lock->unlock();
57         return 0;
60 void WaveCache::put_wave(Asset *asset,
61         int channel,
62         int64_t start,
63         int64_t end,
64         double high,
65         double low)
67         lock->lock("WaveCache::put_wave");
68         WaveCacheItem *item = new WaveCacheItem;
69         item->asset_id = asset->id;
70         item->path = strdup(asset->path);
71         item->channel = channel;
72         item->position = start;
73         item->end = end;
74         item->high = high;
75         item->low = low;
76         
77         put_item(item);
78         lock->unlock();