Example #1
0
FSDrive::~FSDrive()
{
	if (Ready) {
		close_all_channels();
		Ready = false;
	}
}
Example #2
0
bool ArchDrive::change_arch(const char *path)
{
	FILE *new_file;

	// Open new archive file
	if ((new_file = fopen(path, "rb")) != NULL) {

		file_info.clear();

		// Read header, determine archive type and parse archive contents
		uint8 header[64];
		fread(header, 1, 64, new_file);
		bool parsed_ok = false;
		if (is_t64_header(header)) {
			archive_type = TYPE_T64;
			parsed_ok = parse_t64_file(new_file, file_info, dir_title);
		} else if (is_lynx_header(header)) {
			archive_type = TYPE_LYNX;
			parsed_ok = parse_lynx_file(new_file, file_info, dir_title);
		} else if (is_p00_header(header)) {
			archive_type = TYPE_P00;
			parsed_ok = parse_p00_file(new_file, file_info, dir_title);
		}

		if (!parsed_ok) {
			fclose(new_file);
			if (the_file) {
				close_all_channels();
				fclose(the_file);
				the_file = NULL;
			}
			return false;
		}

		// Close old archive if open, and set new file
		if (the_file) {
			close_all_channels();
			fclose(the_file);
			the_file = NULL;
		}
		the_file = new_file;
		return true;
	}
	return false;
}
Example #3
0
ArchDrive::~ArchDrive()
{
	// Close archive file
	if (the_file) {
		close_all_channels();
		fclose(the_file);
	}
	Ready = false;
}
Example #4
0
static int _impl_shutdown(rh_aout_api_itf * itf) {

    struct sles_api_instance * instance;

    if(!itf)
        return -1;

    instance = (struct sles_api_instance *)*itf;

    if(instance) {

    	if( instance->outputMix )
			(*instance->outputMix)->Destroy(instance->outputMix);

		if( instance->engineObject )
			(*instance->engineObject)->Destroy(instance->engineObject);

        if(instance->thread) {
            const struct io_command_struct cmd = { EXIT_COMMAND, NULL };
            if( pipe_send( *itf, &cmd ) == 0)
                while(instance->thread)
                    sched_yield();
        }

        close_all_channels(*itf);

        bucket_free(instance->aout_itf_bucket);
        instance->aout_itf_bucket = NULL;

        close(instance->cmd_pipe.write);
        instance->cmd_pipe.write = 0;

        close(instance->cmd_pipe.read);
        instance->cmd_pipe.read = 0;

        free(instance->interface);
        free(instance);
    }

    *itf = NULL;

    return 0;
}
Example #5
0
void T64Drive::open_close_t64_file(const char *t64name)
{
    uint8 buf[64];
    bool parsed_ok = false;

    // Close old .t64, if open
    if (the_file != NULL) {
        close_all_channels();
        fclose(the_file);
        the_file = NULL;
        delete[] file_info;
        file_info = NULL;
    }

    // Open new .t64 file
    if (t64name[0]) {
        if ((the_file = fopen(t64name, "rb")) != NULL) {

            // Check file ID
            fread(&buf, 64, 1, the_file);
            if (buf[0] == 0x43 && buf[1] == 0x36 && buf[2] == 0x34) {
                is_lynx = false;
                parsed_ok = parse_t64_file();
            } else if (buf[0x3c] == 0x4c && buf[0x3d] == 0x59 && buf[0x3e] == 0x4e && buf[0x3f] == 0x58) {
                is_lynx = true;
                parsed_ok = parse_lynx_file();
            }

            if (!parsed_ok) {
                fclose(the_file);
                the_file = NULL;
                delete[] file_info;
                file_info = NULL;
                return;
            }
        }
    }
}
Example #6
0
static void client_stop(
        struct peer_connection* const client
) {
    // Stop transports & close gatherer
    if (rawrtc_sctp_transport_stop(client->sctp_transport) != RAWRTC_CODE_SUCCESS) {
        printf("Error stopping sctp transport \n");
        exit (-1);
    }

    if (rawrtc_dtls_transport_stop(client->dtls_transport) != RAWRTC_CODE_SUCCESS) {
        printf("Error stopping dtls transport \n");
        exit (-1);
    }

    close_all_channels(client);
    // Un-reference & close
    rawrtc_mem_deref(client->local_parameters.sctp_parameters.capabilities);

    parameters_destroy(&client->local_parameters);

    rawrtc_mem_deref(client->data_transport);

    rawrtc_mem_deref(client->sctp_transport);

    rawrtc_list_flush(&client->dtls_transport->certificates);

    rawrtc_mem_deref(client->dtls_transport);

    rawrtc_mem_deref(client->ice_transport);

    rawrtc_mem_deref(client->certificate);

    rawrtc_mem_deref(client->gather_options);

    rawrtc_mem_deref(client->remote_parameters.ice_candidates);
}
Example #7
0
static int _impl_setup(rh_aout_api_itf self) {

	extern AAssetManager * __rh_hack_get_android_asset_manager();

	static const SLEngineOption options[] = {
			{ SL_ENGINEOPTION_THREADSAFE, 		SL_BOOLEAN_TRUE },
			{ SL_ENGINEOPTION_LOSSOFCONTROL, 	SL_BOOLEAN_FALSE },
	};

    struct sles_api_instance * instance = (struct sles_api_instance *)self;

    instance->asset_manager = __rh_hack_get_android_asset_manager();

    if(!instance->asset_manager)
    	goto bad;

    if (SL_RESULT_SUCCESS
			!= slCreateEngine(&instance->engineObject,
					sizeof(options) / sizeof(options[0]), options, 0, NULL,
					NULL))
		goto bad;

	if (SL_RESULT_SUCCESS
			!= (*instance->engineObject)->Realize(instance->engineObject,
					SL_BOOLEAN_FALSE ))
		goto bad;

	if (SL_RESULT_SUCCESS
			!= (*instance->engineObject)->GetInterface(instance->engineObject,
					SL_IID_ENGINE, &instance->engineItf))
		goto bad;

	if (SL_RESULT_SUCCESS
			!= (*instance->engineItf)->CreateOutputMix(instance->engineItf,
					&instance->outputMix, 0, NULL, NULL))
		goto bad;

	if (SL_RESULT_SUCCESS
			!= (*instance->outputMix)->Realize(instance->outputMix,
					SL_BOOLEAN_FALSE ))
		goto bad;

    if( pipe( &instance->cmd_pipe.read ) != 0 )
        goto bad;

    if(fcntl( instance->cmd_pipe.read, F_SETFL, O_NONBLOCK) != 0)
        goto bad;

    if(bucket_create(&instance->aout_itf_bucket) != 0)
        goto bad;

    if(add_channels(self, 3) != 0)
        goto bad;

    {
        pthread_t thread;
        if(pthread_create(&thread, NULL, &api_main_loop, (void*)self) != 0)
            goto bad;
        instance->thread = thread;
    }

    pthread_detach( instance->thread );

good:
    return 0;

bad:

	if( instance->outputMix )
		(*instance->outputMix)->Destroy(instance->outputMix);

	if( instance->engineObject )
		(*instance->engineObject)->Destroy(instance->engineObject);

    if(instance->aout_itf_bucket) {
        close_all_channels(self);
        bucket_free(instance->aout_itf_bucket);
    }
    if(instance->cmd_pipe.write)
        close(instance->cmd_pipe.write);
    if(instance->cmd_pipe.read)
        close(instance->cmd_pipe.read);
    return -1;
}