diff options
author | Max Horn | 2009-02-15 22:34:41 +0000 |
---|---|---|
committer | Max Horn | 2009-02-15 22:34:41 +0000 |
commit | 29611bc7ead4d3d5fc9df63c04dd9e2577805557 (patch) | |
tree | 42d26aab7ab2e7e97fe5b4763281d8071d878eed /engines/sci/sfx/pcm_device | |
parent | 921e6ff5cf3944c1a62a3ad9a91c29bb21aa9942 (diff) | |
download | scummvm-rg350-29611bc7ead4d3d5fc9df63c04dd9e2577805557.tar.gz scummvm-rg350-29611bc7ead4d3d5fc9df63c04dd9e2577805557.tar.bz2 scummvm-rg350-29611bc7ead4d3d5fc9df63c04dd9e2577805557.zip |
SCI: Run astyle to make the code be more compliant with our Code Formatting Guidelines: sfx dir
svn-id: r38322
Diffstat (limited to 'engines/sci/sfx/pcm_device')
-rw-r--r-- | engines/sci/sfx/pcm_device/alsa.cpp | 52 | ||||
-rw-r--r-- | engines/sci/sfx/pcm_device/audbuf_test.cpp | 52 | ||||
-rw-r--r-- | engines/sci/sfx/pcm_device/audiobuf.cpp | 45 | ||||
-rw-r--r-- | engines/sci/sfx/pcm_device/pcm_devices.cpp | 27 | ||||
-rw-r--r-- | engines/sci/sfx/pcm_device/scummvm.cpp | 4 | ||||
-rw-r--r-- | engines/sci/sfx/pcm_device/sdl.cpp | 63 |
6 files changed, 103 insertions, 140 deletions
diff --git a/engines/sci/sfx/pcm_device/alsa.cpp b/engines/sci/sfx/pcm_device/alsa.cpp index 26d4c35044..4698d66478 100644 --- a/engines/sci/sfx/pcm_device/alsa.cpp +++ b/engines/sci/sfx/pcm_device/alsa.cpp @@ -44,7 +44,7 @@ static snd_pcm_format_t format = SND_PCM_FORMAT_S16; static unsigned int rate = 44100; /* FIXME */ static unsigned int channels = 2; /* FIXME */ static unsigned int buffer_time = 100000; /* FIXME */ -static unsigned int period_time = 1000000/60; /* 60Hz */ /* FIXME */ +static unsigned int period_time = 1000000 / 60; /* 60Hz */ /* FIXME */ static snd_pcm_sframes_t buffer_size; static snd_pcm_sframes_t period_size; @@ -64,8 +64,7 @@ static volatile byte run_thread; static pthread_mutex_t mutex; static int -xrun_recovery(snd_pcm_t *handle, int err) -{ +xrun_recovery(snd_pcm_t *handle, int err) { if (err == -EPIPE) { /* under-run */ err = snd_pcm_prepare(handle); if (err < 0) @@ -85,8 +84,7 @@ xrun_recovery(snd_pcm_t *handle, int err) } static void * -alsa_thread(void *arg) -{ +alsa_thread(void *arg) { gint16 *ptr; int err, cptr; guint8 *buf; @@ -130,22 +128,20 @@ alsa_thread(void *arg) } static sfx_timestamp_t -pcmout_alsa_output_timestamp(sfx_pcm_device_t *self) -{ +pcmout_alsa_output_timestamp(sfx_pcm_device_t *self) { /* Number of frames enqueued in the output device: */ int delta = (buffer_size - period_size) / frame_size - /* Number of frames enqueued in the internal audio buffer: */ - + audio_buffer.frames_nr; + /* Number of frames enqueued in the internal audio buffer: */ + + audio_buffer.frames_nr; return sfx_timestamp_add(sfx_new_timestamp(last_callback_secs, - last_callback_usecs, - rate), - delta); + last_callback_usecs, + rate), + delta); } static int -pcmout_alsa_init(sfx_pcm_device_t *self) -{ +pcmout_alsa_init(sfx_pcm_device_t *self) { unsigned int rrate; int err, dir; snd_pcm_hw_params_t *hwparams; @@ -195,7 +191,7 @@ pcmout_alsa_init(sfx_pcm_device_t *self) sciprintf("[SND:ALSA] Unable to set buffer time %i for playback: %s\n", buffer_time, snd_strerror(err)); return SFX_ERROR; } - err = snd_pcm_hw_params_get_buffer_size(hwparams, (snd_pcm_uframes_t*)&buffer_size); + err = snd_pcm_hw_params_get_buffer_size(hwparams, (snd_pcm_uframes_t*) & buffer_size); if (err < 0) { sciprintf("[SND:ALSA] Unable to get buffer size for playback: %s\n", snd_strerror(err)); return SFX_ERROR; @@ -205,7 +201,7 @@ pcmout_alsa_init(sfx_pcm_device_t *self) sciprintf("[SND:ALSA] Unable to set period time %i for playback: %s\n", period_time, snd_strerror(err)); return SFX_ERROR; } - err = snd_pcm_hw_params_get_period_size(hwparams, (snd_pcm_uframes_t*)&period_size, &dir); + err = snd_pcm_hw_params_get_period_size(hwparams, (snd_pcm_uframes_t*) & period_size, &dir); if (err < 0) { sciprintf("[SND:ALSA] Unable to get period size for playback: %s\n", snd_strerror(err)); return SFX_ERROR; @@ -270,8 +266,7 @@ pcmout_alsa_init(sfx_pcm_device_t *self) static int pcmout_alsa_output(sfx_pcm_device_t *self, byte *buf, - int count, sfx_timestamp_t *ts) -{ + int count, sfx_timestamp_t *ts) { if (ts) sfx_audbuf_write_timestamp(&audio_buffer, *ts); @@ -280,14 +275,12 @@ pcmout_alsa_output(sfx_pcm_device_t *self, byte *buf, } static int -pcmout_alsa_set_option(sfx_pcm_device_t *self, char *name, char *value) -{ +pcmout_alsa_set_option(sfx_pcm_device_t *self, char *name, char *value) { return SFX_ERROR; } static void -pcmout_alsa_exit(sfx_pcm_device_t *self) -{ +pcmout_alsa_exit(sfx_pcm_device_t *self) { int err; run_thread = 0; @@ -310,15 +303,13 @@ pcmout_alsa_exit(sfx_pcm_device_t *self) } static int -timer_alsa_set_option(char *name, char *value) -{ +timer_alsa_set_option(char *name, char *value) { return SFX_ERROR; } static int -timer_alsa_init(void (*callback)(void *data), void *data) -{ +timer_alsa_init(void (*callback)(void *data), void *data) { alsa_sfx_timer_callback = callback; alsa_sfx_timer_data = data; @@ -326,16 +317,14 @@ timer_alsa_init(void (*callback)(void *data), void *data) } static int -timer_alsa_stop(void) -{ +timer_alsa_stop(void) { alsa_sfx_timer_callback = NULL; return SFX_OK; } static int -timer_alsa_block(void) -{ +timer_alsa_block(void) { if (pthread_mutex_lock(&mutex) != 0) { fprintf(stderr, "[SND:ALSA] Failed to lock mutex\n"); return SFX_ERROR; @@ -345,8 +334,7 @@ timer_alsa_block(void) } static int -timer_alsa_unblock(void) -{ +timer_alsa_unblock(void) { if (pthread_mutex_unlock(&mutex) != 0) { fprintf(stderr, "[SND:ALSA] Failed to unlock mutex\n"); return SFX_ERROR; diff --git a/engines/sci/sfx/pcm_device/audbuf_test.cpp b/engines/sci/sfx/pcm_device/audbuf_test.cpp index 216aa9079e..08e8b2ad5e 100644 --- a/engines/sci/sfx/pcm_device/audbuf_test.cpp +++ b/engines/sci/sfx/pcm_device/audbuf_test.cpp @@ -36,12 +36,11 @@ sfx_audio_buf_t buf; void -tester_write(unsigned char *data, int datalen, int framesize, int gran) -{ +tester_write(unsigned char *data, int datalen, int framesize, int gran) { int i; for (i = 0; i < datalen; i += gran) { - int size = (i + gran < datalen)? gran : datalen - i; + int size = (i + gran < datalen) ? gran : datalen - i; sfx_audbuf_write(&buf, data + (i * framesize), framesize, size); } @@ -49,22 +48,21 @@ tester_write(unsigned char *data, int datalen, int framesize, int gran) void -tester_read(unsigned char *data, int datalen, int framesize, int gran) -{ +tester_read(unsigned char *data, int datalen, int framesize, int gran) { unsigned char *readdata = malloc(datalen * framesize); int i; for (i = 0; i < datalen; i += gran) { - int size = (i + gran < datalen)? gran : datalen - i; + int size = (i + gran < datalen) ? gran : datalen - i; int j; sfx_audbuf_read(&buf, readdata + (i * framesize), framesize, size); for (j = 0; j < gran * framesize; j++) { - int offset = i*framesize + j; + int offset = i * framesize + j; if (data[i] != readdata[i]) { fprintf(stderr, "[ERROR] Mismatch at offset %08x (sample #%d): Expected %02x, got %02x\n", - offset, i, readdata[i], data[i]); + offset, i, readdata[i], data[i]); } } } @@ -75,7 +73,7 @@ tester_read(unsigned char *data, int datalen, int framesize, int gran) void test1(unsigned char *data, int len) - /* Test the 'regular' case */ +/* Test the 'regular' case */ { int framesize; int stepsize; @@ -102,7 +100,7 @@ test1(unsigned char *data, int len) void test2(unsigned char *data, int framesize) - /* Test whether buffer underrun repeats are handled correctly */ +/* Test whether buffer underrun repeats are handled correctly */ { int i; unsigned char *src; @@ -123,7 +121,7 @@ test2(unsigned char *data, int framesize) for (j = 0; j < framesize; j++) if (src[j + offset] != data[j]) { fprintf(stderr, "[ERROR] At copy sample %d, frame %d, offset %d: Expected %02x, got %02x\n", - i, inst, j, data[j], src[j+offset]); + i, inst, j, data[j], src[j+offset]); } } memset(src, 0xbf, framesize * TEST2_LEN); @@ -141,21 +139,20 @@ test2(unsigned char *data, int framesize) #define CHUNK_LEN_2 16 #define CHUNK_LEN_3 40 -unsigned char test_data_0[CHUNK_LEN_0] = - { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; -unsigned char test_data_1[CHUNK_LEN_1] = - { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, - 0xff, 0x00, 0xff, 0x00}; -unsigned char test_data_2[CHUNK_LEN_2] = - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -unsigned char test_data_3[CHUNK_LEN_3] = - { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88 }; +unsigned char test_data_0[CHUNK_LEN_0] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; +unsigned char test_data_1[CHUNK_LEN_1] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, + 0xff, 0x00, 0xff, 0x00 + }; +unsigned char test_data_2[CHUNK_LEN_2] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; +unsigned char test_data_3[CHUNK_LEN_3] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88 + }; struct { int len; @@ -168,8 +165,7 @@ struct { }; int -main(int argc, char **argv) -{ +main(int argc, char **argv) { int i; sfx_audbuf_init(&buf); diff --git a/engines/sci/sfx/pcm_device/audiobuf.cpp b/engines/sci/sfx/pcm_device/audiobuf.cpp index fa23708ce4..15c5bb765b 100644 --- a/engines/sci/sfx/pcm_device/audiobuf.cpp +++ b/engines/sci/sfx/pcm_device/audiobuf.cpp @@ -36,8 +36,7 @@ buffer_underrun_status = NO_BUFFER_UNDERRUN; static sfx_audio_buf_chunk_t * -sfx_audbuf_alloc_chunk(void) -{ +sfx_audbuf_alloc_chunk(void) { sfx_audio_buf_chunk_t *ch = (sfx_audio_buf_chunk_t*)sci_malloc(sizeof(sfx_audio_buf_chunk_t)); ch->used = 0; ch->next = NULL; @@ -47,8 +46,7 @@ sfx_audbuf_alloc_chunk(void) } void -sfx_audbuf_init(sfx_audio_buf_t *buf, sfx_pcm_config_t pcm_conf) -{ +sfx_audbuf_init(sfx_audio_buf_t *buf, sfx_pcm_config_t pcm_conf) { int framesize = SFX_PCM_FRAME_SIZE(pcm_conf); byte silence[16]; int silencew = pcm_conf.format & ~SFX_PCM_FORMAT_LMASK; @@ -81,8 +79,7 @@ sfx_audbuf_init(sfx_audio_buf_t *buf, sfx_pcm_config_t pcm_conf) } static void -sfx_audbuf_free_chain(sfx_audio_buf_chunk_t *b) -{ +sfx_audbuf_free_chain(sfx_audio_buf_chunk_t *b) { while (b) { sfx_audio_buf_chunk_t *n = b->next; sci_free(b); @@ -91,8 +88,7 @@ sfx_audbuf_free_chain(sfx_audio_buf_chunk_t *b) } void -sfx_audbuf_free(sfx_audio_buf_t *buf) -{ +sfx_audbuf_free(sfx_audio_buf_t *buf) { sfx_audbuf_free_chain(buf->first); sfx_audbuf_free_chain(buf->unused); buf->first = buf->last = buf->unused = NULL; @@ -100,8 +96,7 @@ sfx_audbuf_free(sfx_audio_buf_t *buf) } void -sfx_audbuf_write(sfx_audio_buf_t *buf, unsigned char *src, int frames) -{ +sfx_audbuf_write(sfx_audio_buf_t *buf, unsigned char *src, int frames) { /* In here, we compute PER BYTE */ int data_left = buf->framesize * frames; @@ -147,7 +142,7 @@ sfx_audbuf_write(sfx_audio_buf_t *buf, unsigned char *src, int frames) buf->unused = buf_next_unused; } else /* Allocate */ buf->last->next = - sfx_audbuf_alloc_chunk(); + sfx_audbuf_alloc_chunk(); buf->last->prev = old; } @@ -174,13 +169,12 @@ sfx_audbuf_write(sfx_audio_buf_t *buf, unsigned char *src, int frames) #endif if (frames && (src - buf->framesize) != buf->last_frame) - /* Backup last frame, unless we're already filling from it */ + /* Backup last frame, unless we're already filling from it */ memcpy(buf->last_frame, src - buf->framesize, buf->framesize); } int -sfx_audbuf_read(sfx_audio_buf_t *buf, unsigned char *dest, int frames) -{ +sfx_audbuf_read(sfx_audio_buf_t *buf, unsigned char *dest, int frames) { int written = 0; if (frames <= 0) @@ -189,9 +183,9 @@ sfx_audbuf_read(sfx_audio_buf_t *buf, unsigned char *dest, int frames) if (buf->read_timestamp.secs >= 0) { /* Have a timestamp? Must update it! */ buf->read_timestamp = - sfx_timestamp_add(buf->read_timestamp, - frames); - + sfx_timestamp_add(buf->read_timestamp, + frames); + } buf->frames_nr -= frames; @@ -245,9 +239,9 @@ sfx_audbuf_read(sfx_audio_buf_t *buf, unsigned char *dest, int frames) written += rdframes; if (frames && - (!buf->first || buf->read_offset == buf->first->used)) { + (!buf->first || buf->read_offset == buf->first->used)) { fprintf(stderr, "Underrun by %d frames at %d\n", frames, - buf->read_timestamp.frame_rate); + buf->read_timestamp.frame_rate); /* Buffer underrun! */ if (!buffer_underrun_status == NO_BUFFER_UNDERRUN) { buffer_underrun_status = SAW_BUFFER_UNDERRUN; @@ -265,8 +259,7 @@ sfx_audbuf_read(sfx_audio_buf_t *buf, unsigned char *dest, int frames) #if 0 static void -_sfx_audbuf_rewind_stream(sfx_audio_buf_t *buf, int delta) -{ +_sfx_audbuf_rewind_stream(sfx_audio_buf_t *buf, int delta) { if (delta > buf->frames_nr) delta = buf->frames_nr; @@ -296,8 +289,7 @@ _sfx_audbuf_rewind_stream(sfx_audio_buf_t *buf, int delta) #endif void -sfx_audbuf_write_timestamp(sfx_audio_buf_t *buf, sfx_timestamp_t ts) -{ +sfx_audbuf_write_timestamp(sfx_audio_buf_t *buf, sfx_timestamp_t ts) { sfx_timestamp_t newstamp; newstamp = sfx_timestamp_add(ts, -buf->frames_nr); @@ -308,7 +300,7 @@ sfx_audbuf_write_timestamp(sfx_audio_buf_t *buf, sfx_timestamp_t ts) buf->read_timestamp = newstamp; else { int delta = sfx_timestamp_frame_diff(newstamp, buf->read_timestamp); - long s1,s2,s3,u1,u2,u3; + long s1, s2, s3, u1, u2, u3; sfx_timestamp_gettime(&(buf->read_timestamp), &s1, &u1); sfx_timestamp_gettime(&(newstamp), &s2, &u2); sfx_timestamp_gettime(&(ts), &s3, &u3); @@ -322,7 +314,7 @@ sfx_audbuf_write_timestamp(sfx_audio_buf_t *buf, sfx_timestamp_t ts) #endif } else if (delta > 0) { fprintf(stderr, "[SFX-BUF] audiobuf.c: Timestamp delta %d at %d: Filling in as silence frames\n", - delta, buf->read_timestamp.frame_rate); + delta, buf->read_timestamp.frame_rate); /* Fill up with silence */ while (delta--) { sfx_audbuf_write(buf, buf->last_frame, 1); @@ -333,8 +325,7 @@ sfx_audbuf_write_timestamp(sfx_audio_buf_t *buf, sfx_timestamp_t ts) } int -sfx_audbuf_read_timestamp(sfx_audio_buf_t *buf, sfx_timestamp_t *ts) -{ +sfx_audbuf_read_timestamp(sfx_audio_buf_t *buf, sfx_timestamp_t *ts) { if (buf->read_timestamp.secs > 0) { *ts = buf->read_timestamp; return 0; diff --git a/engines/sci/sfx/pcm_device/pcm_devices.cpp b/engines/sci/sfx/pcm_device/pcm_devices.cpp index 09e20bb07b..b8e5b51b39 100644 --- a/engines/sci/sfx/pcm_device/pcm_devices.cpp +++ b/engines/sci/sfx/pcm_device/pcm_devices.cpp @@ -39,16 +39,16 @@ extern sfx_pcm_device_t sfx_pcm_driver_dc; sfx_pcm_device_t *pcmout_drivers[] = { #ifndef NO_PCMOUT #ifdef SCUMMVM - &sfx_pcm_driver_scummvm, + &sfx_pcm_driver_scummvm, #else // SCUMMVM # ifdef HAVE_SDL - &sfx_pcm_driver_sdl, + &sfx_pcm_driver_sdl, # endif # ifdef HAVE_ALSA - &sfx_pcm_driver_alsa, + &sfx_pcm_driver_alsa, # endif # ifdef __DC__ - &sfx_pcm_driver_dc, + &sfx_pcm_driver_dc, # endif #endif // SCUMMVM #endif @@ -56,18 +56,17 @@ sfx_pcm_device_t *pcmout_drivers[] = { }; sfx_pcm_device_t * -sfx_pcm_find_device(char *name) -{ - int retval = 0; +sfx_pcm_find_device(char *name) { + int retval = 0; - if (!name) { /* Find default driver */ - return pcmout_drivers[0]; - } + if (!name) { /* Find default driver */ + return pcmout_drivers[0]; + } - while (pcmout_drivers[retval] && - strcasecmp(name, pcmout_drivers[retval]->name)) - retval++; + while (pcmout_drivers[retval] && + strcasecmp(name, pcmout_drivers[retval]->name)) + retval++; - return pcmout_drivers[retval]; + return pcmout_drivers[retval]; } diff --git a/engines/sci/sfx/pcm_device/scummvm.cpp b/engines/sci/sfx/pcm_device/scummvm.cpp index c66aa0706e..e6bb5f9c25 100644 --- a/engines/sci/sfx/pcm_device/scummvm.cpp +++ b/engines/sci/sfx/pcm_device/scummvm.cpp @@ -33,7 +33,7 @@ static void pcmout_scummvm_exit(sfx_pcm_device_t *self) { } static int pcmout_scummvm_output(sfx_pcm_device_t *self, byte *buf, int count, - sfx_timestamp_t *timestamp) { + sfx_timestamp_t *timestamp) { byte *__buf = new byte[count * pcmout_scummvm_framesize]; @@ -57,4 +57,4 @@ sfx_pcm_device_t sfx_pcm_driver_scummvm = { 0, NULL, NULL - }; +}; diff --git a/engines/sci/sfx/pcm_device/sdl.cpp b/engines/sci/sfx/pcm_device/sdl.cpp index bd125835cb..c4c47ed2a1 100644 --- a/engines/sci/sfx/pcm_device/sdl.cpp +++ b/engines/sci/sfx/pcm_device/sdl.cpp @@ -46,24 +46,22 @@ static long last_callback_secs, last_callback_usecs; static int last_callback_len; static sfx_timestamp_t -pcmout_sdl_output_timestamp(sfx_pcm_device_t *self) -{ +pcmout_sdl_output_timestamp(sfx_pcm_device_t *self) { /* Number of frames enqueued in the output device: */ int delta = (buf_size - last_callback_len) / frame_size - /* Number of frames enqueued in the internal audio buffer: */ - + audio_buffer.frames_nr; + /* Number of frames enqueued in the internal audio buffer: */ + + audio_buffer.frames_nr; return sfx_timestamp_add(sfx_new_timestamp(last_callback_secs, - last_callback_usecs, - rate), - delta); + last_callback_usecs, + rate), + delta); } FILE *fil = NULL; static void -timer_sdl_internal_callback(void *userdata, byte *dest, int len) -{ +timer_sdl_internal_callback(void *userdata, byte *dest, int len) { sci_gettime(&last_callback_secs, &last_callback_usecs); last_callback_len = len; @@ -83,12 +81,12 @@ timer_sdl_internal_callback(void *userdata, byte *dest, int len) deltatime = sfx_timestamp_usecs_diff(ts, real_ts); fprintf(stderr, "[SDL] Frames requested: %d Playing %ld too late. Needed %ldus for computations.\n", - len / frame_size, deltatime, - (usec2-usec) + (sec2-sec)*1000000); + len / frame_size, deltatime, + (usec2 - usec) + (sec2 - sec)*1000000); if (abs(deltatime) > DELTA_TIME_LIMIT) sciprintf("[SND:SDL] Very high delta time for PCM playback: %ld too late (%d frames in the future)\n", - deltatime, sfx_timestamp_frame_diff(sfx_new_timestamp(sec, usec, rate), ts)); + deltatime, sfx_timestamp_frame_diff(sfx_new_timestamp(sec, usec, rate), ts)); #if 0 if (deltatime < 0) { @@ -97,7 +95,7 @@ timer_sdl_internal_callback(void *userdata, byte *dest, int len) int frames_to_kill = sfx_timestamp_frame_diff(real_ts, ts); while (frames_to_kill) { - int d = frames_to_kill > max_read? max_read : frames_to_kill; + int d = frames_to_kill > max_read ? max_read : frames_to_kill; sfx_audbuf_read(&audio_buffer, dest, d); frames_to_kill -= d; } @@ -126,12 +124,11 @@ timer_sdl_internal_callback(void *userdata, byte *dest, int len) static int -pcmout_sdl_init(sfx_pcm_device_t *self) -{ +pcmout_sdl_init(sfx_pcm_device_t *self) { SDL_AudioSpec a; - if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_NOPARACHUTE) != 0) { - fprintf (stderr, "[SND:SDL] Error while initialising: %s\n", SDL_GetError()); + if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE) != 0) { + fprintf(stderr, "[SND:SDL] Error while initialising: %s\n", SDL_GetError()); return -1; } @@ -146,8 +143,8 @@ pcmout_sdl_init(sfx_pcm_device_t *self) a.callback = timer_sdl_internal_callback; a.userdata = NULL; - if (SDL_OpenAudio (&a, NULL) < 0) { - fprintf (stderr, "[SND:SDL] Error while opening audio: %s\n", SDL_GetError()); + if (SDL_OpenAudio(&a, NULL) < 0) { + fprintf(stderr, "[SND:SDL] Error while opening audio: %s\n", SDL_GetError()); return SFX_ERROR; } @@ -162,15 +159,14 @@ pcmout_sdl_init(sfx_pcm_device_t *self) frame_size = SFX_PCM_FRAME_SIZE(self->conf); sfx_audbuf_init(&audio_buffer, self->conf); - SDL_PauseAudio (0); + SDL_PauseAudio(0); return SFX_OK; } int pcmout_sdl_output(sfx_pcm_device_t *self, byte *buf, - int count, sfx_timestamp_t *ts) -{ + int count, sfx_timestamp_t *ts) { if (ts) sfx_audbuf_write_timestamp(&audio_buffer, *ts); sfx_audbuf_write(&audio_buffer, buf, count); @@ -179,15 +175,13 @@ pcmout_sdl_output(sfx_pcm_device_t *self, byte *buf, static int -pcmout_sdl_set_option(sfx_pcm_device_t *self, char *name, char *value) -{ +pcmout_sdl_set_option(sfx_pcm_device_t *self, char *name, char *value) { return SFX_ERROR; /* Option not supported */ } static void -pcmout_sdl_exit(sfx_pcm_device_t *self) -{ - SDL_PauseAudio (1); +pcmout_sdl_exit(sfx_pcm_device_t *self) { + SDL_PauseAudio(1); SDL_CloseAudio(); sfx_audbuf_free(&audio_buffer); @@ -201,15 +195,13 @@ pcmout_sdl_exit(sfx_pcm_device_t *self) static int -timer_sdl_set_option(char *name, char *value) -{ +timer_sdl_set_option(char *name, char *value) { return SFX_ERROR; } static int -timer_sdl_init(void (*callback)(void *data), void *data) -{ +timer_sdl_init(void (*callback)(void *data), void *data) { sdl_sfx_timer_callback = callback; sdl_sfx_timer_data = data; @@ -218,24 +210,21 @@ timer_sdl_init(void (*callback)(void *data), void *data) } static int -timer_sdl_stop(void) -{ +timer_sdl_stop(void) { sdl_sfx_timer_callback = NULL; return SFX_OK; } static int -timer_sdl_block(void) -{ +timer_sdl_block(void) { SDL_LockAudio(); return SFX_OK; } static int -timer_sdl_unblock(void) -{ +timer_sdl_unblock(void) { SDL_UnlockAudio(); return SFX_OK; |