comparison src/audio/android/SDL_androidaudio.c @ 4996:8d7315668e35

Fixed audio buffer lifecycle and implemented audio shutdown
author Sam Lantinga <slouken@libsdl.org>
date Thu, 13 Jan 2011 12:32:55 -0800
parents 9f9bea41e88f
children 327f181542f1
comparison
equal deleted inserted replaced
4995:9f9bea41e88f 4996:8d7315668e35
101 } 101 }
102 102
103 static void 103 static void
104 AndroidAUD_PlayDevice(_THIS) 104 AndroidAUD_PlayDevice(_THIS)
105 { 105 {
106 Android_JNI_WriteAudioBufferAndUnpin(); 106 Android_JNI_WriteAudioBuffer();
107 this->hidden->mixbuf = NULL;
108 } 107 }
109 108
110 static Uint8 * 109 static Uint8 *
111 AndroidAUD_GetDeviceBuf(_THIS) 110 AndroidAUD_GetDeviceBuf(_THIS)
112 { 111 {
113 if (this->hidden->mixbuf == NULL) { 112 return Android_JNI_GetAudioBuffer();
114 this->hidden->mixbuf = Android_JNI_PinAudioBuffer();
115 }
116 return this->hidden->mixbuf;
117 } 113 }
118 114
119 static void 115 static void
120 AndroidAUD_CloseDevice(_THIS) 116 AndroidAUD_CloseDevice(_THIS)
121 { 117 {
122 if (this->hidden != NULL) { 118 if (this->hidden != NULL) {
123 if (this->hidden->mixbuf != NULL) {
124 Android_JNI_WriteAudioBufferAndUnpin();
125 }
126 SDL_free(this->hidden); 119 SDL_free(this->hidden);
127 this->hidden = NULL; 120 this->hidden = NULL;
128 } 121 }
129 Android_JNI_CloseAudioDevice(); 122 Android_JNI_CloseAudioDevice();
130 123