Example #1
0
long long SeekLiveStream(long long iPosition, int iWhence /* = SEEK_SET */)
{
  auto p = g_pvr_client->seek(iPosition);
  if (XBMC)
    XBMC->Log(LOG_DEBUG, "SeekLiveStream %lld->%lld %d", iPosition, p, iWhence);
  return p;
}
Example #2
0
	FileType suggestFileType( const std::unique_ptr<IFile>& file )
	{
		if ( file == nullptr )
		{
			LOG( "Argument 'file' is nullptr." );
			return FILETYPE_UNKNOWN;
		}

		FileType suggested_type = FILETYPE_UNKNOWN;

		//現在位置保存
		unsigned long cursor = file->tell();

		//ヘッダ読み取り
		{
			char buffer[ 17 ];
			buffer[ 16 ] = '\0'; //オーバーランの保険
			char* str = buffer;

			file->seek( 0 );
			file->read( str, 16 );

			if ( strstr( str, "RIFF" ) == str )
			{
				//wave
				str += 8;
				if ( strstr( str, "WAVE" ) == str )
					suggested_type = FILETYPE_WAVE;
			} else if ( strstr( str, "OggS" ) == str )
			{
				//ogg
				suggested_type = FILETYPE_OGG;
			}
		}

		//元の位置に戻る
		file->seek( cursor );

		//完了
		return suggested_type;
	}
    // Insert multiple keys and try to iterate through all of them
    // using a reverse cursor while calling savePosition() and
    // restorePosition() in succession.
    TEST( SortedDataInterface, SaveAndRestorePositionWhileIterateCursorReversed ) {
        const std::unique_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );
        const std::unique_ptr<SortedDataInterface> sorted( harnessHelper->newSortedDataInterface( false ) );

        {
            const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT( sorted->isEmpty( opCtx.get() ) );
        }

        int nToInsert = 10;
        for ( int i = 0; i < nToInsert; i++ ) {
            const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            {
                WriteUnitOfWork uow( opCtx.get() );
                BSONObj key = BSON( "" << i );
                RecordId loc( 42, i * 2 );
                ASSERT_OK( sorted->insert( opCtx.get(), key, loc, true ) );
                uow.commit();
            }
        }

        {
            const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT_EQUALS( nToInsert, sorted->numEntries( opCtx.get() ) );
        }

        {
            const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get(), false) );
            int i = nToInsert - 1;
            for (auto entry = cursor->seek(maxKey, true); entry; i--, entry = cursor->next()) {
                ASSERT_GTE(i, 0);
                ASSERT_EQ(entry, IndexKeyEntry(BSON( "" << i), RecordId(42, i * 2)));

                cursor->savePositioned();
                cursor->restore( opCtx.get() );
            }
            ASSERT( !cursor->next() );
            ASSERT_EQ(i, -1);
        }
    }
    // Insert the same key multiple times and try to iterate through each
    // occurrence using a forward cursor while calling savePosition() and
    // restorePosition() in succession. Verify that the RecordId is saved
    // as part of the current position of the cursor.
    TEST( SortedDataInterface, SaveAndRestorePositionWhileIterateCursorWithDupKeys ) {
        const std::unique_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );
        const std::unique_ptr<SortedDataInterface> sorted( harnessHelper->newSortedDataInterface( false ) );

        {
            const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT( sorted->isEmpty( opCtx.get() ) );
        }

        int nToInsert = 10;
        for ( int i = 0; i < nToInsert; i++ ) {
            const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            {
                WriteUnitOfWork uow( opCtx.get() );
                RecordId loc( 42, i * 2 );
                ASSERT_OK( sorted->insert( opCtx.get(), key1, loc, true /* allow duplicates */ ) );
                uow.commit();
            }
        }

        {
            const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT_EQUALS( nToInsert, sorted->numEntries( opCtx.get() ) );
        }

        {
            const std::unique_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            const std::unique_ptr<SortedDataInterface::Cursor> cursor( sorted->newCursor(opCtx.get()) );
            int i = 0;
            for (auto entry = cursor->seek(minKey, true); entry; i++, entry = cursor->next()) {
                ASSERT_LT(i, nToInsert);
                ASSERT_EQ(entry, IndexKeyEntry(key1, RecordId(42, i * 2)));

                cursor->savePositioned();
                cursor->restore( opCtx.get() );
            }
            ASSERT( !cursor->next() );
            ASSERT_EQ(i, nToInsert);
        }
    }
Example #5
0
void Plugin_Flush(int t)
{
	Global::DebugWrite(_T("seek\n"));
	forwarder->Flush(t);
	streamManager->seek(t);
}