コード例 #1
0
bool COrganyaCodec::Init(const std::string& strFile, unsigned int filecache, int& channels,
                         int& samplerate, int& bitspersample, int64_t& totaltime,
                         int& bitrate, AEDataFormat& format, std::vector<AEChannel>& channelinfo)
{
  sample_buffer.Create(4096);
  kodi::vfs::CFile file;
  file.OpenFile(strFile);
  if (!file.OpenFile(strFile, 0))
    return false;
  std::string temp = kodi::GetSettingString("__addonpath__") + "/resources/samples";
  tune = org_decoder_create(&file, temp.c_str(), 1);
  tune->state.sample_rate = 48000;
  totaltime = org_decoder_get_total_samples(tune)*1000/48000;
  length = totaltime/1000*48000*4;
  format = AE_FMT_S16NE;
  channelinfo = { AE_CH_FL, AE_CH_FR, AE_CH_NULL };
  channels = 2;
  bitspersample = 16;
  bitrate = 0.0;
  samplerate = 48000;

  file.Close();
  Seek(0);

  return true;
}
コード例 #2
0
ファイル: FileShoutcast.cpp プロジェクト: Avoidnf8/xbmc-fork
CFileShoutcast::CFileShoutcast()
{
  // FIXME: without this check
  // the playback stops when CFile::Stat()
  // or CFile::Exists() is called

  // Do we already have another file
  // using the ripper?
  if (!m_pShoutCastRipper)
  {
    m_fileState.bBuffering = true;
    m_fileState.bRipDone = false;
    m_fileState.bRipStarted = false;
    m_fileState.bRipError = false;
    m_ringbuf.Create(1024*1024); // must be big enough. some stations use 192kbps.
    m_pShoutCastRipper = this;
  }
}
コード例 #3
0
/* Read in data from the ring buffer to another ring buffer object specified by
 * 'rBuf'.
 */
bool CRingBuffer::ReadData(CRingBuffer &rBuf, unsigned int size)
{
  CSingleLock lock(m_critSection);
  if (rBuf.getBuffer() == NULL)
    rBuf.Create(size);

  bool bOk = size <= rBuf.getMaxWriteSize() && size <= getMaxReadSize();
  if (bOk)
  {
    unsigned int chunksize = std::min(size, m_size - m_readPtr);
    bOk = rBuf.WriteData(&getBuffer()[m_readPtr], chunksize);
    if (bOk && chunksize < size)
      bOk = rBuf.WriteData(&getBuffer()[0], size - chunksize);
    if (bOk)
      SkipBytes(size);
  }

  return bOk;
}
コード例 #4
0
ファイル: TestRingBuffer.cpp プロジェクト: Arcko/xbmc
TEST(TestRingBuffer, General)
{
  CRingBuffer a;
  char data[20];
  unsigned int i;

  EXPECT_TRUE(a.Create(20));
  EXPECT_EQ((unsigned int)20, a.getSize());
  memset(data, 0, sizeof(data));
  for (i = 0; i < a.getSize(); i++)
    EXPECT_TRUE(a.WriteData(data, 1));
  a.Clear();

  memcpy(data, "0123456789", sizeof("0123456789"));
  EXPECT_TRUE(a.WriteData(data, sizeof("0123456789")));
  EXPECT_STREQ("0123456789", a.getBuffer());

  memset(data, 0, sizeof(data));
  EXPECT_TRUE(a.ReadData(data, 5));
  EXPECT_STREQ("01234", data);
}