summaryrefslogtreecommitdiff
path: root/src/myriad.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/myriad.cpp')
-rw-r--r--src/myriad.cpp53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/myriad.cpp b/src/myriad.cpp
index 044e35e..9e128d1 100644
--- a/src/myriad.cpp
+++ b/src/myriad.cpp
@@ -352,8 +352,22 @@ int Bu::Myriad::findEmptyBlock()
352 return iBlocks++; 352 return iBlocks++;
353} 353}
354 354
355void Bu::Myriad::deleteStream( int /*iID*/ ) 355void Bu::Myriad::deleteStream( int iId )
356{ 356{
357 for( StreamArray::iterator i = aStreams.begin(); i; i++ )
358 {
359 if( (*i)->iId == iId )
360 {
361 Stream *pStream = *i;
362 for( BlockArray::iterator j = pStream->aBlocks.begin(); j; j++ )
363 {
364 bsBlockUsed.setBit( *j, false );
365 }
366 aStreams.erase( i );
367 bHeaderChanged = true;
368 return;
369 }
370 }
357} 371}
358 372
359Bu::MyriadStream Bu::Myriad::openStream( int iId ) 373Bu::MyriadStream Bu::Myriad::openStream( int iId )
@@ -426,9 +440,42 @@ void Bu::Myriad::syncBlock( Block *pBlock )
426 } 440 }
427} 441}
428 442
443int Bu::Myriad::streamAddBlock( Stream *pStream )
444{
445 int iBlock = findEmptyBlock();
446 pStream->aBlocks.append( iBlock );
447 bsBlockUsed.setBit( iBlock );
448 return iBlock;
449}
450
429void Bu::Myriad::setStreamSize( Stream *pStream, long iSize ) 451void Bu::Myriad::setStreamSize( Stream *pStream, long iSize )
430{ 452{
431 sio << "Oh man, you have to implement Bu::Myriad::setStreamSize!!! (line " 453 if( pStream->iSize == iSize )
432 << __LINE__ << ")" << sio.nl; 454 {
455 return;
456 }
457 else if( pStream->iSize > iSize )
458 {
459 // Shrink
460 for( int iNewSize = pStream->aBlocks.getSize()*iBlockSize;
461 iNewSize-64 > iSize; iNewSize -= iBlockSize )
462 {
463 bsBlockUsed.setBit( pStream->aBlocks.last(), false );
464 pStream->aBlocks.eraseLast();
465 }
466 pStream->iSize = iSize;
467 bHeaderChanged = true;
468 }
469 else
470 {
471 // Grow
472 for( int iNewSize = pStream->aBlocks.getSize()*iBlockSize;
473 iNewSize < iSize; iNewSize += iBlockSize )
474 {
475 streamAddBlock( pStream );
476 }
477 pStream->iSize = iSize;
478 bHeaderChanged = true;
479 }
433} 480}
434 481