wxSoundStream& wxSoundStreamG72X::Write(const void *buffer, wxUint32 len) { wxUint16 *old_linear; register wxUint16 *linear_buffer; register wxUint32 countdown = len; register wxUint32 real_len; // Compute the real length (PCM format) to sendt to the sound card real_len = (len * m_n_bits / 8); // Allocate a temporary buffer old_linear = linear_buffer = new wxUint16[real_len]; // Bad, we override the const m_io_buffer = (wxUint8 *)buffer; m_current_b_pos = 0; // Decode the datas while (countdown != 0) { *linear_buffer++ = m_decoder(GetBits(), AUDIO_ENCODING_LINEAR, m_state); countdown--; } m_lastcount = len; // Send them to the sound card m_router->Write(old_linear, real_len); // Destroy the temporary buffer delete[] old_linear; return *m_router; }
bool CG711Codec::DecodeBuf(unsigned char *pInData, unsigned long inLen, unsigned char *pOutData, unsigned long *pOutLen) { long sampleNum = inLen; unsigned short * pOut = (unsigned short *)(pOutData); for(long i = 0; i < sampleNum; i++) { *pOut++ = m_decoder(pInData[i]); } *pOutLen = inLen * 2; return true; }