diff options
Diffstat (limited to 'platform/bb10/audio_driver_bb10.cpp')
-rw-r--r-- | platform/bb10/audio_driver_bb10.cpp | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/platform/bb10/audio_driver_bb10.cpp b/platform/bb10/audio_driver_bb10.cpp index b6ea0bc267..5416fc5f02 100644 --- a/platform/bb10/audio_driver_bb10.cpp +++ b/platform/bb10/audio_driver_bb10.cpp @@ -34,11 +34,11 @@ Error AudioDriverBB10::init() { return init(NULL); }; -Error AudioDriverBB10::init(const char* p_name) { +Error AudioDriverBB10::init(const char *p_name) { - active=false; - thread_exited=false; - exit_thread=false; + active = false; + thread_exited = false; + exit_thread = false; pcm_open = false; samples_in = NULL; samples_out = NULL; @@ -46,11 +46,11 @@ Error AudioDriverBB10::init(const char* p_name) { mix_rate = 44100; speaker_mode = SPEAKER_MODE_STEREO; - char* dev_name; + char *dev_name; if (p_name == NULL) { dev_name = "pcmPreferred"; } else { - dev_name = (char *) p_name; + dev_name = (char *)p_name; } printf("******** reconnecting to device %s\n", dev_name); int ret = snd_pcm_open_name(&pcm_handle, dev_name, SND_PCM_OPEN_PLAYBACK); @@ -58,7 +58,7 @@ Error AudioDriverBB10::init(const char* p_name) { pcm_open = true; snd_pcm_channel_info_t cinfo; - zeromem(&cinfo, sizeof (cinfo)); + zeromem(&cinfo, sizeof(cinfo)); cinfo.channel = SND_PCM_CHANNEL_PLAYBACK; snd_pcm_plugin_info(pcm_handle, &cinfo); @@ -117,9 +117,9 @@ Error AudioDriverBB10::init(const char* p_name) { return OK; }; -void AudioDriverBB10::thread_func(void* p_udata) { +void AudioDriverBB10::thread_func(void *p_udata) { - AudioDriverBB10* ad = (AudioDriverBB10*)p_udata; + AudioDriverBB10 *ad = (AudioDriverBB10 *)p_udata; int channels = speaker_mode; int frame_count = ad->sample_buf_count / channels; @@ -127,10 +127,9 @@ void AudioDriverBB10::thread_func(void* p_udata) { while (!ad->exit_thread) { - if (!ad->active) { - for (int i=0; i < ad->sample_buf_count; i++) { + for (int i = 0; i < ad->sample_buf_count; i++) { ad->samples_out[i] = 0; }; @@ -142,20 +141,19 @@ void AudioDriverBB10::thread_func(void* p_udata) { ad->unlock(); - for(int i=0;i<frame_count*channels;i++) { + for (int i = 0; i < frame_count * channels; i++) { - ad->samples_out[i]=ad->samples_in[i]>>16; + ad->samples_out[i] = ad->samples_in[i] >> 16; } }; - int todo = bytes_out; int total = 0; while (todo) { - uint8_t* src = (uint8_t*)ad->samples_out; - int wrote = snd_pcm_plugin_write(ad->pcm_handle, (void*)(src + total), todo); + uint8_t *src = (uint8_t *)ad->samples_out; + int wrote = snd_pcm_plugin_write(ad->pcm_handle, (void *)(src + total), todo); if (wrote < 0) { // error? break; @@ -179,7 +177,7 @@ void AudioDriverBB10::thread_func(void* p_udata) { break; }; if (status.status == SND_PCM_STATUS_READY || - status.status == SND_PCM_STATUS_UNDERRUN) { + status.status == SND_PCM_STATUS_UNDERRUN) { snd_pcm_plugin_prepare(ad->pcm_handle, SND_PCM_CHANNEL_PLAYBACK); } else { break; @@ -188,9 +186,9 @@ void AudioDriverBB10::thread_func(void* p_udata) { }; }; - snd_pcm_plugin_flush (ad->pcm_handle, SND_PCM_CHANNEL_PLAYBACK); + snd_pcm_plugin_flush(ad->pcm_handle, SND_PCM_CHANNEL_PLAYBACK); - ad->thread_exited=true; + ad->thread_exited = true; printf("**************** audio thread exit\n"); }; @@ -253,4 +251,3 @@ AudioDriverBB10::~AudioDriverBB10() { memdelete(mutex); mutex = NULL; }; - |