本文整理汇总了C++中snd_pcm_frames_to_bytes函数的典型用法代码示例。如果您正苦于以下问题:C++ snd_pcm_frames_to_bytes函数的具体用法?C++ snd_pcm_frames_to_bytes怎么用?C++ snd_pcm_frames_to_bytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snd_pcm_frames_to_bytes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: write_alsa_output
static int
write_alsa_output (char * output_data, int output_size) {
int err;
snd_pcm_uframes_t frames;
while (output_size > 0) {
frames = snd_pcm_bytes_to_frames(pcm, output_size);
if ((err = snd_pcm_writei(pcm, output_data, frames)) < 0) {
if (snd_pcm_state(pcm) == SND_PCM_STATE_XRUN) {
if ((err = snd_pcm_prepare(pcm)) < 0)
printf("snd_pcm_prepare() failed.\r\n");
alsa_first_time = 1;
continue;
}
return err;
}
output_size -= snd_pcm_frames_to_bytes(pcm, err);
output_data += snd_pcm_frames_to_bytes(pcm, err);
if (alsa_first_time) {
alsa_first_time = 0;
snd_pcm_start(pcm);
}
}
return 0;
}
开发者ID:AlexRu,项目名称:rosa-media-player,代码行数:26,代码来源:midiplayerthread.cpp
示例2: snd_pcm_file_hw_params
static int snd_pcm_file_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
{
snd_pcm_file_t *file = pcm->private_data;
unsigned int channel;
snd_pcm_t *slave = file->gen.slave;
int err = _snd_pcm_hw_params(slave, params);
if (err < 0)
return err;
file->buffer_bytes = snd_pcm_frames_to_bytes(slave, slave->buffer_size);
file->wbuf_size = slave->buffer_size * 2;
file->wbuf_size_bytes = snd_pcm_frames_to_bytes(slave, file->wbuf_size);
file->wbuf_used_bytes = 0;
assert(!file->wbuf);
file->wbuf = malloc(file->wbuf_size_bytes);
if (file->wbuf == NULL) {
snd_pcm_file_hw_free(pcm);
return -ENOMEM;
}
file->wbuf_areas = malloc(sizeof(*file->wbuf_areas) * slave->channels);
if (file->wbuf_areas == NULL) {
snd_pcm_file_hw_free(pcm);
return -ENOMEM;
}
file->appl_ptr = file->file_ptr_bytes = 0;
for (channel = 0; channel < slave->channels; ++channel) {
snd_pcm_channel_area_t *a = &file->wbuf_areas[channel];
a->addr = file->wbuf;
a->first = slave->sample_bits * channel;
a->step = slave->frame_bits;
}
return 0;
}
开发者ID:OpenSmalltalk,项目名称:opensmalltalk-vm,代码行数:32,代码来源:pcm_file.c
示例3: ALSANoMMapProc
static ALuint ALSANoMMapProc(ALvoid *ptr)
{
ALCdevice *Device = (ALCdevice*)ptr;
alsa_data *data = (alsa_data*)Device->ExtraData;
snd_pcm_sframes_t avail;
char *WritePtr;
SetRTPriority();
while(!data->killNow)
{
int state = verify_state(data->pcmHandle);
if(state < 0)
{
ERR("Invalid state detected: %s\n", snd_strerror(state));
aluHandleDisconnect(Device);
break;
}
WritePtr = data->buffer;
avail = data->size / snd_pcm_frames_to_bytes(data->pcmHandle, 1);
aluMixData(Device, WritePtr, avail);
while(avail > 0)
{
int ret = snd_pcm_writei(data->pcmHandle, WritePtr, avail);
switch (ret)
{
case -EAGAIN:
continue;
case -ESTRPIPE:
case -EPIPE:
case -EINTR:
ret = snd_pcm_recover(data->pcmHandle, ret, 1);
if(ret < 0)
avail = 0;
break;
default:
if (ret >= 0)
{
WritePtr += snd_pcm_frames_to_bytes(data->pcmHandle, ret);
avail -= ret;
}
break;
}
if (ret < 0)
{
ret = snd_pcm_prepare(data->pcmHandle);
if(ret < 0)
break;
}
}
}
return 0;
}
开发者ID:LighFusion,项目名称:surreal,代码行数:56,代码来源:alsa.c
示例4: snd_pcm_bytes_to_frames
int AudioInputALSA::PcmRead(void* buf, uint nbytes)
{
unsigned char* bufptr = (unsigned char*)buf;
snd_pcm_uframes_t to_read = snd_pcm_bytes_to_frames(pcm_handle, nbytes);
snd_pcm_uframes_t nframes = to_read;
snd_pcm_sframes_t nread, avail;
int retries = 0;
while (nframes > 0 && retries < 3)
{
if (AlsaBad((avail = snd_pcm_avail_update(pcm_handle)),
"available update failed"))
{
if (!Recovery(avail))
{
++retries;
continue;
}
}
if ((nread = snd_pcm_readi(pcm_handle, bufptr, nframes)) < 0)
{
switch (nread)
{
case -EAGAIN:
break;
case -EBADFD:
LOG(VB_GENERAL, LOG_ERR, LOC_DEV +
QString("in a state unfit to read (%1): %2")
.arg(nread).arg(snd_strerror(nread)));
break;
case -EINTR:
case -EPIPE:
case -ESTRPIPE:
Recovery(nread);
break;
default:
LOG(VB_GENERAL, LOG_ERR, LOC_DEV +
QString("weird return from snd_pcm_readi: %1")
.arg(snd_strerror(nread)));
break;
}
}
else
{
nframes -= nread;
bufptr += snd_pcm_frames_to_bytes(pcm_handle, nread);
}
++retries;
}
if (nframes > 0)
LOG(VB_AUDIO, LOG_ERR, LOC_DEV +
QString("short pcm read, %1 of %2 frames, retries %3")
.arg(to_read - nframes).arg(to_read).arg(retries));
return snd_pcm_frames_to_bytes(pcm_handle, to_read - nframes);
}
开发者ID:kzmi,项目名称:mythtv_isdb,代码行数:54,代码来源:audioinputalsa.cpp
示例5: bytesFree
bool QAudioOutputPrivate::deviceReady()
{
if(pullMode) {
int l = 0;
int chunks = bytesAvailable/period_size;
if(chunks==0) {
bytesAvailable = bytesFree();
return false;
}
#ifdef DEBUG_AUDIO
qDebug()<<"deviceReady() avail="<<bytesAvailable<<" bytes, period size="<<period_size<<" bytes";
qDebug()<<"deviceReady() no. of chunks that can fit ="<<chunks<<", chunks in bytes ="<<period_size*chunks;
#endif
int input = period_frames*chunks;
if(input > (int)buffer_frames)
input = buffer_frames;
l = audioSource->read(audioBuffer,snd_pcm_frames_to_bytes(handle, input));
if(l > 0) {
// Got some data to output
if(deviceState != QAudio::ActiveState)
return true;
write(audioBuffer,l);
bytesAvailable = bytesFree();
} else if(l == 0) {
// Did not get any data to output
bytesAvailable = bytesFree();
if(bytesAvailable > snd_pcm_frames_to_bytes(handle, buffer_frames-period_frames)) {
// Underrun
errorState = QAudio::UnderrunError;
deviceState = QAudio::IdleState;
emit stateChanged(deviceState);
}
} else if(l < 0) {
close();
errorState = QAudio::IOError;
emit stateChanged(deviceState);
}
} else
bytesAvailable = bytesFree();
if(deviceState != QAudio::ActiveState)
return true;
if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) {
emit notify();
elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime;
timeStamp.restart();
}
return true;
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:52,代码来源:qaudiooutput_alsa_p.cpp
示例6: alsa_stop_capture
static void alsa_stop_capture(ALCdevice *Device)
{
alsa_data *data = (alsa_data*)Device->ExtraData;
ALCuint avail;
int err;
/* OpenAL requires access to unread audio after stopping, but ALSA's
* snd_pcm_drain is unreliable and snd_pcm_drop drops it. Capture what's
* available now so it'll be available later after the drop. */
avail = alsa_available_samples(Device);
if(!data->ring && avail > 0)
{
/* The ring buffer implicitly captures when checking availability.
* Direct access needs to explicitly capture it into temp storage. */
ALsizei size;
void *ptr;
size = snd_pcm_frames_to_bytes(data->pcmHandle, avail);
ptr = realloc(data->buffer, size);
if(ptr)
{
data->buffer = ptr;
alsa_capture_samples(Device, data->buffer, avail);
data->size = size;
}
}
err = snd_pcm_drop(data->pcmHandle);
if(err < 0)
ERR("drop failed: %s\n", snd_strerror(err));
data->doCapture = AL_FALSE;
}
开发者ID:LighFusion,项目名称:surreal,代码行数:31,代码来源:alsa.c
示例7: wodUpdatePlayedTotal
/**************************************************************************
* wodUpdatePlayedTotal [internal]
*
*/
static BOOL wodUpdatePlayedTotal(WINE_WAVEDEV* wwo, snd_pcm_status_t* ps)
{
snd_pcm_sframes_t delay;
snd_pcm_sframes_t avail;
snd_pcm_uframes_t buf_size = 0;
snd_pcm_state_t state;
state = snd_pcm_state(wwo->pcm);
avail = snd_pcm_avail_update(wwo->pcm);
snd_pcm_hw_params_get_buffer_size(wwo->hw_params, &buf_size);
delay = buf_size - avail;
if (state != SND_PCM_STATE_RUNNING && state != SND_PCM_STATE_PREPARED)
{
WARN("Unexpected state (%d) while updating Total Played, resetting\n", state);
wine_snd_pcm_recover(wwo->pcm, -EPIPE, 0);
delay=0;
}
/* A delay < 0 indicates an underrun; for our purposes that's 0. */
if (delay < 0)
{
WARN("Unexpected delay (%ld) while updating Total Played, resetting\n", delay);
delay=0;
}
InterlockedExchange((LONG*)&wwo->dwPlayedTotal, wwo->dwWrittenTotal - snd_pcm_frames_to_bytes(wwo->pcm, delay));
return TRUE;
}
开发者ID:mikekap,项目名称:wine,代码行数:33,代码来源:waveout.c
示例8: snd_pcm_avail_update
int QAudioOutputPrivate::bytesFree() const
{
if(resuming)
return period_size;
if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState)
return 0;
int frames = snd_pcm_avail_update(handle);
if (frames == -EPIPE) {
// Try and handle buffer underrun
int err = snd_pcm_recover(handle, frames, 0);
if (err < 0)
return 0;
else
frames = snd_pcm_avail_update(handle);
} else if (frames < 0) {
return 0;
}
if ((int)frames > (int)buffer_frames)
frames = buffer_frames;
return snd_pcm_frames_to_bytes(handle, frames);
}
开发者ID:zccrs,项目名称:qt-mobility,代码行数:25,代码来源:qaudiooutput_alsa_p.cpp
示例9: while
EmErrorCode AlsaRenderer::Write(const char* buf, uint32_t len)
{
int off = 0;
int leftFrames = (len + m_FrameLength - 1) / m_FrameLength;
while (leftFrames > 0) {
int written = snd_pcm_writei(m_PcmHandle, buf+off, leftFrames);
if (written > 0) {
leftFrames -= written;
off += snd_pcm_frames_to_bytes(m_PcmHandle, written);
} else if (written == -EPIPE) {
if (snd_pcm_prepare(m_PcmHandle) < 0)
printf("FATAL: snd_pcm_prepare() failed!\n");
} else if (written == -ESTRPIPE) {
while ((written = snd_pcm_resume(m_PcmHandle)) == -EAGAIN)
usleep(100);
if (written < 0) {
if ((written = snd_pcm_prepare(m_PcmHandle)) < 0)
return ErrorCode::RendererFailedToWrite;
}
} else if (written <= 0) {
printf("writei error / short write\n");
}
}
return ErrorCode::Ok;
}
开发者ID:ClarkWang12,项目名称:mous,代码行数:27,代码来源:AlsaRenderer.cpp
示例10: while
qint64 QAudioInputPrivate::read( char *data, qint64 maxlen )
{
int rc = -1, count=0;
if (handle != NULL)
{
while(count < 5) {
int frames = snd_pcm_bytes_to_frames(handle, (int)maxlen);
int readFrames = snd_pcm_readi(handle, data, frames);
if (readFrames >= 0) {
rc = snd_pcm_frames_to_bytes(handle, readFrames);
qLog(QAudioInput) << QString("read in bytes = %1 (frames=%2)").arg(rc).arg(readFrames).toLatin1().constData();
break;
}
else if ((readFrames == -EAGAIN) || (readFrames == -EINTR)) {
qLog(QAudioInput) << "ALSA: EAGAIN || EINTR error";
rc = 0;
break;
}
else {
if(readFrames == -EPIPE) {
qLog(QAudioInput) << "ALSA: underrun!!!";
rc = snd_pcm_prepare(handle);
} else if(readFrames == -ESTRPIPE) {
qLog(QAudioInput) << "ALSA: suspend recovery!!!!";
rc = snd_pcm_prepare(handle);
}
if(rc != 0) break;
}
count++;
}
}
return rc;
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:35,代码来源:qaudioinput_alsa.cpp
示例11: alsa_write_audio
/* transfer data to audio h/w via normal write */
static void
alsa_write_audio(char* data, int length) {
snd_pcm_sframes_t written_frames;
while(length > 0) {
int frames = snd_pcm_bytes_to_frames(alsa_pcm, length);
written_frames = snd_pcm_writei(alsa_pcm, data, frames);
if(written_frames > 0) {
int written = snd_pcm_frames_to_bytes(alsa_pcm,
written_frames);
length -= written;
data += written;
alsa_hw_written += written;
} else {
int err = alsa_handle_error((int) written_frames);
if(err < 0) {
printf("alsa_write_audio(): write error: %s\n",
snd_strerror(-err));
break;
}
}
}
}
开发者ID:TA1DB,项目名称:rtl_hpsdr,代码行数:26,代码来源:local_sound.c
示例12: snd_pcm_prepare
void QAudioOutputPrivate::resume()
{
if(deviceState == QAudio::SuspendedState) {
int err = 0;
if(handle) {
err = snd_pcm_prepare( handle );
if(err < 0)
xrun_recovery(err);
err = snd_pcm_start(handle);
if(err < 0)
xrun_recovery(err);
bytesAvailable = (int)snd_pcm_frames_to_bytes(handle, buffer_frames);
}
resuming = true;
if(pullMode)
deviceState = QAudio::ActiveState;
else
deviceState = QAudio::IdleState;
errorState = QAudio::NoError;
timer->start(period_time/1000);
emit stateChanged(deviceState);
}
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:27,代码来源:qaudiooutput_alsa_p.cpp
示例13: gst_alsasink_write
static guint
gst_alsasink_write (GstAudioSink * asink, gpointer data, guint length)
{
GstAlsaSink *alsa;
gint err;
gint cptr;
gint16 *ptr = data;
alsa = GST_ALSA_SINK (asink);
if (alsa->iec958 && alsa->need_swap) {
guint i;
GST_DEBUG_OBJECT (asink, "swapping bytes");
for (i = 0; i < length / 2; i++) {
ptr[i] = GUINT16_SWAP_LE_BE (ptr[i]);
}
}
GST_LOG_OBJECT (asink, "received audio samples buffer of %u bytes", length);
cptr = length / alsa->bytes_per_sample;
GST_ALSA_SINK_LOCK (asink);
while (cptr > 0) {
/* start by doing a blocking wait for free space. Set the timeout
* to 4 times the period time */
err = snd_pcm_wait (alsa->handle, (4 * alsa->period_time / 1000));
if (err < 0) {
GST_DEBUG_OBJECT (asink, "wait error, %d", err);
} else {
GST_DELAY_SINK_LOCK (asink);
err = snd_pcm_writei (alsa->handle, ptr, cptr);
GST_DELAY_SINK_UNLOCK (asink);
}
GST_DEBUG_OBJECT (asink, "written %d frames out of %d", err, cptr);
if (err < 0) {
GST_DEBUG_OBJECT (asink, "Write error: %s", snd_strerror (err));
if (err == -EAGAIN) {
continue;
} else if (xrun_recovery (alsa, alsa->handle, err) < 0) {
goto write_error;
}
continue;
}
ptr += snd_pcm_frames_to_bytes (alsa->handle, err);
cptr -= err;
}
GST_ALSA_SINK_UNLOCK (asink);
return length - (cptr * alsa->bytes_per_sample);
write_error:
{
GST_ALSA_SINK_UNLOCK (asink);
return length; /* skip one period */
}
}
开发者ID:pli3,项目名称:gst-plugins-base,代码行数:60,代码来源:gstalsasink.c
示例14: snd_pcm_file_add_frames
static void snd_pcm_file_add_frames(snd_pcm_t *pcm,
const snd_pcm_channel_area_t *areas,
snd_pcm_uframes_t offset,
snd_pcm_uframes_t frames)
{
snd_pcm_file_t *file = pcm->private_data;
while (frames > 0) {
snd_pcm_uframes_t n = frames;
snd_pcm_uframes_t cont = file->wbuf_size - file->appl_ptr;
snd_pcm_uframes_t avail = file->wbuf_size - snd_pcm_bytes_to_frames(pcm, file->wbuf_used_bytes);
if (n > cont)
n = cont;
if (n > avail)
n = avail;
snd_pcm_areas_copy(file->wbuf_areas, file->appl_ptr,
areas, offset,
pcm->channels, n, pcm->format);
frames -= n;
offset += n;
file->appl_ptr += n;
if (file->appl_ptr == file->wbuf_size)
file->appl_ptr = 0;
file->wbuf_used_bytes += snd_pcm_frames_to_bytes(pcm, n);
if (file->wbuf_used_bytes > file->buffer_bytes)
snd_pcm_file_write_bytes(pcm, file->wbuf_used_bytes - file->buffer_bytes);
assert(file->wbuf_used_bytes < file->wbuf_size_bytes);
}
}
开发者ID:OpenSmalltalk,项目名称:opensmalltalk-vm,代码行数:28,代码来源:pcm_file.c
示例15: sa_stream_drain
int
sa_stream_drain(sa_stream_t *s)
{
if (s == NULL || s->output_unit == NULL) {
return SA_ERROR_NO_INIT;
}
if (snd_pcm_state(s->output_unit) == SND_PCM_STATE_PREPARED) {
size_t min_samples = 0;
size_t min_bytes = 0;
void *buf;
if (sa_stream_get_min_write(s, &min_samples) < 0)
return SA_ERROR_SYSTEM;
min_bytes = snd_pcm_frames_to_bytes(s->output_unit, min_samples);
buf = malloc(min_bytes);
if (!buf)
return SA_ERROR_SYSTEM;
memset(buf, 0, min_bytes);
sa_stream_write(s, buf, min_bytes);
free(buf);
}
if (snd_pcm_state(s->output_unit) != SND_PCM_STATE_RUNNING) {
return SA_ERROR_INVALID;
}
snd_pcm_drain(s->output_unit);
return SA_SUCCESS;
}
开发者ID:hadicoffee,项目名称:jb412gecko,代码行数:30,代码来源:sydney_audio_alsa.c
示例16: memmove
qint64 OutputALSA::writeAudio(unsigned char *data, qint64 maxSize)
{
if((maxSize = qMin(maxSize, m_prebuf_size - m_prebuf_fill)) > 0)
{
memmove(m_prebuf + m_prebuf_fill, data, maxSize);
m_prebuf_fill += maxSize;
}
snd_pcm_uframes_t l = snd_pcm_bytes_to_frames(pcm_handle, m_prebuf_fill);
while (l >= m_chunk_size)
{
snd_pcm_wait(pcm_handle, 10);
long m;
if ((m = alsa_write(m_prebuf, m_chunk_size)) >= 0)
{
l -= m;
m = snd_pcm_frames_to_bytes(pcm_handle, m); // convert frames to bytes
m_prebuf_fill -= m;
memmove(m_prebuf, m_prebuf + m, m_prebuf_fill); //move data to begin
}
else
return -1;
}
return maxSize;
}
开发者ID:Greedysky,项目名称:qmmp,代码行数:26,代码来源:outputalsa.cpp
示例17: audio_write
static int audio_write(audiodevice_t *dev, unsigned char *buf, int cnt) {
audio_alsa09_t *alsa = (audio_alsa09_t *)dev->data_pcm;
int len, err;
if (NULL == alsa->handle) return NG;
if (cnt == 0) return 0;
len = snd_pcm_bytes_to_frames(alsa->handle, cnt);
while(0 > (err = snd_pcm_writei(alsa->handle, buf, len))) {
if (err == -EPIPE) {
if (0 > snd_pcm_prepare(alsa->handle)) {
return -1;
}
continue;
} else if (err == -ESTRPIPE) {
while(-EAGAIN == (err = snd_pcm_resume(alsa->handle))) {
sleep(1);
}
if (err < 0) {
if (0 > snd_pcm_prepare(alsa->handle)) {
return -1;
}
}
continue;
}
if (0 > snd_pcm_prepare(alsa->handle)) {
return -1;
}
}
return (snd_pcm_frames_to_bytes(alsa->handle, err));
}
开发者ID:kichikuou,项目名称:xsystem35-nacl,代码行数:33,代码来源:audio_alsa09.c
示例18: snd_pcm_file_rewind
static snd_pcm_sframes_t snd_pcm_file_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
snd_pcm_file_t *file = pcm->private_data;
snd_pcm_sframes_t err;
snd_pcm_uframes_t n;
n = snd_pcm_frames_to_bytes(pcm, frames);
if (n > file->wbuf_used_bytes)
frames = snd_pcm_bytes_to_frames(pcm, file->wbuf_used_bytes);
err = snd_pcm_rewind(file->gen.slave, frames);
if (err > 0) {
file->appl_ptr = (file->appl_ptr - err + file->wbuf_size) % file->wbuf_size;
n = snd_pcm_frames_to_bytes(pcm, err);
file->wbuf_used_bytes -= n;
}
return err;
}
开发者ID:OpenSmalltalk,项目名称:opensmalltalk-vm,代码行数:17,代码来源:pcm_file.c
示例19: snd_pcm_file_forward
static snd_pcm_sframes_t snd_pcm_file_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
snd_pcm_file_t *file = pcm->private_data;
snd_pcm_sframes_t err;
snd_pcm_uframes_t n;
n = snd_pcm_frames_to_bytes(pcm, frames);
if (file->wbuf_used_bytes + n > file->wbuf_size_bytes)
frames = snd_pcm_bytes_to_frames(pcm, file->wbuf_size_bytes - file->wbuf_used_bytes);
err = INTERNAL(snd_pcm_forward)(file->gen.slave, frames);
if (err > 0) {
file->appl_ptr = (file->appl_ptr + err) % file->wbuf_size;
n = snd_pcm_frames_to_bytes(pcm, err);
file->wbuf_used_bytes += n;
}
return err;
}
开发者ID:OpenSmalltalk,项目名称:opensmalltalk-vm,代码行数:17,代码来源:pcm_file.c
示例20: write
void write( const char *data, qint64 len )
{
if ( !handle )
return;
int count=0;
qLog(QAudioOutput)<<"frames to write out = "<<
snd_pcm_bytes_to_frames( handle, (int)len )<<" ("<<len<<") bytes";
while ( len > 0 ) {
int err=0;
int frames = snd_pcm_bytes_to_frames( handle, (int)len );
#ifdef ALSA_USE_AVAILABLE
if(frames < (int)period_size)
return;
int available = snd_pcm_avail_update(handle);
qLog(QAudioOutput) <<"available space = "<<available;
if(available == 0) {
while(available < frames) {
snd_pcm_wait(handle,period_size/1000);
usleep(period_size*10);
available = snd_pcm_avail_update(handle);
qLog(QAudioOutput) <<"->available space = "<<available;
count++;
if((count > 5)||(available < 0))
return;
}
}
#endif
err = snd_pcm_writei( handle, data, frames );
// Handle errors
if ( err >= 0 ) {
if(err == 0) count++;
int bytes = snd_pcm_frames_to_bytes( handle, err );
qLog(QAudioOutput) << QString("write out = %1").arg(bytes).toLatin1().constData();
data += bytes;
len -= bytes;
} else {
count++;
qLog(QAudioOutput) <<"err = "<<err;
err = xrun_recovery(err);
}
if(count > 5) {
qLog(QAudioOutput) <<"failing to write, close() and re-open() to try and recover!";
close();
open();
snd_pcm_prepare(handle);
break;
}
}
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:57,代码来源:qaudiooutput_alsa.cpp
注:本文中的snd_pcm_frames_to_bytes函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论