Changeset 3261:6c96218934f2 in roaraudio


Ignore:
Timestamp:
01/30/10 21:14:30 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

write-only DMX4Linux support

Location:
libroaross
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libroaross/Makefile

    r3181 r3261  
    1111CFLAGS += -g -Wall -O2 $(DEFINES) $(INCLUDE) $(INCPATH) $(SHARED_CF) $(fPIC) 
    1212LDFLAGS = -g $(SHARED) $(LDPATH) -L../lib 
    13 LIBS    = $(LIBROAR) $(lib_dl) 
     13LIBS    = $(LIBROAR) $(LIBROARLIGHT) $(lib_dl) 
    1414 
    1515all: ${TARGETS} 
  • libroaross/libroaross.c

    r3248 r3261  
    3434 
    3535#include "roaraudio.h" 
     36#include "libroarlight/libroarlight.h" 
    3637 
    3738#if defined(ROAR_HAVE_OSS_BSD) || defined(ROAR_HAVE_OSS) 
     
    460461    handle->stream.info.codec    = ROAR_CODEC_MIDI; 
    461462   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; 
    462469 } 
    463470 
     
    792799 _init(); 
    793800 
     801 if ( pathname == NULL ) { 
     802  errno = EFAULT; 
     803  return -1; 
     804 } 
     805 
     806 ROAR_DBG("open(pathname='%s', flags=%x, ...) = ?\n", pathname, flags); 
    794807 ret = _open_file(pathname, flags); 
    795808 
     
    827840 
    828841ssize_t write(int fd, const void *buf, size_t count) { 
     842 struct roar_roardmx_message roardmxmsg; 
    829843 struct pointer * pointer; 
    830844 ssize_t ret; 
     845 int i; 
    831846 
    832847 _init(); 
    833848 
    834849 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; 
    839895     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; 
    849897  } 
    850898 } 
Note: See TracChangeset for help on using the changeset viewer.