Changeset 5157:065c4c7f1be2 in roaraudio
- Timestamp:
- 10/16/11 09:11:27 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- plugins
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/alsa/pcm_roar.c
r5156 r5157 77 77 self->bufptr = 0; 78 78 self->thread_active = 1; // We have to activate the thread before starting it, because the thread lives on that thread_active is 1. 79 if ( pthread_create(&(self->thread), NULL, roar_ thread, self) < 0 ) {79 if ( pthread_create(&(self->thread), NULL, roar_plugin_thread, self) < 0 ) { 80 80 self->thread_active = 0; 81 81 return -1; … … 85 85 } 86 86 87 void roar_ reset(struct roar_alsa_pcm *self) {87 void roar_plugin_reset(struct roar_alsa_pcm *self) { 88 88 if ( !self->stream_opened ) 89 89 return; … … 120 120 } 121 121 122 roar_ reset(self);122 roar_plugin_reset(self); 123 123 124 124 return 0; … … 240 240 buf = (char *)areas->addr + (areas->first + areas->step * offset) / 8; 241 241 242 ret = roar_ write(self, buf, len);242 ret = roar_plugin_write(self, buf, len); 243 243 244 244 if ( ret == -1 ) … … 260 260 // TODO: We need to set *delayp the latency in frames. 261 261 pthread_mutex_lock(&(self->lock)); 262 roar_ drain(self);262 roar_plugin_drain(self); 263 263 *delayp = snd_pcm_bytes_to_frames(io->pcm, self->bytes_in_buffer); 264 264 pthread_mutex_unlock(&(self->lock)); -
plugins/alsa/roar.h
r5156 r5157 76 76 }; 77 77 78 void roar_ reset(struct roar_alsa_pcm * self);79 void* roar_ thread (void * thread_data);80 size_t roar_ write(struct roar_alsa_pcm * self, const char * buf, size_t size);81 void roar_ drain(struct roar_alsa_pcm * self);78 void roar_plugin_reset(struct roar_alsa_pcm * self); 79 void* roar_plugin_thread (void * thread_data); 80 size_t roar_plugin_write(struct roar_alsa_pcm * self, const char * buf, size_t size); 81 void roar_plugin_drain(struct roar_alsa_pcm * self); 82 82 83 83 #endif -
plugins/alsa/thread.c
r5156 r5157 43 43 44 44 // Writes to the FIFO buffer. Waits until there is room to write. 45 size_t roar_ write(struct roar_alsa_pcm *self, const char *buf, size_t size) {45 size_t roar_plugin_write(struct roar_alsa_pcm *self, const char *buf, size_t size) { 46 46 /* Wait until we have a ready buffer */ 47 47 while (1) { … … 82 82 83 83 // Attemps to drain the buffer at all times and write to libroar. 84 // If there is no data, it will wait for roar_ write() to fill up more data.85 void* roar_ thread (void * thread_data) {84 // If there is no data, it will wait for roar_plugin_write() to fill up more data. 85 void* roar_plugin_thread (void * thread_data) { 86 86 /* We share data between thread and callable functions */ 87 87 struct roar_alsa_pcm *self = thread_data; … … 109 109 if ( rc < 0 ) { 110 110 _TEST_CANCEL(); 111 roar_ reset(self);111 roar_plugin_reset(self); 112 112 113 113 /* Wakes up a potentially sleeping fill_buffer() */ … … 135 135 self->bufptr -= rc; 136 136 pthread_mutex_unlock(&(self->lock)); 137 ROAR_DBG("roar_ thread(*): Wrote data to vio. New bufptr: %i", (int)self->bufptr);137 ROAR_DBG("roar_plugin_thread(*): Wrote data to vio. New bufptr: %i", (int)self->bufptr); 138 138 139 139 /* Buffer has decreased, signal fill_buffer() */ … … 158 158 } 159 159 160 void roar_ drain(struct roar_alsa_pcm *self) {160 void roar_plugin_drain(struct roar_alsa_pcm *self) { 161 161 struct timespec now_tv; 162 162 int64_t temp, temp2; -
plugins/alsavs/pcm_roar.c
r5156 r5157 77 77 self->bufptr = 0; 78 78 self->thread_active = 1; // We have to activate the thread before starting it, because the thread lives on that thread_active is 1. 79 if ( pthread_create(&(self->thread), NULL, roar_ thread, self) < 0 ) {79 if ( pthread_create(&(self->thread), NULL, roar_plugin_thread, self) < 0 ) { 80 80 self->thread_active = 0; 81 81 return -1; … … 85 85 } 86 86 87 void roar_ reset(struct roar_alsa_pcm *self) {87 void roar_plugin_reset(struct roar_alsa_pcm *self) { 88 88 if ( !self->stream_opened ) 89 89 return; … … 120 120 } 121 121 122 roar_ reset(self);122 roar_plugin_reset(self); 123 123 124 124 return 0; … … 240 240 buf = (char *)areas->addr + (areas->first + areas->step * offset) / 8; 241 241 242 ret = roar_ write(self, buf, len);242 ret = roar_plugin_write(self, buf, len); 243 243 244 244 if ( ret == -1 ) … … 260 260 // TODO: We need to set *delayp the latency in frames. 261 261 pthread_mutex_lock(&(self->lock)); 262 roar_ drain(self);262 roar_plugin_drain(self); 263 263 *delayp = snd_pcm_bytes_to_frames(io->pcm, self->bytes_in_buffer); 264 264 pthread_mutex_unlock(&(self->lock)); -
plugins/alsavs/roar.h
r5156 r5157 76 76 }; 77 77 78 void roar_ reset(struct roar_alsa_pcm * self);79 void* roar_ thread (void * thread_data);80 size_t roar_ write(struct roar_alsa_pcm * self, const char * buf, size_t size);81 void roar_ drain(struct roar_alsa_pcm * self);78 void roar_plugin_reset(struct roar_alsa_pcm * self); 79 void* roar_plugin_thread (void * thread_data); 80 size_t roar_plugin_write(struct roar_alsa_pcm * self, const char * buf, size_t size); 81 void roar_plugin_drain(struct roar_alsa_pcm * self); 82 82 83 83 #endif -
plugins/alsavs/thread.c
r5156 r5157 43 43 44 44 // Writes to the FIFO buffer. Waits until there is room to write. 45 size_t roar_ write(struct roar_alsa_pcm *self, const char *buf, size_t size) {45 size_t roar_plugin_write(struct roar_alsa_pcm *self, const char *buf, size_t size) { 46 46 /* Wait until we have a ready buffer */ 47 47 while (1) { … … 82 82 83 83 // Attemps to drain the buffer at all times and write to libroar. 84 // If there is no data, it will wait for roar_ write() to fill up more data.85 void* roar_ thread (void * thread_data) {84 // If there is no data, it will wait for roar_plugin_write() to fill up more data. 85 void* roar_plugin_thread (void * thread_data) { 86 86 /* We share data between thread and callable functions */ 87 87 struct roar_alsa_pcm *self = thread_data; … … 109 109 if ( rc < 0 ) { 110 110 _TEST_CANCEL(); 111 roar_ reset(self);111 roar_plugin_reset(self); 112 112 113 113 /* Wakes up a potentially sleeping fill_buffer() */ … … 135 135 self->bufptr -= rc; 136 136 pthread_mutex_unlock(&(self->lock)); 137 ROAR_DBG("roar_ thread(*): Wrote data to vio. New bufptr: %i", (int)self->bufptr);137 ROAR_DBG("roar_plugin_thread(*): Wrote data to vio. New bufptr: %i", (int)self->bufptr); 138 138 139 139 /* Buffer has decreased, signal fill_buffer() */ … … 158 158 } 159 159 160 void roar_ drain(struct roar_alsa_pcm *self) {160 void roar_plugin_drain(struct roar_alsa_pcm *self) { 161 161 struct timespec now_tv; 162 162 int64_t temp, temp2;
Note: See TracChangeset
for help on using the changeset viewer.