diff options
| -rw-r--r-- | include/system/audio.h | 34 | ||||
| -rw-r--r-- | toolbox/rm.c | 15 | ||||
| -rw-r--r-- | toolbox/touch.c | 35 |
3 files changed, 75 insertions, 9 deletions
diff --git a/include/system/audio.h b/include/system/audio.h index da235dd..c49b0ee 100644 --- a/include/system/audio.h +++ b/include/system/audio.h @@ -383,9 +383,41 @@ typedef enum { // controls related to voice calls. AUDIO_OUTPUT_FLAG_FAST = 0x4, // output supports "fast tracks", // defined elsewhere - AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8 // use deep audio buffers + AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8, // use deep audio buffers + AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD = 0x10, // offload playback of compressed + // streams to hardware codec + AUDIO_OUTPUT_FLAG_NON_BLOCKING = 0x20 // use non-blocking write } audio_output_flags_t; +/* Additional information about compressed streams offloaded to + * hardware playback + * The version and size fields must be initialized by the caller by using + * one of the constants defined here. + */ +typedef struct { + uint16_t version; // version of the info structure + uint16_t size; // total size of the structure including version and size + uint32_t sample_rate; // sample rate in Hz + audio_channel_mask_t channel_mask; // channel mask + audio_format_t format; // audio format + audio_stream_type_t stream_type; // stream type + uint32_t bit_rate; // bit rate in bits per second + int64_t duration_us; // duration in microseconds, -1 if unknown + bool has_video; // true if stream is tied to a video stream + bool is_streaming; // true if streaming, false if local playback +} audio_offload_info_t; + +#define AUDIO_MAKE_OFFLOAD_INFO_VERSION(maj,min) \ + ((((maj) & 0xff) << 8) | ((min) & 0xff)) + +#define AUDIO_OFFLOAD_INFO_VERSION_0_1 AUDIO_MAKE_OFFLOAD_INFO_VERSION(0, 1) +#define AUDIO_OFFLOAD_INFO_VERSION_CURRENT AUDIO_OFFLOAD_INFO_VERSION_0_1 + +static const audio_offload_info_t AUDIO_INFO_INITIALIZER = { + version: AUDIO_OFFLOAD_INFO_VERSION_CURRENT, + size: sizeof(audio_offload_info_t), +}; + static inline bool audio_is_output_device(audio_devices_t device) { if (((device & AUDIO_DEVICE_BIT_IN) == 0) && diff --git a/toolbox/rm.c b/toolbox/rm.c index 127cbc4..957b586 100644 --- a/toolbox/rm.c +++ b/toolbox/rm.c @@ -45,8 +45,10 @@ static int unlink_recursive(const char* name, int flags) continue; sprintf(dn, "%s/%s", name, de->d_name); if (unlink_recursive(dn, flags) < 0) { - fail = 1; - break; + if (!(flags & OPT_FORCE)) { + fail = 1; + break; + } } errno = 0; } @@ -71,6 +73,7 @@ int rm_main(int argc, char *argv[]) int ret; int i, c; int flags = 0; + int something_failed = 0; if (argc < 2) return usage(); @@ -110,10 +113,14 @@ int rm_main(int argc, char *argv[]) if (ret < 0) { fprintf(stderr, "rm failed for %s, %s\n", argv[i], strerror(errno)); - return -1; + if (!(flags & OPT_FORCE)) { + return -1; + } else { + something_failed = 1; + } } } - return 0; + return something_failed; } diff --git a/toolbox/touch.c b/toolbox/touch.c index b8ab310..52ddf2a 100644 --- a/toolbox/touch.c +++ b/toolbox/touch.c @@ -5,13 +5,40 @@ #include <sys/stat.h> #include <stdlib.h> #include <fcntl.h> +#include <time.h> static void usage(void) { - fprintf(stderr, "touch: usage: touch [-alm] [-t time_t] <file>\n"); + fprintf(stderr, "touch: usage: touch [-alm] [-t YYYYMMDD[.hhmmss]] <file>\n"); exit(1); } +static time_t parse_time(char *s) +{ + struct tm tm; + int day = atoi(s); + int hour = 0; + + while (*s && *s != '.') { + s++; + } + + if (*s) { + s++; + hour = atoi(s); + } + + tm.tm_year = day / 10000 - 1900; + tm.tm_mon = (day % 10000) / 100 - 1; + tm.tm_mday = day % 100; + tm.tm_hour = hour / 10000; + tm.tm_min = (hour % 10000) / 100; + tm.tm_sec = hour % 100; + tm.tm_isdst = -1; + + return mktime(&tm); +} + int touch_main(int argc, char *argv[]) { int i, fd, aflag = 0, mflag = 0, debug = 0, flags = 0; @@ -31,9 +58,9 @@ int touch_main(int argc, char *argv[]) case 't': if ((i+1) >= argc) usage(); - specified_time.tv_sec = atol(argv[++i]); - if (specified_time.tv_sec == 0) { - fprintf(stderr, "touch: invalid time_t\n"); + specified_time.tv_sec = parse_time(argv[++i]); + if (specified_time.tv_sec == -1) { + fprintf(stderr, "touch: invalid timestamp specified\n"); exit(1); } specified_time.tv_nsec = 0; |
