diff --git a/android/client/if-sco.c b/android/client/if-sco.c
index 06ac6e8..14b7dcc 100644
--- a/android/client/if-sco.c
+++ b/android/client/if-sco.c
static void open_output_stream_p(int argc, const char **argv)
{
+ struct audio_config *config;
int err;
RETURN_IF_NULL(if_audio_sco);
}
pthread_mutex_unlock(&state_mutex);
+ if (argc < 3) {
+ haltest_info("No sampling rate specified. Use default conf\n");
+ config = NULL;
+ } else {
+ config = calloc(1, sizeof(struct audio_config));
+ if (!config)
+ return;
+
+ config->sample_rate = atoi(argv[2]);
+ config->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
+ config->format = AUDIO_FORMAT_PCM_16_BIT;
+ }
+
err = if_audio_sco->open_output_stream(if_audio_sco,
0,
AUDIO_DEVICE_OUT_ALL_SCO,
AUDIO_OUTPUT_FLAG_NONE,
- NULL,
+ config,
&stream_out);
if (err < 0) {
haltest_error("open output stream returned %d\n", err);
- return;
+ goto failed;
}
buffer_size = stream_out->common.get_buffer_size(&stream_out->common);
haltest_error("Invalid buffer size received!\n");
else
haltest_info("Using buffer size: %zu\n", buffer_size);
+failed:
+ if (config)
+ free(config);
}
static void close_output_stream_p(int argc, const char **argv)
static void open_input_stream_p(int argc, const char **argv)
{
+ struct audio_config *config;
int err;
RETURN_IF_NULL(if_audio_sco);
}
pthread_mutex_unlock(&state_mutex);
+ if (argc < 3) {
+ haltest_info("No sampling rate specified. Use default conf\n");
+ config = NULL;
+ } else {
+ config = calloc(1, sizeof(struct audio_config));
+ if (!config)
+ return;
+
+ config->sample_rate = atoi(argv[2]);
+ config->channel_mask = AUDIO_CHANNEL_OUT_MONO;
+ config->format = AUDIO_FORMAT_PCM_16_BIT;
+ }
+
err = if_audio_sco->open_input_stream(if_audio_sco,
0,
AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
- NULL,
+ config,
&stream_in);
if (err < 0) {
haltest_error("open output stream returned %d\n", err);
- return;
+ goto failed;
}
buffer_size_in = stream_in->common.get_buffer_size(&stream_in->common);
haltest_error("Invalid buffer size received!\n");
else
haltest_info("Using buffer size: %zu\n", buffer_size_in);
+failed:
+ if (config)
+ free(config);
}
static void close_input_stream_p(int argc, const char **argv)
static struct method methods[] = {
STD_METHOD(init),
STD_METHOD(cleanup),
- STD_METHOD(open_output_stream),
+ STD_METHODH(open_output_stream, "sample_rate"),
STD_METHOD(close_output_stream),
- STD_METHOD(open_input_stream),
+ STD_METHODH(open_input_stream, "sampling rate"),
STD_METHOD(close_input_stream),
STD_METHODH(play, "<path to pcm file>"),
STD_METHOD(read),