本文整理汇总了C++中AudioStream类的典型用法代码示例。如果您正苦于以下问题:C++ AudioStream类的具体用法?C++ AudioStream怎么用?C++ AudioStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AudioStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blocksignals
/***************************************
* startSendingAudio
* Helper function
***************************************/
void * AudioStream::startSendingAudio(void *par)
{
AudioStream *conf = (AudioStream *)par;
blocksignals();
Log("SendAudioThread [%d]\n",getpid());
pthread_exit((void *)conf->SendAudio());
}
示例2: AAudioStream_write
AAUDIO_API aaudio_result_t AAudioStream_write(AAudioStream* stream,
const void *buffer,
int32_t numFrames,
int64_t timeoutNanoseconds)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
if (buffer == nullptr) {
return AAUDIO_ERROR_NULL;
}
// Don't allow writes when playing with a callback.
if (audioStream->getDataCallbackProc() != nullptr && audioStream->isActive()) {
ALOGE("Cannot write to a callback stream when running.");
return AAUDIO_ERROR_INVALID_STATE;
}
if (numFrames < 0) {
return AAUDIO_ERROR_ILLEGAL_ARGUMENT;
} else if (numFrames == 0) {
return 0;
}
aaudio_result_t result = audioStream->write(buffer, numFrames, timeoutNanoseconds);
return result;
}
示例3: TimerCallback
// Timer callback for Timer object created by ::Play method.
BOOL AudioStream::TimerCallback (DWORD dwUser)
{
// dwUser contains ptr to AudioStream object
AudioStream * pas = (AudioStream *) dwUser;
return (pas->ServiceBuffer ());
}
示例4: pushMIDISysex
bool SynthRoute::pushMIDISysex(const Bit8u *sysexData, unsigned int sysexLen, MasterClockNanos refNanos) {
recorder.recordSysex(sysexData, sysexLen, refNanos);
AudioStream *stream = audioStream;
if (stream == NULL) return false;
quint64 timestamp = stream->estimateMIDITimestamp(refNanos);
return qSynth.playMIDISysex(sysexData, sysexLen, timestamp);
}
示例5: flow
virtual int flow(AudioStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r) {
assert(input.isStereo() == stereo);
#ifdef DEBUG_RATECONV
debug("Copy st=%d rev=%d", stereo, reverseStereo);
#endif
st_size_t len;
st_sample_t *ostart = obuf;
if (stereo)
osamp *= 2;
// Reallocate temp buffer, if necessary
if (osamp > _bufferSize) {
free(_buffer);
_buffer = (st_sample_t *)malloc(osamp * 2);
_bufferSize = osamp;
}
// Read up to 'osamp' samples into our temporary buffer
len = input.readBuffer(_buffer, osamp);
if (len <= 0)
return 0;
// Mix the data into the output buffer
if (stereo && reverseStereo)
obuf = ARM_CopyRate_R(len, obuf, vol_l, vol_r, _buffer);
else if (stereo)
obuf = ARM_CopyRate_S(len, obuf, vol_l, vol_r, _buffer);
else
obuf = ARM_CopyRate_M(len, obuf, vol_l, vol_r, _buffer);
return (obuf-ostart)/2;
}
示例6: createAudioStream
size_t ASFStream::readBuffer(int16 *buffer, const size_t numSamples) {
size_t samplesDecoded = 0;
for (;;) {
if (_curAudioStream) {
const size_t n = _curAudioStream->readBuffer(buffer + samplesDecoded, numSamples - samplesDecoded);
if (n == kSizeInvalid)
return kSizeInvalid;
samplesDecoded += n;
if (_curAudioStream->endOfData()) {
delete _curAudioStream;
_curAudioStream = 0;
}
}
if (samplesDecoded == numSamples || endOfData())
break;
if (!_curAudioStream) {
_curAudioStream = createAudioStream();
}
}
return samplesDecoded;
}
示例7: AAudioStream_requestStart
AAUDIO_API aaudio_result_t AAudioStream_requestStart(AAudioStream* stream)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
ALOGD("AAudioStream_requestStart(%p) called --------------", stream);
aaudio_result_t result = audioStream->systemStart();
ALOGD("AAudioStream_requestStart(%p) returned %d ---------", stream, result);
return result;
}
示例8: AAudioStream_waitForStateChange
AAUDIO_API aaudio_result_t AAudioStream_waitForStateChange(AAudioStream* stream,
aaudio_stream_state_t inputState,
aaudio_stream_state_t *nextState,
int64_t timeoutNanoseconds)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
return audioStream->waitForStateChange(inputState, nextState, timeoutNanoseconds);
}
示例9: get_audio_stream
void AudioManager::stop_stream(int stream_idx)
{
if (stream_idx < 0)
return;
AudioStream *strm = get_audio_stream(stream_idx);
if (strm && strm->is_playing())
strm->stop();
}
示例10: AAudioStream_close
AAUDIO_API aaudio_result_t AAudioStream_close(AAudioStream* stream)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
ALOGD("AAudioStream_close(%p)", stream);
if (audioStream != nullptr) {
audioStream->close();
audioStream->unregisterPlayerBase();
delete audioStream;
return AAUDIO_OK;
}
return AAUDIO_ERROR_NULL;
}
示例11: AAudioStream_getTimestamp
AAUDIO_API aaudio_result_t AAudioStream_getTimestamp(AAudioStream* stream,
clockid_t clockid,
int64_t *framePosition,
int64_t *timeNanoseconds)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
if (framePosition == nullptr) {
return AAUDIO_ERROR_NULL;
} else if (timeNanoseconds == nullptr) {
return AAUDIO_ERROR_NULL;
} else if (clockid != CLOCK_MONOTONIC && clockid != CLOCK_BOOTTIME) {
return AAUDIO_ERROR_ILLEGAL_ARGUMENT;
}
return audioStream->getTimestamp(clockid, framePosition, timeNanoseconds);
}
示例12: checkAndSave
void Laboratory::checkAndSave(TrialsSet& trialsSet, AudioStream& audioStream, InputAudioParameters& str, CheckMethodType checkMethod, std::string folderForAudioResults ) {
//Check - write result to file
if(str.data_source == AudioStream::AUDIO_FILE_AS_SOURCE) {
audioStream.close (resultsPath_ + folderForAudioResults + std::string("/") + str.outFileName, true);
audioStream.cutAndClose (resultsPath_ + folderForAudioResults + std::string("/") + std::string("cutted__") +str.outFileName, trialsSet, false );
}
if(str.data_source == AudioStream::RANDOM_DATA_AS_SOURCE)
if(checkMethod == CheckMethodType::ifOutSilence)
if(audioStream.checkIfOutSilence())
throw UnkownInternalProcessingError_Exception();
if(checkMethod == CheckMethodType::ifTheInTheSameAsOut)
if(!audioStream.checkIfOutTheSameAsIn())
throw UnkownInternalProcessingError_Exception();
//.
}
示例13: lock
int QueuingAudioStreamImpl::readBuffer(int16 *buffer, const int numSamples) {
Common::StackLock lock(_mutex);
int samplesDecoded = 0;
while (samplesDecoded < numSamples && !_queue.empty()) {
AudioStream *stream = _queue.front()._stream;
samplesDecoded += stream->readBuffer(buffer + samplesDecoded, numSamples - samplesDecoded);
if (stream->endOfData()) {
StreamHolder tmp = _queue.pop();
if (tmp._disposeAfterUse == DisposeAfterUse::YES)
delete stream;
}
}
return samplesDecoded;
}
示例14: pushMIDIShortMessage
bool SynthRoute::pushMIDIShortMessage(Bit32u msg, MasterClockNanos refNanos) {
recorder.recordShortMessage(msg, refNanos);
AudioStream *stream = audioStream;
if (stream == NULL) return false;
quint64 timestamp = stream->estimateMIDITimestamp(refNanos);
if (msg == 0) {
// This is a special event sent by the test driver
qint64 delta = qint64(timestamp - debugLastEventTimestamp);
MasterClockNanos debugEventNanoOffset = (refNanos == 0) ? 0 : MasterClock::getClockNanos() - refNanos;
if ((delta < debugDeltaLowerLimit) || (debugDeltaUpperLimit < delta) || ((15 * MasterClock::NANOS_PER_MILLISECOND) < debugEventNanoOffset)) {
qDebug() << "M" << delta << timestamp << 1e-6 * debugEventNanoOffset;
}
debugLastEventTimestamp = timestamp;
return false;
}
return qSynth.playMIDIShortMessage(msg, timestamp);
}
示例15: AAudioStreamBuilder_openStream
AAUDIO_API aaudio_result_t AAudioStreamBuilder_openStream(AAudioStreamBuilder* builder,
AAudioStream** streamPtr)
{
AudioStream *audioStream = nullptr;
// Please leave these logs because they are very helpful when debugging.
ALOGD("AAudioStreamBuilder_openStream() called ----------------------------------------");
AudioStreamBuilder *streamBuilder = COMMON_GET_FROM_BUILDER_OR_RETURN(streamPtr);
aaudio_result_t result = streamBuilder->build(&audioStream);
ALOGD("AAudioStreamBuilder_openStream() returns %d = %s for (%p) ----------------",
result, AAudio_convertResultToText(result), audioStream);
if (result == AAUDIO_OK) {
audioStream->registerPlayerBase();
*streamPtr = (AAudioStream*) audioStream;
} else {
*streamPtr = nullptr;
}
return result;
}