Beispiel #1
0
static void adev_close_input_stream(struct audio_hw_device *dev,
                                   struct audio_stream_in *stream)
{
    ALOGV("%s", __func__);

    in_standby(&stream->common);
    free(stream);

    return;
}
static void adev_close_input_stream(struct audio_hw_device *dev, struct audio_stream_in *stream)
{
    struct stream_in *in = (struct stream_in *)stream;

    /* Close the pcm device */
    in_standby(&stream->common);

    free(in->conversion_buffer);

    free(stream);
}
Beispiel #3
0
static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
                       size_t bytes)
{
    struct stream_in *in = (struct stream_in *)stream;
    struct audio_device *adev = in->dev;
    int i, ret = -1;

    ALOGV("%s enter",__func__);

    pthread_mutex_lock(&in->lock);
    if (in->standby) {
        pthread_mutex_lock(&adev->lock);
        ret = start_input_stream(in);
        pthread_mutex_unlock(&adev->lock);
        if (ret != 0) {
            goto exit;
        }
        in->standby = false;
    }

    if (in->pcm) {
        ret = pcm_read(in->pcm, buffer, bytes);
    }
    ALOGV("in_read returned %d bytes ret = %d",bytes,ret);

exit:
    pthread_mutex_unlock(&in->lock);

    if (ret != 0) {
        in_standby(&in->stream.common);
        uint64_t duration_ms = ((bytes * 1000)/
                                (audio_stream_frame_size(&in->stream.common)) /
                                (in_get_sample_rate(&in->stream.common)));
        ALOGV("%s : silence read - read failed", __func__);
        usleep(duration_ms * 1000);
    }
    ALOGV("%s exit",__func__);

    return bytes;
}