static int Set(playlist* p, int No, const void* Data, int Size) { int Result = ERR_INVALID_PARAM; switch (No) { case PLAYLIST_STREAM: SETVALUENULL(p->Stream,stream*,UpdateStream(p),p->Stream=NULL); break; case PLAYLIST_DATAFEED: ParserDataFeed(&p->Parser,Data,Size); Result = ERR_NONE; break; } return Result; }
void DACSignedWrite(INT32 Chip, UINT8 Data) { #if defined FBA_DEBUG if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACSignedWrite called without init\n")); if (Chip > NumChips) bprintf(PRINT_ERROR, _T("DACSignedWrite called with invalid chip number %x\n"), Chip); #endif struct dac_info *ptr; ptr = &dac_table[Chip]; UpdateStream(Chip, ptr->pSyncCallback()); ptr->Output = (INT32)(SignedVolTable[Data] * ptr->nVolume); }
//+----------------------------------------------------------------------------+ //|Channel* Play(Channel* dedicatedChannel, int flags) //|Used to create a channel, an "instance of the sound". This is returned for detailed control while sound is playing. //|The sound may be played using a specific dedicated channel //\----------------------------------------------------------------------------+ Channel* SoundSDL::Play(Channel* dedicatedChannel, int flags) { ChannelSDL* channel = nullptr; ///Streaming audio may only have one channel dedicated if(m_Type == Audio::SoundType::STREAM) { if(m_NumInstaces > 0) return nullptr; UpdateStream(); } ///Dedicated if(dedicatedChannel) { channel = reinterpret_cast<ChannelSDL*>(dedicatedChannel); } ///Get new free channel else { channel = reinterpret_cast<ChannelSDL*>(m_AudioEngine->GetFreeChannel()); } channel->Reset(); if((flags & IS_3D) == IS_3D) channel->SetIs3D(true); if((flags & LOOPING) == LOOPING) channel->SetLooping(true); channel->Lock(); channel->SetSound(this); channel->Play(); if((flags & PAUSED) == PAUSED) channel->Pause(); m_NumInstaces++; ///Streaming audio needs to be activated to update if(m_Type == Audio::SoundType::STREAM) m_StreamingActive = true; return channel; };
void DACUpdate(INT16* Buffer, INT32 Length) { #if defined FBA_DEBUG if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACUpdate called without init\n")); #endif struct dac_info *ptr; for (INT32 i = 0; i < NumChips; i++) { UpdateStream(i, nBurnSoundLen); } INT16 *lbuf = lBuffer; INT16 *rbuf = rBuffer; if (bAddSignal) { while (Length--) { Buffer[0] = BURN_SND_CLIP((INT32)(lbuf[0] + Buffer[0])); Buffer[1] = BURN_SND_CLIP((INT32)(rbuf[0] + Buffer[1])); Buffer += 2; lbuf[0] = 0; // clear buffer rbuf[0] = 0; // clear buffer lbuf++; rbuf++; } } else { while (Length--) { Buffer[0] = lbuf[0]; Buffer[1] = rbuf[0]; Buffer += 2; lbuf[0] = 0; // clear buffer rbuf[0] = 0; // clear buffer lbuf++; rbuf++; } } for (INT32 i = 0; i < NumChips; i++) { ptr = &dac_table[i]; ptr->nCurrentPosition = 0; } }
bool Session::initialize() { // Get URN's wich are supported by this addon if (!license_type_.empty()) { GetSupportedDecrypterURN(dashtree_.adp_pssh_); xbmc->Log(ADDON::LOG_DEBUG, "Supported URN: %s", dashtree_.adp_pssh_.first.c_str()); } // Open mpd file size_t paramPos = mpdFileURL_.find('?'); dashtree_.base_url_ = (paramPos == std::string::npos)? mpdFileURL_:mpdFileURL_.substr(0, paramPos); paramPos = dashtree_.base_url_.find_last_of('/', dashtree_.base_url_.length()); if (paramPos == std::string::npos) { xbmc->Log(ADDON::LOG_ERROR, "Invalid mpdURL: / expected (%s)", mpdFileURL_.c_str()); return false; } dashtree_.base_url_.resize(paramPos + 1); if (!dashtree_.open(mpdFileURL_.c_str()) || dashtree_.empty()) { xbmc->Log(ADDON::LOG_ERROR, "Could not open / parse mpdURL (%s)", mpdFileURL_.c_str()); return false; } xbmc->Log(ADDON::LOG_INFO, "Successfully parsed .mpd file. Download speed: %0.4f Bytes/s", dashtree_.download_speed_); if (dashtree_.encryptionState_ == dash::DASHTree::ENCRYTIONSTATE_ENCRYPTED) { xbmc->Log(ADDON::LOG_ERROR, "Unable to handle decryption. Unsupported!"); return false; } uint32_t min_bandwidth(0), max_bandwidth(0); { int buf; xbmc->GetSetting("MINBANDWIDTH", (char*)&buf); min_bandwidth = buf; xbmc->GetSetting("MAXBANDWIDTH", (char*)&buf); max_bandwidth = buf; } // create SESSION::STREAM objects. One for each AdaptationSet unsigned int i(0); const dash::DASHTree::AdaptationSet *adp; for (std::vector<STREAM*>::iterator b(streams_.begin()), e(streams_.end()); b != e; ++b) SAFE_DELETE(*b); streams_.clear(); while ((adp = dashtree_.GetAdaptationSet(i++))) { streams_.push_back(new STREAM(dashtree_, adp->type_)); STREAM &stream(*streams_.back()); stream.stream_.prepare_stream(adp, width_, height_, min_bandwidth, max_bandwidth); switch (adp->type_) { case dash::DASHTree::VIDEO: stream.info_.m_streamType = INPUTSTREAM_INFO::TYPE_VIDEO; break; case dash::DASHTree::AUDIO: stream.info_.m_streamType = INPUTSTREAM_INFO::TYPE_AUDIO; break; case dash::DASHTree::TEXT: stream.info_.m_streamType = INPUTSTREAM_INFO::TYPE_TELETEXT; break; default: break; } stream.info_.m_pID = i; strcpy(stream.info_.m_language, adp->language_.c_str()); UpdateStream(stream); } // Try to initialize an SingleSampleDecryptor #if 1 if (dashtree_.encryptionState_) { if (dashtree_.protection_key_.size()!=16 || license_data_.empty()) return false; uint8_t ld[1024]; unsigned int ld_size(1024); b64_decode(license_data_.c_str(), license_data_.size(), ld, ld_size); const uint8_t *uuid((uint8_t*)strstr((const char*)ld, "{UUID}")); unsigned int license_size = uuid ? ld_size + 36 -6: ld_size; //Build up proto header AP4_DataBuffer init_data; init_data.Reserve(512); uint8_t *protoptr(init_data.UseData()); *protoptr++ = 18; //id=16>>3=2, type=2(flexlen) *protoptr++ = 16; //length of key memcpy(protoptr, dashtree_.protection_key_.data(), 16); protoptr += 16; //----------- *protoptr++ = 34;//id=32>>3=4, type=2(flexlen) do { *protoptr++ = static_cast<uint8_t>(license_size & 127); license_size >>= 7; if (license_size) *(protoptr - 1) |= 128; else break; } while (1); if (uuid) { static const uint8_t hexmap[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' }; memcpy(protoptr, ld, uuid - ld); protoptr += uuid - ld; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[3]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[3]) & 15]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[2]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[2]) & 15]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[1]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[1]) & 15]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[0]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[0]) & 15]; *protoptr++ = '-'; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[5]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[5]) & 15]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[4]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[4]) & 15]; *protoptr++ = '-'; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[7]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[7]) & 15]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[6]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[6]) & 15]; *protoptr++ = '-'; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[8]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[8]) & 15]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[9]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[9]) & 15]; *protoptr++ = '-'; for (i = 10; i < 16; ++i) { *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[i]) >> 4]; *protoptr++ = hexmap[(uint8_t)(dashtree_.protection_key_.data()[i]) & 15]; } unsigned int sizeleft = ld_size - ((uuid - ld) + 6); memcpy(protoptr, uuid+6, sizeleft); protoptr += sizeleft; } else { memcpy(protoptr, ld, ld_size); protoptr += ld_size; } init_data.SetDataSize(protoptr - init_data.UseData()); return (single_sample_decryptor_ = CreateSingleSampleDecrypter(init_data))!=0; }