Skip to content

Commit

Permalink
Hummm...
Browse files Browse the repository at this point in the history
  • Loading branch information
Themaister committed Apr 28, 2010
1 parent 7e45d66 commit 3c86634
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions roar/pcm_roar.c
Expand Up @@ -54,6 +54,12 @@ static int roar_pcm_start (snd_pcm_ioplug_t * io) {
return -EINVAL;
}

int fd;
roar_vio_ctl(&(self->stream_vio), ROAR_VIO_CTL_GET_SELECT_WRITE_FH, &fd);
io->poll_fd = fd;

snd_pcm_ioplug_reinit_status(io);

// Stream is now active, yay.
self->stream_opened = 1;
self->writec = 0;
Expand All @@ -74,6 +80,8 @@ void roar_reset(struct roar_alsa_pcm *self)
self->stream_opened = 0;
self->thread_active = 0;
self->bufptr = 0;
self->last_ptr = 0;
self->writec = 0;
}


Expand All @@ -87,7 +95,6 @@ static int roar_pcm_stop (snd_pcm_ioplug_t *io) {

ROAR_DBG("roar_pcm_stop(*) = 0");

roar_reset(self);

if ( self->thread_active )
{
Expand All @@ -96,6 +103,8 @@ static int roar_pcm_stop (snd_pcm_ioplug_t *io) {
pthread_join(self->thread, NULL);
}

roar_reset(self);

return 0;
}

Expand Down Expand Up @@ -181,6 +190,7 @@ static snd_pcm_sframes_t roar_pcm_pointer(snd_pcm_ioplug_t *io) {
}

ptr = snd_pcm_bytes_to_frames(io->pcm, self->bufptr);
//fprintf(stderr, "POINTER: %d\n", ptr);
ptr = io->appl_ptr - ptr;
self->last_ptr = io->appl_ptr;

Expand Down Expand Up @@ -406,8 +416,8 @@ SND_PCM_PLUGIN_DEFINE_FUNC(roar) {

self->io.version = SND_PCM_IOPLUG_VERSION;
self->io.name = "RoarAudio Plugin";
self->io.poll_fd = -1;
self->io.poll_events = 0;
/* self->io.poll_fd = 1; */
self->io.poll_events = POLLOUT;
self->io.mmap_rw = 0;
self->io.callback = &roar_pcm_callback;
self->io.private_data = self;
Expand Down
3 changes: 2 additions & 1 deletion roar/thread.c
Expand Up @@ -12,7 +12,7 @@ size_t roar_write( struct roar_alsa_pcm *self, const char *buf, size_t size )
if ( !self->thread_active )
return 0;

fprintf(stderr, "%d + %d : %d\n", (int)self->bufptr, (int)size, (int)self->bufsize);
//fprintf(stderr, "%d + %d : %d\n", (int)self->bufptr, (int)size, (int)self->bufsize);
pthread_mutex_lock(&self->lock);
if ( self->bufptr + size <= self->bufsize )
{
Expand Down Expand Up @@ -67,6 +67,7 @@ void* roar_thread ( void * thread_data )

pthread_testcancel();
rc = roar_vio_write(&(self->stream_vio), self->buffer, CHUNK_SIZE);
// fprintf(stderr, "Thread wrote %d\n", rc);

/* If this happens, we should make sure that subsequent and current calls to rsd_write() will fail. */
if ( rc < 0 )
Expand Down

0 comments on commit 3c86634

Please sign in to comment.