示例#1
0
void openal_stream_play(audio_stream *stream) {
    openal_stream *local = stream_get_userdata(stream);

    // Fill initial buffers
    char buf[AUDIO_BUFFER_SIZE];
    for(int i = 0; i < AUDIO_BUFFER_COUNT; i++) {
        int ret = source_update(stream->src, buf, AUDIO_BUFFER_SIZE);
        if(ret > 0) {
            alBufferData(
                local->buffers[i],
                local->format,
                buf, ret,
                source_get_frequency(stream->src));
            alSourceQueueBuffers(local->source, 1, &local->buffers[i]);
        }
    }

    // Set volume etc.
    openal_stream_apply(stream);

    // Start playback
    alSourcePlay(local->source);
    int err = alGetError();
    if(err != AL_NO_ERROR) {
        PERROR("OpenAL Stream: Source playback error: %d.", err);
    }
}
int sources_update(tn_array *sources, unsigned flags)
{
    int i, nerr = 0;
    
    for (i=0; i < n_array_size(sources); i++) {
        struct source *src = n_array_nth(sources, i);
        
        if (src->flags & PKGSOURCE_NOAUTOUP)
            continue;
        
        if (i > 0)
            msgn(0, "\n");

        if (!source_update(src, flags))
            nerr++;
    }

    return nerr == 0;
}
示例#3
0
void openal_stream_update(audio_stream *stream) {
    openal_stream *local = stream_get_userdata(stream);

    // See if we have any empty buffers to fill
    int val;
    alGetSourcei(local->source, AL_BUFFERS_PROCESSED, &val);
    if(val <= 0) {
        return;
    }

    // Handle buffer filling and loading
    char buf[AUDIO_BUFFER_SIZE];
    ALuint n;
    while(val--) {
        // Fill buffer & re-queue
        int ret = source_update(stream->src, buf, AUDIO_BUFFER_SIZE);
        if(ret > 0) {
            alSourceUnqueueBuffers(local->source, 1, &n);
            alBufferData(n, local->format, buf, ret, source_get_frequency(stream->src));
            alSourceQueueBuffers(local->source, 1, &n);

            // Check for any errors
            int err = alGetError();
            if(err != AL_NO_ERROR) {
                PERROR("OpenAL Stream: Error %d while buffering!", err);
            }
        } else {
            stream_set_finished(stream);
            break;
        }
    }

    // Make sure we are playing stream
    if(stream_get_status(stream) == STREAM_STATUS_PLAYING) {
        ALenum state;
        alGetSourcei(local->source, AL_SOURCE_STATE, &state);
        if(state != AL_PLAYING) {
            alSourcePlay(local->source);
        }
    }
}
示例#4
0
文件: gui.c 项目: adtools/db101
void event_loop()
{
            ULONG wait, signal;
			BOOL shouldplay = FALSE;
			char *symbol = NULL;
			branch branchallowed = NOBRANCH;

            /* Obtain the window wait signal mask. */
            //IIntuition->GetAttr( WINDOW_SigMask, MainWinObj, &signal );
            
            /* Input Event Loop */
            while( !done )
            {
				signal = obtain_all_signals();

                wait = IExec->Wait(signal|SIGBREAKF_CTRL_C|SIGF_CHILD);
                								
                if (wait & SIGBREAKF_CTRL_C) done = TRUE;
                
				if(wait & debug_sigfield)
				{
					//console_printf(OUTPUT_SYSTEM, "SIG from debug hook\n");
					//console_printf(OUTPUT_SYSTEM, "traptype = 0x%08x\n", *((uint32 *)debug_hook.h_Data));

					button_set_continue();

					BOOL crashed = FALSE;
					uint32 traptype = *((uint32 *)debug_hook.h_Data);
					if(traptype != 0x700 && traptype != 0xd00)
					{
						catch_sline = FALSE;
						should_continue = FALSE;
						console_printf(OUTPUT_WARNING, "Your program has crashed! ip = 0x%x", context_copy.ip);
					}

					BOOL tracing = FALSE;

					//signal from debugger means TRAP
					task_playing = FALSE;
					suspend_all_breakpoints();
					
					if(stepping_out)
					{
						stepping_out = FALSE;
						stepout_remove();
					}
					if (asm_trace)
					{
						asmstep_remove();
						if(!should_continue && !stepping_over)
						{
							switch(is_branch_allowed())
							{
								case DISALLOWEDBRANCH:
									if(catch_sline)
									{
										stepping_out = TRUE;
										stepout_install();
										shouldplay = TRUE;
									}
									else
									{
										//console_printf(OUTPUT_WARNING, "Branch into new area not allowed!");
										enable(TRUE, GAD_STEPOUT_BUTTON, TAG_END);
										enable(FALSE, GAD_STEPINTO_BUTTON, GAD_STEPOVER_BUTTON, GAD_DISASSEMBLER_STEP_BUTTON, TAG_END);
									}
									catch_sline = FALSE;
									stepping_over = FALSE;
									break;
								case DISALLOWEDBRANCHCOND:
									if(catch_sline)
									{
										stepping_out = TRUE;
										stepout_install();
										shouldplay = TRUE;
									}
									else
									{
										//console_printf(OUTPUT_WARNING, "Branch into new area not allowed!");
										enable(TRUE, GAD_STEPOVER_BUTTON, GAD_STEPOUT_BUTTON, TAG_END);
										enable(FALSE, GAD_STEPINTO_BUTTON, GAD_DISASSEMBLER_STEP_BUTTON, TAG_END);
									}
									catch_sline = FALSE;
									stepping_over = FALSE;
									break;
								default:
									break;
							}
						}			
						tracing = TRUE;
						if(!should_continue && !catch_sline)
						{
							disassembler_makelist();
							variables_update();
							source_update();
						}
					}
					if (should_continue)
					{
						install_all_breakpoints();
						shouldplay = TRUE;
						should_continue = FALSE;
					}
					else
					{
						current_function = stabs_get_function_from_address (context_copy.ip);
						if (current_function)
							hasfunctioncontext = TRUE;
						else if(!stepping_over && try_import_segment(context_copy.ip) > 0)
						{
							current_function = stabs_get_function_from_address(context_copy.ip);
							if(current_function)
								hasfunctioncontext = TRUE;
							else
								hasfunctioncontext = FALSE;
						}
						else
							hasfunctioncontext = FALSE;
							
						if (hasfunctioncontext)
						{
							//dprintf("current_function == %s\n", current_function->name);
							//if(stepover_func)
							//	dprintf("stepover_func == %s\n", stepover_func->name);
							
							int nline = get_nline_from_address (context_copy.ip);
							
							if(nline >= 0)
							{
								if(stepping_over)
								{
									if(current_function == stepover_func
										&& current_function->line[nline].infile != current_function->line[current_function->currentline].infile)
									{
										catch_sline = FALSE;
										stepping_over = FALSE;
										current_function->currentline = nline;
									}
								}
								else
								{
									catch_sline = FALSE;
									current_function->currentline = nline;
								}
							}
							else if (!catch_sline)
							{
								nline = guess_line_in_function();
								if(nline)
									current_function->currentline = nline;
							}
							else if (!tracing)
							{
								console_printf(OUTPUT_WARNING, "Function overload error!");
								//printf("function size: 0x%x function address: 0x%x\n", current_function->size, current_function->address);
							}
						}
						else if(!stepping_over && (symbol = get_symbol_from_value(context_copy.ip)))
						{
							console_printf(OUTPUT_NORMAL, "At symbol %s: 0x%x", symbol, context_copy.ip);
							if(catch_sline)
							{
								catch_sline = FALSE;
								enable(TRUE, GAD_START_BUTTON, GAD_STEPINTO_BUTTON, GAD_STEPOUT_BUTTON, GAD_DISASSEMBLER_STEP_BUTTON, TAG_END);
								enable(FALSE, GAD_PAUSE_BUTTON, GAD_STEPOVER_BUTTON, TAG_END);
							}
							source_update();
							variables_update();
							stacktrace_update();
							disassembler_makelist();
							
							show_disassembler();
						}
						else if(!stepping_over && !tracing)
						{
							console_printf(OUTPUT_WARNING, "Program has stopped at an unknown point in memory (TRAP)");
							disassembler_makelist();
							variables_update();
							stacktrace_update();
							show_disassembler();
						}

						if(catch_sline)
						{
							if(stepping_over && get_branched_function() != current_function)
								asmstep_nobranch();
							else
								asmstep();
						}
						else if(hasfunctioncontext)
						{
							if (current_function != old_function)
								output_functionheader();
							old_function = current_function;

							enable(TRUE, GAD_START_BUTTON, GAD_STEPOVER_BUTTON, GAD_STEPINTO_BUTTON, GAD_STEPOUT_BUTTON, GAD_KILL_BUTTON, TAG_END);
							enable(FALSE, GAD_PAUSE_BUTTON, GAD_SELECT_BUTTON, TAG_END);

							remove_line_breakpoints();

							variables_update();
							stacktrace_update();
							disassembler_makelist();
							source_update();
							
							if(!tracing)
								show_source();
						}
					}
				}
                if(wait & SIGF_CHILD)
				{
					task_exists = FALSE;
					task_playing = FALSE;
					should_continue = FALSE;
					asm_trace = FALSE;
					hasfunctioncontext = FALSE;
					current_function = NULL;
					breakpoints_installed = FALSE;

					enable(TRUE, GAD_RELOAD_BUTTON, GAD_SELECT_BUTTON, TAG_END);
					enable(FALSE, GAD_START_BUTTON, GAD_PAUSE_BUTTON, GAD_STEPOVER_BUTTON, GAD_STEPINTO_BUTTON,
								  GAD_KILL_BUTTON, GAD_SETBREAK_BUTTON, GAD_FILENAME_STRING, GAD_HEX_BUTTON, TAG_END);

					button_set_start();
					IIntuition->RefreshGadgets ((struct Gadget *)MainObj[GAD_FILENAME_STRING], mainwin, NULL);

					close_all_elfhandles();
					free_symbols();
					stabs_free_stabs();
					free_breakpoints();
					//tracking_clear();

					modules_close_window();
					hex_close_window();
					variables_clear();
					source_clear();
					sourcelist_clear();
					stacktrace_clear();
					disassembler_clear();

					console_printf(OUTPUT_SYSTEM, "Program has ended");
				}

				if (wait & main_obtain_window_signal())
				{
					main_event_handler();
				}
				if (wait & hex_obtain_window_signal())
				{
					hex_event_handler();
				}
				if (wait & breakpoints_obtain_window_signal())
				{
					breakpoints_event_handler();
				}
				if (wait & sigwin_obtain_signal())
				{
					sigwin_event_handler();
				}
				if(wait & import_obtain_window_signal())
				{
					import_event_handler();
				}
				if(wait & arexx_obtain_signal())
				{
					arexx_event_handler();
				}
				if(wait & pipe_obtain_signal())
				{
					char buffer[1024];
					int len = pipe_read(buffer);
					console_write_raw_data(OUTPUT_FROM_EXECUTABLE, buffer, len);
				}
				if (shouldplay)
				{
					play();
					task_playing = TRUE;
				}
				shouldplay = FALSE;
			}
			return;
}