// File permissions for stream log files.
#define LOG_STREAM_FILE_PERMISSIONS (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
#endif // LOG_STREAMS_TO_FILES
+// limit for number of read error log entries to avoid spamming the logs
+#define MAX_READ_ERROR_LOGS 5
// Common limits macros.
#ifndef min
#if LOG_STREAMS_TO_FILES
int log_fd;
#endif // LOG_STREAMS_TO_FILES
+
+ volatile int16_t read_error_count;
};
// Determine whether the specified sample rate is supported by the submix module.
struct submix_stream_out * const out)
{
ALOG_ASSERT(in || out);
- ALOGV("submix_audio_device_create_pipe()");
+ ALOGD("submix_audio_device_create_pipe()");
pthread_mutex_lock(&rsxadev->lock);
// Save a reference to the specified input or output stream and the associated channel
// mask.
// before they shutdown.
static void submix_audio_device_release_pipe(struct submix_audio_device * const rsxadev)
{
- ALOGV("submix_audio_device_release_pipe()");
+ ALOGD("submix_audio_device_release_pipe()");
rsxadev->rsxSink.clear();
rsxadev->rsxSource.clear();
}
#endif // ENABLE_LEGACY_INPUT_OPEN
}
if (out != NULL) rsxadev->output = NULL;
- if (rsxadev->input != NULL && rsxadev->output != NULL) {
+ if (rsxadev->input == NULL && rsxadev->output == NULL) {
submix_audio_device_release_pipe(rsxadev);
- ALOGV("submix_audio_device_destroy_pipe(): pipe destroyed");
+ ALOGD("submix_audio_device_destroy_pipe(): pipe destroyed");
}
pthread_mutex_unlock(&rsxadev->lock);
}
return 0;
}
- ALOGI("out_set_parameters(): shutdown");
+ ALOGD("out_set_parameters(): shutting down MonoPipe sink");
sink->shutdown(true);
} // done using the sink
pthread_mutex_unlock(&rsxadev->lock);
// about to read from audio source
sp<MonoPipeReader> source = rsxadev->rsxSource;
if (source == NULL) {
- ALOGE("no audio pipe yet we're trying to read!");
+ in->read_error_count++;// ok if it rolls over
+ ALOGE_IF(in->read_error_count < MAX_READ_ERROR_LOGS,
+ "no audio pipe yet we're trying to read! (not all errors will be logged)");
pthread_mutex_unlock(&rsxadev->lock);
usleep(frames_to_read * 1000000 / in_get_sample_rate(&stream->common));
memset(buffer, 0, bytes);
const char *address __unused)
{
struct submix_audio_device * const rsxadev = audio_hw_device_get_submix_audio_device(dev);
- ALOGV("adev_open_output_stream()");
+ ALOGD("adev_open_output_stream()");
struct submix_stream_out *out;
bool force_pipe_creation = false;
(void)handle;
// Store a pointer to the device from the output stream.
out->dev = rsxadev;
// Initialize the pipe.
- ALOGV("adev_open_output_stream(): Initializing pipe");
+ ALOGV("adev_open_output_stream(): about to create pipe");
submix_audio_device_create_pipe(rsxadev, config, DEFAULT_PIPE_SIZE_IN_FRAMES,
DEFAULT_PIPE_PERIOD_COUNT, NULL, out);
#if LOG_STREAMS_TO_FILES
struct audio_stream_out *stream)
{
struct submix_stream_out * const out = audio_stream_out_get_submix_stream_out(stream);
- ALOGV("adev_close_output_stream()");
+ ALOGD("adev_close_output_stream()");
submix_audio_device_destroy_pipe(audio_hw_device_get_submix_audio_device(dev), NULL, out);
#if LOG_STREAMS_TO_FILES
if (out->log_fd >= 0) close(out->log_fd);
{
struct submix_audio_device *rsxadev = audio_hw_device_get_submix_audio_device(dev);
struct submix_stream_in *in;
- ALOGI("adev_open_input_stream()");
+ ALOGD("adev_open_input_stream()");
(void)handle;
(void)devices;
sp<MonoPipe> sink = rsxadev->rsxSink;
ALOG_ASSERT(sink != NULL);
// If the sink has been shutdown, delete the pipe.
- if (sink->isShutdown()) submix_audio_device_release_pipe(rsxadev);
+ if (sink != NULL) {
+ if (sink->isShutdown()) {
+ ALOGD(" Non-NULL shut down sink when opening input stream, releasing, refcount=%d",
+ in->ref_count);
+ submix_audio_device_release_pipe(rsxadev);
+ } else {
+ ALOGD(" Non-NULL sink when opening input stream, refcount=%d", in->ref_count);
+ }
+ } else {
+ ALOGE("NULL sink when opening input stream, refcount=%d", in->ref_count);
+ }
}
pthread_mutex_unlock(&rsxadev->lock);
#else
in->read_counter_frames = 0;
in->output_standby = rsxadev->output_standby;
in->dev = rsxadev;
+ in->read_error_count = 0;
// Initialize the pipe.
+ ALOGV("adev_open_input_stream(): about to create pipe");
submix_audio_device_create_pipe(rsxadev, config, DEFAULT_PIPE_SIZE_IN_FRAMES,
DEFAULT_PIPE_PERIOD_COUNT, in, NULL);
#if LOG_STREAMS_TO_FILES
struct audio_stream_in *stream)
{
struct submix_stream_in * const in = audio_stream_in_get_submix_stream_in(stream);
- ALOGV("adev_close_input_stream()");
+ ALOGD("adev_close_input_stream()");
submix_audio_device_destroy_pipe(audio_hw_device_get_submix_audio_device(dev), in, NULL);
#if LOG_STREAMS_TO_FILES
if (in->log_fd >= 0) close(in->log_fd);