Changeset 4166:cde6dd3edef8 in roaraudio for plugins/alsa
- Timestamp:
- 08/14/10 00:05:46 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/alsa/thread.c
r4165 r4166 43 43 size_t roar_write(struct roar_alsa_pcm *self, const char *buf, size_t size) { 44 44 /* Wait until we have a ready buffer */ 45 for (;;) {45 while (1) { 46 46 /* Should the thread be shut down while we're running, return with error */ 47 47 if ( !self->thread_active ) … … 156 156 157 157 void roar_drain(struct roar_alsa_pcm *self) { 158 struct timespec now_tv; 159 int64_t temp, temp2; 160 158 161 /* If the audio playback has started on the server we need to use timers. */ 159 162 if ( self->has_written ) { 160 int64_t temp, temp2;161 163 162 164 /* Falls back to gettimeofday() when CLOCK_MONOTONIC is not supported */ 163 165 164 166 /* Calculates the amount of bytes that the server has consumed. */ 165 struct timespec now_tv;166 167 clock_gettime(CLOCK_MONOTONIC, &now_tv); 167 168 168 temp = (int64_t)now_tv.tv_sec - (int64_t)self->start_tv.tv_sec;169 temp = (int64_t)now_tv.tv_sec - (int64_t)self->start_tv.tv_sec; 169 170 170 temp *= self->info.rate * self->info.channels * self->info.bits / 8;171 temp *= self->info.rate * self->info.channels * self->info.bits / 8; 171 172 172 temp2 = (int64_t)now_tv.tv_nsec - (int64_t)self->start_tv.tv_nsec;173 temp2 = (int64_t)now_tv.tv_nsec - (int64_t)self->start_tv.tv_nsec; 173 174 temp2 *= self->info.rate * self->info.channels * self->info.bits / 8; 174 temp2 /= 1000000000 ;175 temp += temp2;175 temp2 /= 1000000000LL; 176 temp += temp2; 176 177 /* Calculates the amount of data we have in our virtual buffer. Only used to calculate delay. */ 177 178 self->bytes_in_buffer = (int)((int64_t)self->total_written + (int64_t)self->bufptr - temp); … … 181 182 } 182 183 183 184 184 //ll
Note: See TracChangeset
for help on using the changeset viewer.