Changeset 457:60f64b109d75 in roaraudio for plugins/xmms


Ignore:
Timestamp:
08/12/08 05:52:22 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

some non working pthread based meta data update code

Location:
plugins/xmms
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • plugins/xmms/Makefile

    r456 r457  
    1010INSTALL_DIR=`xmms-config --output-plugin-dir` 
    1111 
    12 DEFINES=-DDEBUG 
     12#DEFINES=-DDEBUG 
    1313CFLAGS  = -g -Wall -O2 $(DEFINES) $(INCLUDE) -fPIC $(GTK_CFLAFS) $(XMMS_CFLAGS) 
    1414LDFLAGS = -g -shared -lroar $(GTK_LIBS) $(XMMS_LIBS) 
  • plugins/xmms/roar.c

    r456 r457  
    77#include <stdio.h> 
    88#include <string.h> 
     9#include <pthread.h> 
    910 
    1011#include "xmms/plugin.h" 
     
    5455        roar_close, 
    5556        NULL, //roar_flush, 
    56         NULL, //roar_pause, 
     57        roar_pause, 
    5758        roar_free, 
    5859        roar_playing, 
     
    7475 int session; 
    7576 int next_test; 
     77 int pause; 
     78 int updateing; 
    7679} g_inst; 
    7780 
     
    8386 g_inst.state = 0; 
    8487 g_inst.server = NULL; 
     88 g_inst.updateing = 0; 
    8589 g_inst.session = ctrlsocket_get_session_id(); 
    8690 ROAR_DBG("roar_init(*) = (void)"); 
     
    9397void roar_write(void *ptr, int length) { 
    9498 int r; 
     99 int need_update = 0; 
     100 pthread_t thread; 
     101 
     102 if ( g_inst.next_test < 1 ) { 
     103  need_update = 1; 
     104  g_inst.next_test = g_inst.bps; 
     105  pthread_create(&thread, NULL, (void (*)(void*))roar_chk_metadata, NULL); 
     106  //roar_socket_nonblock(g_inst.data_fh, ROAR_SOCKET_NONBLOCK); 
     107 } 
     108 
     109 if ( g_inst.pause ) 
     110  return; 
    95111 
    96112 while (length) { 
    97   if ( (r = write(g_inst.data_fh, ptr, length >= 1764 ? 1764 : length)) != -1 ) { 
     113  if ( (r = write(g_inst.data_fh, ptr, length >= 17640 ? 17640 : length)) != -1 ) { 
    98114   g_inst.written   += r; 
    99115   ptr              += r; 
     
    101117   g_inst.next_test -= r; 
    102118  } else { 
    103    return; 
     119   if ( errno == EAGAIN ) { 
     120    roar_socket_nonblock(g_inst.data_fh, ROAR_SOCKET_BLOCK); 
     121   } else { 
     122    return; 
     123   } 
    104124  } 
    105125 } 
    106126 
    107127 
    108  if ( g_inst.next_test < 1 ) { 
    109   roar_chk_metadata(); 
    110   g_inst.next_test = g_inst.bps; 
     128 if ( need_update ) { 
     129  //roar_socket_nonblock(g_inst.data_fh, ROAR_SOCKET_BLOCK); 
     130  pthread_join(thread, NULL); 
    111131 } 
    112132} 
     
    169189 
    170190 g_inst.written = 0; 
     191 g_inst.pause   = 0; 
    171192 
    172193 roar_update_metadata(); 
     
    182203} 
    183204 
    184 void roar_pause(short p); 
     205void roar_pause(short p) { 
     206 g_inst.pause = p; 
     207} 
    185208 
    186209int roar_free(void) { 
     
    236259 int pos; 
    237260 
     261 g_inst.updateing++; 
     262 
     263 if ( g_inst.updateing > 1 ) { 
     264  g_inst.updateing--; 
     265  return -1; 
     266 } 
     267 
    238268 pos     = xmms_remote_get_playlist_pos(g_inst.session); 
    239269 
     
    269299 } 
    270300 
     301 g_inst.updateing--; 
    271302 return 0; 
    272303} 
Note: See TracChangeset for help on using the changeset viewer.