void sound_lowlevel_end( void ) { sfifo_flush( &sound_fifo ); sfifo_close( &sound_fifo ); AUDIO_StopDMA(); }
static EEL_xno n2_tcp_close(EEL_vm *vm) { EEL_value *args = vm->heap + vm->argv; EB_socket *ebs; if(EEL_TYPE(args) != md.net2_socket_cid) return EEL_XWRONGTYPE; ebs = o2EB_socket(args->objref.v); if(!ebs->rs) return EEL_XDEVICECLOSED; if(ebs->rs->n2socket < 0) return EEL_XDEVICECLOSED; if(ebs->rs->status) return ebs->rs->status; if(eb_sockets) eb_sockets[ebs->rs->n2socket] = NULL; if(ebs->rs->sender) { ebs->rs->closed = 1; ebs->rs->status = EEL_XDEVICECLOSED; } else { NET2_TCPClose(ebs->rs->n2socket); sfifo_close(&ebs->rs->fifo); free(ebs->rs); ebs->rs = NULL; } return 0; }
static int close_coreaudio(audio_output_t *ao) { mpg123_coreaudio_t* ca = (mpg123_coreaudio_t*)ao->userptr; if (ca) { ca->decode_done = 1; while(!ca->play_done && ca->play) usleep(10000); /* No matter the error code, we want to close it (by brute force if necessary) */ AudioConverterDispose(ca->converter); AudioOutputUnitStop(ca->outputUnit); AudioUnitUninitialize(ca->outputUnit); CloseComponent(ca->outputUnit); /* Free the ring buffer */ sfifo_close( &ca->fifo ); /* Free the conversion buffer */ if (ca->buffer) { free( ca->buffer ); ca->buffer = NULL; } } return 0; }
static void ftpd_dataclose(struct tcp_pcb *pcb, struct ftpd_datastate *fsd) { tcp_arg(pcb, NULL); tcp_sent(pcb, NULL); tcp_recv(pcb, NULL); fsd->msgfs->datafs = NULL; sfifo_close(&fsd->fifo); free(fsd); tcp_arg(pcb, NULL); tcp_close(pcb); }
static EEL_xno n2_tcp_setbuf(EEL_vm *vm) { EEL_value *args = vm->heap + vm->argv; EB_socket *ebs; if(EEL_TYPE(args) != md.net2_socket_cid) return EEL_XWRONGTYPE; ebs = o2EB_socket(args->objref.v); if(!ebs->rs) return EEL_XDEVICECLOSED; if(ebs->rs->sender) { /* * Change buffer size! * We need to close the sender thread, buffer etc, * and set up new gear to do this safely. To avoid * mixed up data, we wait for the old thread to * finish before moving on. */ ebs->rs->closed = 2; SDL_WaitThread(ebs->rs->sender, NULL); sfifo_close(&ebs->rs->fifo); } ebs->rs->fifosize = eel_v2l(args + 1); if(vm->argc >= 3) ebs->rs->pollperiod = eel_v2l(args + 2); if(sfifo_init(&ebs->rs->fifo, ebs->rs->fifosize) != 0) return EEL_XMEMORY; ebs->rs->sender = SDL_CreateThread(n2s_sender_thread, ebs->rs); if(!ebs->rs->sender) { sfifo_close(&ebs->rs->fifo); return EEL_XTHREADCREATE; } return 0; }
static void cmd_abrt(const char *arg, struct tcp_pcb *pcb, struct ftpd_msgstate *fsm) { if (fsm->datafs != NULL) { tcp_arg(fsm->datapcb, NULL); tcp_sent(fsm->datapcb, NULL); tcp_recv(fsm->datapcb, NULL); tcp_arg(fsm->datapcb, NULL); tcp_abort(pcb); sfifo_close(&fsm->datafs->fifo); free(fsm->datafs); fsm->datafs = NULL; } fsm->state = FTPD_IDLE; }
static void ftpd_msgclose(struct tcp_pcb *pcb, struct ftpd_msgstate *fsm) { tcp_arg(pcb, NULL); tcp_sent(pcb, NULL); tcp_recv(pcb, NULL); if (fsm->datafs) ftpd_dataclose(fsm->datapcb, fsm->datafs); sfifo_close(&fsm->fifo); vfs_close(fsm->vfs); fsm->vfs = NULL; if (fsm->renamefrom) free(fsm->renamefrom); fsm->renamefrom = NULL; free(fsm); tcp_arg(pcb, NULL); tcp_close(pcb); }
static void ftpd_msgerr(void *arg, err_t err) { struct ftpd_msgstate *fsm = arg; dbg_printf("ftpd_msgerr: %s (%i)\n", lwip_strerr(err), err); if (fsm == NULL) return; if (fsm->datafs) ftpd_dataclose(fsm->datapcb, fsm->datafs); sfifo_close(&fsm->fifo); vfs_close(fsm->vfs); fsm->vfs = NULL; if (fsm->renamefrom) free(fsm->renamefrom); fsm->renamefrom = NULL; free(fsm); }
static EEL_xno n2s_destruct(EEL_object *eo) { EB_socket *ebs = o2EB_socket(eo); if(!ebs->rs) return 0; /* Detached! We're done here. */ if(ebs->rs->sender) { ebs->rs->closed = 1; SDL_WaitThread(ebs->rs->sender, NULL); sfifo_close(&ebs->rs->fifo); } NET2_TCPClose(ebs->rs->n2socket); if(ebs->rs->n2socket >= 0) if(eb_sockets) eb_sockets[ebs->rs->n2socket] = NULL; free(ebs->rs); return 0; }
void sound_lowlevel_end( void ) { OSStatus err; if( audio_output_started ) verify_noerr( AudioOutputUnitStop( gOutputUnit ) ); err = AudioUnitUninitialize( gOutputUnit ); if( err ) { printf( "AudioUnitUninitialize=%ld", err ); } CloseComponent( gOutputUnit ); sfifo_flush( &sound_fifo ); sfifo_close( &sound_fifo ); }
static int close_sdl(out123_handle *ao) { int stuff; sfifo_t *fifo = (sfifo_t*)ao->userptr; /* Wait at least until SDL emptied the FIFO. */ while((stuff = sfifo_used(fifo))>0) { int msecs = stuff*1000/ao->rate; debug1("still stuff for about %i ms there", msecs); #ifdef WIN32 Sleep(msecs/2); #else usleep(msecs*1000/2); #endif } SDL_CloseAudio(); /* Free up the memory used by the FIFO */ sfifo_close( fifo ); return 0; }