Changeset 984a9ba in mainline for uspace/lib/drv/generic/remote_audio_pcm.c
- Timestamp:
- 2018-07-05T09:34:09Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63d46341
- Parents:
- 76f566d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_audio_pcm.c
r76f566d r984a9ba 600 600 * SERVER SIDE 601 601 */ 602 static void remote_audio_pcm_get_info_str(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);603 static void remote_audio_pcm_query_caps(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);604 static void remote_audio_pcm_events_register(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);605 static void remote_audio_pcm_events_unregister(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);606 static void remote_audio_pcm_get_buffer_pos(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);607 static void remote_audio_pcm_test_format(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);608 static void remote_audio_pcm_get_buffer(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);609 static void remote_audio_pcm_release_buffer(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);610 static void remote_audio_pcm_start_playback(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);611 static void remote_audio_pcm_stop_playback(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);612 static void remote_audio_pcm_start_capture(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);613 static void remote_audio_pcm_stop_capture(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);602 static void remote_audio_pcm_get_info_str(ddf_fun_t *, void *, ipc_call_t *); 603 static void remote_audio_pcm_query_caps(ddf_fun_t *, void *, ipc_call_t *); 604 static void remote_audio_pcm_events_register(ddf_fun_t *, void *, ipc_call_t *); 605 static void remote_audio_pcm_events_unregister(ddf_fun_t *, void *, ipc_call_t *); 606 static void remote_audio_pcm_get_buffer_pos(ddf_fun_t *, void *, ipc_call_t *); 607 static void remote_audio_pcm_test_format(ddf_fun_t *, void *, ipc_call_t *); 608 static void remote_audio_pcm_get_buffer(ddf_fun_t *, void *, ipc_call_t *); 609 static void remote_audio_pcm_release_buffer(ddf_fun_t *, void *, ipc_call_t *); 610 static void remote_audio_pcm_start_playback(ddf_fun_t *, void *, ipc_call_t *); 611 static void remote_audio_pcm_stop_playback(ddf_fun_t *, void *, ipc_call_t *); 612 static void remote_audio_pcm_start_capture(ddf_fun_t *, void *, ipc_call_t *); 613 static void remote_audio_pcm_stop_capture(ddf_fun_t *, void *, ipc_call_t *); 614 614 615 615 /** Remote audio pcm buffer interface operations. */ … … 636 636 637 637 void remote_audio_pcm_get_info_str(ddf_fun_t *fun, void *iface, 638 cap_call_handle_t chandle,ipc_call_t *call)638 ipc_call_t *call) 639 639 { 640 640 const audio_pcm_iface_t *pcm_iface = iface; 641 641 642 642 if (!pcm_iface->get_info_str) { 643 async_answer_0(chandle, ENOTSUP); 644 return; 645 } 643 async_answer_0(call, ENOTSUP); 644 return; 645 } 646 646 647 const char *name = NULL; 647 648 const errno_t ret = pcm_iface->get_info_str(fun, &name); 648 649 const size_t name_size = name ? str_size(name) + 1 : 0; 649 async_answer_1(chandle, ret, name_size); 650 async_answer_1(call, ret, name_size); 651 650 652 /* Send the string. */ 651 653 if (ret == EOK && name_size > 0) { 654 ipc_call_t call; 652 655 size_t size; 653 cap_call_handle_t name_id; 654 if (!async_data_read_receive(&name_id, &size)) { 655 async_answer_0(name_id, EPARTY); 656 if (!async_data_read_receive(&call, &size)) { 657 async_answer_0(&call, EPARTY); 656 658 return; 657 659 } 660 658 661 if (size != name_size) { 659 async_answer_0( name_id, ELIMIT);662 async_answer_0(&call, ELIMIT); 660 663 return; 661 664 } 662 async_data_read_finalize(name_id, name, name_size); 665 666 async_data_read_finalize(&call, name, name_size); 663 667 } 664 668 } 665 669 666 670 void remote_audio_pcm_query_caps(ddf_fun_t *fun, void *iface, 667 cap_call_handle_t chandle,ipc_call_t *call)671 ipc_call_t *call) 668 672 { 669 673 const audio_pcm_iface_t *pcm_iface = iface; … … 671 675 if (pcm_iface->query_cap) { 672 676 const unsigned value = pcm_iface->query_cap(fun, cap); 673 async_answer_1(c handle, EOK, value);677 async_answer_1(call, EOK, value); 674 678 } else { 675 async_answer_0(c handle, ENOTSUP);679 async_answer_0(call, ENOTSUP); 676 680 } 677 681 } 678 682 679 683 static void remote_audio_pcm_events_register(ddf_fun_t *fun, void *iface, 680 cap_call_handle_t chandle,ipc_call_t *call)684 ipc_call_t *call) 681 685 { 682 686 const audio_pcm_iface_t *pcm_iface = iface; 683 687 if (!pcm_iface->get_event_session || 684 688 !pcm_iface->set_event_session) { 685 async_answer_0(c handle, ENOTSUP);686 return; 687 } 688 689 async_answer_0(c handle, EOK);689 async_answer_0(call, ENOTSUP); 690 return; 691 } 692 693 async_answer_0(call, EOK); 690 694 691 695 ipc_call_t callback_call; 692 cap_call_handle_t callback_handle =async_get_call(&callback_call);696 async_get_call(&callback_call); 693 697 async_sess_t *sess = 694 698 async_callback_receive_start(EXCHANGE_ATOMIC, &callback_call); 695 699 if (sess == NULL) { 696 700 ddf_msg(LVL_DEBUG, "Failed to create event callback"); 697 async_answer_0(callback_handle, EAGAIN); 698 return; 699 } 701 async_answer_0(&callback_call, EAGAIN); 702 return; 703 } 704 700 705 const errno_t ret = pcm_iface->set_event_session(fun, sess); 701 706 if (ret != EOK) { 702 707 ddf_msg(LVL_DEBUG, "Failed to set event callback."); 703 708 async_hangup(sess); 704 async_answer_0(callback_handle, ret); 705 return; 706 } 707 async_answer_0(callback_handle, EOK); 709 async_answer_0(&callback_call, ret); 710 return; 711 } 712 713 async_answer_0(&callback_call, EOK); 708 714 } 709 715 710 716 static void remote_audio_pcm_events_unregister(ddf_fun_t *fun, void *iface, 711 cap_call_handle_t chandle,ipc_call_t *call)717 ipc_call_t *call) 712 718 { 713 719 const audio_pcm_iface_t *pcm_iface = iface; 714 720 if (!pcm_iface->get_event_session || 715 721 !pcm_iface->set_event_session) { 716 async_answer_0(chandle, ENOTSUP); 717 return; 718 } 722 async_answer_0(call, ENOTSUP); 723 return; 724 } 725 719 726 async_sess_t *sess = pcm_iface->get_event_session(fun); 720 727 if (sess) { … … 722 729 pcm_iface->set_event_session(fun, NULL); 723 730 } 724 async_answer_0(chandle, EOK); 731 732 async_answer_0(call, EOK); 725 733 } 726 734 727 735 void remote_audio_pcm_get_buffer_pos(ddf_fun_t *fun, void *iface, 728 cap_call_handle_t chandle,ipc_call_t *call)736 ipc_call_t *call) 729 737 { 730 738 const audio_pcm_iface_t *pcm_iface = iface; … … 732 740 const errno_t ret = pcm_iface->get_buffer_pos ? 733 741 pcm_iface->get_buffer_pos(fun, &pos) : ENOTSUP; 734 async_answer_1(c handle, ret, pos);742 async_answer_1(call, ret, pos); 735 743 } 736 744 737 745 void remote_audio_pcm_test_format(ddf_fun_t *fun, void *iface, 738 cap_call_handle_t chandle,ipc_call_t *call)746 ipc_call_t *call) 739 747 { 740 748 const audio_pcm_iface_t *pcm_iface = iface; … … 744 752 const errno_t ret = pcm_iface->test_format ? 745 753 pcm_iface->test_format(fun, &channels, &rate, &format) : ENOTSUP; 746 async_answer_3(c handle, ret, channels, rate, format);754 async_answer_3(call, ret, channels, rate, format); 747 755 } 748 756 749 757 void remote_audio_pcm_get_buffer(ddf_fun_t *fun, void *iface, 750 cap_call_handle_t chandle,ipc_call_t *call)758 ipc_call_t *call) 751 759 { 752 760 const audio_pcm_iface_t *pcm_iface = iface; … … 754 762 if (!pcm_iface->get_buffer || 755 763 !pcm_iface->release_buffer) { 756 async_answer_0(c handle, ENOTSUP);764 async_answer_0(call, ENOTSUP); 757 765 return; 758 766 } … … 760 768 size_t size = DEV_IPC_GET_ARG1(*call); 761 769 errno_t ret = pcm_iface->get_buffer(fun, &buffer, &size); 762 async_answer_1(c handle, ret, size);770 async_answer_1(call, ret, size); 763 771 if (ret != EOK || size == 0) 764 772 return; 765 773 766 774 /* Share the buffer. */ 775 ipc_call_t share; 767 776 size_t share_size = 0; 768 cap_call_handle_t share_id = 0;769 777 770 778 ddf_msg(LVL_DEBUG2, "Receiving share request."); 771 if (!async_share_in_receive(&share _id, &share_size)) {779 if (!async_share_in_receive(&share, &share_size)) { 772 780 ddf_msg(LVL_DEBUG, "Failed to share pcm buffer."); 773 781 pcm_iface->release_buffer(fun); 774 async_answer_0( share_id, EPARTY);782 async_answer_0(&share, EPARTY); 775 783 return; 776 784 } … … 780 788 ddf_msg(LVL_DEBUG, "Incorrect pcm buffer size requested."); 781 789 pcm_iface->release_buffer(fun); 782 async_answer_0( share_id, ELIMIT);790 async_answer_0(&share, ELIMIT); 783 791 return; 784 792 } 785 793 786 794 ddf_msg(LVL_DEBUG2, "Calling share finalize."); 787 ret = async_share_in_finalize( share_id, buffer, AS_AREA_WRITE |795 ret = async_share_in_finalize(&share, buffer, AS_AREA_WRITE | 788 796 AS_AREA_READ); 789 797 if (ret != EOK) { … … 797 805 798 806 void remote_audio_pcm_release_buffer(ddf_fun_t *fun, void *iface, 799 cap_call_handle_t chandle,ipc_call_t *call)807 ipc_call_t *call) 800 808 { 801 809 const audio_pcm_iface_t *pcm_iface = iface; … … 803 811 const errno_t ret = pcm_iface->release_buffer ? 804 812 pcm_iface->release_buffer(fun) : ENOTSUP; 805 async_answer_0(c handle, ret);813 async_answer_0(call, ret); 806 814 } 807 815 808 816 void remote_audio_pcm_start_playback(ddf_fun_t *fun, void *iface, 809 cap_call_handle_t chandle,ipc_call_t *call)817 ipc_call_t *call) 810 818 { 811 819 const audio_pcm_iface_t *pcm_iface = iface; … … 819 827 pcm_iface->start_playback(fun, frames, channels, rate, format) : 820 828 ENOTSUP; 821 async_answer_0(c handle, ret);829 async_answer_0(call, ret); 822 830 } 823 831 824 832 void remote_audio_pcm_stop_playback(ddf_fun_t *fun, void *iface, 825 cap_call_handle_t chandle,ipc_call_t *call)833 ipc_call_t *call) 826 834 { 827 835 const audio_pcm_iface_t *pcm_iface = iface; … … 830 838 const errno_t ret = pcm_iface->stop_playback ? 831 839 pcm_iface->stop_playback(fun, immediate) : ENOTSUP; 832 async_answer_0(c handle, ret);840 async_answer_0(call, ret); 833 841 } 834 842 835 843 void remote_audio_pcm_start_capture(ddf_fun_t *fun, void *iface, 836 cap_call_handle_t chandle,ipc_call_t *call)844 ipc_call_t *call) 837 845 { 838 846 const audio_pcm_iface_t *pcm_iface = iface; … … 846 854 pcm_iface->start_capture(fun, frames, channels, rate, format) : 847 855 ENOTSUP; 848 async_answer_0(c handle, ret);856 async_answer_0(call, ret); 849 857 } 850 858 851 859 void remote_audio_pcm_stop_capture(ddf_fun_t *fun, void *iface, 852 cap_call_handle_t chandle,ipc_call_t *call)860 ipc_call_t *call) 853 861 { 854 862 const audio_pcm_iface_t *pcm_iface = iface; … … 857 865 const errno_t ret = pcm_iface->stop_capture ? 858 866 pcm_iface->stop_capture(fun, immediate) : ENOTSUP; 859 async_answer_0(c handle, ret);867 async_answer_0(call, ret); 860 868 } 861 869 … … 863 871 * @} 864 872 */ 865
Note:
See TracChangeset
for help on using the changeset viewer.