aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES.TXT38
-rw-r--r--android/android.h2
-rw-r--r--android/avd/hardware-properties.ini12
-rw-r--r--android/avd/hw-config-defs.h14
-rw-r--r--android/avd/info.c15
-rw-r--r--android/avd/info.h5
-rw-r--r--android/build/common.sh12
-rw-r--r--android/charmap.h2
-rw-r--r--android/main.c148
-rw-r--r--audio/esdaudio.c339
-rwxr-xr-xdistrib/update-audio.sh23
11 files changed, 308 insertions, 302 deletions
diff --git a/CHANGES.TXT b/CHANGES.TXT
index 8f276d4..f04d275 100644
--- a/CHANGES.TXT
+++ b/CHANGES.TXT
@@ -14,7 +14,43 @@ Versions:
1.8 => SDK 1.1
1.9 => SDK 1.5_r1 (and SDK 1.5_r2)
1.10 => SDK 1.5_r3
- 1.11 => current
+ 1.11 => SDK 1.6_r1
+ 1.12 => current
+
+==============================================================================
+Changes between 1.12 and 1.11
+
+IMPORTANT BUG FIXES:
+
+- Fixed a nasty race condition in the Linux EsounD audio backend which resulted
+ in rare lockups when stopping the emulator on this platform.
+
+- The key-bindings for the Menu button (F2 and PageUp by default) didn't work
+ due to a typo.
+
+OTHER:
+
+- Added two new hardware properties disk.systemPartition.size and
+ disk.dataPartition.size to specify the size of the system and data partition
+ in a given AVD.
+
+ If the emulator detects that an image file is larger than the corresponding
+ setting, it will do the following:
+
+ - for AVDs running from the SDK, an error message will be printed and
+ the emulator aborts. Note that this can only happen if there are some
+ serious mis-configuration of AVDs anyway.
+
+ - when launching the emulator from the Android build system, a warning
+ will be printed, and the partition size will be automatically adjusted
+ at launch.
+
+ Previously, trying to launch an over-sized system image would result in the
+ emulated system booting, but then failing to find certain files, depending on
+ how the yaffs2 disk images are built. This caused hard-to-debug issues.
+
+ Note that the option -partition-size <size> can be used to override the AVD's
+ setting at runtime.
==============================================================================
Changes between 1.11 and 1.10
diff --git a/android/android.h b/android/android.h
index 6d23e6e..6d092fd 100644
--- a/android/android.h
+++ b/android/android.h
@@ -13,7 +13,7 @@
#define _qemu_android_h
#define ANDROID_VERSION_MAJOR 1
-#define ANDROID_VERSION_MINOR 11
+#define ANDROID_VERSION_MINOR 12
#define CONFIG_SHAPER 1
diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini
index c655100..09486d2 100644
--- a/android/avd/hardware-properties.ini
+++ b/android/avd/hardware-properties.ini
@@ -124,6 +124,18 @@ default = yes
abstract = SD Card support
description = Whether the device supports insertion/removal of virtual SD Cards.
+# System partition
+name = disk.systemPartition.size
+type = diskSize
+abstract = System partition size
+default = 66MB
+
+# Data partition
+name = disk.dataPartition.size
+type = diskSize
+abstract = Data partition size
+default = 66MB
+
# Cache partition
name = disk.cachePartition
type = boolean
diff --git a/android/avd/hw-config-defs.h b/android/avd/hw-config-defs.h
index 7fcf732..67bd3d3 100644
--- a/android/avd/hw-config-defs.h
+++ b/android/avd/hw-config-defs.h
@@ -122,6 +122,20 @@ HWCFG_BOOL(
"SD Card support",
"Whether the device supports insertion/removal of virtual SD Cards.")
+HWCFG_DISKSIZE(
+ disk_systemPartition_size,
+ "disk.systemPartition.size",
+ "66MB",
+ "System partition size",
+ "")
+
+HWCFG_DISKSIZE(
+ disk_dataPartition_size,
+ "disk.dataPartition.size",
+ "66MB",
+ "Data partition size",
+ "")
+
HWCFG_BOOL(
disk_cachePartition,
"disk.cachePartition",
diff --git a/android/avd/info.c b/android/avd/info.c
index 1bdb59c..10e2005 100644
--- a/android/avd/info.c
+++ b/android/avd/info.c
@@ -1358,6 +1358,21 @@ avdInfo_getImageFile( AvdInfo* i, AvdImageType imageType )
return i->imagePath[imageType];
}
+uint64_t
+avdInfo_getImageFileSize( AvdInfo* i, AvdImageType imageType )
+{
+ const char* file = avdInfo_getImageFile(i, imageType);
+ uint64_t size;
+
+ if (file == NULL)
+ return 0ULL;
+
+ if (path_get_size(file, &size) < 0)
+ return 0ULL;
+
+ return size;
+}
+
int
avdInfo_isImageReadOnly( AvdInfo* i, AvdImageType imageType )
{
diff --git a/android/avd/info.h b/android/avd/info.h
index 6cd97dc..19df807 100644
--- a/android/avd/info.h
+++ b/android/avd/info.h
@@ -131,6 +131,11 @@ const char* avdInfo_getName( AvdInfo* i );
*/
const char* avdInfo_getImageFile( AvdInfo* i, AvdImageType imageType );
+/* Return the size of a given image file. Returns 0 if the file
+ * does not exist or could not be accessed.
+ */
+uint64_t avdInfo_getImageFileSize( AvdInfo* i, AvdImageType imageType );
+
/* Returns 1 if the corresponding image file is read-only
*/
int avdInfo_isImageReadOnly( AvdInfo* i, AvdImageType imageType );
diff --git a/android/build/common.sh b/android/build/common.sh
index b22ef7d..3f2c642 100644
--- a/android/build/common.sh
+++ b/android/build/common.sh
@@ -444,18 +444,6 @@ locate_android_prebuilt ()
{
# locate prebuilt directory
ANDROID_PREBUILT_HOST_TAG=$OS
- case $OS in
- linux-*)
- # Linux is a special case because in the old tree layout
- # we simply used 'Linux' as the prebuilt host tag, but
- # are now using "linux-x86" in the new layout
- # check which one should be used
- #
- if [ -d $ANDROID_TOP/prebuilt/Linux ] ; then
- PREBUILT_HOST_TAG=Linux
- fi
- ;;
- esac
ANDROID_PREBUILT=$ANDROID_TOP/prebuilt/$ANDROID_PREBUILT_HOST_TAG
if [ ! -d $ANDROID_PREBUILT ] ; then
# this can happen when building on x86_64
diff --git a/android/charmap.h b/android/charmap.h
index 367e730..2b0d071 100644
--- a/android/charmap.h
+++ b/android/charmap.h
@@ -98,7 +98,7 @@ typedef enum {
kKeyCodeHeadsetHook = KEY_HEADSETHOOK,
kKeyCodeFocus = KEY_FOCUS,
kKeyCodePlus = KEY_PLUS,
- kKeyCodeMenu = KEY_MENU,
+ kKeyCodeMenu = KEY_SOFT1,
kKeyCodeNotification = KEY_NOTIFICATION,
kKeyCodeSearch = KEY_SEARCH,
diff --git a/android/main.c b/android/main.c
index 6888d44..104b344 100644
--- a/android/main.c
+++ b/android/main.c
@@ -234,6 +234,25 @@ sdl_set_window_icon( void )
}
+#define ONE_MB (1024*1024)
+
+unsigned convertBytesToMB( uint64_t size )
+{
+ if (size == 0)
+ return 0;
+
+ size = (size + ONE_MB-1) >> 20;
+ if (size > UINT_MAX)
+ size = UINT_MAX;
+
+ return (unsigned) size;
+}
+
+uint64_t convertMBToBytes( unsigned megaBytes )
+{
+ return ((uint64_t)megaBytes << 20);
+}
+
/***********************************************************************/
/***********************************************************************/
/***** *****/
@@ -1721,6 +1740,38 @@ _forceAvdImagePath( AvdImageType imageType,
android_avdParams->forcePaths[imageType] = path;
}
+static uint64_t
+_adjustPartitionSize( const char* description,
+ uint64_t imageBytes,
+ uint64_t defaultBytes,
+ int inAndroidBuild )
+{
+ char temp[64];
+ unsigned imageMB;
+ unsigned defaultMB;
+
+ if (imageBytes <= defaultBytes)
+ return defaultBytes;
+
+ imageMB = convertBytesToMB(imageBytes);
+ defaultMB = convertBytesToMB(defaultBytes);
+
+ if (imageMB > defaultMB) {
+ snprintf(temp, sizeof temp, "(%d MB > %d MB)", imageMB, defaultMB);
+ } else {
+ snprintf(temp, sizeof temp, "(%lld bytes > %lld bytes)", imageBytes, defaultBytes);
+ }
+
+ if (!inAndroidBuild) {
+ derror("%s image file too large for device's hardware configuration %s.\n"
+ "Aborting !", description, temp);
+ exit(1);
+ }
+ dwarning("%s partition size adjusted to match image file %s\n", description, temp);
+
+ return convertMBToBytes(imageMB);
+}
+
#ifdef _WIN32
#undef main /* we don't want SDL to define main */
#endif
@@ -1740,9 +1791,12 @@ int main(int argc, char **argv)
int shell_serial = 0;
int dns_count = 0;
unsigned cachePartitionSize = 0;
- unsigned defaultPartitionSize = 0x4200000;
+ unsigned systemPartitionSize = 0;
+ unsigned dataPartitionSize = 0;
+ unsigned defaultPartitionSize = convertBytesToMB(66);
AndroidHwConfig* hw;
+ AvdInfo* avd;
//const char *appdir = get_app_dir();
char* android_build_root = NULL;
@@ -1760,8 +1814,8 @@ int main(int argc, char **argv)
opt = (++argv)[0];
if(!strcmp(opt, "-qemu")) {
- ++argv;
- --argc;
+ argc--;
+ argv++;
break;
}
@@ -2058,9 +2112,11 @@ int main(int argc, char **argv)
}
}
+ avd = android_avdInfo;
+
/* get the skin from the virtual device configuration */
- opts->skin = (char*) avdInfo_getSkinName( android_avdInfo );
- opts->skindir = (char*) avdInfo_getSkinDir( android_avdInfo );
+ opts->skin = (char*) avdInfo_getSkinName( avd );
+ opts->skindir = (char*) avdInfo_getSkinDir( avd );
if (opts->skin) {
D("autoconfig: -skin %s", opts->skin);
@@ -2071,7 +2127,7 @@ int main(int argc, char **argv)
/* Read hardware configuration */
hw = android_hw;
- if (avdInfo_getHwConfig(android_avdInfo, hw) < 0) {
+ if (avdInfo_getHwConfig(avd, hw) < 0) {
derror("could not read hardware configuration ?");
exit(1);
}
@@ -2203,7 +2259,7 @@ int main(int argc, char **argv)
}
if (opts->trace) {
- char* tracePath = avdInfo_getTracePath(android_avdInfo, opts->trace);
+ char* tracePath = avdInfo_getTracePath(avd, opts->trace);
int ret;
if (tracePath == NULL) {
@@ -2265,38 +2321,84 @@ int main(int argc, char **argv)
n = 1;
/* generate arguments for the underlying qemu main() */
args[n++] = "-kernel";
- args[n++] = (char*) avdInfo_getImageFile(android_avdInfo, AVD_IMAGE_KERNEL);
+ args[n++] = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_KERNEL);
args[n++] = "-initrd";
- args[n++] = (char*) avdInfo_getImageFile(android_avdInfo, AVD_IMAGE_RAMDISK);
+ args[n++] = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_RAMDISK);
if (opts->partition_size) {
char* end;
- long size = strtol(opts->partition_size, &end, 0);
- long maxSize = LONG_MAX / (1024*1024);
- long defaultMB = (defaultPartitionSize + (512*1024)) / (1024*1024);
+ long sizeMB = strtol(opts->partition_size, &end, 0);
+ long minSizeMB = 10;
+ long maxSizeMB = LONG_MAX / ONE_MB;
- if (size < 0 || *end != 0) {
+ if (sizeMB < 0 || *end != 0) {
derror( "-partition-size must be followed by a positive integer" );
exit(1);
}
- if (size < defaultMB || size > maxSize) {
+ if (sizeMB < minSizeMB || sizeMB > maxSizeMB) {
derror( "partition-size (%d) must be between %dMB and %dMB",
- size, defaultMB, maxSize );
+ sizeMB, minSizeMB, maxSizeMB );
exit(1);
}
- defaultPartitionSize = size * 1024*1024;
+ defaultPartitionSize = sizeMB * ONE_MB;
+ }
+
+ /* Check the size of the system partition image.
+ * If we have an AVD, it must be smaller than
+ * the disk.systemPartition.size hardware property.
+ *
+ * Otherwise, we need to adjust the systemPartitionSize
+ * automatically, and print a warning.
+ *
+ */
+ {
+ uint64_t systemBytes = avdInfo_getImageFileSize(avd, AVD_IMAGE_INITSYSTEM);
+ uint64_t defaultBytes = hw->disk_systemPartition_size;
+
+ if (defaultBytes == 0 || opts->partition_size)
+ defaultBytes = defaultPartitionSize;
+
+ systemPartitionSize = _adjustPartitionSize("system", systemBytes, defaultBytes,
+ android_build_out != NULL);
+ }
+
+ /* Check the size of the /data partition. The only interesting cases here are:
+ * - when the USERDATA image already exists and is larger than the deffault
+ * - when we're wiping data and the INITDATA is larger than the default.
+ */
+
+ {
+ const char* dataPath = avdInfo_getImageFile(avd, AVD_IMAGE_USERDATA);
+ uint64_t defaultBytes = hw->disk_dataPartition_size;
+
+ if (defaultBytes == 0 || opts->partition_size)
+ defaultBytes = defaultPartitionSize;
+
+ if (dataPath == NULL || !path_exists(dataPath) || opts->wipe_data) {
+ dataPath = avdInfo_getImageFile(avd, AVD_IMAGE_INITDATA);
+ }
+ if (dataPath == NULL || !path_exists(dataPath)) {
+ dataPartitionSize = defaultBytes;
+ }
+ else {
+ uint64_t dataBytes;
+ path_get_size(dataPath, &dataBytes);
+
+ dataPartitionSize = _adjustPartitionSize("data", dataBytes, defaultBytes,
+ android_build_out != NULL);
+ }
}
{
const char* filetype = "file";
- if (avdInfo_isImageReadOnly(android_avdInfo, AVD_IMAGE_INITSYSTEM))
+ if (avdInfo_isImageReadOnly(avd, AVD_IMAGE_INITSYSTEM))
filetype = "initfile";
bufprint(tmp, tmpend,
- "system,size=0x%x,%s=%s", defaultPartitionSize, filetype,
- avdInfo_getImageFile(android_avdInfo, AVD_IMAGE_INITSYSTEM));
+ "system,size=0x%x,%s=%s", systemPartitionSize, filetype,
+ avdInfo_getImageFile(avd, AVD_IMAGE_INITSYSTEM));
args[n++] = "-nand";
args[n++] = strdup(tmp);
@@ -2304,14 +2406,14 @@ int main(int argc, char **argv)
bufprint(tmp, tmpend,
"userdata,size=0x%x,file=%s",
- defaultPartitionSize,
- avdInfo_getImageFile(android_avdInfo, AVD_IMAGE_USERDATA));
+ dataPartitionSize,
+ avdInfo_getImageFile(avd, AVD_IMAGE_USERDATA));
args[n++] = "-nand";
args[n++] = strdup(tmp);
if (hw->disk_cachePartition) {
- opts->cache = (char*) avdInfo_getImageFile(android_avdInfo, AVD_IMAGE_CACHE);
+ opts->cache = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_CACHE);
cachePartitionSize = hw->disk_cachePartition_size;
}
else if (opts->cache) {
@@ -2334,7 +2436,7 @@ int main(int argc, char **argv)
}
if (hw->hw_sdCard != 0)
- opts->sdcard = (char*) avdInfo_getImageFile(android_avdInfo, AVD_IMAGE_SDCARD);
+ opts->sdcard = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_SDCARD);
else if (opts->sdcard) {
dwarning( "Emulated hardware doesn't support SD Cards" );
opts->sdcard = NULL;
diff --git a/audio/esdaudio.c b/audio/esdaudio.c
index 2226022..a06176e 100644
--- a/audio/esdaudio.c
+++ b/audio/esdaudio.c
@@ -1,7 +1,7 @@
/*
* QEMU ESD audio driver
*
- * Copyright (c) 2008 The Android Open Source Project
+ * Copyright (c) 2008-2009 The Android Open Source Project
* Copyright (c) 2006 Frederick Reeve (brushed up by malc)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -29,7 +29,6 @@
#define AUDIO_CAP "esd"
#include "audio_int.h"
-#include "audio_pt_int.h"
#include <dlfcn.h>
#include "qemu_debug.h"
@@ -60,7 +59,6 @@ typedef struct {
int rpos;
void *pcm_buf;
int fd;
- struct audio_pt pt;
} ESDVoiceOut;
typedef struct {
@@ -71,7 +69,6 @@ typedef struct {
int wpos;
void *pcm_buf;
int fd;
- struct audio_pt pt;
} ESDVoiceIn;
static struct {
@@ -112,128 +109,50 @@ static void GCC_FMT_ATTR (2, 3) qesd_logerr (int err, const char *fmt, ...)
AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err));
}
-/* playback */
-static void *qesd_thread_out (void *arg)
+static int qesd_run_out (HWVoiceOut *hw)
{
- ESDVoiceOut* esd = arg;
- HWVoiceOut* hw = &esd->hw;
- int threshold;
- sigset_t set;
-
- threshold = conf.divisor ? hw->samples / conf.divisor : 0;
-
- if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) {
- return NULL;
- }
-
- /* ignore SIGALRM in this thread */
- sigemptyset(&set);
- sigaddset(&set, SIGALRM);
-
- pthread_sigmask( SIG_BLOCK, &set, NULL);
-
- O("EsounD output thread starting, threshold is %d samples", threshold);
- for (;;) {
- int decr, to_mix, rpos;
-
- for (;;) {
- if (esd->done) {
- goto exit;
- }
-
- if (esd->live > threshold) {
- break;
- }
-
- if (audio_pt_wait (&esd->pt, AUDIO_FUNC)) {
- O("EsounD output thread aborting on wait error");
- goto exit;
- }
- }
-
- decr = to_mix = esd->live;
- rpos = hw->rpos;
-
- if (audio_pt_unlock (&esd->pt, AUDIO_FUNC)) {
- O("EsounD output thread aborting on unlock error");
- return NULL;
- }
-
- while (to_mix) {
- ssize_t written;
- int chunk = audio_MIN (to_mix, hw->samples - rpos);
- st_sample_t *src = hw->mix_buf + rpos;
-
- hw->clip (esd->pcm_buf, src, chunk);
-
- again:
- written = write (esd->fd, esd->pcm_buf, chunk << hw->info.shift);
- if (written == -1) {
- if (errno == EINTR || errno == EAGAIN) {
- goto again;
- }
- qesd_logerr (errno, "write failed\n");
- O("EsounD output thread aborting on write error: %s", strerror(errno));
- return NULL;
- }
-
- if (written != chunk << hw->info.shift) {
- int wsamples = written >> hw->info.shift;
- int wbytes = wsamples << hw->info.shift;
- if (wbytes != written) {
- dolog ("warning: Misaligned write %d (requested %d), "
- "alignment %d\n",
- wbytes, written, hw->info.align + 1);
- }
- to_mix -= wsamples;
- rpos = (rpos + wsamples) % hw->samples;
+ ESDVoiceOut *esd = (ESDVoiceOut *) hw;
+ int liveSamples, totalSamples;
+ int rpos, nwrite, writeSamples, writeBytes;
+
+ liveSamples = audio_pcm_hw_get_live_out (hw);
+ rpos = hw->rpos;
+ totalSamples = 0;
+
+ while (liveSamples > 0) {
+ int chunkSamples = audio_MIN (liveSamples, hw->samples - rpos);
+ int chunkBytes = chunkSamples << hw->info.shift;
+ st_sample_t *src = hw->mix_buf + rpos;
+
+ hw->clip (esd->pcm_buf, src, chunkSamples);
+
+ AGAIN:
+ nwrite = write (esd->fd, esd->pcm_buf, chunkBytes);
+ if (nwrite == -1) {
+ if (errno == EINTR)
+ goto AGAIN;
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
break;
- }
-
- rpos = (rpos + chunk) % hw->samples;
- to_mix -= chunk;
+ qesd_logerr (errno, "write failed: %s\n", strerror(errno));
+ O("EsounD output thread write error: %s", strerror(errno));
+ break;
}
-
- if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) {
- O("EsounD output thread aborting on lock error\n");
- return NULL;
+ if (nwrite == 0)
+ break;
+
+ writeSamples = nwrite >> hw->info.shift;
+ writeBytes = writeSamples << hw->info.shift;
+ if (writeSamples != writeBytes) {
+ dolog ("warning: Misaligned write %d (requested %d), "
+ "alignment %d\n",
+ nwrite, writeBytes, hw->info.align + 1);
}
-
- esd->rpos = rpos;
- esd->live -= decr;
- esd->decr += decr;
+ rpos = (rpos + writeSamples) % hw->samples;
+ totalSamples += writeSamples;
+ liveSamples -= writeSamples;
}
- O("EsounD output thread exiting");
-
- exit:
- audio_pt_unlock (&esd->pt, AUDIO_FUNC);
- return NULL;
-}
-
-static int qesd_run_out (HWVoiceOut *hw)
-{
- int live, decr;
- ESDVoiceOut *esd = (ESDVoiceOut *) hw;
-
- if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) {
- O("%s: exiting on lock error", __FUNCTION__);
- return 0;
- }
-
- live = audio_pcm_hw_get_live_out (hw);
- decr = audio_MIN (live, esd->decr);
- esd->decr -= decr;
- esd->live = live - decr;
- hw->rpos = esd->rpos;
- if (esd->live > 0) {
- O("%s: signaling %d samples\n", __FUNCTION__, esd->live);
- audio_pt_unlock_and_signal (&esd->pt, AUDIO_FUNC);
- }
- else {
- O(".");
- audio_pt_unlock (&esd->pt, AUDIO_FUNC);
- }
- return decr;
+ hw->rpos = rpos;
+ return totalSamples;
}
static int qesd_write (SWVoiceOut *sw, void *buf, int len)
@@ -300,20 +219,15 @@ static int qesd_init_out (HWVoiceOut *hw, audsettings_t *as)
}
}
- if (audio_pt_init (&esd->pt, qesd_thread_out, esd, AUDIO_CAP, AUDIO_FUNC)) {
- goto fail3;
+ {
+ int flags;
+ flags = fcntl(esd->fd, F_GETFL);
+ fcntl(esd->fd, F_SETFL, flags | O_NONBLOCK);
}
result = 0; /* success */
goto exit;
- fail3:
- if (close (esd->fd)) {
- qesd_logerr (errno, "%s: close on esd socket(%d) failed\n",
- AUDIO_FUNC, esd->fd);
- }
- esd->fd = -1;
-
fail2:
qemu_free (esd->pcm_buf);
esd->pcm_buf = NULL;
@@ -327,23 +241,14 @@ static int qesd_init_out (HWVoiceOut *hw, audsettings_t *as)
static void qesd_fini_out (HWVoiceOut *hw)
{
- void *ret;
ESDVoiceOut *esd = (ESDVoiceOut *) hw;
- audio_pt_lock (&esd->pt, AUDIO_FUNC);
- esd->done = 1;
- audio_pt_unlock_and_signal (&esd->pt, AUDIO_FUNC);
- audio_pt_join (&esd->pt, &ret, AUDIO_FUNC);
-
if (esd->fd >= 0) {
if (close (esd->fd)) {
qesd_logerr (errno, "failed to close esd socket\n");
}
esd->fd = -1;
}
-
- audio_pt_fini (&esd->pt, AUDIO_FUNC);
-
qemu_free (esd->pcm_buf);
esd->pcm_buf = NULL;
}
@@ -356,112 +261,56 @@ static int qesd_ctl_out (HWVoiceOut *hw, int cmd, ...)
}
/* capture */
-static void *qesd_thread_in (void *arg)
+static int qesd_run_in (HWVoiceIn *hw)
{
- ESDVoiceIn *esd = arg;
- HWVoiceIn *hw = &esd->hw;
- int threshold;
-
- threshold = conf.divisor ? hw->samples / conf.divisor : 0;
-
- if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) {
- return NULL;
- }
-
- for (;;) {
- int incr, to_grab, wpos;
-
- for (;;) {
- if (esd->done) {
- goto exit;
- }
+ int wpos, liveSamples, totalSamples;
+ int grabSamples;
+ ESDVoiceIn *esd = (ESDVoiceIn *) hw;
- if (esd->dead > threshold) {
+ wpos = hw->wpos;
+ liveSamples = audio_pcm_hw_get_live_in (hw);
+ grabSamples = hw->samples - liveSamples;
+ totalSamples = 0;
+
+ while (grabSamples > 0) {
+ ssize_t nread;
+ int chunkSamples = audio_MIN (grabSamples, hw->samples - wpos);
+ int chunkBytes = chunkSamples << hw->info.shift;
+ int readSamples, readBytes;
+ void* buf = advance (esd->pcm_buf, wpos);
+
+ AGAIN:
+ nread = read (esd->fd, buf, chunkBytes);
+ if (nread == -1) {
+ if (errno == EINTR)
+ goto AGAIN;
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
break;
- }
- if (audio_pt_wait (&esd->pt, AUDIO_FUNC)) {
- goto exit;
- }
+ qesd_logerr (errno, "read failed: %s\n", strerror(errno));
+ break;
}
+ if (nread == 0)
+ break;
- incr = to_grab = esd->dead;
- wpos = hw->wpos;
+ readSamples = nread >> hw->info.shift;
+ readBytes = readSamples << hw->info.shift;
- if (audio_pt_unlock (&esd->pt, AUDIO_FUNC)) {
- return NULL;
+ if (readBytes != nread) {
+ dolog ("warning: Misaligned read %d (requested %d), "
+ "alignment %d\n",
+ nread, readBytes, hw->info.align + 1);
}
- while (to_grab) {
- ssize_t nread;
- int chunk = audio_MIN (to_grab, hw->samples - wpos);
- void *buf = advance (esd->pcm_buf, wpos);
-
- again:
- nread = read (esd->fd, buf, chunk << hw->info.shift);
- if (nread == -1) {
- if (errno == EINTR || errno == EAGAIN) {
- goto again;
- }
- qesd_logerr (errno, "read failed\n");
- return NULL;
- }
-
- if (nread != chunk << hw->info.shift) {
- int rsamples = nread >> hw->info.shift;
- int rbytes = rsamples << hw->info.shift;
- if (rbytes != nread) {
- dolog ("warning: Misaligned write %d (requested %d), "
- "alignment %d\n",
- rbytes, nread, hw->info.align + 1);
- }
- to_grab -= rsamples;
- wpos = (wpos + rsamples) % hw->samples;
- break;
- }
-
- hw->conv (hw->conv_buf + wpos, buf, nread >> hw->info.shift,
- &nominal_volume);
- wpos = (wpos + chunk) % hw->samples;
- to_grab -= chunk;
- }
+ hw->conv (hw->conv_buf + wpos, buf, readSamples,
+ &nominal_volume);
- if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) {
- return NULL;
- }
-
- esd->wpos = wpos;
- esd->dead -= incr;
- esd->incr += incr;
+ wpos = (wpos + readSamples) % hw->samples;
+ grabSamples -= readSamples;
+ totalSamples += readSamples;
}
-
- exit:
- audio_pt_unlock (&esd->pt, AUDIO_FUNC);
- return NULL;
-}
-
-static int qesd_run_in (HWVoiceIn *hw)
-{
- int live, incr, dead;
- ESDVoiceIn *esd = (ESDVoiceIn *) hw;
-
- if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) {
- return 0;
- }
-
- live = audio_pcm_hw_get_live_in (hw);
- dead = hw->samples - live;
- incr = audio_MIN (dead, esd->incr);
- esd->incr -= incr;
- esd->dead = dead - incr;
- hw->wpos = esd->wpos;
- if (esd->dead > 0) {
- audio_pt_unlock_and_signal (&esd->pt, AUDIO_FUNC);
- }
- else {
- audio_pt_unlock (&esd->pt, AUDIO_FUNC);
- }
- return incr;
+ hw->wpos = wpos;
+ return totalSamples;
}
static int qesd_read (SWVoiceIn *sw, void *buf, int len)
@@ -523,20 +372,15 @@ static int qesd_init_in (HWVoiceIn *hw, audsettings_t *as)
}
}
- if (audio_pt_init (&esd->pt, qesd_thread_in, esd, AUDIO_CAP, AUDIO_FUNC)) {
- goto fail3;
+ {
+ int flags;
+ flags = fcntl(esd->fd, F_GETFL);
+ fcntl(esd->fd, F_SETFL, flags | O_NONBLOCK);
}
result = 0; /* success */
goto exit;
- fail3:
- if (close (esd->fd)) {
- qesd_logerr (errno, "%s: close on esd socket(%d) failed\n",
- AUDIO_FUNC, esd->fd);
- }
- esd->fd = -1;
-
fail2:
qemu_free (esd->pcm_buf);
esd->pcm_buf = NULL;
@@ -550,23 +394,14 @@ static int qesd_init_in (HWVoiceIn *hw, audsettings_t *as)
static void qesd_fini_in (HWVoiceIn *hw)
{
- void *ret;
ESDVoiceIn *esd = (ESDVoiceIn *) hw;
- audio_pt_lock (&esd->pt, AUDIO_FUNC);
- esd->done = 1;
- audio_pt_unlock_and_signal (&esd->pt, AUDIO_FUNC);
- audio_pt_join (&esd->pt, &ret, AUDIO_FUNC);
-
if (esd->fd >= 0) {
if (close (esd->fd)) {
qesd_logerr (errno, "failed to close esd socket\n");
}
esd->fd = -1;
}
-
- audio_pt_fini (&esd->pt, AUDIO_FUNC);
-
qemu_free (esd->pcm_buf);
esd->pcm_buf = NULL;
}
diff --git a/distrib/update-audio.sh b/distrib/update-audio.sh
index 56bada2..79d1650 100755
--- a/distrib/update-audio.sh
+++ b/distrib/update-audio.sh
@@ -8,16 +8,16 @@
# assumes this script is located in the 'distrib' sub-directory
cd `dirname $0`
cd ..
+. android/build/common.sh
-locate_depot_files ()
-{
- root=$(p4 where $1) || (
- echo "you need to map $1 into your workspace to build an emulator source release package"
- exit 3
- )
- root=$(echo $root | cut -d" " -f3 | sed -e "s%/\.\.\.%%")
- echo $root
-}
+check_android_build
+if [ $IN_ANDROID_BUILD != yes ] ; then
+ echo "Sorry, this script can only be run from a full Android build tree"
+ exit 1
+fi
+
+force_32bit_binaries
+locate_android_prebuilt
# find the prebuilt directory
OS=`uname -s`
@@ -87,9 +87,8 @@ $GNUMAKE $source BUILD_QEMU_AUDIO_LIB=true || (echo "could not build the audio l
# now do a p4 edit, a copy and ask for submission
#
-TARGET=$PREBUILT/emulator/libqemu-audio.a
+TARGET=$ANDROID_PREBUILT/emulator/libqemu-audio.a
-p4 edit $TARGET || (echo "could not p4 edit $TARGET" && exit 3)
cp -f $source $TARGET
-echo "please do: p4 submit $TARGET"
+echo "ok, file copied to $TARGET"