diff options
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r-- | firmware/target/hosted/android/pcm-android.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/firmware/target/hosted/android/pcm-android.c b/firmware/target/hosted/android/pcm-android.c index 0428e5f541..0608e971a7 100644 --- a/firmware/target/hosted/android/pcm-android.c +++ b/firmware/target/hosted/android/pcm-android.c | |||
@@ -58,7 +58,6 @@ static inline void unlock_audio(void) | |||
58 | pthread_mutex_unlock(&audio_lock_mutex); | 58 | pthread_mutex_unlock(&audio_lock_mutex); |
59 | } | 59 | } |
60 | 60 | ||
61 | |||
62 | /* | 61 | /* |
63 | * write pcm samples to the hardware. Calls AudioTrack.write directly (which | 62 | * write pcm samples to the hardware. Calls AudioTrack.write directly (which |
64 | * is usually a blocking call) | 63 | * is usually a blocking call) |
@@ -93,18 +92,23 @@ Java_org_rockbox_RockboxPCM_nativeWrite(JNIEnv *env, jobject this, | |||
93 | (*env)->SetByteArrayRegion(env, temp_array, 0, | 92 | (*env)->SetByteArrayRegion(env, temp_array, 0, |
94 | transfer_size, (jbyte*)pcm_data_start); | 93 | transfer_size, (jbyte*)pcm_data_start); |
95 | 94 | ||
96 | ret = (*env)->CallIntMethod(env, this, write_method, | ||
97 | temp_array, 0, transfer_size); | ||
98 | |||
99 | if (new_buffer) | 95 | if (new_buffer) |
100 | { | 96 | { |
101 | new_buffer = false; | 97 | new_buffer = false; |
102 | pcm_play_dma_status_callback(PCM_DMAST_STARTED); | 98 | pcm_play_dma_status_callback(PCM_DMAST_STARTED); |
103 | |||
104 | /* NOTE: might need to release the mutex and sleep here if the | ||
105 | buffer is shorter than the required buffer (like pcm-sdl.c) to | ||
106 | have the mixer clocked at a regular interval */ | ||
107 | } | 99 | } |
100 | /* SetByteArrayRegion copies, which enables us to unlock audio. This | ||
101 | * is good because the below write() call almost certainly block. | ||
102 | * This allows the mixer to be clocked at a regular interval which vastly | ||
103 | * improves responsiveness when pausing/stopping playback */ | ||
104 | unlock_audio(); | ||
105 | ret = (*env)->CallIntMethod(env, this, write_method, | ||
106 | temp_array, 0, transfer_size); | ||
107 | lock_audio(); | ||
108 | |||
109 | /* check if still playing. might have changed during the write() call */ | ||
110 | if (!pcm_is_playing()) | ||
111 | break; | ||
108 | 112 | ||
109 | if (ret < 0) | 113 | if (ret < 0) |
110 | { | 114 | { |