add additional device query functions 16/282616/3
authorSeungbae Shin <seungbae.shin@samsung.com>
Thu, 6 Oct 2022 11:41:20 +0000 (20:41 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Wed, 12 Oct 2022 02:50:43 +0000 (11:50 +0900)
[Version] 0.13.20
[Issue Type] Feature

Change-Id: I4f5982ebaa0840ebd426b4eb0b506f85e59422b5

include/mm_sound.h
include/mm_sound_device.h
mm_sound_device.c
mm_sound_proxy.c
packaging/libmm-sound.spec

index 1732042..e6d3105 100644 (file)
@@ -586,6 +586,10 @@ int mm_sound_get_device_name(MMSoundDevice_t device_h, char **name);
 int mm_sound_get_device_vendor_id(MMSoundDevice_t device_h, int *vendor_id);
 int mm_sound_get_device_product_id(MMSoundDevice_t device_h, int *product_id);
 
+int mm_sound_get_device_sample_format(MMSoundDevice_t device_h, int *format);
+int mm_sound_get_device_sample_rate(MMSoundDevice_t device_h, int *samplerate);
+int mm_sound_get_device_channels(MMSoundDevice_t device_h, int *channels);
+
 /* Ducking */
 typedef void (*mm_sound_ducking_state_changed_cb) (int idx, bool is_ducked, void *user_data);
 int mm_sound_add_ducking_state_changed_callback(mm_sound_ducking_state_changed_cb func, void *user_data, unsigned int *subs_id);
index 58ce2b1..0f7f9de 100644 (file)
@@ -57,6 +57,10 @@ typedef struct {
        int product_id;
 
        bool is_running;
+
+       int format;
+       int samplerate;
+       int channels;
 } mm_sound_device_t;
 
 typedef struct {
index ad2fa62..ff4d554 100644 (file)
@@ -495,6 +495,48 @@ int mm_sound_get_device_product_id(MMSoundDevice_t device_h, int *product_id)
 }
 
 EXPORT_API
+int mm_sound_get_device_sample_format(MMSoundDevice_t device_h, int *format)
+{
+       mm_sound_device_t *device = (mm_sound_device_t*)device_h;
+       if (!device) {
+               debug_error("invalid handle");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+       *format = device->format;
+       debug_log("device_handle:%p, format:%d", device, *format);
+
+       return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_get_device_sample_rate(MMSoundDevice_t device_h, int *samplerate)
+{
+       mm_sound_device_t *device = (mm_sound_device_t*)device_h;
+       if (!device) {
+               debug_error("invalid handle");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+       *samplerate = device->samplerate;
+       debug_log("device_handle:%p, samplerate:%d", device, *samplerate);
+
+       return MM_ERROR_NONE;
+}
+
+EXPORT_API
+int mm_sound_get_device_channels(MMSoundDevice_t device_h, int *channels)
+{
+       mm_sound_device_t *device = (mm_sound_device_t*)device_h;
+       if (!device) {
+               debug_error("invalid handle");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+       *channels = device->channels;
+       debug_log("device_handle:%p, channels:%d", device, *channels);
+
+       return MM_ERROR_NONE;
+}
+
+EXPORT_API
 int mm_sound_is_stream_on_device(int stream_id, MMSoundDevice_t device_h, bool *is_on)
 {
        int ret = MM_ERROR_NONE;
index e2e39a6..2e2b48d 100644 (file)
@@ -387,15 +387,18 @@ int mm_sound_proxy_get_current_connected_device_list(int device_flags, GList** d
        g_variant_iter_init(&iter, child);
        while (1) {
                device_item = g_malloc0(sizeof(mm_sound_device_t));
-               if (device_item && g_variant_iter_loop(&iter, "(i&sii&siib)",
+               if (device_item && g_variant_iter_loop(&iter, "(i&sii&siibiii)",
                                        &device_item->id, &device_type_tmp, &device_item->io_direction, &device_item->state,
-                                       &device_name_tmp, &device_item->vendor_id, &device_item->product_id, &device_item->is_running)) {
+                                       &device_name_tmp, &device_item->vendor_id, &device_item->product_id, &device_item->is_running,
+                                       &device_item->format, &device_item->samplerate, &device_item->channels)) {
                        MMSOUND_STRNCPY(device_item->name, device_name_tmp, MAX_DEVICE_NAME_NUM);
                        MMSOUND_STRNCPY(device_item->type, device_type_tmp, MAX_DEVICE_TYPE_STR_LEN);
                        *device_list = g_list_append(*device_list, device_item);
-                       debug_log("Added device id(%d) type(%17s) direction(%d) state(%d) name(%s) vendor-id(%04x) product-id(%04x) is_running(%d)",
+                       debug_log("Added device id(%d) type(%17s) direction(%d) state(%d) name(%s) vendor-id(%04x) "\
+                                       "product-id(%04x) is_running(%d) format(%d), samplerate(%d), channels(%d)",
                                        device_item->id, device_item->type, device_item->io_direction, device_item->state,
-                                       device_item->name, device_item->vendor_id, device_item->product_id, device_item->is_running);
+                                       device_item->name, device_item->vendor_id, device_item->product_id, device_item->is_running,
+                                       device_item->format, device_item->samplerate, device_item->channels);
                        device_item->stream_num = -1;
                } else {
                        g_free(device_item);
index 0f20aa0..19a30b9 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and focus server binary
-Version:    0.13.19
+Version:    0.13.20
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0