Пример #1
0
 virtual void ApplyData(const Chunk::Ptr& data)
 {
   //work with 16-bit
   BOOST_STATIC_ASSERT(Sample::BITS == 16);
   BOOST_STATIC_ASSERT(Sample::CHANNELS == 2);
   data->ToS16();
   while (const int res = LameApi->lame_encode_buffer_interleaved(Context.get(),
     safe_ptr_cast<short int*>(&data->front()), data->size(), &Encoded[0], Encoded.size()))
   {
     if (res > 0) //encoded
     {
       Stream->ApplyData(Binary::DataAdapter(&Encoded[0], res));
       break;
     }
     else if (-1 == res)//buffer too small
     {
       ResizeBuffer();
     }
     else
     {
       CheckLameCall(res, THIS_LINE);
     }
   }
 }
Пример #2
0
 void ApplyData(Chunk::Ptr data) override
 {
   //work with 16-bit
   static_assert(Sample::BITS == 16, "Incompatible sound sample bits count");
   static_assert(Sample::CHANNELS == 2, "Incompatible sound channels count");
   data->ToS16();
   while (const int res = LameApi->lame_encode_buffer_interleaved(Context.get(),
     safe_ptr_cast<short int*>(&data->front()), data->size(), &Encoded[0], Encoded.size()))
   {
     if (res > 0) //encoded
     {
       Stream->ApplyData(Binary::DataAdapter(&Encoded[0], res));
       break;
     }
     else if (-1 == res)//buffer too small
     {
       ResizeBuffer();
     }
     else
     {
       CheckLameCall(res, THIS_LINE);
     }
   }
 }