h->intf.get_volume_value = dlsym(h->dl_handle, "audio_get_volume_value");
h->intf.get_volume_mute = dlsym(h->dl_handle, "audio_get_volume_mute");
h->intf.set_volume_mute = dlsym(h->dl_handle, "audio_set_volume_mute");
+ h->intf.do_route = dlsym(h->dl_handle, "audio_do_route");
+ h->intf.update_route_option = dlsym(h->dl_handle, "audio_update_route_option");
+ h->intf.update_stream_connection_info = dlsym(h->dl_handle, "audio_update_stream_connection_info");
+ h->intf.get_buffer_attr = dlsym(h->dl_handle, "audio_get_buffer_attr");
h->intf.alsa_pcm_open = dlsym(h->dl_handle, "audio_alsa_pcm_open");
h->intf.alsa_pcm_close = dlsym(h->dl_handle, "audio_alsa_pcm_close");
h->intf.pcm_open = dlsym(h->dl_handle, "audio_pcm_open");
h->intf.pcm_avail = dlsym(h->dl_handle, "audio_pcm_avail");
h->intf.pcm_write = dlsym(h->dl_handle, "audio_pcm_write");
h->intf.pcm_read = dlsym(h->dl_handle, "audio_pcm_read");
- h->intf.do_route = dlsym(h->dl_handle, "audio_do_route");
- h->intf.update_route_option = dlsym(h->dl_handle, "audio_update_route_option");
- h->intf.update_stream_connection_info = dlsym(h->dl_handle, "audio_update_stream_connection_info");
- h->intf.get_buffer_attr = dlsym(h->dl_handle, "audio_get_buffer_attr");
if (h->intf.init) {
/* TODO : no need to pass platform_data as second param. need to fix hal. */
if (h->intf.init(&h->data, user_data) != AUDIO_RET_OK) {
pa_xfree(h);
}
-int32_t pa_hal_manager_get_buffer_attribute(pa_hal_manager *h, io_direction_t direction, const char *latency, void *new_data, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize) {
- int32_t ret = 0;
- audio_return_t hal_ret = AUDIO_RET_OK;
- pa_sample_spec *sample_spec = NULL;
-
- pa_assert(h);
- pa_assert(new_data);
-
- sample_spec = (direction==DIRECTION_OUT)?(&((pa_sink_input_new_data*)new_data)->sample_spec):(&((pa_source_output_new_data*)new_data)->sample_spec);
- pa_log_info("latency:%s, rate:%u, format:%d, channels:%u", latency, sample_spec->rate, sample_spec->format, sample_spec->channels);
-
- if (AUDIO_IS_ERROR(hal_ret = h->intf.get_buffer_attr(h->data, direction, latency, sample_spec->rate, sample_spec->format, sample_spec->channels, maxlength, tlength, prebuf, minreq, fragsize))) {
- pa_log_error("get_buffer_attr returns error:0x%x", hal_ret);
- ret = -1;
- } else
- pa_log_info("maxlength:%d, tlength:%d, prebuf:%d, minreq:%d, fragsize:%d", *maxlength, *tlength, *prebuf, *minreq, *fragsize);
-
- return ret;
-}
-
-int32_t pa_hal_manager_get_volume_level_max (pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *level) {
+int32_t pa_hal_manager_get_volume_level_max(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *level) {
int32_t ret = 0;
audio_return_t hal_ret = AUDIO_RET_OK;
audio_volume_info_t info = {NULL, NULL, 0};
return ret;
}
-int32_t pa_hal_manager_get_volume_level (pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *level) {
+int32_t pa_hal_manager_get_volume_level(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *level) {
int32_t ret = 0;
audio_return_t hal_ret = AUDIO_RET_OK;
audio_volume_info_t info = {NULL, NULL, 0};
return ret;
}
-int32_t pa_hal_manager_set_volume_level (pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t level) {
+int32_t pa_hal_manager_set_volume_level(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t level) {
int32_t ret = 0;
audio_return_t hal_ret = AUDIO_RET_OK;
audio_volume_info_t info = {NULL, NULL, 0};
return ret;
}
-int32_t pa_hal_manager_get_volume_value (pa_hal_manager *h, const char *volume_type, const char *gain_type, io_direction_t direction, uint32_t level, double *value) {
+int32_t pa_hal_manager_get_volume_value(pa_hal_manager *h, const char *volume_type, const char *gain_type, io_direction_t direction, uint32_t level, double *value) {
int32_t ret = 0;
audio_return_t hal_ret = AUDIO_RET_OK;
audio_volume_info_t info = {NULL, NULL, 0};
return ret;
}
-int32_t pa_hal_manager_get_mute (pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *mute) {
+int32_t pa_hal_manager_get_mute(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *mute) {
int32_t ret = 0;
audio_return_t hal_ret = AUDIO_RET_OK;
audio_volume_info_t info = {NULL, NULL, 0};
return ret;
}
-int32_t pa_hal_manager_set_mute (pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t mute) {
+int32_t pa_hal_manager_set_mute(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t mute) {
int32_t ret = 0;
audio_return_t hal_ret = AUDIO_RET_OK;
audio_volume_info_t info = {NULL, NULL, 0};
return ret;
}
-int32_t pa_hal_manager_do_route (pa_hal_manager *h, hal_route_info *info) {
+int32_t pa_hal_manager_do_route(pa_hal_manager *h, hal_route_info *info) {
int32_t ret = 0;
audio_return_t hal_ret = AUDIO_RET_OK;
return ret;
}
-int32_t pa_hal_manager_update_route_option (pa_hal_manager *h, hal_route_option *option) {
+int32_t pa_hal_manager_update_route_option(pa_hal_manager *h, hal_route_option *option) {
int32_t ret = 0;
audio_return_t hal_ret = AUDIO_RET_OK;
return ret;
}
-int32_t pa_hal_manager_update_stream_connection_info (pa_hal_manager *h, hal_stream_connection_info *info) {
+int32_t pa_hal_manager_update_stream_connection_info(pa_hal_manager *h, hal_stream_connection_info *info) {
int32_t ret = 0;
audio_return_t hal_ret = AUDIO_RET_OK;
audio_stream_info_t hal_info;
}
return ret;
}
+
+int32_t pa_hal_manager_get_buffer_attribute(pa_hal_manager *h, hal_stream_info *info,
+ uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize) {
+ int32_t ret = 0;
+ audio_return_t hal_ret = AUDIO_RET_OK;
+
+ pa_assert(h);
+ pa_assert(info);
+
+ pa_log_info("latency:%s, rate:%u, format:%d, channels:%u",
+ info->latency, info->sample_spec->rate, info->sample_spec->format, info->sample_spec->channels);
+
+ if (AUDIO_IS_ERROR(hal_ret = h->intf.get_buffer_attr(h->data, info->direction, info->latency, info->sample_spec->rate, info->sample_spec->format,
+ info->sample_spec->channels, maxlength, tlength, prebuf, minreq, fragsize))) {
+ pa_log_error("get_buffer_attr returns error:0x%x", hal_ret);
+ ret = -1;
+ } else
+ pa_log_info("maxlength:%d, tlength:%d, prebuf:%d, minreq:%d, fragsize:%d", *maxlength, *tlength, *prebuf, *minreq, *fragsize);
+
+ return ret;
+}
+
+int32_t pa_hal_manager_pcm_open(pa_hal_manager *h, pcm_handle *pcm_h, io_direction_t direction, pa_sample_spec *sample_spec) {
+ int32_t ret = 0;
+ audio_return_t hal_ret = AUDIO_RET_OK;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+ pa_assert(sample_spec);
+
+ if (AUDIO_IS_ERROR(hal_ret = h->intf.pcm_open(h->data, pcm_h, sample_spec, direction))) {
+ pa_log_error("pcm_open returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+int32_t pa_hal_manager_pcm_start(pa_hal_manager *h, pcm_handle pcm_h) {
+ int32_t ret = 0;
+ audio_return_t hal_ret = AUDIO_RET_OK;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+
+ if (AUDIO_IS_ERROR(hal_ret = h->intf.pcm_start(h->data, pcm_h))) {
+ pa_log_error("pcm_start returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+int32_t pa_hal_manager_pcm_stop(pa_hal_manager *h, pcm_handle pcm_h) {
+ int32_t ret = 0;
+ audio_return_t hal_ret = AUDIO_RET_OK;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+
+ if (AUDIO_IS_ERROR(hal_ret = h->intf.pcm_stop(h->data, pcm_h))) {
+ pa_log_error("pcm_stop returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+int32_t pa_hal_manager_pcm_close(pa_hal_manager *h, pcm_handle pcm_h) {
+ int32_t ret = 0;
+ audio_return_t hal_ret = AUDIO_RET_OK;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+
+ if (AUDIO_IS_ERROR(hal_ret = h->intf.pcm_close(h->data, pcm_h))) {
+ pa_log_error("pcm_close returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+int32_t pa_hal_manager_pcm_available(pa_hal_manager *h, pcm_handle pcm_h, uint32_t *available) {
+ int32_t ret = 0;
+ audio_return_t hal_ret = AUDIO_RET_OK;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+ pa_assert(available);
+
+ if (AUDIO_IS_ERROR(hal_ret = h->intf.pcm_avail(h->data, pcm_h, available))) {
+ pa_log_error("pcm_avail returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+int32_t pa_hal_manager_pcm_write(pa_hal_manager *h, pcm_handle pcm_h, const void *buffer, uint32_t frames) {
+ int32_t ret = 0;
+ audio_return_t hal_ret = AUDIO_RET_OK;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+ pa_assert(buffer);
+
+ if (AUDIO_IS_ERROR(hal_ret = h->intf.pcm_write(h->data, pcm_h, buffer, frames))) {
+ pa_log_error("pcm_write returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
+
+int32_t pa_hal_manager_pcm_read(pa_hal_manager *h, pcm_handle pcm_h, void *buffer, uint32_t frames) {
+ int32_t ret = 0;
+ audio_return_t hal_ret = AUDIO_RET_OK;
+
+ pa_assert(h);
+ pa_assert(pcm_h);
+ pa_assert(buffer);
+
+ if (AUDIO_IS_ERROR(hal_ret = h->intf.pcm_read(h->data, pcm_h, buffer, frames))) {
+ pa_log_error("pcm_read returns error:0x%x", hal_ret);
+ ret = -1;
+ }
+ return ret;
+}
pa_bool_t is_connected;
} hal_stream_connection_info;
+typedef struct _hal_stream_info {
+ io_direction_t direction;
+ const char *latency;
+ pa_sample_spec *sample_spec;
+} hal_stream_info;
+
+typedef void* pcm_handle;
+
pa_hal_manager* pa_hal_manager_get(pa_core *core, void *user_data);
pa_hal_manager* pa_hal_manager_ref(pa_hal_manager *h);
void pa_hal_manager_unref(pa_hal_manager *h);
-int32_t pa_hal_manager_get_buffer_attribute(pa_hal_manager *h, io_direction_t direction, const char *latency, void *new_data, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
-int32_t pa_hal_manager_get_volume_level_max (pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *level);
-int32_t pa_hal_manager_get_volume_level (pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *level);
-int32_t pa_hal_manager_set_volume_level (pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t level);
-int32_t pa_hal_manager_get_volume_value (pa_hal_manager *h, const char *volume_type, const char *gain_type, io_direction_t direction, uint32_t level, double *value);
-int32_t pa_hal_manager_get_mute (pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *mute);
-int32_t pa_hal_manager_set_mute (pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t mute);
-int32_t pa_hal_manager_do_route (pa_hal_manager *h, hal_route_info *info);
-int32_t pa_hal_manager_update_route_option (pa_hal_manager *h, hal_route_option *option);
-int32_t pa_hal_manager_update_stream_connection_info (pa_hal_manager *h, hal_stream_connection_info *info);
+int32_t pa_hal_manager_get_volume_level_max(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *level);
+int32_t pa_hal_manager_get_volume_level(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *level);
+int32_t pa_hal_manager_set_volume_level(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t level);
+int32_t pa_hal_manager_get_volume_value(pa_hal_manager *h, const char *volume_type, const char *gain_type, io_direction_t direction, uint32_t level, double *value);
+int32_t pa_hal_manager_get_mute(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t *mute);
+int32_t pa_hal_manager_set_mute(pa_hal_manager *h, const char *volume_type, io_direction_t direction, uint32_t mute);
+int32_t pa_hal_manager_do_route(pa_hal_manager *h, hal_route_info *info);
+int32_t pa_hal_manager_update_route_option(pa_hal_manager *h, hal_route_option *option);
+int32_t pa_hal_manager_update_stream_connection_info(pa_hal_manager *h, hal_stream_connection_info *info);
+int32_t pa_hal_manager_get_buffer_attribute(pa_hal_manager *h, hal_stream_info *info, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
+int32_t pa_hal_manager_pcm_open(pa_hal_manager *h, pcm_handle *pcm_h, io_direction_t direction, pa_sample_spec *sample_spec);
+int32_t pa_hal_manager_pcm_start(pa_hal_manager *h, pcm_handle pcm_h);
+int32_t pa_hal_manager_pcm_stop(pa_hal_manager *h, pcm_handle pcm_h);
+int32_t pa_hal_manager_pcm_close(pa_hal_manager *h, pcm_handle pcm_h);
+int32_t pa_hal_manager_pcm_available(pa_hal_manager *h, pcm_handle pcm_h, uint32_t *available);
+int32_t pa_hal_manager_pcm_write(pa_hal_manager *h, pcm_handle pcm_h, const void *buffer, uint32_t frames);
+int32_t pa_hal_manager_pcm_read(pa_hal_manager *h, pcm_handle pcm_h, void *buffer, uint32_t frames);
#endif
audio_return_t (*do_route)(void *userdata, audio_route_info_t *info);
audio_return_t (*update_route_option)(void *userdata, audio_route_option_t *option);
audio_return_t (*update_stream_connection_info) (void *userdata, audio_stream_info_t *info, uint32_t is_connected);
+ audio_return_t (*get_buffer_attr)(void *userdata, uint32_t direction, const char *latency, uint32_t samplerate, int format, uint32_t channels, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
+ /* Interface of PCM device */
audio_return_t (*alsa_pcm_open)(void *userdata, void **pcm_handle, char *device_name, uint32_t direction, int mode);
audio_return_t (*alsa_pcm_close)(void *userdata, void *pcm_handle);
-
- /* Interface of PCM device */
audio_return_t (*pcm_open)(void *userdata, void **pcm_handle, void *sample_spec, uint32_t direction);
audio_return_t (*pcm_start)(void *userdata, void *pcm_handle);
audio_return_t (*pcm_stop)(void *userdata, void *pcm_handle);
audio_return_t (*pcm_avail)(void *userdata, void *pcm_handle, uint32_t *avail);
audio_return_t (*pcm_write)(void *userdata, void *pcm_handle, const void *buffer, uint32_t frames);
audio_return_t (*pcm_read)(void *userdata, void *pcm_handle, void *buffer, uint32_t frames);
-
- audio_return_t (*get_buffer_attr)(void *userdata, uint32_t direction, const char *latency, uint32_t samplerate, int format, uint32_t channels, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
- audio_return_t (*set_route)(void *userdata, uint32_t session, uint32_t subsession, uint32_t device_in, uint32_t device_out, uint32_t route_flag);
} audio_interface_t;
audio_return_t audio_init (void **userdata, void *platform_data);
audio_return_t audio_do_route (void *userdata, audio_route_info_t *info);
audio_return_t audio_update_route_option (void *userdata, audio_route_option_t *option);
audio_return_t audio_update_stream_connection_info (void *userdata, audio_stream_info_t *info, uint32_t is_connected);
+audio_return_t audio_get_buffer_attr (void *userdata, uint32_t direction, const char *latency, uint32_t samplerate, int format, uint32_t channels, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
audio_return_t audio_alsa_pcm_open (void *userdata, void **pcm_handle, char *device_name, uint32_t direction, int mode);
audio_return_t audio_alsa_pcm_close (void *userdata, void *pcm_handle);
audio_return_t audio_pcm_open (void *userdata, void **pcm_handle, void *sample_spec, uint32_t direction);
audio_return_t audio_pcm_avail (void *userdata, void *pcm_handle, uint32_t *avail);
audio_return_t audio_pcm_write (void *userdata, void *pcm_handle, const void *buffer, uint32_t frames);
audio_return_t audio_pcm_read (void *userdata, void *pcm_handle, void *buffer, uint32_t frames);
-audio_return_t audio_get_buffer_attr (void *userdata, uint32_t direction, const char *latency, uint32_t samplerate, int format, uint32_t channels, uint32_t *maxlength, uint32_t *tlength, uint32_t *prebuf, uint32_t* minreq, uint32_t *fragsize);
-audio_return_t audio_set_route (void *userdata, uint32_t session, uint32_t subsession, uint32_t device_in, uint32_t device_out, uint32_t route_flag);
#endif