当前位置: 首页>>代码示例>>C++>>正文


C++ BlockFile::OpenWriting方法代码示例

本文整理汇总了C++中BlockFile::OpenWriting方法的典型用法代码示例。如果您正苦于以下问题:C++ BlockFile::OpenWriting方法的具体用法?C++ BlockFile::OpenWriting怎么用?C++ BlockFile::OpenWriting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BlockFile的用法示例。


在下文中一共展示了BlockFile::OpenWriting方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InitBlock

bool WaveTrack::InitBlock(WaveBlock * b)
{
   wxASSERT(b);

   BlockFile *f = b->f;

   if (!f->OpenWriting())
      return false;

   f->Write(headerTag, headerTagLen);

   /*
    * This code shouldn't be needed because UpdateSummaries
    * always writes exactly what's needed.

    sampleCount slen = summary64KLen + summary256Len;
    sampleType *tempSamples = new sampleType[slen];
    for(int i=0; i<slen; i++)
    tempSamples[i] = 0;
    f->Write((void *)tempSamples, sizeof(sampleType) * slen);
    delete[] tempSamples;
    */

   f->Close();

   return true;
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:27,代码来源:WaveTrack.cpp

示例2: AppendAlias

void WaveTrack::AppendAlias(wxString fullPath,
                            sampleCount start,
                            sampleCount len, int channel)
{
   WaveBlock *newBlock = new WaveBlock();
   newBlock->start = numSamples;
   newBlock->len = len;
   newBlock->f =
       dirManager->NewAliasBlockFile(totalHeaderLen,
                                     fullPath, start, len, channel);

   InitBlock(newBlock);

   BlockFile *f = newBlock->f;

   sampleType *buffer = new sampleType[len];
   Read(buffer, newBlock, 0, len);

   wxASSERT(f);
   bool opened = f->OpenWriting();
   wxASSERT(opened);
   UpdateSummaries(buffer, newBlock, len);
   f->Close();

   delete[]buffer;

   block->Add(newBlock);
   numSamples += newBlock->len;

   envelope.SetTrackLen(numSamples / rate);
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:31,代码来源:WaveTrack.cpp

示例3: CopyWrite

void WaveTrack::CopyWrite(sampleType * buffer, WaveBlock * b,
                          sampleCount start, sampleCount len)
{
   // Usually we don't write to an existing block; to support Undo,
   // we copy the old block entirely into memory, dereference it,
   // make the change, and then write the new block to disk.

   wxASSERT(b);
   wxASSERT(b->len <= maxSamples);
   wxASSERT(start + len <= b->len);

   dirty++;                     // forces redraw

   sampleType *newBuffer = 0;

   newBuffer = new sampleType[maxSamples];
   wxASSERT(newBuffer);

   Read(newBuffer, b, 0, b->len);

   for (int i = 0; i < len; i++)
      newBuffer[start + i] = buffer[i];

   BlockFile *oldBlockFile = b->f;
   b->f = dirManager->NewBlockFile();
   bool inited = InitBlock(b);
   wxASSERT(inited);

   buffer = newBuffer;
   start = 0;
   len = b->len;

   dirManager->Deref(oldBlockFile);

   // Write the block

   BlockFile *f = b->f;

   wxASSERT(f);
   bool opened = f->OpenWriting();
   wxASSERT(opened);

   f->SeekTo(totalHeaderLen + (start * sizeof(sampleType)));

   f->Write((void *) buffer, len * sizeof(sampleType));

   UpdateSummaries(buffer, b, len);

   if (newBuffer)
      delete[]newBuffer;

   f->Close();
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:53,代码来源:WaveTrack.cpp

示例4: FirstWrite

void WaveTrack::FirstWrite(sampleType * buffer, WaveBlock * b,
                           sampleCount len)
{
   wxASSERT(b);
   wxASSERT(b->len <= maxSamples);

   dirty++;                     // forces redraw

   BlockFile *f = b->f;

   wxASSERT(f);
   bool opened = f->OpenWriting();
   wxASSERT(opened);

   f->SeekTo(totalHeaderLen);
   f->Write((void *) buffer, len * sizeof(sampleType));

   UpdateSummaries(buffer, b, len);

   f->Close();
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:21,代码来源:WaveTrack.cpp


注:本文中的BlockFile::OpenWriting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。