예제 #1
0
파일: audio.cpp 프로젝트: Bith76/iUAE
void check_prefs_changed_audio (void)
{
    if (sound_available && sound_prefs_changed ()) {
		close_sound ();
		
		produce_sound = changed_produce_sound;
		if (produce_sound) {
			if (init_audio ()) {
				last_cycles = get_cycles () - 1;
				next_sample_evtime = scaled_sample_evtime;
			} else
				if (! sound_available) {
					write_log ("Sound is not supported.\n");
				} else {
					write_log ("Sorry, can't initialize sound.\n");
					produce_sound = 0;
					/* So we don't do this every frame */
					produce_sound = 0;
				}
		}
    }
    if (!produce_sound) {
		eventtab[ev_audio].active = 0;
		events_schedule ();
    }
}
예제 #2
0
void do_leave_program (void)
{
    graphics_leave ();
    inputdevice_close ();

#ifdef SCSIEMU
    scsidev_exit ();
#endif
    DISK_free ();
    close_sound ();
    dump_counts ();
#ifdef SERIAL_PORT
    serial_exit ();
#endif
/*
#ifdef CD32
    akiko_free ();
#endif
*/
	if (! no_gui)
	gui_exit ();

#ifdef AUTOCONFIG
    expansion_cleanup ();
#endif
#ifdef FILESYS
    filesys_cleanup ();
#endif
#ifdef SAVESTATE
    savestate_free ();
#endif
    memory_cleanup ();
    cfgfile_addcfgparam (0);
}
예제 #3
0
파일: menu.c 프로젝트: pepone42/gngb
int toggle_sound(MENU_ITEM *self)
{
  conf.sound^=1;
  if (conf.sound)
    gbsound_init();
  else
    close_sound();

  return 2;
}
예제 #4
0
void do_leave_program (void)
{
	sampler_free ();
	graphics_leave ();
	inputdevice_close ();
	DISK_free ();
	close_sound ();
	dump_counts ();
#ifdef SERIAL_PORT
	serial_exit ();
#endif
#ifdef CDTV
	cdtv_free ();
#endif
#ifdef A2091
	a2091_free ();
	a3000scsi_free ();
#endif
#ifdef NCR
	ncr710_free();
	ncr_free();
#endif
#ifdef NCR9X
	ncr9x_free();
#endif
#ifdef CD32
	akiko_free ();
	cd32_fmv_free();
#endif
	if (! no_gui)
		gui_exit ();
#ifdef USE_SDL
	SDL_Quit ();
#endif
#ifdef AUTOCONFIG
	expansion_cleanup ();
#endif
#ifdef FILESYS
	filesys_cleanup ();
#endif
#ifdef BSDSOCKET
	bsdlib_reset ();
#endif
	gayle_free ();
	device_func_reset ();
#ifdef WITH_LUA
	uae_lua_free ();
#endif
	savestate_free ();
	memory_cleanup ();
	free_shm ();
	cfgfile_addcfgparam (0);
	machdep_free ();
}
예제 #5
0
파일: main.cpp 프로젝트: CypherXG/UAE4Droid
void do_leave_program (void)
{
    graphics_leave ();
    close_joystick ();
    close_sound ();
    dump_counts ();
    zfile_exit ();
#ifdef USE_SDL
    SDL_Quit ();
#endif
    memory_cleanup ();
}
예제 #6
0
파일: main.c 프로젝트: kristianhk/PUAE
void do_leave_program (void)
{
#ifdef SAMPLER
	sampler_free ();
#endif
	graphics_leave ();
	inputdevice_close ();
	DISK_free ();
	close_sound ();
	dump_counts ();
#ifdef SERIAL_PORT
	serial_exit ();
#endif
#ifdef CDTV
	cdtv_free ();
#endif
#ifdef A2091
	a2091_free ();
#endif
#ifdef NCR
	ncr_free ();
#endif
#ifdef CD32
	akiko_free ();
#endif
	if (! no_gui)
		gui_exit ();
#ifdef USE_SDL
	SDL_Quit ();
#endif
#ifdef AUTOCONFIG
	expansion_cleanup ();
#endif
#ifdef FILESYS
	filesys_cleanup ();
#endif
#ifdef BSDSOCKET
	bsdlib_reset ();
#endif
#ifdef SCSIEMU
#ifdef GAYLE
	gayle_free ();
#endif
	device_func_reset ();
#endif
	savestate_free ();
	memory_cleanup ();
#ifdef NATMEM_OFFSET
	free_shm ();
#endif
	cfgfile_addcfgparam (0);
	machdep_free ();
}
예제 #7
0
void do_leave_program (void)
{
#ifdef USE_SDL
  if(current_screenshot != NULL)
    SDL_FreeSurface(current_screenshot);
#endif
    graphics_leave ();
    close_joystick ();
    close_sound ();
    zfile_exit ();
#ifdef USE_SDL
    SDL_Quit ();
#endif
    memory_cleanup ();
}
예제 #8
0
파일: main.c 프로젝트: bernds/UAE
void do_leave_program (void)
{
    graphics_leave ();
    inputdevice_close ();
    close_sound ();
    dump_counts ();
    serial_exit ();
    zfile_exit ();
    if (! no_gui)
	gui_exit ();
#ifdef USE_SDL
    SDL_Quit ();
#endif
    expansion_cleanup ();
    memory_cleanup ();
}
예제 #9
0
/* Called at avi capture stop       */
static void
aviClose (struct ALL_DATA *all_data)
{
	float tottime = 0;

	struct GLOBAL *global = all_data->global;
	//struct vdIn *videoIn = all_data->videoIn;
	struct VideoFormatData *videoF = all_data->videoF;
	struct paRecordData *pdata = all_data->pdata;

	if (videoF->avi)
	{
		tottime = (float) ((int64_t) (global->Vidstoptime - global->Vidstarttime) / 1000000); // convert to miliseconds

		if (global->debug) g_print("stop= %llu start=%llu \n",
			(unsigned long long) global->Vidstoptime, (unsigned long long) global->Vidstarttime);
		if (tottime > 0)
		{
			/*try to find the real frame rate*/
			videoF->avi->fps = (double) (global->framecount * 1000) / tottime;
		}
		else
		{
			/*set the hardware frame rate*/
			videoF->avi->fps = global->fps;
		}

		if (global->debug) g_print("VIDEO: %d frames in %f ms = %f fps\n",global->framecount,tottime,videoF->avi->fps);
		/*------------------- close audio stream and clean up -------------------*/
		if (global->Sound_enable > 0)
		{
			if (close_sound (pdata)) g_printerr("Sound Close error\n");
		}
		avi_close(videoF->avi);

		global->framecount = 0;
		global->Vidstarttime = 0;
		if (global->debug) g_print ("close avi\n");
	}

	avi_destroy_context(videoF->avi);
	pdata = NULL;
	global = NULL;
	//videoIn = NULL;
	videoF->avi = NULL;
}
예제 #10
0
파일: sound.c 프로젝트: mahiso/JudoShiai
gpointer sound_thread(gpointer args)
{
    open_sound();

    for ( ; *((gboolean *)args) ; )   /* exit loop when flag is cleared */
    {
        if (play) {
            start_sound(args);
            play = FALSE;
        } else {
            g_usleep(100000);
        }
    }

    close_sound();
    g_thread_exit(NULL);    /* not required just good pratice */
    return NULL;
}
예제 #11
0
int uade_main (int argc, char **argv)
{
    quit_program = 0;

    default_prefs (&currprefs);

    uade_option (argc, argv);

    machdep_init ();

    if (! setup_sound ()) {
    __android_log_print(ANDROID_LOG_VERBOSE, "UADE", "Sound driver unavailable: Sound output disabled\n");
    currprefs.produce_sound = 0;
    exit(1);
    }

    init_sound();

    fix_options ();
    changed_prefs = currprefs;
    check_prefs_changed_cpu();

    memory_init ();

    custom_init (); /* Must come after memory_init */

    reset_frame_rate_hack ();
    init_m68k(); /* must come after reset_frame_rate_hack (); */

    /* compiler_init (); */

    if (currprefs.start_debugger)
      activate_debugger ();

    m68k_go();

    close_sound ();
    dump_counts ();

    return 0;
}
예제 #12
0
파일: sound.c 프로젝트: agwatic/PUAE
int setup_sound(void)
{
    ppb_audio_interface = (PPB_Audio *) NaCl_GetInterface(PPB_AUDIO_INTERFACE);
    ppb_audio_config_interface = (PPB_AudioConfig *)
        NaCl_GetInterface(PPB_AUDIO_CONFIG_INTERFACE);
    pp_instance = NaCl_GetInstance();

    if (!ppb_audio_interface) {
        write_log("Could not acquire PPB_Audio interface.\n");
        return 0;
    }
    if (!ppb_audio_config_interface) {
        write_log("Could not acquire PPB_AudioConfig interface.\n");
        return 0;
    }
    if (!pp_instance) {
        write_log("Could not find current Pepper instance.\n");
        return 0;
    }

    if (!init_sound()) return 0;
    close_sound();

    write_log("Pepper audio successfully set up.\n");
    write_log("Frequency: %d\n", currprefs.sound_freq);
    write_log("Stereo   : %d\n", currprefs.sound_stereo);
    write_log("Latency  : %d\n", currprefs.sound_latency);

    init_sound_table16();
    sample_handler = sample16s_handler;
    obtainedfreq = currprefs.sound_freq;
    have_sound = 1;
    sound_available = 1;
    update_sound (fake_vblank_hz, 1, currprefs.ntscmode);

    return sound_available;
}
예제 #13
0
static void
mkvClose(struct ALL_DATA *all_data)
{
	float tottime = 0;

	struct GLOBAL *global = all_data->global;
	//struct vdIn *videoIn = all_data->videoIn;
	struct VideoFormatData *videoF = all_data->videoF;
	struct paRecordData *pdata = all_data->pdata;

	if (videoF->mkv)
	{
		tottime = (float) ((int64_t) (global->Vidstoptime - global->Vidstarttime) / 1000000); // convert to miliseconds

		if (global->debug) g_print("stop= %llu start=%llu \n",
			(unsigned long long) global->Vidstoptime, (unsigned long long) global->Vidstarttime);

		if (global->debug) g_print("VIDEO: %d frames in %f ms \n",global->framecount,tottime);
		/*------------------- close audio stream and clean up -------------------*/
		if (global->Sound_enable > 0)
		{
			if (close_sound (pdata)) g_printerr("Sound Close error\n");
		}
		mkv_close(videoF->mkv);

		global->framecount = 0;
		global->Vidstarttime = 0;
		if (global->debug) g_print ("close mkv\n");
	}

	mkv_destroy_context(videoF->mkv);
	pdata = NULL;
	global = NULL;
	//videoIn = NULL;
	videoF->mkv = NULL;
}
예제 #14
0
void change_sound_format(void)
{ if (sound_recording)
     errormsg("Recording in Progress will be stoped",0);
  close_sound();
}
예제 #15
0
void exit_sound(void)
{ if (sound_recording) stop_sound();
  kill_encoder();
  close_sound();
}
예제 #16
0
  /* scale */
  return output >> scalebits;
}

