Changeset 3261:6c96218934f2 in roaraudio for libroaross/libroaross.c
- Timestamp:
- 01/30/10 21:14:30 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroaross/libroaross.c
r3248 r3261 34 34 35 35 #include "roaraudio.h" 36 #include "libroarlight/libroarlight.h" 36 37 37 38 #if defined(ROAR_HAVE_OSS_BSD) || defined(ROAR_HAVE_OSS) … … 460 461 handle->stream.info.codec = ROAR_CODEC_MIDI; 461 462 break; 463 case HT_DMX: 464 handle->stream.info.rate = 0; 465 handle->stream.info.bits = ROAR_LIGHT_BITS; 466 handle->stream.info.channels = 512; 467 handle->stream.info.codec = ROAR_CODEC_ROARDMX; 468 break; 462 469 } 463 470 … … 792 799 _init(); 793 800 801 if ( pathname == NULL ) { 802 errno = EFAULT; 803 return -1; 804 } 805 806 ROAR_DBG("open(pathname='%s', flags=%x, ...) = ?\n", pathname, flags); 794 807 ret = _open_file(pathname, flags); 795 808 … … 827 840 828 841 ssize_t write(int fd, const void *buf, size_t count) { 842 struct roar_roardmx_message roardmxmsg; 829 843 struct pointer * pointer; 830 844 ssize_t ret; 845 int i; 831 846 832 847 _init(); 833 848 834 849 if ( (pointer = _get_pointer_by_fh(fd)) != NULL ) { 835 if ( pointer->handle->type == HT_STREAM ) { 836 if ( pointer->handle->stream_opened == 0 ) { 837 if ( _open_stream(pointer->handle) == -1 ) { 838 errno = EIO; 850 switch (pointer->handle->type) { 851 case HT_STREAM: 852 if ( pointer->handle->stream_opened == 0 ) { 853 if ( _open_stream(pointer->handle) == -1 ) { 854 errno = EIO; 855 return -1; 856 } 857 } 858 ret = roar_vio_write(&(pointer->handle->stream_vio), (char*)buf, count); 859 if ( ret > 0 ) 860 pointer->handle->writec += ret; 861 return ret; 862 break; 863 case HT_DMX: 864 if ( pointer->handle->stream_opened == 0 ) { 865 if ( _open_stream(pointer->handle) == -1 ) { 866 errno = EIO; 867 return -1; 868 } 869 } 870 if ( count > 0 ) { 871 if ( roar_roardmx_message_new_sset(&roardmxmsg) == -1 ) { 872 errno = EIO; 873 return -1; 874 } 875 for (i = 0; i < count; i++) { 876 if ( roar_roardmx_message_add_chanval(&roardmxmsg, pointer->handle->pos + i, ((unsigned char*)buf)[i]) == -1 ) { 877 #ifdef EMSGSIZE 878 errno = EMSGSIZE; 879 #else 880 errno = EIO; 881 #endif 882 return -1; 883 } 884 } 885 if ( roar_roardmx_message_send(&roardmxmsg, &(pointer->handle->stream_vio)) == -1 ) { 886 errno = EIO; 887 return -1; 888 } 889 } 890 pointer->handle->pos += count; 891 return count; 892 break; 893 default: 894 errno = EINVAL; 839 895 return -1; 840 } 841 } 842 ret = roar_vio_write(&(pointer->handle->stream_vio), (char*)buf, count); 843 if ( ret > 0 ) 844 pointer->handle->writec += ret; 845 return ret; 846 } else { 847 errno = EINVAL; 848 return -1; 896 break; 849 897 } 850 898 }
Note: See TracChangeset
for help on using the changeset viewer.