Ticket #428: protocol-esound.c.diff
| File protocol-esound.c.diff, 3.8 KB (added by EDevriendt, 3 years ago) |
|---|
-
protocol-esound.c
old new 165 165 static int esd_proto_server_info(connection *c, esd_proto_t request, const void *data, size_t length); 166 166 static int esd_proto_all_info(connection *c, esd_proto_t request, const void *data, size_t length); 167 167 static int esd_proto_stream_pan(connection *c, esd_proto_t request, const void *data, size_t length); 168 static int esd_proto_sample_pan(connection *c, esd_proto_t request, const void *data, size_t length); 168 169 static int esd_proto_sample_cache(connection *c, esd_proto_t request, const void *data, size_t length); 169 170 static int esd_proto_sample_free_or_play(connection *c, esd_proto_t request, const void *data, size_t length); 170 171 static int esd_proto_sample_get_id(connection *c, esd_proto_t request, const void *data, size_t length); … … 199 200 { -1, NULL, "TODO: unsubscribe" }, 200 201 201 202 { 3 * sizeof(int), esd_proto_stream_pan, "stream pan"}, 202 { 3 * sizeof(int), NULL, "sample pan" },203 { 3 * sizeof(int), esd_proto_sample_pan, "sample pan" }, 203 204 204 205 { sizeof(int), NULL, "standby mode" }, 205 206 { 0, esd_proto_get_latency, "get latency" } … … 673 674 for (ce = pa_idxset_first(c->protocol->core->scache, &idx); ce; ce = pa_idxset_next(c->protocol->core->scache, &idx)) { 674 675 int32_t id, rate, lvolume, rvolume, format, len; 675 676 char name[ESD_NAME_MAX]; 677 uint8_t rchan; 676 678 677 679 pa_assert(t >= s*2); 678 680 … … 697 699 connection_write(c, &lvolume, sizeof(int32_t)); 698 700 699 701 /*right*/ 700 rvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, (ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM); 702 if(ce->volume.channels == 1) { 703 /* mono */ 704 rchan = 0; /* same as left */ 705 } else { 706 rchan = 1; 707 } 708 rvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, (ce->volume.values[rchan]*ESD_VOLUME_BASE)/PA_VOLUME_NORM); 701 709 connection_write(c, &rvolume, sizeof(int32_t)); 702 710 703 711 /*format*/ … … 755 763 return 0; 756 764 } 757 765 766 static int esd_proto_sample_pan(connection *c, PA_GCC_UNUSED esd_proto_t request, const void *data, size_t length) { 767 int32_t ok = 0; 768 uint32_t idx, lvolume, rvolume; 769 pa_cvolume volume; 770 pa_scache_entry *ce; 771 772 connection_assert_ref(c); 773 pa_assert(data); 774 pa_assert(length == sizeof(int32_t)*3); 775 776 memcpy(&idx, data, sizeof(uint32_t)); 777 idx = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, idx) - 1; 778 data = (const char*)data + sizeof(uint32_t); 779 780 memcpy(&lvolume, data, sizeof(uint32_t)); 781 lvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, lvolume); 782 data = (const char*)data + sizeof(uint32_t); 783 784 memcpy(&rvolume, data, sizeof(uint32_t)); 785 rvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, rvolume); 786 data = (const char*)data + sizeof(uint32_t); 787 788 volume.values[0] = (lvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; 789 volume.values[1] = (rvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; 790 volume.channels = 2; 791 792 ok = 0; 793 794 if(c->protocol->core->scache) { 795 if(ce = pa_idxset_get_by_index(c->protocol->core->scache, idx)) { 796 if(volume.channels > ce->volume.channels) /* sample is mono */ 797 volume.channels = ce->volume.channels; 798 ce->volume = volume; 799 } 800 ok = 1; 801 } 802 803 connection_write(c, &ok, sizeof(int32_t)); 804 805 return 0; 806 } 807 758 808 static int esd_proto_sample_cache(connection *c, PA_GCC_UNUSED esd_proto_t request, const void *data, size_t length) { 759 809 pa_sample_spec ss; 760 810 int32_t format, rate, sc_length;
