From: Good Guy Date: Mon, 7 Nov 2016 16:05:19 +0000 (-0700) Subject: fix segv in ogg playback, add db tx test X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=d8506a82d13c3179b5a30c985e6e2045304e95cf;p=goodguy%2Fhistory.git fix segv in ogg playback, add db tx test --- diff --git a/cinelerra-5.1/cinelerra/fileogg.C b/cinelerra-5.1/cinelerra/fileogg.C index 747fa399..6c789b39 100644 --- a/cinelerra-5.1/cinelerra/fileogg.C +++ b/cinelerra-5.1/cinelerra/fileogg.C @@ -1577,9 +1577,12 @@ int FileOGG::set_audio_position(int64_t x) int FileOGG::move_history(int from, int to, int len) { - for(int i = 0; i < asset->channels; i++) - memmove(pcm_history[i] + to, pcm_history[i] + from, sizeof(float) * len); + if( len > 0 ) { + for(int i = 0; i < asset->channels; i++) + memmove(pcm_history[i] + to, pcm_history[i] + from, sizeof(float) * len); + } history_start = history_start + from - to; + if( history_start < 0 ) history_start = 0; return 0; } diff --git a/cinelerra-5.1/db/tx.C b/cinelerra-5.1/db/tx.C new file mode 100644 index 00000000..f7a8141e --- /dev/null +++ b/cinelerra-5.1/db/tx.C @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include +#include + +#include "txs.h" + +// create, modify, list db as set of text lines +// ./a.out new /tmp/x.db +// ./a.out add /tmp/x.db < /data/add.txt +// ./a.out del /tmp/x.db < /data/del.txt +// ./a.out get /tmp/x.db < /data/get.txt +// ./a.out lst /tmp/x.db > /data/dat.txt + +/* first, paste this +./xsch theDb txs <create(av[2]); + delete db; + return 0; + } + + db = new theDb(); + if( db->open(av[2]) < 0 ) exit(1); + + int64_t n = 0; + + if( !strcmp(av[1],"add") ) { + while( fgets(line,sizeof(line),stdin) ) { + if( !line[0] ) continue; + int l = strlen(line); + line[l-1] = 0; + int ret = ItemData(db->item,ItemKey(line,l)).Find(); + if( !ret ) continue; // duplicate + db->item.Allocate(); + db->item.Data((unsigned char *)line, l); + db->item.Construct(); + ++n; + } + db->commit(); + } + else if( !strcmp(av[1],"del") ) { + while( fgets(line,sizeof(line),stdin) ) { + if( !line[0] ) continue; + int l = strlen(line); + line[l-1] = 0; + int ret = ItemData(db->item,ItemKey(line,l)).Find(); + if( ret ) continue; // not found + db->item.Destruct(); + db->item.Deallocate(); + ++n; + } + db->commit(); + } + else if( !strcmp(av[1],"get") ) { + while( fgets(line,sizeof(line),stdin) ) { + if( !line[0] ) continue; + int l = strlen(line); + line[l-1] = 0; + int ret = ItemData(db->item,ItemKey(line,l)).Find(); + if( ret ) continue; + printf("%s\n", (char*)db->item.Data()); + ++n; + } + } + else if( !strcmp(av[1],"lst") ) { + if( !DataItem(db->item).First() ) do { + printf("%s\n", (char*)db->item.Data()); + ++n; + } while( !DataItem(db->item).Next() ); + } + else { + fprintf(stderr, "unknown cmd %s\n must be new,add,del,get,lst\n", av[1]); + exit(1); + } + + fprintf(stderr, "%jd items input\n", n); + fprintf(stderr, "%d items in db\n", db->Item.Count()); + db->close(); + delete db; + return 0; +} +