#define INPUT_BUFFER_SIZE  (5*8192)
#define OUTPUT_BUFFER_SIZE  8192 /* Must be an integer multiple of 4. */
void real_mpeg_play(char* fname)
{
    unsigned char InputBuffer[INPUT_BUFFER_SIZE],
        OutputBuffer[OUTPUT_BUFFER_SIZE],
        *OutputPtr=OutputBuffer;
    const unsigned char  *OutputBufferEnd=OutputBuffer+OUTPUT_BUFFER_SIZE;
    int Status=0, i, fd;
    unsigned long FrameCount=0;
    sound_t sound;
    struct mp3entry mp3;
    static struct dither d0, d1;
    int key=0;
  
    mp3info(&mp3, fname, false); /* FIXME: honor the v1first setting */

    init_sound(&sound);

    /* Configure sound device for this file - always select Stereo because
       some sound cards don't support mono */
    config_sound(&sound,mp3.frequency,2);

    if ((fd=open(fname,O_RDONLY)) < 0) {
        fprintf(stderr,"could not open %s\n",fname);
        return;
    }

    /* First the structures used by libmad must be initialized. */
    mad_stream_init(&Stream);
    mad_frame_init(&Frame);
    mad_synth_init(&Synth);
    mad_timer_reset(&Timer);

    do {
        if (Stream.buffer==NULL || Stream.error==MAD_ERROR_BUFLEN) {
            size_t ReadSize,Remaining;
            unsigned char *ReadStart;

            if(Stream.next_frame!=NULL) {
                Remaining=Stream.bufend-Stream.next_frame;
                memmove(InputBuffer,Stream.next_frame,Remaining);
                ReadStart=InputBuffer+Remaining;
                ReadSize=INPUT_BUFFER_SIZE-Remaining;
            } else {
                ReadSize=INPUT_BUFFER_SIZE,
                    ReadStart=InputBuffer,
                    Remaining=0;
            }

            if ((int)(ReadSize=read(fd,ReadStart,ReadSize)) < 0) {
                fprintf(stderr,"end of input stream\n");
                break;
            }

            mad_stream_buffer(&Stream,InputBuffer,ReadSize+Remaining);
            Stream.error=0;
        }

        if(mad_frame_decode(&Frame,&Stream)) {
            if(MAD_RECOVERABLE(Stream.error)) {
                fprintf(stderr,"recoverable frame level error\n");
                fflush(stderr);
                continue;
            } else {
                if(Stream.error==MAD_ERROR_BUFLEN) {
                    continue;
                } else {
                    fprintf(stderr,"unrecoverable frame level error\n");
                    Status=1;
                    break;
                }
            }
        }

        FrameCount++;
        mad_timer_add(&Timer,Frame.header.duration);
        
        mad_synth_frame(&Synth,&Frame);

        for(i=0;i<Synth.pcm.length;i++) {
            unsigned short  Sample;
            
            /* Left channel */
            Sample=scale(Synth.pcm.samples[0][i],&d0);
            *(OutputPtr++)=Sample&0xff;
            *(OutputPtr++)=Sample>>8;
            
            /* Right channel. If the decoded stream is monophonic then
             * the right output channel is the same as the left one.
             */
            if(MAD_NCHANNELS(&Frame.header)==2) {
                Sample=scale(Synth.pcm.samples[1][i],&d1);
            }

            *(OutputPtr++)=Sample&0xff;
            *(OutputPtr++)=Sample>>8;
            
            /* Flush the buffer if it is full. */
            if (OutputPtr==OutputBufferEnd) {
                if (output_sound(&sound, OutputBuffer,
                                 OUTPUT_BUFFER_SIZE)!=OUTPUT_BUFFER_SIZE) {
                    fprintf(stderr,"PCM write error.\n");
                    Status=2;
                    break;
                }
                OutputPtr=OutputBuffer;
            }
            }

        if ((key=button_get(0))==BUTTON_STOP)
	{
            break; 
	}

    }while(1);
    
    /* Mad is no longer used, the structures that were initialized must
     * now be cleared.
     */
    mad_synth_finish(&Synth);
    mad_frame_finish(&Frame);
    mad_stream_finish(&Stream);

    /* If the output buffer is not empty and no error occured during
     * the last write, then flush it. */
    if(OutputPtr!=OutputBuffer && Status!=2)
        {
            size_t  BufferSize=OutputPtr-OutputBuffer;

            if (output_sound(&sound, OutputPtr, BufferSize)!=(int)BufferSize)
                {
                    fprintf(stderr,"PCM write error\n");
                    Status=2;
                }
        }

    /* Accounting report if no error occured. */
    if(!Status)
        {
            char  Buffer[80];

            mad_timer_string(Timer,Buffer,"%lu:%02lu.%03u",
                             MAD_UNITS_MINUTES,MAD_UNITS_MILLISECONDS,0);
            fprintf(stderr,"%lu frames decoded (%s).\n",FrameCount,Buffer);
        }

    close_sound(&sound);
    /* That's the end of the world (in the H. G. Wells way). */
    return;
}
예제 #17
0
파일: devices.cpp 프로젝트: emoon/fs-uae
void do_leave_program (void)
{
	sampler_free ();
	graphics_leave ();
	inputdevice_close ();
	DISK_free ();
	close_sound ();
	dump_counts ();
#ifdef PARALLEL_PORT
	parallel_exit();
#endif
#ifdef SERIAL_PORT
	serial_exit ();
#endif
#ifdef CDTV
	cdtv_free();
	cdtvcr_free();
#endif
#ifdef A2091
	a2091_free ();
	gvp_free ();
	a3000scsi_free ();
#endif
	soft_scsi_free();
#ifdef NCR
	ncr_free();
#endif
#ifdef NCR9X
	ncr9x_free();
#endif
#ifdef CD32
	akiko_free ();
	cd32_fmv_free();
#endif
	if (! no_gui)
		gui_exit ();
#ifdef USE_SDL
	SDL_Quit ();
#endif
#ifdef AUTOCONFIG
	expansion_cleanup ();
#endif
#ifdef WITH_PCI
	pci_free();
#endif
#ifdef WITH_X86
	x86_bridge_free();
#endif
#ifdef FILESYS
	filesys_cleanup ();
#endif
#ifdef BSDSOCKET
	bsdlib_reset ();
#endif
	gayle_free ();
	idecontroller_free();
	device_func_reset ();
#ifdef WITH_LUA
	uae_lua_free ();
#endif
#ifdef WITH_PPC
	uae_ppc_free();
#endif
#ifdef WITH_TOCCATA
	sndboard_free();
#endif
	gfxboard_free();
#ifdef SAVESTATE
	savestate_free ();
#endif
	memory_cleanup ();
	free_shm ();
	cfgfile_addcfgparam (0);
	machdep_free ();
#ifdef DRIVESOUND
	driveclick_free();
#endif
	ethernet_enumerate_free();
}
예제 #18
0
/*
* 1) Parses arguments
* 2) Opens each sound file given (or reads from stdin)
* 3) Concatenates sounds in order
* 4) Writes out sound
*/
int main(int argc, char* argv[])
{
    sndtype out_type = CS229;
    int i;
    char c;
    char* outfile = NULL;
    snd_t* info = 0;
    snd_t* current;
    FILE* out;

    while((c = getopt(argc, argv, "ho:w")) != -1)
    {
        switch(c)
        {
            case 'h':
                print_usage(0);
                break;
            case 'o':
                outfile = optarg;
                break;
            case 'w':
                out_type = WAVE;
                break;
            case '?':
                fprintf(stderr, "sndcat: Error: Try 'sndcat -h' for more information.\n");
                exit(1);
                break;
            default:
                print_usage(1);
        }
    }
    
    /*
    Get from stdin
    */
    if(optind == argc)
    {
        info = read_sound(stdin, "Standard Input");
    }

    for(i = optind; i < argc; ++i)
    {
        if(!info)
        {
            info = open_sound(argv[i]);
            if(!info)
            {
                fprintf(stderr, "sndcat: Error: %s could not be opened. Exiting.\n", argv[i]);
                exit(1);
            }

            continue;
        }

        current = open_sound(argv[i]);
        if(!current)
        {
            fprintf(stderr, "sndcat: Error: %s could not be opened. Exiting.\n", argv[i]);
            exit(1);
        }
        concatenate(info, current);
        free(current);
    }
    
    if(out_type != info->type)
    {
        convert(info);
    }
    
    if(!outfile)
    {
        out = stdout;
    }
    else
    {
        out = fopen(outfile, "wb");
    }

    write_sound(out, info);
    close_sound(info);

    if(out != stdout)
    {
        fclose(out);
    }
    
    return 0;
}